9front - general discussion about 9front
 help / color / mirror / Atom feed
* /sys/src/cmd/awk/maketab.c
@ 2017-06-02  4:14 arisawa
  0 siblings, 0 replies; only message in thread
From: arisawa @ 2017-06-02  4:14 UTC (permalink / raw)
  To: 9front

Hello,

In porting awk to plan9port, maketab.c failed with "Segmentation fault".
Isn’t it better to fix the code as follows:

 {
 	struct xx *p;
-	int i, tok;
+	int i, n, tok;
 	Biobuf *fp;
 	char *buf, *toks[3];
 
@@ -133,8 +133,8 @@
 	i = 0;
 	while ((buf = Brdline(fp, '\n')) != nil) {
 		buf[Blinelen(fp)-1] = '\0';
-		tokenize(buf, toks, 3);
-		if (toks[0] == nil || strcmp("#define", toks[0]) != 0)	/* not a valid #define */
+		n = tokenize(buf, toks, 3);
+		if (n == 0 || strcmp("#define", toks[0]) != 0)	/* not a valid #define */
 			continue;
 		tok = strtol(toks[2], nil, 10);
 		if (tok < FIRSTTOKEN || tok > LASTTOKEN) {


Kenji Arisawa



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-02  4:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-02  4:14 /sys/src/cmd/awk/maketab.c arisawa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).