diff options
author | Ori Bernstein <ori@eigenstate.org> | 2014-12-13 23:21:11 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2014-12-13 23:21:44 -0800 |
commit | 24a3d753f2ac998c0b10579191984d79cfed0b7d (patch) | |
tree | 1b9733502a435451ce5ecf8785c14bbe1fc6705a /parse/node.c | |
parent | 008887ccd998a43db6980fa57f1e210ec26c4acf (diff) | |
download | mc-24a3d753f2ac998c0b10579191984d79cfed0b7d.tar.gz |
Add plan9 instruction formats.
Work towards a plan9 port. This commit also fixes a bug with
strings that contain '\0'. The commits got tangled, and I'm
too lazy to detangle them.
Diffstat (limited to 'parse/node.c')
-rw-r--r-- | parse/node.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/parse/node.c b/parse/node.c index 8d9a173..65f93e5 100644 --- a/parse/node.c +++ b/parse/node.c @@ -214,13 +214,15 @@ Node *mklbl(Srcloc loc, char *lbl) return mkexpr(loc, Olit, n, NULL); } -Node *mkstr(Srcloc loc, char *val) +Node *mkstr(Srcloc loc, Str val) { Node *n; n = mknode(loc, Nlit); n->lit.littype = Lstr; - n->lit.strval = strdup(val); + n->lit.strval.len = val.len; + n->lit.strval.buf = malloc(val.len); + memcpy(n->lit.strval.buf, val.buf, val.len); return n; } @@ -368,7 +370,8 @@ int liteq(Node *a, Node *b) case Lflt: return a->lit.fltval == b->lit.fltval; case Lstr: - return !strcmp(a->lit.strval, b->lit.strval); + return a->lit.strval.len == b->lit.strval.len && + !memcmp(a->lit.strval.buf, b->lit.strval.buf, a->lit.strval.len); case Lfunc: return a->lit.fnval == b->lit.fnval; case Llbl: |