Commit Diff


commit - 9ce371ae8369fd306269715db1e1f3ec4be173a1
commit + 52ca685f0973687e6306bd03cb6d2face04d8be8
blob - ddea1a0ca5a495cb1e60f30e1f082ca87099d7f4
blob + 9914c936b8f4c1a2078cb356aef82c1b8cbe7077
--- listprg.c
+++ listprg.c
@@ -2,6 +2,7 @@
  * pesco 2026, ISC license
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>	/* exit */
 #include <fcntl.h>	/* open */
@@ -47,6 +48,7 @@ listprg(const char *file)
 	void *m;
 	size_t len;
 	int fd, i, n;
+	bool instring;
 
 	if ((fd = open(file, O_RDONLY)) == -1)
 		err(1, "%s", file);
@@ -72,8 +74,13 @@ listprg(const char *file)
 		printf("%d ", n);
 
 		/* process line text */
+		instring = false;
 		for (p += 4; *p != 0; p++) {
-			if (*p > 127 && !xflag)
+			if (*p == '"')
+				instring = !instring;
+			if (instring)
+				putchar(*p);
+			else if (*p > 127 && !xflag)
 				fputs(tokens[*p - 128], stdout);
 			else if (*p >= 32 && *p < 127)	/* isprint() */
 				putchar(*p);