Subject: pkg/23887: ...pkgsrc/games/omega build problems.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rkr@olib.org>
List: netbsd-bugs
Date: 12/26/2003 06:42:50
>Number: 23887
>Category: pkg
>Synopsis: ...pkgsrc/games/omega build problems.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Dec 26 12:43:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Richard Rauch
>Release: NetBSD 1.6ZG; recent pkgsrc CVS update -PAd
>Organization:
"I probably don't know what I'm talking about." http://www.olib.org/~rkr/
>Environment:
System: NetBSD socrates 1.6ZG NetBSD 1.6ZG (socrates) #0: Tue Dec 23 06:30:20 CST 2003 root@socrates:/usr/netbsd/current/src/sys/arch/amd64/compile/obj.amd64/socrates amd64
Architecture: x86_64
Machine: amd64
>Description:
Attempting to build the "omega" game produces a mix of errors and
warnings on my system. The errors all occur in "genclr.c", which
is using an illegal way to represent strings. Namely, it writes:
foo_bar("\
asdfasdf\n\
asdfasdf\n\
", other_params);
...which is not accepted by GCC 3.x. There were two curious issues
which I am not 100% sure I fixed. Both were variations on this
theme:
foo_bar("\
""{\n\
");
...note the curious "" at the beginning of the middle line.
I don't understand what that was about. I simply ignored it
and translated as:
foo_bar("{\n");
>How-To-Repeat:
Attempt to build games/omega on a GCC 3.x system. That probably is
sufficient. (Make it NetBSD-current, in any case. (^&)
>Fix:
I offer several patches, which are to be applied after "make patch".
The first deals with genclr.c which actually is causing the whole
build to blow up. Two other warnings make a difference because
the (regular int) {1} is left-shifted into oblivion on AMD64 since
{unsigned long} is bigger than {int} (this may be true of other
64-bit architectures). GCC issues a warning, but it presumably
trashes important stuff. This, I believe, was in "save.c".
The fix was to use {1UL} instead. (Whether the size-difference
between {int} and {long} breaks other things, I do not know, but
shifting {1} to {0} seems to be a bug, so I fixed it.)
The patches are (the first two are actual bug-fixes; the others
just address warnings---please feel free to rip out the XXX
comments if you understand the old, illegal way of breaking
strings across multiple lines and why the ""}\n\ stuff was done):
--- genclr.c 2003-12-26 06:16:30.000000000 -0600
+++ genclr.c.orig 2003-12-26 06:00:58.000000000 -0600
@@ -181,12 +181,13 @@
perror ("");
exit (1);
}
- fprintf (fp,
- "/*\n"
- " * Do not edit this file. It was automatically generated by running:\n"
- " * %s %s %s\n"
- " */\n"
- "\n",
+ fprintf (fp, "\
+/*\n\
+ * Do not edit this file. It was automatically generated by running:\n\
+ * %s %s %s\n\
+ */\n\
+\n\
+",
argv[0], argv[1], argv[2]);
return fp;
}
@@ -279,38 +280,31 @@
* Emit .c file.
*/
fp = emitopen (cfile, argv);
- /*
- * XXX A couple of lines below looked something like:
- * XXX ..."\
- * XXX ""{\n\
- * XXX "
- * XXX I do not understand why a leading pair of double-quotes was
- * XXX used (or indeed, why any were put in on the { line).
- * XXX I converted to:
- * XXX ..."{\n"
- * XXX ...which has the advantage of being valid C. I do not know
- * XXX if this is what was originally intended, however.
- */
- fprintf (fp,
- "#include <curses.h>\n"
- "#include <stdio.h>\n"
- "#include <stdlib.h>\n"
- "\n"
- "#include \"%s\"\n"
- "\n"
- "void clrgen_init (void)\n"
- "{\n" /* XXX was ""{\n\ with broken code; why the "" ? */
- " if (%d > COLOR_PAIRS - 1) {\n"
- " endwin();\n"
- " fputs (\"Too many color pairs!\\n\", stderr);\n"
- " exit (1);\n"
- " }\n",
+ fprintf (fp, "\
+#include <curses.h>\n\
+#include <stdio.h>\n\
+#include <stdlib.h>\n\
+
+#include \"%s\"\n\
+
+void clrgen_init (void)\n\
+""{\n\
+ if (%d > COLOR_PAIRS - 1) {\n\
+ endwin();
+ fputs (\"Too many color pairs!\\n\", stderr);\n\
+ exit (1);\n\
+ }\n\
+",
hfile, ncpairs);
for (i = 0; i < ncpairs; i++)
- fprintf (fp,
- " init_pair (%d, COLOR_%s, COLOR_%s);\n",
+ fprintf (fp, "\
+ init_pair (%d, COLOR_%s, COLOR_%s);\n\
+",
cpairs[i]->idx, cpairs[i]->cfg, cpairs[i]->cbg);
- fputs ("}\n", fp); /* XXX Again, had ""}\n\ on a line */
+ fputs ("\
+""}\n\
+",
+ fp);
emitclose (fp, cfile);
/*
@@ -324,8 +318,10 @@
strlen (pair->ofg) + strlen (pair->obg) > 10 ? "" : "\t",
pair->idx, pair->boldfg ? "|A_BOLD" : "");
}
- fputs ("\n"
- "extern void clrgen_init (void);\n",
+ fputs ("\
+\n\
+extern void clrgen_init (void);\n\
+",
fp);
emitclose (fp, hfile);
--- save.c 2003-12-26 06:23:16.000000000 -0600
+++ save.c.orig 2003-12-26 06:22:54.000000000 -0600
@@ -302,7 +302,7 @@
}
mask >>= 1;
if (level->site[i][j].lstatus&SEEN)
- mask |= (1UL<<(sizeof(long int)*8 - 1));
+ mask |= (1<<(sizeof(long int)*8 - 1));
run--;
}
if (run < 8*sizeof(long int))
@@ -442,7 +442,7 @@
}
mask >>= 1;
if (c_statusp(i, j, SEEN))
- mask |= (1UL<<(sizeof(long int)*8 - 1));
+ mask |= (1<<(sizeof(long int)*8 - 1));
run--;
}
if (run < 8*sizeof(long int))
--- compress.c 2003-12-26 06:19:43.000000000 -0600
+++ compress.c.orig 2003-12-26 06:21:21.000000000 -0600
@@ -104,7 +104,7 @@
#ifdef PBITS /* Preferred BITS for this memory size */
# ifndef BITS
# define BITS PBITS
-# endif /* BITS */
+# endif BITS
#endif /* PBITS */
#if BITS == 16
@@ -347,7 +347,7 @@
#else
count_int htab [HSIZE];
unsigned short codetab [HSIZE];
-#endif /* sel */
+#endif sel
#define htabof(i) htab[i]
#define codetabof(i) codetab[i]
--- omega.c 2003-12-26 06:21:44.000000000 -0600
+++ omega.c.orig 2003-12-26 06:21:28.000000000 -0600
@@ -187,7 +187,7 @@
store = RANDFUNCTION();
/* Pseudo Random Seed */
if (environment == E_RANDOM)
- seed = (int) time(NULL);
+ seed = (int) time((long *)NULL);
else if (environment == E_RESTORE)
seed = store;
else
>Release-Note:
>Audit-Trail:
>Unformatted: