]> code.delx.au - gnu-emacs/blobdiff - lib-src/emacsclient.c
(last_node): Make it a global variable.
[gnu-emacs] / lib-src / emacsclient.c
index 10f95decd8024342dd0268a84d5f4244faf5b5fa..27bce2d0b1dabb1e5c288634e99f7d7fe7e25edc 100644 (file)
@@ -21,9 +21,14 @@ Boston, MA 02111-1307, USA.  */
 
 
 #define NO_SHORTNAMES
-#include <../src/config.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #undef signal
 
+#include <ctype.h>
 #include <stdio.h>
 #include <getopt.h>
 #ifdef HAVE_UNISTD_H
@@ -83,18 +88,18 @@ decode_options (argc, argv)
        break;
 
       alternate_editor = getenv ("ALTERNATE_EDITOR");
-      
+
       switch (opt)
        {
        case 0:
          /* If getopt returns 0, then it has already processed a
             long-named option.  We should do nothing.  */
          break;
-         
+
        case 'a':
          alternate_editor = optarg;
          break;
-         
+
        case 'n':
          nowait = 1;
          break;
@@ -115,7 +120,7 @@ void
 print_help_and_exit ()
 {
   fprintf (stderr,
-          "Usage: %s [-a ALTERNATE-EDITOR] [-n] [--no-wait] [+LINENUMBER] FILENAME\n",
+          "Usage: %s [-a ALTERNATE-EDITOR] [-n] [--no-wait] [+LINE[:COLUMN]] FILENAME\n",
           progname);
   fprintf (stderr,
           "Or %s --version\n",
@@ -156,7 +161,6 @@ quote_file_name (name)
     }
   *q++ = 0;
 
-  
   return copy;
 }
 
@@ -188,6 +192,7 @@ fail (argc, argv)
     {
       int i = optind -1 ;
       execvp (alternate_editor, argv + i);
+      return;
     }
   else
     {
@@ -196,7 +201,6 @@ fail (argc, argv)
 }
 
 
-       
 \f
 #if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC)
 
@@ -270,7 +274,7 @@ main (argc, argv)
   if (argc - optind < 1)
     print_help_and_exit ();
 
-  /* 
+  /*
    * Open up an AF_UNIX socket in this person's home directory
    */
 
@@ -280,7 +284,7 @@ main (argc, argv)
       perror ("socket");
       fail (argc, argv);
     }
-  
+
   server.sun_family = AF_UNIX;
 
   {
@@ -305,7 +309,7 @@ main (argc, argv)
   {
     int sock_status = 0;
 
-    sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);
+    sprintf (server.sun_path, "/tmp/esrv%d-%s", (int) geteuid (), system_name);
 
     /* See if the socket exists, and if it's owned by us. */
     sock_status = socket_status (server.sun_path);
@@ -315,11 +319,11 @@ main (argc, argv)
           our euid.  If so, look for a socket based on the UID
           associated with the name.  This is reminiscent of the logic
           that init_editfns uses to set the global Vuser_full_name.  */
+
        char *user_name = (char *) getenv ("LOGNAME");
        if (!user_name)
          user_name = (char *) getenv ("USER");
-       
+
        if (user_name)
          {
            struct passwd *pw = getpwnam (user_name);
@@ -327,12 +331,12 @@ main (argc, argv)
              {
                /* We're running under su, apparently. */
                sprintf (server.sun_path, "/tmp/esrv%d-%s",
-                        pw->pw_uid, system_name);
+                        (int) pw->pw_uid, system_name);
                sock_status = socket_status (server.sun_path);
              }
          }
       }
+
      switch (sock_status)
        {
        case 1:
@@ -344,7 +348,7 @@ main (argc, argv)
             fail (argc, argv);
           }
         break;
-        
+
        case 2:
         /* `stat' failed */
         if (errno == ENOENT)
@@ -423,7 +427,7 @@ main (argc, argv)
       if (*argv[i] == '+')
        {
          char *p = argv[i] + 1;
-         while (*p >= '0' && *p <= '9') p++;
+         while (isdigit ((unsigned char) *p) || *p == ':') p++;
          if (*p != 0)
            fprintf (out, "%s/", quote_file_name (cwd));
        }
@@ -446,8 +450,8 @@ main (argc, argv)
      the first line we read will actually be the output we just sent.
      We can't predict whether that will happen, so if it does, we
      detect it by recognizing `Client: ' at the beginning.  */
-  
-  while (str = fgets (string, BUFSIZ, in))
+
+  while ((str = fgets (string, BUFSIZ, in)))
     printf ("%s", str);
 
   return 0;
@@ -566,7 +570,8 @@ main (argc, argv)
       if (*modified_arg == '+')
        {
          char *p = modified_arg + 1;
-         while (*p >= '0' && *p <= '9') p++;
+         while (isdigit (*p) || *p == ':')
+           p++;
          if (*p != 0)
            need_cwd = 1;
        }