Browse Source

Plan 9 from Bell Labs 2008-04-28

David du Colombier 13 years ago
parent
commit
d6695ce334
5 changed files with 26 additions and 19 deletions
  1. 3 3
      dist/replica/_plan9.db
  2. 3 3
      dist/replica/plan9.db
  3. 3 0
      dist/replica/plan9.log
  4. 5 4
      sys/man/1/awk
  5. 12 9
      sys/src/cmd/awk/run.c

+ 3 - 3
dist/replica/_plan9.db

@@ -158,7 +158,7 @@
 386/bin/aux/write - 775 sys sys 1085077011 4188
 386/bin/aux/zerotrunc - 775 sys sys 1108268388 3891
 386/bin/awd - 775 sys sys 1168402289 58975
-386/bin/awk - 775 sys sys 1173754554 324980
+386/bin/awk - 775 sys sys 1209323924 327170
 386/bin/basename - 775 sys sys 1148500606 37919
 386/bin/bc - 775 sys sys 1168402290 82001
 386/bin/bind - 775 sys sys 1168402290 59805
@@ -7371,7 +7371,7 @@ sys/man/1/acme - 664 sys sys 1196638934 18540
 sys/man/1/ap - 664 sys sys 1196638934 364
 sys/man/1/ar - 664 sys sys 1196638934 3153
 sys/man/1/ascii - 664 sys sys 1196638934 2726
-sys/man/1/awk - 664 sys sys 1205384921 11042
+sys/man/1/awk - 664 sys sys 1209274334 11077
 sys/man/1/basename - 664 sys sys 1196638931 535
 sys/man/1/bc - 664 sys sys 1196638934 3784
 sys/man/1/bind - 664 sys sys 1196638931 4009
@@ -9944,7 +9944,7 @@ sys/src/cmd/awk/parse.c - 664 sys sys 944960802 5068
 sys/src/cmd/awk/proctab.c - 664 sys sys 944960803 5123
 sys/src/cmd/awk/proto.h - 664 sys sys 944960802 6159
 sys/src/cmd/awk/re.c - 664 sys sys 964456820 6987
-sys/src/cmd/awk/run.c - 664 sys sys 1142009077 42795
+sys/src/cmd/awk/run.c - 664 sys sys 1209274332 42886
 sys/src/cmd/awk/tran.c - 664 sys sys 944960802 11855
 sys/src/cmd/basename.c - 664 sys sys 944961619 605
 sys/src/cmd/bc.y - 664 sys sys 1143696254 13463

+ 3 - 3
dist/replica/plan9.db

@@ -158,7 +158,7 @@
 386/bin/aux/write - 775 sys sys 1085077011 4188
 386/bin/aux/zerotrunc - 775 sys sys 1108268388 3891
 386/bin/awd - 775 sys sys 1168402289 58975
-386/bin/awk - 775 sys sys 1173754554 324980
+386/bin/awk - 775 sys sys 1209323924 327170
 386/bin/basename - 775 sys sys 1148500606 37919
 386/bin/bc - 775 sys sys 1168402290 82001
 386/bin/bind - 775 sys sys 1168402290 59805
@@ -7371,7 +7371,7 @@ sys/man/1/acme - 664 sys sys 1196638934 18540
 sys/man/1/ap - 664 sys sys 1196638934 364
 sys/man/1/ar - 664 sys sys 1196638934 3153
 sys/man/1/ascii - 664 sys sys 1196638934 2726
-sys/man/1/awk - 664 sys sys 1205384921 11042
+sys/man/1/awk - 664 sys sys 1209274334 11077
 sys/man/1/basename - 664 sys sys 1196638931 535
 sys/man/1/bc - 664 sys sys 1196638934 3784
 sys/man/1/bind - 664 sys sys 1196638931 4009
@@ -9944,7 +9944,7 @@ sys/src/cmd/awk/parse.c - 664 sys sys 944960802 5068
 sys/src/cmd/awk/proctab.c - 664 sys sys 944960803 5123
 sys/src/cmd/awk/proto.h - 664 sys sys 944960802 6159
 sys/src/cmd/awk/re.c - 664 sys sys 964456820 6987
-sys/src/cmd/awk/run.c - 664 sys sys 1142009077 42795
+sys/src/cmd/awk/run.c - 664 sys sys 1209274332 42886
 sys/src/cmd/awk/tran.c - 664 sys sys 944960802 11855
 sys/src/cmd/basename.c - 664 sys sys 944961619 605
 sys/src/cmd/bc.y - 664 sys sys 1143696254 13463

+ 3 - 0
dist/replica/plan9.log

@@ -19074,3 +19074,6 @@
 1209186003 31 c 386/lib/libthread.a - 664 sys sys 1209184474 73142
 1209186003 32 c 386/lib/libventi.a - 664 sys sys 1209184478 191764
 1209186003 33 c sys/src/boot/pc/ether82563.c - 664 sys sys 1209184829 26037
+1209274204 0 c sys/src/cmd/awk/run.c - 664 sys sys 1209274332 42886
+1209276005 0 c sys/man/1/awk - 664 sys sys 1209274334 11077
+1209324603 0 c 386/bin/awk - 775 sys sys 1209323924 327170

+ 5 - 4
sys/man/1/awk

@@ -547,10 +547,11 @@ to force it to be treated as a string concatenate
 The scope rules for variables in functions are a botch;
 the syntax is worse.
 .br
-UTF is not always dealt with correctly
-(e.g., in the
-.I split
-function with an empty string as final argument),
+UTF is not always dealt with correctly,
 though
 .I awk
 does make an attempt to do so.
+The
+.I split
+function with an empty string as final argument now copes
+with UTF in the string being split.

+ 12 - 9
sys/src/cmd/awk/run.c

@@ -30,6 +30,7 @@ THIS SOFTWARE.
 #include <string.h>
 #include <stdlib.h>
 #include <time.h>
+#include <utf.h>
 #include "awk.h"
 #include "y.tab.h"
 
@@ -1194,10 +1195,9 @@ Cell *dopa2(Node **a, int n)	/* a[0], a[1] { a[2] } */
 Cell *split(Node **a, int nnn)	/* split(a[0], a[1], a[2]); a[3] is type */
 {
 	Cell *x = 0, *y, *ap;
-	char *s;
-	int sep;
-	char *t, temp, num[50], *fs = 0;
-	int n, tempstat, arg3type;
+	char *s, *t, *fs = 0;
+	char temp, num[50];
+	int n, nb, sep, tempstat, arg3type;
 
 	y = execute(a[0]);	/* source string */
 	s = getsval(y);
@@ -1279,12 +1279,15 @@ Cell *split(Node **a, int nnn)	/* split(a[0], a[1], a[2]); a[3] is type */
 				s++;
 		}
 	} else if (sep == 0) {	/* new: split(s, a, "") => 1 char/elem */
-		for (n = 0; *s != 0; s++) {
-			char buf[2];
+		for (n = 0; *s != 0; s += nb) {
+			Rune r;
+			char buf[UTFmax+1];
+
 			n++;
-			sprintf(num, "%d", n);
-			buf[0] = *s;
-			buf[1] = 0;
+			snprintf(num, sizeof num, "%d", n);
+			nb = chartorune(&r, s);
+			memmove(buf, s, nb);
+			buf[nb] = '\0';
 			if (isdigit(buf[0]))
 				setsymtab(num, buf, atof(buf), STR|NUM, (Array *) ap->sval);
 			else