shithub: puzzles

Download patch

ref: d4c1f40bd25a2241d47ff5cfaa8b0e2a3906b265
parent: 8b6a38b1230441d6850634dec79af0c9996bd5e8
author: sirjofri <sirjofri@sirjofri.de>
date: Fri May 24 07:52:27 EDT 2024

adds log with parameters

--- a/mkfile
+++ b/mkfile
@@ -1,6 +1,6 @@
 </$objtype/mkfile
 
-CFLAGS=$CFLAGS -p -I/sys/include/npe -D__plan9__ -D__${objtype}__ -DNO_TGMATH_H -I. # -D__plan9_keep_main__
+CFLAGS=$CFLAGS -p -I/sys/include/npe -D__plan9__ -D__${objtype}__ -DNO_TGMATH_H -I. -D__plan9_keep_main__
 
 TARG=\
 	blackbox\
@@ -97,8 +97,6 @@
 BIN=/$objtype/bin/puzzles
 
 </sys/src/cmd/mkmany
-
-# LDFLAGS=$LDFLAGS -p
 
 auxiliary/hatgen.$O: auxiliary/hatgen.c
 	$CC $CFLAGS -o $target auxiliary/hatgen.c
--- a/plan9.c
+++ b/plan9.c
@@ -18,6 +18,16 @@
 int logfd = -1;
 int logpipe[2];
 #define LOG(c) { if (dolog) fprint(logpipe[1], "%s\n", c); }
+void
+Log(char *fmt, ...)
+{
+	va_list arg;
+	if (!dolog)
+		return;
+	va_start(arg, fmt);
+	vfprint(logfd, fmt, arg);
+	va_end(arg);
+}
 
 struct frontend {
 	midend *me;
@@ -884,7 +894,7 @@
 					showframe(GAME);
 				}
 			} else {
-				LOG(args[0]);
+				Log("unknown command: %s\n", args[0]);
 			}
 			break;
 		case 1: /* timer */