$NetBSD: patch-ab,v 1.3 2012/01/20 17:05:53 joerg Exp $ --- xworm.c.orig 1997-05-07 16:25:57.000000000 +0000 +++ xworm.c @@ -3,13 +3,21 @@ #include #include +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) +#include +#endif +#include #include #include #include -#define gridfile "xworm.grid" -#define fontfile "xworm.font" -#define logofile "xworm.raw" +#ifndef PREFIX +#define PREFIX "." +#endif + +#define gridfile PREFIX "/xworm.grid" +#define fontfile PREFIX "/xworm.font" +#define logofile PREFIX "/xworm.raw" #define maxQ 5000 /* max queue */ #define NCOLORS 15 /* number of colours */ @@ -137,7 +145,7 @@ void vec_line(int,int,int,int); int vec_wrline(char *,int,int,int); int vec_wrlineX(char *,int,int,int,float); -void main(int argc, char **argv) { +int main(int argc, char **argv) { memset(&timeout, 0, sizeof(struct timeval)); @@ -551,16 +559,24 @@ void AllocColours(void){ colormap = DefaultColormap(display, screen); if (!XAllocColorCells(display, colormap, True, NULL, 0, pixels, npixels)) { fprintf(stderr, "failed to allocate all %d colours\n", NCOLORS); - exit(1); - } - for (i = 0; i < NCOLORS; i++) { /* Initialize RGB values ... */ - color_tab[i].pixel = pixels[i]; - color_tab[i].red = rgb_tab[i].r; - color_tab[i].green = rgb_tab[i].g; - color_tab[i].blue = rgb_tab[i].b; - color_tab[i].flags = DoRed | DoGreen | DoBlue; + for (i = 0; i < NCOLORS; i++) { /* Initialize RGB values ... */ + color_tab[i].pixel = pixels[i]; + color_tab[i].red = rgb_tab[i].r; + color_tab[i].green = rgb_tab[i].g; + color_tab[i].blue = rgb_tab[i].b; + color_tab[i].flags = DoRed | DoGreen | DoBlue; + XAllocColor(display, colormap, &color_tab[i]); + } + } else { + for (i = 0; i < NCOLORS; i++) { /* Initialize RGB values ... */ + color_tab[i].pixel = pixels[i]; + color_tab[i].red = rgb_tab[i].r; + color_tab[i].green = rgb_tab[i].g; + color_tab[i].blue = rgb_tab[i].b; + color_tab[i].flags = DoRed | DoGreen | DoBlue; + } + XStoreColors(display, colormap, color_tab, npixels); } - XStoreColors(display, colormap, color_tab, npixels); } Bool predproc (display,event,arg) @@ -773,7 +789,7 @@ float rnd(int x) { /* This routine retur void rgrid(void){ FILE *fpg; if ((fpg=fopen(gridfile,"rb")) == NULL) { - printf("Error opening file /users/paalde/bin/xworm.grid. unrecoverable \n"); + printf("Error opening file %s/xworm.grid. unrecoverable \n", PREFIX); exit (0); } for (i=1;i