# HG changeset patch # User Alan Coopersmith # Date 1305950721 25200 # Node ID 7dc974a70bc8450311dfb13f1276b408a3028ed2 # Parent e9cbce844ef66c837c3de497eb22cf7c7daee190 7047071 xcolor segfaults on startup diff -r e9cbce844ef6 -r 7dc974a70bc8 open-src/app/xcolor/sun-src/HSBmap.c --- a/open-src/app/xcolor/sun-src/HSBmap.c Wed May 18 13:42:51 2011 -0700 +++ b/open-src/app/xcolor/sun-src/HSBmap.c Fri May 20 21:05:21 2011 -0700 @@ -1,7 +1,7 @@ /*- * HSBmap.c - Create an HSB ramp. * - * Copyright (c) 1991, 1995, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1991, 2011, Oracle and/or its affiliates. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -29,15 +29,17 @@ #include #include +#include "xcolor.h" -void -hsb2rgb(H, S, B, r, g, b) +static void +hsb2rgb( double H, - S, - B; + double S, + double B, u_char *r, - *g, - *b; + u_char *g, + u_char *b) + { register int i; register double f, @@ -90,18 +92,18 @@ void -HSBramp(h1, s1, b1, h2, s2, b2, start, end, red, green, blue) +HSBramp( double h1, - s1, - b1, - h2, - s2, - b2; + double s1, + double b1, + double h2, + double s2, + double b2, int start, - end; + int end, u_char *red, - *green, - *blue; + u_char *green, + u_char *blue) { double dh, ds, diff -r e9cbce844ef6 -r 7dc974a70bc8 open-src/app/xcolor/sun-src/Makefile --- a/open-src/app/xcolor/sun-src/Makefile Wed May 18 13:42:51 2011 -0700 +++ b/open-src/app/xcolor/sun-src/Makefile Fri May 20 21:05:21 2011 -0700 @@ -1,8 +1,8 @@ ############################################################################### # -# xcolor 1.x Makefile +# xcolor Makefile # -# Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -28,7 +28,7 @@ OBJS = HSBmap.o XCrDynCmap.o XCrHsbCmap.o xcolor.o xcolor: $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) -lX11 + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) -lX11 -lm install: xcolor mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 diff -r e9cbce844ef6 -r 7dc974a70bc8 open-src/app/xcolor/sun-src/XCrDynCmap.c --- a/open-src/app/xcolor/sun-src/XCrDynCmap.c Wed May 18 13:42:51 2011 -0700 +++ b/open-src/app/xcolor/sun-src/XCrDynCmap.c Fri May 20 21:05:21 2011 -0700 @@ -1,7 +1,7 @@ /*- * XCrDynCmap.c - X11 library routine to create dynamic colormaps. * - * Copyright (c) 1990, 1995, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1990, 2011, Oracle and/or its affiliates. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -31,22 +31,22 @@ #include #include #include +#include "xcolor.h" Status -XCreateDynamicColormap(dsp, screen, cmap, visual, colors, - count, red, green, blue) - Display *dsp; - int screen; - Colormap *cmap; /* return */ - Visual **visual; /* return */ - XColor *colors; - int count; +XCreateDynamicColormap( + Display *dsp, + int screen, + Colormap *cmap, /* return */ + Visual **visual, /* return */ + XColor *colors, + int count, u_char *red, - *green, - *blue; + u_char *green, + u_char *blue) { XVisualInfo vinfo; - int pixels[256]; + unsigned long pixels[256]; int i, ncolors, planes; diff -r e9cbce844ef6 -r 7dc974a70bc8 open-src/app/xcolor/sun-src/XCrHsbCmap.c --- a/open-src/app/xcolor/sun-src/XCrHsbCmap.c Wed May 18 13:42:51 2011 -0700 +++ b/open-src/app/xcolor/sun-src/XCrHsbCmap.c Fri May 20 21:05:21 2011 -0700 @@ -1,7 +1,7 @@ /*- * XCrHsbCmap.c - X11 library routine to create an HSB ramp colormaps. * - * Copyright (c) 1991, 1995, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1991, 2011, Oracle and/or its affiliates. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -29,23 +29,22 @@ #include #include #include - -extern void HSBmap(); +#include "xcolor.h" Status -XCreateHSBColormap(dsp, screen, cmap, count, h1, s1, b1, h2, s2, b2, bw, visual) - Display *dsp; - int screen; - Colormap *cmap; /* colormap return value */ - int count; /* number of entrys to use */ +XCreateHSBColormap( + Display *dsp, + int screen, + Colormap *cmap, /* colormap return value */ + int count, /* number of entries to use */ double h1, /* starting hue */ - s1, /* starting saturation */ - b1, /* starting brightness */ - h2, /* ending hue */ - s2, /* ending saturation */ - b2; /* ending brightness */ - int bw; /* Boolean: True = save black and white */ - Visual **visual; + double s1, /* starting saturation */ + double b1, /* starting brightness */ + double h2, /* ending hue */ + double s2, /* ending saturation */ + double b2, /* ending brightness */ + int bw, /* Boolean: True = save black and white */ + Visual **visual) { u_char red[256]; u_char green[256]; diff -r e9cbce844ef6 -r 7dc974a70bc8 open-src/app/xcolor/sun-src/xcolor.c --- a/open-src/app/xcolor/sun-src/xcolor.c Wed May 18 13:42:51 2011 -0700 +++ b/open-src/app/xcolor/sun-src/xcolor.c Fri May 20 21:05:21 2011 -0700 @@ -1,7 +1,7 @@ /*- * xcolor.c - X11 client to display all colors in current colormap. * - * Copyright (c) 1989, 1995, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1989, 2011, Oracle and/or its affiliates. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,12 +28,14 @@ #include +#include #include #include #include #include #include #include +#include "xcolor.h" #define DEFX 256 #define DEFY 256 @@ -59,16 +61,15 @@ int cmap_size; -void -error(s1, s2) - char *s1, - *s2; +static void +error(const char *s1, const void *s2) { fprintf(stderr, s1, pname, s2); exit(1); } -dumpCmap() +static void +dumpCmap(void) { register int i; XColor color[256]; @@ -82,8 +83,8 @@ } } -redisplay_indexed(window) - Window window; +static void +redisplay_indexed(Window window) { int max; register int i, @@ -118,9 +119,8 @@ } } - -redisplay_direct(window) - Window window; +static void +redisplay_direct(Window window) { register int i, j, k; @@ -182,9 +182,8 @@ } } - -redisplay (w) - Window w; +static void +redisplay (Window w) { if (visual->class == TrueColor || visual->class == DirectColor) redisplay_direct(w); @@ -192,8 +191,8 @@ redisplay_indexed(w); } - -HandleEvents() +static void +HandleEvents(void) { XEvent event; XConfigureEvent *xce = (XConfigureEvent *) & event; @@ -236,10 +235,11 @@ } } - -main(argc, argv) - int argc; - char *argv[]; +int +main( + int argc, + char *argv[] + ) { XSetWindowAttributes xswa; XGCValues xgcv; @@ -283,15 +283,9 @@ \t[-dump] [-nobw] [-half] [-noinst] [-iconwin]\n", NULL); } - /* SUNSOFT_BUYBACK - if (!(dsp = XOpenDisplay(displayName))) - error("%s: unable to open display, %s.\n", displayName); - **********/ if (!(dsp = XOpenDisplay(displayName))) { - if (displayName) - error("%s: unable to open display, %s.\n", displayName); - else - error("unable to open display\n"); + error("%s: unable to open display, %s.\n", + displayName ? displayName : "no display specified"); } screen = DefaultScreen(dsp); @@ -310,7 +304,7 @@ 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, !nobw, &visual); if (stat != Success) - error("%s: unable create colormap (%d).\n", stat); + error("%s: unable create colormap (%d).\n", (void *) stat); } size_hints.x = DEFX; diff -r e9cbce844ef6 -r 7dc974a70bc8 open-src/app/xcolor/sun-src/xcolor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/open-src/app/xcolor/sun-src/xcolor.h Fri May 20 21:05:21 2011 -0700 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef _XCOLOR_H +#define _XCOLOR_H + +#include +#include +#include + +extern void HSBramp( + double h1, + double s1, + double b1, + double h2, + double s2, + double b2, + int start, + int end, + u_char *red, + u_char *green, + u_char *blue); + +extern Status XCreateDynamicColormap( + Display *dsp, + int screen, + Colormap *cmap, /* return */ + Visual **visual, /* return */ + XColor *colors, + int count, + u_char *red, + u_char *green, + u_char *blue); + +extern Status XCreateHSBColormap( + Display *dsp, + int screen, + Colormap *cmap, /* colormap return value */ + int count, /* number of entries to use */ + double h1, /* starting hue */ + double s1, /* starting saturation */ + double b1, /* starting brightness */ + double h2, /* ending hue */ + double s2, /* ending saturation */ + double b2, /* ending brightness */ + int bw, /* Boolean: True = save black and white */ + Visual **visual); + +#endif /* _XCOLOR_H */