summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-05-08 12:58:52 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-05-08 12:58:52 -0400
commita9671258f0df7892135797443c9dd9839be80a11 (patch)
tree27ddadfa744447124ce8d3160a6914b4a8f5773d
parent11ec62df93c86bda4100bcdd712c4406a68dd149 (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.c31
1 files changed, 4 insertions, 27 deletions
diff --git a/assemble.c b/assemble.c
index cdd82d6..a6abe1f 100644
--- a/assemble.c
+++ b/assemble.c
@@ -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;
}