From 839c052a938f78fde18b9b2431c24c6163e4a7f3 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 2 Jan 2011 16:01:05 -0500 Subject: acid: 4-byte Runes R=rsc http://codereview.appspot.com/3860041 --- src/cmd/acid/exec.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/cmd/acid/exec.c b/src/cmd/acid/exec.c index 2022da53..c6b07842 100644 --- a/src/cmd/acid/exec.c +++ b/src/cmd/acid/exec.c @@ -205,7 +205,7 @@ convflt(Node *r, char *flt) void indir(Map *m, ulong addr, char fmt, Node *r) { - int i; + int i, j, k; u32int ival; u64int vval; int ret; @@ -280,16 +280,19 @@ indir(Map *m, ulong addr, char fmt, Node *r) break; case 'R': r->type = TSTRING; - for(i = 0; i < sizeof(buf)-2; i += 2) { - ret = get1(m, addr, (uchar*)&buf[i], 2); + assert(sizeof(Rune) == 4); + for(i = 0; i < sizeof(buf)-4; i += 4) { + ret = get4(m, addr, &ival); if (ret < 0) error("indir: %r"); - addr += 2; - if(buf[i] == 0 && buf[i+1] == 0) + rval = ival; + memmove(buf+i, &ival, 4); + addr += 4; + if(ival == 0) break; } - buf[i++] = 0; - buf[i] = 0; + ival = 0; + memmove(buf+i, &ival, 4); r->store.u.string = runenode((Rune*)buf); break; case 'i': -- cgit v1.2.3