printf("%c", 0); could produce unexpected results the utf function was in the wrong place, so never worked. another issue, although less trivial, and probably not a bug, is that, i'd expect this: awk 'BEGIN {s="arble z a b c d"; split(s, a, " "); for(i in a){printf("''%s''\n", i)}}' to print: 'z' 'a' 'b' 'c' 'd' [or some permutation of the above] but it doesn't; it actually prints: '2' '3' '4' '5' '6' '1' this is probably just awk being its usual nasty, unintuitive self. Notes: Thu Mar 9 09:13:26 EST 2006 rsc Could you check that you're up-to-date with sources and resubmit? If you run patch/diff sorry/awkbugs you'll see all sorts of changes that don't seem to have anything to do with what you reported. The one line you added looks like (in run.c): else *p++ = '\0'; >> *p = '\0'; which at the least is indented wrong. As for your split example, for(k in a) iterates over the keys k in the hash table a in an unspecified order. If you want to iterate over an array, you should do n=split(); for(i=0; inobj; - if (notlegal(nobj)) /* probably a Cell* but too risky to print */ + if (notlegal(a->nobj)) /* probably a Cell* but too risky to print */ FATAL("illegal statement"); - proc = proctab[nobj-FIRSTTOKEN]; - x = (*proc)(a->narg, nobj); + proc = proctab[a->nobj-FIRSTTOKEN]; + x = (*proc)(a->narg, a->nobj); if (isfld(x) && !donefld) fldbld(); else if (isrec(x) && !donerec) @@ -905,6 +903,7 @@ sprintf(p, fmt, (int) getfval(x)); else *p++ = '\0'; + *p = '\0'; } else sprintf(p, fmt, getsval(x)[0]); break; @@ -1542,7 +1541,6 @@ Cell *printstat(Node **a, int n) /* print a[0] */ { - int r; Node *x; Cell *y; FILE *fp; @@ -1556,15 +1554,14 @@ fputs(getsval(y), fp); tempfree(y); if (x->nnext == NULL) - r = fputs(*ORS, fp); + fputs(*ORS, fp); else - r = fputs(*OFS, fp); - if (r == EOF) - FATAL("write error on %s", filename(fp)); + fputs(*OFS, fp); } if (a[1] != 0) - if (fflush(fp) == EOF) - FATAL("write error on %s", filename(fp)); + fflush(fp); + if (ferror(fp)) + FATAL("write error on %s", filename(fp)); return(True); } --- /sys/src/cmd/awk/lex.c Thu Mar 9 14:20:05 2006 +++ /sys/src/cmd/awk/lex.c Thu Mar 9 14:20:00 2006 @@ -86,8 +86,8 @@ { "system", FSYSTEM, BLTIN }, { "tolower", FTOLOWER, BLTIN }, { "toupper", FTOUPPER, BLTIN }, - { "while", WHILE, WHILE }, { "utf", FUTF, BLTIN }, + { "while", WHILE, WHILE }, }; #define DEBUG