shithub: kwa

Download patch

ref: e6dff2afe66a7aea90440fe000f6b2f7513f1888
parent: 52a6023c85229ee680e0cb53df168cac214a915e
author: qwx <qwx@sciops.net>
date: Thu Sep 25 17:38:15 EDT 2025

minor style changes and correct comment

--- a/lex.c
+++ b/lex.c
@@ -164,9 +164,11 @@
 			return 0;
 		if (c == 'a')
 			return word(buf);
+		/* may be unsuitable for printing (T.strnum) so don't set STR,
+		 * but may be a regex to be treated literally (T.coerce[23])
+		 * via strnode, so save a copy. */
 		if (c == '0') {
 			yylval.cp = setsymtab(buf, tostring(buf), f, CON|NUM, symtab);
-			/* should this also have STR set? */	/* FIXME: yes. */
 			RET(NUMBER);
 		}
 	
@@ -428,7 +430,7 @@
 	Keyword *kp;
 	int c, n;
 
-	n = binsearch(w, keywords, sizeof(keywords)/sizeof(keywords[0]));
+	n = binsearch(w, keywords, nelem(keywords));
 	kp = keywords + n;
 	if (n != -1) {	/* found in table */
 		yylval.i = kp->sub;
--- a/run.c
+++ b/run.c
@@ -331,7 +331,7 @@
 	case EXIT:
 		if (a[0] != nil) {
 			y = execute(a[0]);
-			if((y->tval & (NUM|STR)) == STR) {
+			if ((y->tval & (NUM|STR)) == STR) {
 				exitstatus = getsval(y);
 			} else if((int) getfval(y) != 0) {
 				exitstatus = "error";
--