[Xquartz-changes] xserver: Branch 'master' - 2 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Mon Apr 25 22:01:45 PDT 2011


 hw/xquartz/GL/capabilities.c          |    6 -
 hw/xquartz/X11Application.m           |   10 +-
 hw/xquartz/darwin.c                   |    4 -
 hw/xquartz/mach-startup/bundle-main.c |   73 ++++++++++---------
 hw/xquartz/mach-startup/stub.c        |   16 ----
 hw/xquartz/pbproxy/app-main.m         |   16 +++-
 hw/xquartz/pbproxy/main.m             |   20 -----
 hw/xquartz/pbproxy/pbproxy.h          |   10 +-
 hw/xquartz/pbproxy/x-input.m          |    2 
 hw/xquartz/pbproxy/x-selection.m      |  129 ++++++++++++++++------------------
 hw/xquartz/quartzKeyboard.c           |    4 -
 11 files changed, 136 insertions(+), 154 deletions(-)

New commits:
commit 6f29dbf5e36bef5ecb08f02d367988dee0f9f1cd
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Apr 25 22:00:41 2011 -0700

    XQuartz: Use ErrorF rather than fprintf to log errors
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/GL/capabilities.c b/hw/xquartz/GL/capabilities.c
index fc7dd57..dd3f855 100644
--- a/hw/xquartz/GL/capabilities.c
+++ b/hw/xquartz/GL/capabilities.c
@@ -507,7 +507,7 @@ bool getGlCapabilities(struct glCapabilities *cap) {
 
 	err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers);
     if(err) {
-	    fprintf(stderr, "CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
+	    ErrorF("CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
         return err;
 	}
 
@@ -518,8 +518,8 @@ bool getGlCapabilities(struct glCapabilities *cap) {
 
 	    err = handleRendererDescriptions(info, r, &tmpconf);
 	    if(err) {
-            fprintf(stderr, "handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
-            fprintf(stderr, "trying to continue...\n");
+            ErrorF("handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
+            ErrorF("trying to continue...\n");
             continue;
 	    }
 
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 2a45cc5..283132e 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -978,7 +978,7 @@ static inline pthread_t create_thread(void *(*func)(void *), void *arg) {
 static void *xpbproxy_x_thread(void *args) {
     xpbproxy_run();
 
-    fprintf(stderr, "xpbproxy thread is terminating unexpectedly.\n");
+    ErrorF("xpbproxy thread is terminating unexpectedly.\n");
     return NULL;
 }
 
@@ -1021,15 +1021,15 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
     last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();    
 
     if(!last_key_layout)
-        fprintf(stderr, "X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
+        ErrorF("X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
 #else
     KLGetCurrentKeyboardLayout(&last_key_layout);
     if(!last_key_layout)
-        fprintf(stderr, "X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
+        ErrorF("X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
 #endif
 
     if (!QuartsResyncKeymap(FALSE)) {
-        fprintf(stderr, "X11ApplicationMain: Could not build a valid keymap.\n");
+        ErrorF("X11ApplicationMain: Could not build a valid keymap.\n");
     }
 
     /* Tell the server thread that it can proceed */
@@ -1370,7 +1370,7 @@ static const char *untrusted_str(NSEvent *e) {
 #endif
                     /* Update keyInfo */
                     if (!QuartsResyncKeymap(TRUE)) {
-                        fprintf(stderr, "sendX11NSEvent: Could not build a valid keymap.\n");
+                        ErrorF("sendX11NSEvent: Could not build a valid keymap.\n");
                     }
                 }
             }
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 2e18a74..50234f2 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -136,9 +136,9 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
 void
 DarwinPrintBanner(void)
 { 
-  // this should change depending on which specific server we are building
   ErrorF("Xquartz starting:\n");
-  ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE );
+  ErrorF("X.Org X Server %s\n", XSERVER_VERSION);
+  ErrorF("Build Date: %s\n", BUILD_DATE );
 }
 
 
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index bde259e..846025b 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -64,6 +64,9 @@
 /* From darwinEvents.c ... but don't want to pull in all the server cruft */
 void DarwinListenOnOpenFD(int fd);
 
+/* Ditto, from os/log.c */
+extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
+
 extern int noPanoramiXExtension;
 
 #define DEFAULT_CLIENT X11BINDIR "/xterm"
@@ -134,13 +137,13 @@ static mach_port_t checkin_or_register(char *bname) {
     /* We probably were not started by launchd or the old mach_init */
     kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp);
     if (kr != KERN_SUCCESS) {
-        fprintf(stderr, "mach_port_allocate(): %s\n", mach_error_string(kr));
+        ErrorF("mach_port_allocate(): %s\n", mach_error_string(kr));
         exit(EXIT_FAILURE);
     }
 
     kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
     if (kr != KERN_SUCCESS) {
-        fprintf(stderr, "mach_port_insert_right(): %s\n", mach_error_string(kr));
+        ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr));
         exit(EXIT_FAILURE);
     }
 
@@ -154,7 +157,7 @@ static mach_port_t checkin_or_register(char *bname) {
 #endif
 
     if (kr != KERN_SUCCESS) {
-        fprintf(stderr, "bootstrap_register(): %s\n", mach_error_string(kr));
+        ErrorF("bootstrap_register(): %s\n", mach_error_string(kr));
         exit(EXIT_FAILURE);
     }
 
@@ -197,7 +200,7 @@ static int accept_fd_handoff(int connected_fd) {
     *((int*)CMSG_DATA(cmsg)) = -1;
     
     if(recvmsg(connected_fd, &msg, 0) < 0) {
-        fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor.  recvmsg() error: %s\n", strerror(errno));
+        ErrorF("X11.app: Error receiving $DISPLAY file descriptor.  recvmsg() error: %s\n", strerror(errno));
         return -1;
     }
     
@@ -230,14 +233,14 @@ static void *socket_handoff_thread(void *arg) {
     while(launchd_fd == -1) {
         connected_fd = accept(handoff_data->fd, NULL, NULL);
         if(connected_fd == -1) {
-            fprintf(stderr, "X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno));
+            ErrorF("X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno));
             sleep(2);
             continue;
         }
 
         launchd_fd = accept_fd_handoff(connected_fd);
         if(launchd_fd == -1)
-            fprintf(stderr, "X11.app: Error receiving $DISPLAY file descriptor, no descriptor received?  Waiting for another connection.\n");
+            ErrorF("X11.app: Error receiving $DISPLAY file descriptor, no descriptor received?  Waiting for another connection.\n");
 
         close(connected_fd);
     }
@@ -246,7 +249,7 @@ static void *socket_handoff_thread(void *arg) {
     unlink(handoff_data->filename);
     free(handoff_data);
         
-    fprintf(stderr, "X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);
+    ErrorF("X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);
     DarwinListenOnOpenFD(launchd_fd);
 
 #ifndef HAVE_LIBDISPATCH
@@ -274,24 +277,24 @@ static int create_socket(char *filename_out) {
         
         ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
         if(ret_fd == -1) {
-            fprintf(stderr, "X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
+            ErrorF("X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
             continue;
         }
         
         if(bind(ret_fd, servaddr, servaddr_len) != 0) {
-            fprintf(stderr, "X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno));
+            ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno));
             close(ret_fd);
             return 0;
         }
         
         if(listen(ret_fd, 10) != 0) {
-            fprintf(stderr, "X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
+            ErrorF("X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
             close(ret_fd);
             return 0;
         }
         
 #ifdef DEBUG
-        fprintf(stderr, "X11.app: Listening on socket for fd handoff:  (%d) %s\n", ret_fd, filename_out);
+        ErrorF("X11.app: Listening on socket for fd handoff:  (%d) %s\n", ret_fd, filename_out);
 #endif
         
         return ret_fd;
@@ -309,7 +312,7 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename)
 
     handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
     if(!handoff_data) {
-        fprintf(stderr, "X11.app: Error allocating memory for handoff_data\n");
+        ErrorF("X11.app: Error allocating memory for handoff_data\n");
         return KERN_FAILURE;
     }
 
@@ -330,7 +333,7 @@ kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename)
 #endif
     
 #ifdef DEBUG
-    fprintf(stderr, "X11.app: Thread created for handoff.  Returning success to tell caller to connect and push the fd.\n");
+    ErrorF("X11.app: Thread created for handoff.  Returning success to tell caller to connect and push the fd.\n");
 #endif
 
     return KERN_SUCCESS;
@@ -355,7 +358,7 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
      * unset DISPLAY or we can run into problems with pbproxy
      */
     if(!launchd_socket_handed_off) {
-        fprintf(stderr, "X11.app: No launchd socket handed off, unsetting DISPLAY\n");
+        ErrorF("X11.app: No launchd socket handed off, unsetting DISPLAY\n");
         unsetenv("DISPLAY");
     }
     
@@ -363,10 +366,10 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
         return KERN_FAILURE;
     }
 
-    fprintf(stderr, "X11.app: do_start_x11_server(): argc=%d\n", argvCnt);
+    ErrorF("X11.app: do_start_x11_server(): argc=%d\n", argvCnt);
     for(i=0; i < argvCnt; i++) {
         _argv[i] = argv[i];
-        fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
+        ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
     }
     _argv[argvCnt] = NULL;
     
@@ -404,7 +407,7 @@ static int startup_trigger(int argc, char **argv, char **envp) {
         newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
         
         if(!newargv || !newenvp) {
-            fprintf(stderr, "Memory allocation failure\n");
+            ErrorF("Memory allocation failure\n");
             exit(EXIT_FAILURE);
         }
         
@@ -418,16 +421,16 @@ static int startup_trigger(int argc, char **argv, char **envp) {
         kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
         if (kr != KERN_SUCCESS) {
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-            fprintf(stderr, "bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr));
+            ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr));
 #else
-            fprintf(stderr, "bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr);
+            ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr);
 #endif
             exit(EXIT_FAILURE);
         }
 
         kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
         if (kr != KERN_SUCCESS) {
-            fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr));
+            ErrorF("start_x11_server: %s\n", mach_error_string(kr));
             exit(EXIT_FAILURE);
         }
         exit(EXIT_SUCCESS);
@@ -449,10 +452,10 @@ static int startup_trigger(int argc, char **argv, char **envp) {
 
     /* Start the server */
     if((s = getenv("DISPLAY"))) {
-        fprintf(stderr, "X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting).  Starting X server.\n", s);
+        ErrorF("X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting).  Starting X server.\n", s);
         unsetenv("DISPLAY");
     } else {
-        fprintf(stderr, "X11.app: Could not connect to server (DISPLAY is not set).  Starting X server.\n");
+        ErrorF("X11.app: Could not connect to server (DISPLAY is not set).  Starting X server.\n");
     }
     return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
 }
@@ -496,7 +499,7 @@ static void setup_env(void) {
 
     server_bootstrap_name = strdup(pds);
     if(!server_bootstrap_name) {
-        fprintf(stderr, "X11.app: Memory allocation error.\n");
+        ErrorF("X11.app: Memory allocation error.\n");
         exit(1);
     }
     setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1);
@@ -504,7 +507,7 @@ static void setup_env(void) {
     len = strlen(server_bootstrap_name);
     bundle_id_prefix = malloc(sizeof(char) * (len - 3));
     if(!bundle_id_prefix) {
-        fprintf(stderr, "X11.app: Memory allocation error.\n");
+        ErrorF("X11.app: Memory allocation error.\n");
         exit(1);
     }
     strlcpy(bundle_id_prefix, server_bootstrap_name, len - 3);
@@ -520,11 +523,11 @@ static void setup_env(void) {
 
         if(s && *s) {
             if(strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) {
-                fprintf(stderr, "X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
+                ErrorF("X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
             } else {
                 temp = (char *)malloc(sizeof(char) * len);
                 if(!temp) {
-                    fprintf(stderr, "X11.app: Memory allocation error creating space for socket name test.\n");
+                    ErrorF("X11.app: Memory allocation error creating space for socket name test.\n");
                     exit(1);
                 }
                 strlcpy(temp, bundle_id_prefix, len);
@@ -532,14 +535,14 @@ static void setup_env(void) {
             
                 if(strcmp(temp, s) != 0) {
                     /* If we don't have a match, unset it. */
-                    fprintf(stderr, "X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, bundle_id_prefix);
+                    ErrorF("X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, bundle_id_prefix);
                     unsetenv("DISPLAY");
                 }
                 free(temp);
             }
         } else {
             /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
-            fprintf(stderr, "X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
+            ErrorF("X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
             unsetenv("DISPLAY");
         }
     }
@@ -570,9 +573,9 @@ int main(int argc, char **argv, char **envp) {
     /* Setup the initial crasherporter info */
     strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__));
     
-    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
+    ErrorF("X11.app: main(): argc=%d\n", argc);
     for(i=0; i < argc; i++) {
-        fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
+        ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
         if(!strcmp(argv[i], "--listenonly")) {
             listenOnly = TRUE;
         }
@@ -580,7 +583,7 @@ int main(int argc, char **argv, char **envp) {
 
     mp = checkin_or_register(server_bootstrap_name);
     if(mp == MACH_PORT_NULL) {
-        fprintf(stderr, "NULL mach service: %s", server_bootstrap_name);
+        ErrorF("NULL mach service: %s", server_bootstrap_name);
         return EXIT_FAILURE;
     }
     
@@ -629,10 +632,10 @@ int main(int argc, char **argv, char **envp) {
     }
     
     /* Main event loop */
-    fprintf(stderr, "Waiting for startup parameters via Mach IPC.\n");
+    ErrorF("Waiting for startup parameters via Mach IPC.\n");
     kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
     if (kr != KERN_SUCCESS) {
-        fprintf(stderr, "%s.X11(mp): %s\n", BUNDLE_ID_PREFIX, mach_error_string(kr));
+        ErrorF("%s.X11(mp): %s\n", BUNDLE_ID_PREFIX, mach_error_string(kr));
         return EXIT_FAILURE;
     }
     
@@ -648,9 +651,9 @@ static int execute(const char *command) {
     newargv[2] = command;
     newargv[3] = NULL;
     
-    fprintf(stderr, "X11.app: Launching %s:\n", command);
+    ErrorF("X11.app: Launching %s:\n", command);
     for(p=newargv; *p; p++) {
-        fprintf(stderr, "\targv[%ld] = %s\n", (long int)(p - newargv), *p);
+        ErrorF("\targv[%ld] = %s\n", (long int)(p - newargv), *p);
     }
 
     execvp (newargv[0], (char * const *) newargv);
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index 245d1bc..9055bad 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -53,12 +53,22 @@ static void signal_handler (int sig) {
     }
 }
 
+void
+ErrorF(const char * f, ...)
+{
+    va_list args;
+
+    va_start(args, f);
+    vfprintf(stderr, f, args);
+    va_end(args);
+}
+
 int main (int argc, const char *argv[]) {
     const char *s;
     int i;
 
 #ifdef DEBUG
-    printf("pid: %u\n", getpid());
+    ErrorF("pid: %u\n", getpid());
 #endif
 
     xpbproxy_is_standalone = YES;
@@ -70,13 +80,13 @@ int main (int argc, const char *argv[]) {
         if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) {
             app_prefs_domain = argv[++i];
         } else if (strcmp (argv[i], "--help") == 0) {
-            printf("usage: xpbproxy OPTIONS\n"
+            ErrorF("usage: xpbproxy OPTIONS\n"
                    "Pasteboard proxying for X11.\n\n"
                    "--prefs-domain <domain>   Change the domain used for reading preferences\n"
                    "                          (default: %s)\n", app_prefs_domain);
             return 0;
         } else {
-            fprintf(stderr, "usage: xpbproxy OPTIONS...\n"
+            ErrorF("usage: xpbproxy OPTIONS...\n"
                     "Try 'xpbproxy --help' for more information.\n");
             return 1;
         }
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index bb06465..dbdb6d0 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -105,7 +105,7 @@ int xpbproxy_run (void) {
     }
     
     if (xpbproxy_dpy == NULL) {
-        fprintf (stderr, "xpbproxy: can't open default display\n");
+        ErrorF("xpbproxy: can't open default display\n");
         [pool release];
         return EXIT_FAILURE;
     }
@@ -115,7 +115,7 @@ int xpbproxy_run (void) {
     
     if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
                                  &xpbproxy_apple_wm_error_base)) {
-        fprintf (stderr, "xpbproxy: can't open AppleWM server extension\n");
+        ErrorF("xpbproxy: can't open AppleWM server extension\n");
         [pool release];
         return EXIT_FAILURE;
     }
@@ -147,19 +147,3 @@ Time xpbproxy_current_timestamp (void) {
     /* FIXME: may want to fetch a timestamp from the server.. */
     return CurrentTime;
 }
-
-void debug_printf (const char *fmt, ...) {
-    static int spew = -1;
-    
-    if (spew == -1) {
-        char *x = getenv ("DEBUG");
-        spew = (x != NULL && atoi (x) != 0);
-    }
-    
-    if (spew) {
-        va_list args;
-        va_start(args, fmt);
-        vfprintf (stderr, fmt, args);
-        va_end(args);
-    }
-}
diff --git a/hw/xquartz/pbproxy/pbproxy.h b/hw/xquartz/pbproxy/pbproxy.h
index 013f981..fcbf4c4 100644
--- a/hw/xquartz/pbproxy/pbproxy.h
+++ b/hw/xquartz/pbproxy/pbproxy.h
@@ -77,14 +77,16 @@ extern BOOL xpbproxy_have_xfixes;
 /* from x-input.m */
 extern BOOL xpbproxy_input_register (void);
 
+/* os/log.c or app-main.m */
+extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
+
 #ifdef DEBUG
 /* BEWARE: this can cause a string memory leak, according to the leaks program. */
-# define DB(msg, args...) debug_printf("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
+# define DebugF(msg, args...) ErrorF("%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args)
 #else
-# define DB(msg, args...) do {} while (0)
+# define DebugF(...) /* */
 #endif
 
-#define TRACE() DB("TRACE\n")
-extern void debug_printf (const char *fmt, ...);
+#define TRACE() DebugF("TRACE\n")
 
 #endif /* PBPROXY_H */
diff --git a/hw/xquartz/pbproxy/x-input.m b/hw/xquartz/pbproxy/x-input.m
index 405ba3c..ebb8998 100644
--- a/hw/xquartz/pbproxy/x-input.m
+++ b/hw/xquartz/pbproxy/x-input.m
@@ -87,7 +87,7 @@ static void xpbproxy_process_xevents(void) {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     
     if(pool == nil) {
-        fprintf(stderr, "unable to allocate/init auto release pool!\n");
+        ErrorF("unable to allocate/init auto release pool!\n");
         return;
     }
     
diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 99cc543..7964f51 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -81,19 +81,19 @@ static struct propdata null_propdata = {NULL, 0, 0};
 
 #ifdef DEBUG
 static void
-dump_prefs (FILE *fp) {
-    fprintf(fp, 
-	    "pbproxy preferences:\n"
-	    "\tactive %u\n"
-	    "\tprimary_on_grab %u\n"
-	    "\tclipboard_to_pasteboard %u\n"
-	    "\tpasteboard_to_primary %u\n"
-	    "\tpasteboard_to_clipboard %u\n",
-	    pbproxy_prefs.active,
-	    pbproxy_prefs.primary_on_grab,
-	    pbproxy_prefs.clipboard_to_pasteboard,
-	    pbproxy_prefs.pasteboard_to_primary,
-	    pbproxy_prefs.pasteboard_to_clipboard);
+dump_prefs() {
+    ErrorF(fp, 
+	   "pbproxy preferences:\n"
+	   "\tactive %u\n"
+	   "\tprimary_on_grab %u\n"
+	   "\tclipboard_to_pasteboard %u\n"
+	   "\tpasteboard_to_primary %u\n"
+	   "\tpasteboard_to_clipboard %u\n",
+	   pbproxy_prefs.active,
+	   pbproxy_prefs.primary_on_grab,
+	   pbproxy_prefs.clipboard_to_pasteboard,
+	   pbproxy_prefs.pasteboard_to_primary,
+	   pbproxy_prefs.pasteboard_to_clipboard);
 }
 #endif
 
@@ -152,7 +152,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	unsigned char *newbuf = NULL;
 	
 #ifdef TEST   
-	printf("bytesleft %lu\n", bytesleft);
+	ErrorF("bytesleft %lu\n", bytesleft);
 #endif
 
 	if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
@@ -161,17 +161,17 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 					   type, &format, &numitems, 
 					   &bytesleft, &chunk)) 
 	{
-	    DB ("Error while getting window property.\n");
+	    DebugF ("Error while getting window property.\n");
 	    *pdata = null_propdata;
 	    free (buf);
 	    return True;
 	}
 	
 #ifdef TEST
-	printf("format %d numitems %lu bytesleft %lu\n",
+	ErrorF("format %d numitems %lu bytesleft %lu\n",
 	       format, numitems, bytesleft);
 	
-	printf("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
+	ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
 #endif
 	
 	/* Format is the number of bits. */
@@ -183,7 +183,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	  chunkbytesize = numitems * sizeof(long);
 
 #ifdef TEST
-	printf("chunkbytesize %zu\n", chunkbytesize);
+	ErrorF("chunkbytesize %zu\n", chunkbytesize);
 #endif
  	newbuflen = buflen + chunkbytesize;
 	if (newbuflen > 0) 
@@ -211,7 +211,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	}
 	
 #ifdef TEST
-	printf("bytesleft %lu\n", bytesleft);
+	ErrorF("bytesleft %lu\n", bytesleft);
 #endif
     } while (bytesleft > 0);
     
@@ -236,7 +236,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     if (pdata->format != 32)
     {
-	fprintf(stderr, "Atom list is expected to be formatted as an array of 32bit values.\n");
+	ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n");
 	return None;
     }
 
@@ -265,7 +265,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	    char *type = XGetAtomName(xpbproxy_dpy, a);
 	    if (type)
 	    {
-		DB("Unhandled X11 mime type: %s", type);
+		DebugF("Unhandled X11 mime type: %s", type);
 		XFree(type);
 	    }
 	}
@@ -378,7 +378,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     if (countNow != changeCount)
     {
-        DB ("changed pasteboard!\n");
+        DebugF ("changed pasteboard!\n");
         changeCount = countNow;
         
         if (pbproxy_prefs.pasteboard_to_primary)
@@ -462,9 +462,8 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
             return TRUE;
 
         if(owner != None) {
-            fprintf (stderr, "A clipboard manager using window 0x%lx "
-		     "already owns the clipboard selection.  "
-		     "pbproxy will not sync clipboard to pasteboard.\n", owner);
+            ErrorF("A clipboard manager using window 0x%lx already owns the clipboard selection.  "
+		   "pbproxy will not sync clipboard to pasteboard.\n", owner);
             return FALSE;
         }
         
@@ -491,7 +490,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     TRACE ();
         
-    DB ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
+    DebugF ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
     
     if(e->selection == atoms->clipboard) {
         /* 
@@ -508,7 +507,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
             /* Another CLIPBOARD_MANAGER has set itself as owner.  Disable syncing
              * to avoid a race.
              */
-            fprintf(stderr, "Another clipboard manager was started!  "
+            ErrorF("Another clipboard manager was started!  "
 		    "xpbproxy is disabling syncing with clipboard.\n"); 
             pbproxy_prefs.clipboard_to_pasteboard = NO;
         }
@@ -533,7 +532,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
          * The owner probably died or we are just starting up pbproxy.
          * Set pbproxy's _selection_window as the owner, and continue.
          */
-        DB ("No clipboard owner.\n");
+        DebugF ("No clipboard owner.\n");
         [self copy_completed:atoms->clipboard];
         return;
     } else if (owner == _selection_window) {
@@ -541,7 +540,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
         return;
     }
     
-    DB ("requesting targets\n");
+    DebugF ("requesting targets\n");
     
     request_atom = atoms->targets;
     XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets,
@@ -581,7 +580,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
      * We are supposed to use an empty event mask, and not propagate
      * the event, according to the ICCCM.
      */
-    DB ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
+    DebugF ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
   
     XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply);
     XFlush (xpbproxy_dpy);
@@ -618,7 +617,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	if ([pbtypes containsObject:NSStringPboardType])
 	{
 	    /* We have a string type that we can convert to UTF8, or Latin-1... */
-	    DB ("NSStringPboardType\n");
+	    DebugF ("NSStringPboardType\n");
 	    list[count] = atoms->utf8_string;
 	    ++count;
 	    list[count] = atoms->string;
@@ -639,7 +638,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	    || [pbtypes containsObject:NSTIFFPboardType]) 
 	{
 	    /* We can convert a TIFF to a PNG or JPEG. */
-	    DB ("NSTIFFPboardType\n");
+	    DebugF ("NSTIFFPboardType\n");
 	    list[count] = atoms->image_png;
 	    ++count;
 	    list[count] = atoms->image_jpeg;
@@ -684,7 +683,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	return;
     }
 
-    DB ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
+    DebugF ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
 
     data = [pb stringForType:NSStringPboardType];
 
@@ -704,19 +703,19 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	length = strlen (bytes);
 	
 	if (length < 50) {
-	    DB ("UTF-8: %s\n", bytes);
-	    DB ("UTF-8 length: %u\n", length); 
+	    DebugF ("UTF-8: %s\n", bytes);
+	    DebugF ("UTF-8 length: %u\n", length); 
 	}
     } 
     else 
     {
-	DB ("Latin-1\n");
+	DebugF ("Latin-1\n");
 	bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
 	/*WARNING: bytes is not NUL-terminated. */
 	length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
     }
 
-    DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
+    DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
     
     XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
 		     8, PropModeReplace, (unsigned char *) bytes, length);
@@ -758,7 +757,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	    {
 		
 		if (8 != textprop.format)
-		    DB ("textprop.format is unexpectedly not 8 - it's %d instead\n",
+		    DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n",
 			textprop.format);
 
 		XChangeProperty (xpbproxy_dpy, e->requestor, e->property, 
@@ -850,7 +849,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     if (nil == data)
     {
 	[img autorelease];
-	fprintf(stderr, "unable to convert PICT to TIFF!\n");
+	ErrorF("unable to convert PICT to TIFF!\n");
 	return YES;
     }
         
@@ -926,7 +925,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	imagetype = NSJPEGFileType;
     else 
     {
-	fprintf(stderr, "internal failure in xpbproxy!  imagetype being sent isn't PNG or JPEG.\n");
+	ErrorF("internal failure in xpbproxy!  imagetype being sent isn't PNG or JPEG.\n");
     }
 
     pbtypes = [pb types];
@@ -997,7 +996,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     
 
     if (None != e->target)
-	DB ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
+	DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
 
     if (e->target == atoms->targets) 
     {
@@ -1049,15 +1048,15 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     [self release_pending];
  
     if (None == e->property) {
-	DB ("e->property is None.\n");
+	DebugF ("e->property is None.\n");
 	[self copy_completed:e->selection];
 	/* Nothing is selected. */
 	return;
     }
 
 #if 0
-    printf ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
-    printf ("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
+    ErrorF("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
+    ErrorF("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
 #endif
 
     if ([self is_incr_type:e]) 
@@ -1066,7 +1065,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	 * This is an INCR-style transfer, which means that we 
 	 * will get the data after a series of PropertyNotify events.
 	 */
-	DB ("is INCR\n");
+	DebugF ("is INCR\n");
 
 	if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type)) 
 	{
@@ -1083,7 +1082,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
       	pending.requestor = e->requestor;
 	pending.selection = e->selection;
 
-	DB ("set pending.requestor to 0x%lx\n", pending.requestor);
+	DebugF ("set pending.requestor to 0x%lx\n", pending.requestor);
     }
     else
     {
@@ -1096,7 +1095,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	/* We have the complete selection data.*/
 	[self handle_selection:e->selection type:type propdata:&pdata];
 	
-	DB ("handled selection with the first notify_event\n");
+	DebugF ("handled selection with the first notify_event\n");
     }
 }
 
@@ -1116,7 +1115,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
 	if (name) 
 	{
-	    DB ("e->atom %s\n", name);
+	    DebugF ("e->atom %s\n", name);
 	    XFree(name);
 	}
 #endif
@@ -1124,7 +1123,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     if (None != pending.requestor && PropertyNewValue == e->state) 
     {
-	DB ("pending.requestor 0x%lx\n", pending.requestor);
+	DebugF ("pending.requestor 0x%lx\n", pending.requestor);
 
 	if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type))
         {
@@ -1166,7 +1165,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
         case XFixesSelectionWindowDestroyNotify:
         case XFixesSelectionClientCloseNotify:
         default:
-            fprintf(stderr, "Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
+            ErrorF("Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
             break;
     }
 }
@@ -1196,7 +1195,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     if (name)
     {
-	DB ("requesting %s\n", name);
+	DebugF ("requesting %s\n", name);
     }
 #endif
     request_atom = preferred;
@@ -1220,11 +1219,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     if (nil == data)
     {
-	DB ("unable to create NSData object!\n");
+	DebugF ("unable to create NSData object!\n");
 	return;
     }
 
-    DB ("data retainCount before NSBitmapImageRep initWithData: %u\n",
+    DebugF ("data retainCount before NSBitmapImageRep initWithData: %u\n",
 	[data retainCount]);
 
     bmimage = [[NSBitmapImageRep alloc] initWithData:data];
@@ -1232,11 +1231,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     if (nil == bmimage)
     {
 	[data autorelease];
-	DB ("unable to create NSBitmapImageRep!\n");
+	DebugF ("unable to create NSBitmapImageRep!\n");
 	return;
     }
 
-    DB ("data retainCount after NSBitmapImageRep initWithData: %u\n", 
+    DebugF ("data retainCount after NSBitmapImageRep initWithData: %u\n", 
 	[data retainCount]);
 
     @try 
@@ -1246,13 +1245,13 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     @catch (NSException *e) 
     {
-	DB ("NSTIFFException!\n");
+	DebugF ("NSTIFFException!\n");
 	[data autorelease];
 	[bmimage autorelease];
 	return;
     }
     
-    DB ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
+    DebugF ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
 
     pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
 
@@ -1266,12 +1265,12 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     [pb declareTypes:pbtypes owner:nil];
     if (YES != [pb setData:tiff forType:NSTIFFPboardType])
     {
-	DB ("writing pasteboard data failed!\n");
+	DebugF ("writing pasteboard data failed!\n");
     }
 
     [data autorelease];
 
-    DB ("bmimage retainCount before release %u\n", [bmimage retainCount]);
+    DebugF ("bmimage retainCount before release %u\n", [bmimage retainCount]);
     [bmimage autorelease];
 }
 
@@ -1299,10 +1298,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     [pb declareTypes:pbtypes owner:nil];
     
     if (YES != [pb setString:string forType:NSStringPboardType]) {
-	fprintf(stderr, "pasteboard setString:forType: failed!\n");
+	ErrorF("pasteboard setString:forType: failed!\n");
     }
     [string autorelease];
-    DB ("done handling utf8 string\n");
+    DebugF ("done handling utf8 string\n");
 }
 
 /* This handles the STRING type, which should be in Latin-1. */
@@ -1328,7 +1327,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 
     [pb declareTypes:pbtypes owner:nil];
     if (YES != [pb setString:string forType:NSStringPboardType]) {
-	fprintf(stderr, "pasteboard setString:forType failed in handle_string!\n");
+	ErrorF("pasteboard setString:forType failed in handle_string!\n");
     }
     [string autorelease];
 }
@@ -1394,7 +1393,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     name = XGetAtomName (xpbproxy_dpy, selection);
     if (name)
     {
-	DB ("copy_completed: %s\n", name);
+	DebugF ("copy_completed: %s\n", name);
 	XFree (name);
     }
 #endif
@@ -1455,10 +1454,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     pbproxy_prefs.pasteboard_to_clipboard =  prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard);
 
     /* This is used for debugging. */
-    //dump_prefs(stdout);
+    //dump_prefs();
 
     if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) {
-        fprintf(stderr, "Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
+        ErrorF("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
         pbproxy_prefs.primary_on_grab = NO;
     }
 
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index af12de4..c540114 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -367,9 +367,9 @@ static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue
         if (pDev->kbdfeed)
             memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize);
 
-        //fprintf(stderr, "per_key_repeat =\n");
+        //ErrorF("per_key_repeat =\n");
         //for(i=0; i < XkbPerKeyBitArraySize; i++)
-        //    fprintf(stderr, "%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
+        //    ErrorF("%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
 
         /* And now we notify the puppies about the changes */
         XkbDDXChangeControls(pDev, &old, ctrl);
commit cb083b05c469352ef80e1005a29ac320f2e4e096
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Mon Apr 25 21:25:10 2011 -0700

    XQuartz: stub: Dead code removal
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 3653bca..c8a6283 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -56,15 +56,6 @@ static char *server_bootstrap_name = kX11AppBundleId;
 
 #include "launchd_fd.h"
 
-#ifndef BUILD_DATE
-#define BUILD_DATE "?"
-#endif
-#ifndef XSERVER_VERSION
-#define XSERVER_VERSION "?"
-#endif
-
-#define DEBUG 1
-
 static char x11_path[PATH_MAX + 1];
 
 static pid_t x11app_pid = 0;
@@ -197,13 +188,6 @@ int main(int argc, char **argv, char **envp) {
     string_t handoff_socket_filename;
     sig_t handler;
 
-    if(argc == 2 && !strcmp(argv[1], "-version")) {
-        fprintf(stderr, "X.org Release 7.5\n");
-        fprintf(stderr, "X.Org X Server %s\n", XSERVER_VERSION);
-        fprintf(stderr, "Build Date: %s\n", BUILD_DATE);
-        return EXIT_SUCCESS;
-    }
-
     if(getenv("X11_PREFS_DOMAIN"))
         server_bootstrap_name = getenv("X11_PREFS_DOMAIN");
     


More information about the Xquartz-changes mailing list