19 static escape_t escape_new(
size_t length,
char code)
33 case 'n':
return escape_new(2,
'\n');
34 case 't':
return escape_new(2,
'\t');
35 case 'r':
return escape_new(2,
'\r');
36 case '0':
return escape_new(2,
'\0');
37 case '\\':
return escape_new(2,
'\\');
38 case '"':
return escape_new(2,
'"');
39 case '\'':
return escape_new(2,
'\'');
42 msg_notify(reports, &kEvent_InvalidStringEscape, node,
"unknown escape sequence '\\%c'", *text);
43 return escape_new(1, *text);
51 case '\\':
return consume_escape(reports, node, text + 1);
52 default:
return escape_new(1, *text);
67 for (
size_t i = 0; i < length;)
69 escape_t escape = consume_text(reports, node, text + i);
85 for (
size_t i = 0; i < length; i++)
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
CT_CONSTFN CT_BASE_API text_t text_make(STA_READS(length) char *text, size_t length)
create a new owning text array text must be a valid string at least length bytes long
#define ARENA_IDENTIFY(ptr, name, parent, arena)
rename and reparent a pointer in a custom allocator
CT_NOTIFY_API event_builder_t msg_notify(INOUT_NOTNULL logger_t *logs, const diagnostic_t *diagnostic, const node_t *node, STA_FORMAT_STRING const char *fmt,...)
notify the logger of a new message
#define CTASSERT(expr)
assert a condition, prints the condition as a message
CT_STD_API typevec_t typevec_make(size_t width, size_t len, arena_t *arena)
create a new typed vector on the stack
CT_STD_API void * typevec_push(typevec_t *vec, const void *src)
push a value onto the vector
CT_NODISCARD CT_PUREFN CT_STD_API size_t typevec_len(const typevec_t *vec)
get the length of a vector
CT_NODISCARD CT_PUREFN CT_STD_API void * typevec_data(const typevec_t *vec)
get a pointer to the underlying data
a position in a source file
A vector with a fixed type size.
STA_DECL bool util_text_has_escapes(const char *text, size_t length)
STA_DECL text_t util_text_escape(logger_t *reports, const node_t *node, const char *text, size_t length, arena_t *arena)