spaf@cs.purdue.EDU (Gene Spafford) (10/31/88)
The following changes will make xcolors work for all colors currently defined in the RGB database, whether duplicated or not. I'm sure other hacks could also be added.... *** xcolors.c.orig Sun Oct 30 14:43:40 1988 --- xcolors.c Sun Oct 30 15:11:56 1988 *************** *** 106,138 **** colordemo(parent) Widget parent; { ! int r, g, b, prev_r, prev_g, prev_b, dups; ! char colorname[50], save_colorname[50]; ! FILE *rgb; ! if (!(rgb = fopen(RGB_TXT, "r"))) { perror(RGB_TXT); exit(2); /* vms will be with me forever */ } - dups = 0; prev_r = prev_g = prev_b = -1; ! save_colorname[0] = '\0'; ! while (4 == fscanf(rgb, "%d %d %d %[^\n]\n", &r, &g, &b, colorname)) { ! if (r == prev_r && g == prev_g && b == prev_b) { ! dups++; ! strcpy(save_colorname, colorname); ! } else { ! dups = 0; ! if (save_colorname[0]) ! do_color(parent, save_colorname); prev_r = r; prev_g = g; prev_b = b; } ! } ! if (dups) ! do_color(parent, colorname); } --- 106,132 ---- colordemo(parent) Widget parent; { ! int r, g, b, prev_r, prev_g, prev_b; ! char colorname[50]; ! FILE *rgb, *popen(); ! char cbuf[256]; ! sprintf(cbuf, "/usr/bin/sort -n +0 -4 %s", RGB_TXT); ! if (!(rgb = popen(cbuf, "r"))) { perror(RGB_TXT); exit(2); /* vms will be with me forever */ } prev_r = prev_g = prev_b = -1; ! while (4 == fscanf(rgb, "%d %d %d %[^\n]\n", &r, &g, &b, colorname)) ! if (r != prev_r || g != prev_g || b != prev_b) { ! do_color(parent, colorname); prev_r = r; prev_g = g; prev_b = b; } ! ! pclose (rgb); } *** xcolors.manX.orig Sun Oct 30 15:26:12 1988 --- xcolors.manX Sun Oct 30 15:25:03 1988 *************** *** 12,20 **** .TP RGBFILE X11 color names and values. .SH BUGS - It requires every color to be defined twice or more. (It uses the - last definition since that is usually the capitalized name). - .br Dumps core if the server was started with different dbm databases. .SH AUTHOR Paul Vixie (vix@ubvax.ub.com) --- 12,17 ---- -- Gene Spafford NSF/Purdue/U of Florida Software Engineering Research Center, Dept. of Computer Sciences, Purdue University, W. Lafayette IN 47907-2004 Internet: spaf@cs.purdue.edu uucp: ...!{decwrl,gatech,ucbvax}!purdue!spaf