diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-05-08 12:58:52 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-05-08 12:58:52 -0400 |
commit | a9671258f0df7892135797443c9dd9839be80a11 (patch) | |
tree | 27ddadfa744447124ce8d3160a6914b4a8f5773d | |
parent | 11ec62df93c86bda4100bcdd712c4406a68dd149 (diff) |
Replace the old string parsing code in
handle_directive() with a call to parse_quote().
This not only reduces code duplication, but also makes
it more robust in the process.
-rw-r--r-- | assemble.c | 31 |
1 files changed, 4 insertions, 27 deletions
@@ -274,33 +274,10 @@ uint64_t handle_directive(token *t, bytecount *bc, uint8_t isasm, uint64_t addre break; case TOK_STRING: if (type == DIR_BYTE) { - for (uint16_t k = 0; t->str[k] != '\0'; k++) { - switch (t->str[k]) { - case '\\': - switch (t->str[k+1]) { - case 'n' : c = '\n'; break; - case 'r' : c = '\r'; break; - case 't' : c = '\t'; break; - case '\"': c = '\"'; break; - case '\'': c = '\''; break; - case '\\': c = '\\'; break; - case '0' : c = '\0'; break; - } - k++; - break; - default: c = t->str[k]; break; - } - if (isasm) { - addr[tmpaddr] = c; - } - tmpaddr++; - bc->datasize++; - } - if (isasm) { - addr[tmpaddr] = '\0'; - } - tmpaddr++; - bc->datasize++; + char *s = t->str; + tmp = parse_quote(&s, '\0', isasm, &addr[tmpaddr], dbg); + tmpaddr += tmp; + bc->datasize += tmp; } break; } |