diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-08-12 21:58:24 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-08-12 21:58:24 +0300 |
commit | 8f2c2755573b81c1e2c9ef1c42c529d13396d4d2 (patch) | |
tree | 99eaa148631402d7fe600fdcd7ba402c74d13ff2 /field.c | |
parent | 09dca22666681470a207083f339083a1a4a8c973 (diff) | |
parent | 9e2907afe246b3930d9ae6043a2657c4492f4507 (diff) | |
download | egawk-8f2c2755573b81c1e2c9ef1c42c529d13396d4d2.tar.gz egawk-8f2c2755573b81c1e2c9ef1c42c529d13396d4d2.tar.bz2 egawk-8f2c2755573b81c1e2c9ef1c42c529d13396d4d2.zip |
Merge branch 'master' into comment
Diffstat (limited to 'field.c')
-rw-r--r-- | field.c | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -40,7 +40,6 @@ typedef void (* Setfunc)(long, char *, long, NODE *); static long (*parse_field)(long, char **, int, NODE *, Regexp *, Setfunc, NODE *, NODE *, bool); -static void rebuild_record(void); static long re_parse_field(long, char **, int, NODE *, Regexp *, Setfunc, NODE *, NODE *, bool); static long def_parse_field(long, char **, int, NODE *, @@ -140,7 +139,7 @@ set_field(long num, /* rebuild_record --- Someone assigned a value to $(something). Fix up $0 to be right */ -static void +void rebuild_record() { /* @@ -148,9 +147,7 @@ rebuild_record() * a size_t isn't big enough. */ unsigned long tlen; - unsigned long ofslen; NODE *tmp; - NODE *ofs; char *ops; char *cops; long i; @@ -158,14 +155,12 @@ rebuild_record() assert(NF != -1); tlen = 0; - ofs = force_string(OFS_node->var_value); - ofslen = ofs->stlen; for (i = NF; i > 0; i--) { tmp = fields_arr[i]; tmp = force_string(tmp); tlen += tmp->stlen; } - tlen += (NF - 1) * ofslen; + tlen += (NF - 1) * OFSlen; if ((long) tlen < 0) tlen = 0; emalloc(ops, char *, tlen + 2, "rebuild_record"); @@ -183,11 +178,11 @@ rebuild_record() } /* copy OFS */ if (i != NF) { - if (ofslen == 1) - *cops++ = ofs->stptr[0]; - else if (ofslen != 0) { - memcpy(cops, ofs->stptr, ofslen); - cops += ofslen; + if (OFSlen == 1) + *cops++ = *OFS; + else if (OFSlen != 0) { + memcpy(cops, OFS, OFSlen); + cops += OFSlen; } } } @@ -231,7 +226,7 @@ rebuild_record() fields_arr[i] = n; assert((n->flags & WSTRCUR) == 0); } - cops += fields_arr[i]->stlen + ofslen; + cops += fields_arr[i]->stlen + OFSlen; } unref(fields_arr[0]); |