ref: 84dc4bb3cb9d70c182341918e91aa5ffc0af2e15
parent: b1c03eec08fe0d951121ead8f1c52c8271e4d420
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Aug 6 18:22:33 EDT 2012
String handling changes.
--- a/6/isel.c
+++ b/6/isel.c
@@ -815,25 +815,20 @@
return as;
}
-#define Nper 30
static void writeblob(FILE *fd, char *p, size_t sz)
{
size_t i;
- char sep;
for (i = 0; i < sz; i++) {
- if (i % Nper == 0) {
- sep = ' ';
- fprintf(fd, "\t.byte");
- }
+ if (i % 60 == 0)
+ fprintf(fd, "\t.ascii \"");
if (isprint(p[i]))
- fprintf(fd, "%c'%c'", sep, p[i]);
+ fprintf(fd, "%c", p[i]);
else
- fprintf(fd, "%c0x%x", sep, (unsigned)p[i] & 0xff);
+ fprintf(fd, "\\%03o", (uint8_t)p[i] & 0xff);
/* line wrapping for readability */
- if (i % Nper == Nper - 1 || i == sz - 1)
- fprintf(fd, "\n");
- sep = ',';
+ if (i % 60 == 59 || i == sz - 1)
+ fprintf(fd, "\"\n");
}
}
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -72,7 +72,6 @@
struct Tok {
int type;
int line;
- char *strsz;
char *str;
/* values parsed out */
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -284,7 +284,7 @@
else
append(&buf, &len, &sz, c);
};
- buf[len] = '\0';
+ append(&buf, &len, &sz, '\0');
t = mktok(Tstrlit);
t->str = buf;
@@ -318,7 +318,7 @@
append(&buf, &len, &sz, c);
};
- buf[len] = '\0';
+ append(&buf, &len, &sz, '\0');
t = mktok(Tchrlit);
t->str = buf;
--
⑨