Module Name:    xsrc
Committed By:   mrg
Date:           Mon Mar 17 10:03:20 UTC 2014

Modified Files:
        xsrc/external/mit/xmodmap/include: config.h
        xsrc/external/mit/xprop/include: config.h
        xsrc/external/mit/xrandr/dist: xrandr.c
        xsrc/external/mit/xrdb/dist: xrdb.c
Removed Files:
        xsrc/external/mit/xvinfo/dist: xvinfo.man

Log Message:
merge xmessage 1.0.3, xmodmap 1.0.8, xprop 1.2.2, xrandr 1.4.1,
xrdb 1.1.0, xset 1.2.3, xvinfo 1.1.2, and xwd 1.0.6.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xmodmap/include/config.h
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xprop/include/config.h
cvs rdiff -u -r1.9 -r1.10 xsrc/external/mit/xrandr/dist/xrandr.c
cvs rdiff -u -r1.6 -r1.7 xsrc/external/mit/xrdb/dist/xrdb.c
cvs rdiff -u -r1.1.1.3 -r0 xsrc/external/mit/xvinfo/dist/xvinfo.man

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xmodmap/include/config.h
diff -u xsrc/external/mit/xmodmap/include/config.h:1.4 xsrc/external/mit/xmodmap/include/config.h:1.5
--- xsrc/external/mit/xmodmap/include/config.h:1.4	Sat Nov 20 23:24:51 2010
+++ xsrc/external/mit/xmodmap/include/config.h	Mon Mar 17 10:03:19 2014
@@ -1,6 +1,9 @@
 /* config.h.  Generated from config.h.in by configure.  */
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Define to 1 if you have the `asprintf' function. */
+#define HAVE_ASPRINTF 1
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #define HAVE_INTTYPES_H 1
 
@@ -41,7 +44,7 @@
 #define PACKAGE_NAME "xmodmap"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "xmodmap 1.0.5"
+#define PACKAGE_STRING "xmodmap 1.0.8"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "xmodmap"
@@ -50,7 +53,7 @@
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "1.0.5"
+#define PACKAGE_VERSION "1.0.8"
 
 /* Major version of this package */
 #define PACKAGE_VERSION_MAJOR 1
@@ -59,10 +62,10 @@
 #define PACKAGE_VERSION_MINOR 0
 
 /* Patch version of this package */
-#define PACKAGE_VERSION_PATCHLEVEL 5
+#define PACKAGE_VERSION_PATCHLEVEL 8
 
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
 /* Version number of package */
-#define VERSION "1.0.5"
+#define VERSION "1.0.8"

Index: xsrc/external/mit/xprop/include/config.h
diff -u xsrc/external/mit/xprop/include/config.h:1.4 xsrc/external/mit/xprop/include/config.h:1.5
--- xsrc/external/mit/xprop/include/config.h:1.4	Sat Nov 20 23:25:11 2010
+++ xsrc/external/mit/xprop/include/config.h	Mon Mar 17 10:03:19 2014
@@ -47,7 +47,7 @@
 #define PACKAGE_NAME "xprop"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "xprop 1.2.0"
+#define PACKAGE_STRING "xprop 1.2.2"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "xprop"
@@ -56,7 +56,7 @@
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "1.2.0"
+#define PACKAGE_VERSION "1.2.2"
 
 /* Major version of this package */
 #define PACKAGE_VERSION_MAJOR 1
@@ -65,10 +65,10 @@
 #define PACKAGE_VERSION_MINOR 2
 
 /* Patch version of this package */
-#define PACKAGE_VERSION_PATCHLEVEL 0
+#define PACKAGE_VERSION_PATCHLEVEL 2
 
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
 /* Version number of package */
-#define VERSION "1.2.0"
+#define VERSION "1.2.2"

Index: xsrc/external/mit/xrandr/dist/xrandr.c
diff -u xsrc/external/mit/xrandr/dist/xrandr.c:1.9 xsrc/external/mit/xrandr/dist/xrandr.c:1.10
--- xsrc/external/mit/xrandr/dist/xrandr.c:1.9	Wed Jun 12 07:50:29 2013
+++ xsrc/external/mit/xrandr/dist/xrandr.c	Mon Mar 17 10:03:19 2014
@@ -97,62 +97,62 @@ static const struct {
 static void
 usage(void)
 {
-    printf("usage: %s [options]\n", program_name);
-    printf("  where options are:\n");
-    printf("  -display <display> or -d <display>\n");
-    printf("  --help\n");
-    printf("  -o <normal,inverted,left,right,0,1,2,3>\n");
-    printf("            or --orientation <normal,inverted,left,right,0,1,2,3>\n");
-    printf("  -q        or --query\n");
-    printf("  -s <size>/<width>x<height> or --size <size>/<width>x<height>\n");
-    printf("  -r <rate> or --rate <rate> or --refresh <rate>\n");
-    printf("  -v        or --version\n");
-    printf("  -x        (reflect in x)\n");
-    printf("  -y        (reflect in y)\n");
-    printf("  --screen <screen>\n");
-    printf("  --verbose\n");
-    printf("  --current\n");
-    printf("  --dryrun\n");
-    printf("  --nograb\n");
-    printf("  --prop or --properties\n");
-    printf("  --fb <width>x<height>\n");
-    printf("  --fbmm <width>x<height>\n");
-    printf("  --dpi <dpi>/<output>\n");
-    printf("  --output <output>\n");
-    printf("      --auto\n");
-    printf("      --mode <mode>\n");
-    printf("      --preferred\n");
-    printf("      --pos <x>x<y>\n");
-    printf("      --rate <rate> or --refresh <rate>\n");
-    printf("      --reflect normal,x,y,xy\n");
-    printf("      --rotate normal,inverted,left,right\n");
-    printf("      --left-of <output>\n");
-    printf("      --right-of <output>\n");
-    printf("      --above <output>\n");
-    printf("      --below <output>\n");
-    printf("      --same-as <output>\n");
-    printf("      --set <property> <value>\n");
-    printf("      --scale <x>x<y>\n");
-    printf("      --scale-from <w>x<h>\n");
-    printf("      --transform <a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>\n");
-    printf("      --off\n");
-    printf("      --crtc <crtc>\n");
-    printf("      --panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]\n");
-    printf("      --gamma <r>:<g>:<b>\n");
-    printf("      --primary\n");
-    printf("  --noprimary\n");
-    printf("  --newmode <name> <clock MHz>\n");
-    printf("            <hdisp> <hsync-start> <hsync-end> <htotal>\n");
-    printf("            <vdisp> <vsync-start> <vsync-end> <vtotal>\n");
-    printf("            [flags...]\n");
-    printf("            Valid flags: +HSync -HSync +VSync -VSync\n");
-    printf("                         +CSync -CSync CSync Interlace DoubleScan\n");
-    printf("  --rmmode <name>\n");
-    printf("  --addmode <output> <name>\n");
-    printf("  --delmode <output> <name>\n");
-    printf("  --listproviders\n");
-    printf("  --setprovideroutputsource <prov-xid> <source-xid>\n");
-    printf("  --setprovideroffloadsink <prov-xid> <sink-xid>\n");
+    printf("usage: %s [options]\n%s", program_name,
+           "  where options are:\n"
+           "  --display <display> or -d <display>\n"
+           "  --help\n"
+           "  -o <normal,inverted,left,right,0,1,2,3>\n"
+           "            or --orientation <normal,inverted,left,right,0,1,2,3>\n"
+           "  -q        or --query\n"
+           "  -s <size>/<width>x<height> or --size <size>/<width>x<height>\n"
+           "  -r <rate> or --rate <rate> or --refresh <rate>\n"
+           "  -v        or --version\n"
+           "  -x        (reflect in x)\n"
+           "  -y        (reflect in y)\n"
+           "  --screen <screen>\n"
+           "  --verbose\n"
+           "  --current\n"
+           "  --dryrun\n"
+           "  --nograb\n"
+           "  --prop or --properties\n"
+           "  --fb <width>x<height>\n"
+           "  --fbmm <width>x<height>\n"
+           "  --dpi <dpi>/<output>\n"
+           "  --output <output>\n"
+           "      --auto\n"
+           "      --mode <mode>\n"
+           "      --preferred\n"
+           "      --pos <x>x<y>\n"
+           "      --rate <rate> or --refresh <rate>\n"
+           "      --reflect normal,x,y,xy\n"
+           "      --rotate normal,inverted,left,right\n"
+           "      --left-of <output>\n"
+           "      --right-of <output>\n"
+           "      --above <output>\n"
+           "      --below <output>\n"
+           "      --same-as <output>\n"
+           "      --set <property> <value>\n"
+           "      --scale <x>x<y>\n"
+           "      --scale-from <w>x<h>\n"
+           "      --transform <a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>\n"
+           "      --off\n"
+           "      --crtc <crtc>\n"
+           "      --panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]\n"
+           "      --gamma <r>:<g>:<b>\n"
+           "      --primary\n"
+           "  --noprimary\n"
+           "  --newmode <name> <clock MHz>\n"
+           "            <hdisp> <hsync-start> <hsync-end> <htotal>\n"
+           "            <vdisp> <vsync-start> <vsync-end> <vtotal>\n"
+           "            [flags...]\n"
+           "            Valid flags: +HSync -HSync +VSync -VSync\n"
+           "                         +CSync -CSync CSync Interlace DoubleScan\n"
+           "  --rmmode <name>\n"
+           "  --addmode <output> <name>\n"
+           "  --delmode <output> <name>\n"
+           "  --listproviders\n"
+           "  --setprovideroutputsource <prov-xid> <source-xid>\n"
+           "  --setprovideroffloadsink <prov-xid> <sink-xid>\n");
 }
 
 static void _X_NORETURN _X_ATTRIBUTE_PRINTF(1,2)
@@ -229,7 +229,7 @@ reflection_name (Rotation rotation)
     return "invalid reflection";
 }
 
-static char *
+static const char *
 capability_name (int cap_bit)
 {
     switch (cap_bit) {
@@ -2510,7 +2510,8 @@ main (int argc, char **argv)
 
     program_name = argv[0];
     for (i = 1; i < argc; i++) {
-	if (!strcmp ("-display", argv[i]) || !strcmp ("-d", argv[i])) {
+	if (!strcmp ("-display", argv[i]) || !strcmp ("--display", argv[i]) ||
+	    !strcmp ("-d", argv[i])) {
 	    if (++i >= argc) argerr ("%s requires an argument\n", argv[i-1]);
 	    display_name = argv[i];
 	    continue;
@@ -2926,7 +2927,7 @@ main (int argc, char **argv)
 	}
 	if (!strcmp ("--newmode", argv[i]))
 	{
-	    umode_t  *m = malloc (sizeof (umode_t));
+	    umode_t  *m = calloc (1, sizeof (umode_t));
 	    double    clock;
 	    
 	    ++i;
@@ -2968,7 +2969,7 @@ main (int argc, char **argv)
 	}
 	if (!strcmp ("--rmmode", argv[i]))
 	{
-	    umode_t  *m = malloc (sizeof (umode_t));
+	    umode_t  *m = calloc (1, sizeof (umode_t));
 
 	    if (++i >= argc) argerr ("%s requires an argument\n", argv[i-1]);
 	    set_name (&m->name, argv[i], name_string|name_xid);
@@ -2981,7 +2982,7 @@ main (int argc, char **argv)
 	}
 	if (!strcmp ("--addmode", argv[i]))
 	{
-	    umode_t  *m = malloc (sizeof (umode_t));
+	    umode_t  *m = calloc (1, sizeof (umode_t));
 
 	    if (i+2 >= argc) argerr ("%s requires two arguments\n", argv[i]);
 	    set_name (&m->output, argv[++i], name_string|name_xid);
@@ -2995,7 +2996,7 @@ main (int argc, char **argv)
 	}
 	if (!strcmp ("--delmode", argv[i]))
 	{
-	    umode_t  *m = malloc (sizeof (umode_t));
+	    umode_t  *m = calloc (1, sizeof (umode_t));
 
 	    if (i+2 >= argc) argerr ("%s requires two arguments\n", argv[i]);
 	    set_name (&m->output, argv[++i], name_string|name_xid);
@@ -3562,6 +3563,8 @@ main (int argc, char **argv)
 			    print_output_property_value (False, 32, actual_type,
 							 (unsigned char *) &(propinfo->values[k * 2 + 1]));
 			    printf (")");
+			    if (k < propinfo->num_values / 2 - 1)
+				printf (", ");
 			}
 			printf ("\n");
 		    }
@@ -3572,6 +3575,8 @@ main (int argc, char **argv)
 			{
 			    print_output_property_value (False, 32, actual_type,
 							 (unsigned char *) &(propinfo->values[k]));
+			    if (k < propinfo->num_values - 1)
+				printf (", ");
 			}
 			printf ("\n");
 		    }

Index: xsrc/external/mit/xrdb/dist/xrdb.c
diff -u xsrc/external/mit/xrdb/dist/xrdb.c:1.6 xsrc/external/mit/xrdb/dist/xrdb.c:1.7
--- xsrc/external/mit/xrdb/dist/xrdb.c:1.6	Fri Jul 19 08:29:24 2013
+++ xsrc/external/mit/xrdb/dist/xrdb.c	Mon Mar 17 10:03:20 2014
@@ -128,7 +128,7 @@ static int oper = OPLOAD;
 static char *editFile = NULL;
 static const char *cpp_program = NULL;
 static const char* const cpp_locations[] = { CPP };
-static char *backup_suffix = BACKUP_SUFFIX;
+static const char *backup_suffix = BACKUP_SUFFIX;
 static Bool dont_execute = False;
 static String defines;
 static int defines_base;
@@ -140,12 +140,12 @@ static Display *dpy;
 static Buffer buffer;
 static Entries newDB;
 
-static void fatal(char *, ...);
+static void fatal(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
 static void addstring ( String *arg, const char *s );
 static void addescapedstring ( String *arg, const char *s );
 static void addtokstring ( String *arg, const char *s );
-static void FormatEntries ( Buffer *buffer, Entries *entries );
-static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
+static void FormatEntries ( Buffer *b, Entries *entries );
+static void StoreProperty ( Display *display, Window root, Atom res_prop );
 static void Process ( int scrno, Bool doScreen, Bool execute );
 static void ShuffleEntries ( Entries *db, Entries *dbs, int num );
 static void ReProcess ( int scrno, Bool doScreen );
@@ -192,42 +192,42 @@ asprintf(char ** ret, const char *format
 }
 #endif /* HAVE_ASPRINTF */
 
-static void 
+static void
 InitBuffer(Buffer *b)
 {
     b->room = INIT_BUFFER_SIZE;
     b->used = 0;
-    b->buff = (char *)malloc(INIT_BUFFER_SIZE*sizeof(char));
+    b->buff = malloc(INIT_BUFFER_SIZE*sizeof(char));
 }
 
 #ifdef notyet
-static void 
+static void
 FreeBuffer(Buffer *b)
 {
     free(b->buff);
 }
 #endif
 
-static void 
-AppendToBuffer(Buffer *b, char *str, int len)
+static void
+AppendToBuffer(Buffer *b, const char *str, int len)
 {
     while (b->used + len > b->room) {
-	b->buff = (char *)realloc(b->buff, 2*b->room*(sizeof(char)));
+	b->buff = realloc(b->buff, 2*b->room*(sizeof(char)));
 	b->room *= 2;
     }
     strncpy(b->buff + b->used, str, len);
     b->used += len;
 }
 
-static void 
+static void
 InitEntries(Entries *e)
 {
     e->room = INIT_ENTRY_SIZE;
     e->used = 0;
-    e->entry = (Entry *)malloc(INIT_ENTRY_SIZE*sizeof(Entry));
+    e->entry = malloc(INIT_ENTRY_SIZE*sizeof(Entry));
 }
 
-static void 
+static void
 FreeEntries(Entries *e)
 {
     register int i;
@@ -241,7 +241,7 @@ FreeEntries(Entries *e)
     free((char *)e->entry);
 }
 
-static void 
+static void
 AddEntry(Entries *e, Entry *entry)
 {
     register int n;
@@ -250,9 +250,9 @@ AddEntry(Entries *e, Entry *entry)
 	if (!strcmp(e->entry[n].tag, entry->tag)) {
 	    /* overwrite old entry */
 	    if (e->entry[n].lineno && !quiet) {
-		fprintf (stderr, 
+		fprintf (stderr,
 			 "%s:  \"%s\" on line %d overrides entry on line %d\n",
-			 ProgramName, entry->tag, entry->lineno, 
+			 ProgramName, entry->tag, entry->lineno,
 			 e->entry[n].lineno);
 	    }
 	    free(e->entry[n].tag);
@@ -264,8 +264,7 @@ AddEntry(Entries *e, Entry *entry)
     }
 
     if (e->used == e->room) {
-	e->entry = (Entry *)realloc((char *)e->entry,
-				    2*e->room*(sizeof(Entry)));
+	e->entry = realloc(e->entry, 2 * e->room * (sizeof(Entry)));
 	e->room *= 2;
     }
     entry->usable = True;
@@ -273,27 +272,27 @@ AddEntry(Entries *e, Entry *entry)
 }
 
 
-static int 
+static int
 CompareEntries(const void *e1, const void *e2)
 {
-    return strcmp(((Entry *)e1)->tag, ((Entry *)e2)->tag);
+    return strcmp(((const Entry *)e1)->tag, ((const Entry *)e2)->tag);
 }
 
-static void 
-AppendEntryToBuffer(Buffer *buffer, Entry *entry)
+static void
+AppendEntryToBuffer(Buffer *b, Entry *entry)
 {
-    AppendToBuffer(buffer, entry->tag, strlen(entry->tag));
-    AppendToBuffer(buffer, ":\t", 2);
-    AppendToBuffer(buffer, entry->value, strlen(entry->value));
-    AppendToBuffer(buffer, "\n", 1);
+    AppendToBuffer(b, entry->tag, strlen(entry->tag));
+    AppendToBuffer(b, ":\t", 2);
+    AppendToBuffer(b, entry->value, strlen(entry->value));
+    AppendToBuffer(b, "\n", 1);
 }
 
 /*
  * Return the position of the first unescaped occurrence of dest in string.
  * If lines is non-null, return the number of newlines skipped over.
  */
-static char *
-FindFirst(char *string, char dest, int *lines)
+static const char *
+FindFirst(const char *string, char dest, int *lines)
 {
     if (lines)
 	*lines = 0;
@@ -311,10 +310,10 @@ FindFirst(char *string, char dest, int *
     }
 }
 
-static void 
+static void
 GetEntries(Entries *entries, Buffer *buff, int bequiet)
 {
-    register char *line, *colon, *temp, *str;
+    const char *line, *colon, *temp, *str;
     Entry entry;
     register int length;
     int lineno = 0;
@@ -339,15 +338,15 @@ GetEntries(Entries *entries, Buffer *buf
 		lineno = dummy - 1;
 	    continue;
 	}
-	for (temp = str; 
-	     *temp && *temp != '\n' && isascii(*temp) && isspace(*temp); 
+	for (temp = str;
+	     *temp && *temp != '\n' && isascii(*temp) && isspace(*temp);
 	     temp++) ;
 	if (!*temp || *temp == '\n') continue;
 
 	colon = FindFirst(str, ':', NULL);
 	if (!colon || colon > line) {
 	    if (!bequiet && !quiet)
-		fprintf (stderr, 
+		fprintf (stderr,
 			 "%s: colon missing on line %d, ignoring line\n",
 			 ProgramName, lineno);
 	    continue;
@@ -359,20 +358,18 @@ GetEntries(Entries *entries, Buffer *buf
 	length = colon - str;
 	while (length && (str[length-1] == ' ' || str[length-1] == '\t'))
 	    length--;
-	temp = (char *)malloc(length + 1);
-	strncpy(temp, str, length);
-	temp[length] = '\0';
-	entry.tag = temp;
+	entry.tag = malloc(length + 1);
+	strncpy(entry.tag, str, length);
+	entry.tag[length] = '\0';
 
 	/* strip leading and trailing blanks from value and store result */
 	colon++;
 	while (*colon == ' ' || *colon == '\t')
 	    colon++;
 	length = line - colon;
-	temp = (char *)malloc(length + 1);
-	strncpy(temp, colon, length);
-	temp[length] = '\0';
-	entry.value = temp;
+	entry.value = malloc(length + 1);
+	strncpy(entry.value, colon, length);
+	entry.value[length] = '\0';
 	entry.lineno = bequiet ? 0 : lineno;
 
 	AddEntry(entries, &entry);
@@ -391,13 +388,13 @@ GetEntriesString(Entries *entries, char 
     }
 }
 
-static void 
-ReadFile(Buffer *buffer, FILE *input)
+static void
+ReadFile(Buffer *b, FILE *input)
 {
 	     char	buf[BUFSIZ + 1];
     register int	bytes;
 
-    buffer->used = 0;
+    b->used = 0;
     while (!feof(input) && (bytes = fread(buf, 1, BUFSIZ, input)) > 0) {
 #ifdef WIN32
 	char *p;
@@ -409,13 +406,13 @@ ReadFile(Buffer *buffer, FILE *input)
 	    }
 	}
 #endif
-	AppendToBuffer(buffer, buf, bytes);
+	AppendToBuffer(b, buf, bytes);
     }
-    AppendToBuffer(buffer, "", 1);
+    AppendToBuffer(b, "", 1);
 }
 
 static void
-AddDef(String *buff, char *title, char *value)
+AddDef(String *buff, const char *title, const char *value)
 {
 #ifdef PATHETICCPP
     if (need_real_defines) {
@@ -443,13 +440,13 @@ AddDef(String *buff, char *title, char *
 }
 
 static void
-AddSimpleDef(String *buff, char *title)
+AddSimpleDef(String *buff, const char *title)
 {
     AddDef(buff, title, (char *)NULL);
 }
 
 static void
-AddDefQ(String *buff, char *title, char *value)
+AddDefQ(String *buff, const char *title, const char *value)
 {
 #ifdef PATHETICCPP
     if (need_real_defines)
@@ -466,7 +463,7 @@ AddDefQ(String *buff, char *title, char 
 }
 
 static void
-AddNum(String *buff, char *title, int value)
+AddNum(String *buff, const char *title, int value)
 {
     char num[20];
     snprintf(num, sizeof(num), "%d", value);
@@ -474,7 +471,7 @@ AddNum(String *buff, char *title, int va
 }
 
 static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefTok(String *buff, const char *prefix, char *title)
 {
     char name[512];
 
@@ -483,7 +480,7 @@ AddDefTok(String *buff, char *prefix, ch
 }
 
 static void
-AddDefHostname(String *buff, char *title, char *value)
+AddDefHostname(String *buff, const char *title, const char *value)
 {
     char *s;
     char name[512];
@@ -499,7 +496,7 @@ AddDefHostname(String *buff, char *title
 }
 
 static void
-AddUndef(String *buff, char *title)
+AddUndef(String *buff, const char *title)
 {
 #ifdef PATHETICCPP
     if (need_real_defines) {
@@ -518,7 +515,7 @@ AddUndef(String *buff, char *title)
     addtokstring(buff, title);
 }
 
-static void 
+static void
 DoCmdDefines(String *buff)
 {
     int i;
@@ -534,12 +531,15 @@ DoCmdDefines(String *buff)
 		*val = '=';
 	    } else
 		AddSimpleDef(buff, arg + 2);
-	} else
+	} else if (arg[1] == 'U') {
 	    AddUndef(buff, arg + 2);
+	} else if (!strcmp(arg, "-undef") && oper != OPSYMBOLS) {
+	    addstring(buff, " -undef");
+	}
     }
 }
 
-static int 
+static int
 Resolution(int pixels, int mm)
 {
     if (mm == 0)
@@ -558,7 +558,7 @@ DoDisplayDefines(Display *display, Strin
     char client[MAXHOSTNAMELEN], server[MAXHOSTNAMELEN], *colon;
     char **extnames;
     int n;
-    
+
     XmuGetHostname(client, MAXHOSTNAMELEN);
     strncpy(server, XDisplayName(host), sizeof(server));
     server[sizeof(server) - 1] = '\0';
@@ -567,7 +567,7 @@ DoDisplayDefines(Display *display, Strin
     colon = strrchr(server, ':');
     n = 0;
     if (colon) {
-	/* remove extra colon if there are exactly two, since it indicates 
+	/* remove extra colon if there are exactly two, since it indicates
 	   DECnet.  Three colons is an IPv6 address ending in :: though. */
 	if ((colon > server) && (*(colon-1) == ':') &&
 	  ( ((colon - 1) == server) || (*(colon-2) != ':') ) ) {
@@ -596,7 +596,7 @@ DoDisplayDefines(Display *display, Strin
     XFreeExtensionList(extnames);
 }
 
-static char *ClassNames[] = {
+static const char *ClassNames[] = {
     "StaticGray",
     "GrayScale",
     "StaticColor",
@@ -605,6 +605,8 @@ static char *ClassNames[] = {
     "DirectColor"
 };
 
+#define NUM_CLASS_NAMES (int)(sizeof(ClassNames) / sizeof(ClassNames[0]))
+
 static void
 DoScreenDefines(Display *display, int scrno, String *defs)
 {
@@ -613,7 +615,7 @@ DoScreenDefines(Display *display, int sc
     XVisualInfo vinfo, *vinfos;
     int nv, i, j;
     char name[50];
-    
+
     screen = ScreenOfDisplay(display, scrno);
     visual = DefaultVisualOfScreen(screen);
     vinfo.screen = scrno;
@@ -625,9 +627,16 @@ DoScreenDefines(Display *display, int sc
     AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
     AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
     AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
-    AddDefQ(defs, "CLASS", ClassNames[visual->class]);
-    snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
-    AddNum(defs, name, (int)visual->visualid);
+    if (visual->class >= 0 && visual->class < NUM_CLASS_NAMES) {
+	AddDefQ(defs, "CLASS", ClassNames[visual->class]);
+	snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
+	AddNum(defs, name, (int)visual->visualid);
+    }
+    else {
+	fprintf(stderr,
+		"%s: unknown visual type %d for default visual id 0x%lx\n",
+		ProgramName, visual->class, visual->visualid);
+    }
     switch(visual->class) {
 	case StaticColor:
 	case PseudoColor:
@@ -643,9 +652,16 @@ DoScreenDefines(Display *display, int sc
 		break;
 	}
 	if (j < 0) {
-	    snprintf(name, sizeof(name), "CLASS_%s_%d",
-		    ClassNames[vinfos[i].class], vinfos[i].depth);
-	    AddNum(defs, name, (int)vinfos[i].visualid);
+	    if (vinfos[i].class >= 0 && vinfos[i].class < NUM_CLASS_NAMES) {
+		snprintf(name, sizeof(name), "CLASS_%s_%d",
+			 ClassNames[vinfos[i].class], vinfos[i].depth);
+		AddNum(defs, name, (int)vinfos[i].visualid);
+	    }
+	    else {
+		fprintf(stderr,
+			"%s: unknown visual type %d for visual id 0x%lx\n",
+			ProgramName, vinfos[i].class, vinfos[i].visualid);
+	    }
 	}
     }
     XFree((char *)vinfos);
@@ -682,7 +698,7 @@ FindEntry(Entries *db, Buffer  *b)
     return NULL;
 }
 
-static void 
+static void
 EditFile(Entries *new, FILE *in, FILE *out)
 {
     Buffer b;
@@ -716,12 +732,14 @@ cleanup:
     }
 }
 
-static void 
+static void _X_NORETURN
 Syntax (void)
 {
-    fprintf (stderr, 
+    fprintf (stderr,
 	     "usage:  %s [-options ...] [filename]\n\n"
 	     "where options include:\n"
+	     " -help               print this help message\n"
+	     " -version            print the program version\n"
 	     " -display host:dpy   display to use\n"
 	     " -all                do all resources [default]\n"
 	     " -global             do screen-independent resources\n"
@@ -752,8 +770,8 @@ Syntax (void)
  * whether or not the given string is an abbreviation of the arg.
  */
 
-static Bool 
-isabbreviation(char *arg, char *s, int minslen)
+static Bool
+isabbreviation(const char *arg, const char *s, int minslen)
 {
     int arglen;
     int slen;
@@ -779,9 +797,9 @@ addstring(String *arg, const char *s)
 {
     if(arg->used + strlen(s) + 1 >= arg->room) {
 	if(arg->val)
-	    arg->val = (char *)realloc(arg->val, arg->room + CHUNK_SIZE);
+	    arg->val = realloc(arg->val, arg->room + CHUNK_SIZE);
 	else
-	    arg->val = (char *)malloc(arg->room + CHUNK_SIZE);	    
+	    arg->val = malloc(arg->room + CHUNK_SIZE);
 	if(arg->val == NULL)
 	    fatal("%s: Not enough memory\n", ProgramName);
 	arg->room += CHUNK_SIZE;
@@ -791,7 +809,7 @@ addstring(String *arg, const char *s)
     else
 	strcpy(arg->val, s);
     arg->used += strlen(s);
-}   
+}
 
 static void
 addescapedstring(String *arg, const char *s)
@@ -882,6 +900,9 @@ main(int argc, char *argv[])
 	    } else if (isabbreviation ("-help", arg, 2)) {
 		Syntax ();
 		/* doesn't return */
+	    } else if (isabbreviation ("-version", arg, 2)) {
+		printf("%s\n", PACKAGE_STRING);
+		exit(0);
 	    } else if (isabbreviation ("-display", arg, 2)) {
 		if (++i >= argc) Syntax ();
 		displayname = argv[i];
@@ -956,9 +977,16 @@ main(int argc, char *argv[])
 		    fatal("%s: Too many -U/-D arguments\n", ProgramName);
 		}
 		continue;
+	    } else if (!strcmp ("-undef", arg)) {
+		if (num_cmd_defines < MAX_CMD_DEFINES) {
+		    cmd_defines[num_cmd_defines++] = "-undef";
+		} else {
+		    fatal("%s: Too many cpp arguments\n", ProgramName);
+		}
+		continue;
 	    }
 	    Syntax ();
-	} else if (arg[0] == '=') 
+	} else if (arg[0] == '=')
 	    continue;
 	else
 	    filename = arg;
@@ -1033,11 +1061,11 @@ main(int argc, char *argv[])
 	if (!fp)
 	    fatal("%s: Failed to open temp file: %s\n", ProgramName,
 		  filename);
-	while (fgets(inputbuf, sizeof(inputbuf), stdin) != NULL) 
+	while (fgets(inputbuf, sizeof(inputbuf), stdin) != NULL)
 	    fputs(inputbuf, fp);
 	fclose(fp);
     }
-	
+
     DoDisplayDefines(dpy, &defines, displayname);
     defines_base = defines.used;
     need_newline = (oper == OPQUERY || oper == OPSYMBOLS ||
@@ -1077,7 +1105,7 @@ main(int argc, char *argv[])
     else {
 	Entries *dbs;
 
-	dbs = (Entries *)malloc(ScreenCount(dpy) * sizeof(Entries));
+	dbs = malloc(ScreenCount(dpy) * sizeof(Entries));
 	for (i = 0; i < ScreenCount(dpy); i++) {
 	    Process(i, True, False);
 	    dbs[i] = newDB;
@@ -1115,12 +1143,12 @@ main(int argc, char *argv[])
 }
 
 
-static void 
-FormatEntries(Buffer *buffer, Entries *entries)
+static void
+FormatEntries(Buffer *b, Entries *entries)
 {
     register int i;
 
-    buffer->used = 0;
+    b->used = 0;
     if (!entries->used)
 	return;
     if (oper == OPMERGE)
@@ -1128,30 +1156,30 @@ FormatEntries(Buffer *buffer, Entries *e
 	      CompareEntries);
     for (i = 0; i < entries->used; i++) {
 	if (entries->entry[i].usable)
-	    AppendEntryToBuffer(buffer, &entries->entry[i]);
+	    AppendEntryToBuffer(b, &entries->entry[i]);
     }
 }
 
 static void
-StoreProperty(Display *dpy, Window root, Atom res_prop)
+StoreProperty(Display *display, Window root, Atom res_prop)
 {
     int len = buffer.used;
     int mode = PropModeReplace;
     unsigned char *buf = (unsigned char *)buffer.buff;
-    int max = (XMaxRequestSize(dpy) << 2) - 28;
+    int max = (XMaxRequestSize(display) << 2) - 28;
 
     if (len > max) {
-	XGrabServer(dpy);
+	XGrabServer(display);
 	do {
-	    XChangeProperty(dpy, root, res_prop, XA_STRING, 8, mode, buf, max);
+	    XChangeProperty(display, root, res_prop, XA_STRING, 8, mode, buf, max);
 	    buf += max;
 	    len -= max;
 	    mode = PropModeAppend;
 	} while (len > max);
     }
-    XChangeProperty(dpy, root, res_prop, XA_STRING, 8, mode, buf, len);
+    XChangeProperty(display, root, res_prop, XA_STRING, 8, mode, buf, len);
     if (mode != PropModeReplace)
-	XUngrabServer(dpy);
+	XUngrabServer(display);
 }
 
 static void
@@ -1195,7 +1223,7 @@ Process(int scrno, Bool doScreen, Bool e
 	(void) mktemp(template);
 	output = fopen(template, "w");
 #else
-	{ 
+	{
 	int fd = mkstemp(template);
 	output = fdopen(fd, "w");
 	}
@@ -1227,8 +1255,18 @@ Process(int scrno, Bool doScreen, Bool e
 		      template, editFile);
 	}
     } else {
+	const char *cpp_addflags = "";
+
 	if (oper == OPMERGE || oper == OPOVERRIDE)
 	    GetEntriesString(&newDB, xdefs);
+
+	/* Add -P flag only if using cpp, not another preprocessor */
+	if (cpp_program) {
+	    const char *cp = strstr(cpp_program, "cpp");
+
+	    if (cp && ((cp[3] == '\0') || cp[3] == ' '))
+		cpp_addflags = "-P";
+	}
 #ifdef PATHETICCPP
 	if (need_real_defines) {
 #ifdef WIN32
@@ -1238,8 +1276,8 @@ Process(int scrno, Bool doScreen, Bool e
 	    fprintf(input, "\n#include \"%s\"\n", filename);
 	    fclose(input);
 	    (void) mktemp(tmpname3);
-	    if (asprintf(&cmd, "%s -P%s %s > %s", cpp_program, includes.val,
-			 tmpname2, tmpname3) == -1)
+	    if (asprintf(&cmd, "%s %s %s %s > %s", cpp_program, cpp_addflags,
+			 includes.val, tmpname2, tmpname3) == -1)
 		fatal("%s: Out of memory\n", ProgramName);
 	    if (system(cmd) < 0)
 		fatal("%s: cannot run '%s'\n", ProgramName, cmd);
@@ -1253,7 +1291,8 @@ Process(int scrno, Bool doScreen, Bool e
 	    fprintf(stdin, "\n#include \"%s\"\n", filename);
 	    fflush(stdin);
 	    fseek(stdin, 0, 0);
-	    if (asprintf(&cmd, "%s -P%s", cpp_program, includes.val) == -1)
+	    if (asprintf(&cmd, "%s %s %s", cpp_program, cpp_addflags,
+			 includes.val) == -1)
 		fatal("%s: Out of memory\n", ProgramName);
 	    if (!(input = popen(cmd, "r")))
 		fatal("%s: cannot run '%s'\n", ProgramName, cmd);
@@ -1268,8 +1307,8 @@ Process(int scrno, Bool doScreen, Bool e
 	if (cpp_program) {
 #ifdef WIN32
 	    (void) mktemp(tmpname3);
-	    if (asprintf(&cmd, "%s -P%s %s %s > %s", cpp_program,
-			 includes.val, defines.val,
+	    if (asprintf(&cmd, "%s %s %s %s %s > %s", cpp_program,
+			 cpp_addflags, includes.val, defines.val,
 			 filename ? filename : "", tmpname3) == -1)
 		fatal("%s: Out of memory\n", ProgramName);
 	    if (system(cmd) < 0)
@@ -1278,8 +1317,8 @@ Process(int scrno, Bool doScreen, Bool e
 	    if (!(input = fopen(tmpname3, "r")))
 		fatal("%s: can't open file '%s'\n", ProgramName, tmpname3);
 #else
-	    if (asprintf(&cmd, "%s -P%s %s %s", cpp_program,
-			 includes.val, defines.val,
+	    if (asprintf(&cmd, "%s %s %s %s %s", cpp_program,
+			 cpp_addflags, includes.val, defines.val,
 			 filename ? filename : "") == -1)
 		fatal("%s: Out of memory\n", ProgramName);
 	    if (!(input = popen(cmd, "r")))
@@ -1337,7 +1376,7 @@ ShuffleEntries(Entries *db, Entries *dbs
     Entries cur, cmp;
     char *curtag, *curvalue;
 
-    hits = (int *)malloc(num * sizeof(int));
+    hits = malloc(num * sizeof(int));
     cur = dbs[0];
     for (i = 0; i < cur.used; i++) {
 	curtag = cur.entry[i].tag;
@@ -1395,7 +1434,7 @@ ReProcess(int scrno, Bool doScreen)
 }
 
 static void
-fatal(char *msg, ...)
+fatal(const char *msg, ...)
 {
     va_list args;
 

Reply via email to