emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/process.c,v


From: Andreas Schwab
Subject: [Emacs-diffs] Changes to emacs/src/process.c,v
Date: Sat, 23 Aug 2008 18:04:45 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Andreas Schwab <schwab> 08/08/23 18:04:45

Index: process.c
===================================================================
RCS file: /sources/emacs/emacs/src/process.c,v
retrieving revision 1.560
retrieving revision 1.561
diff -u -b -r1.560 -r1.561
--- process.c   23 Aug 2008 16:48:55 -0000      1.560
+++ process.c   23 Aug 2008 18:04:44 -0000      1.561
@@ -7246,10 +7246,10 @@
   char procbuf[1025], *p, *q;
   int fd;
   ssize_t nread;
-  char cmd[PATH_MAX];
+  const char *cmd;
   char *cmdline = NULL;
   size_t cmdsize;
-  int c;
+  unsigned char c;
   int proc_id, ppid, uid, gid, pgrp, sess, tty, tpgid, thcount;
   unsigned long long utime, stime, cutime, cstime, start;
   long priority, nice, rss;
@@ -7277,7 +7277,7 @@
   uid_eint = uid;
   attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (uid_eint)), attrs);
   BLOCK_INPUT;
-  pw = (struct passwd *) getpwuid (uid);
+  pw = getpwuid (uid);
   UNBLOCK_INPUT;
   if (pw)
     attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs);
@@ -7286,7 +7286,7 @@
   gid_eint = gid;
   attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (gid_eint)), attrs);
   BLOCK_INPUT;
-  gr = (struct group *) getgrgid (gid);
+  gr = getgrgid (gid);
   UNBLOCK_INPUT;
   if (gr)
     attrs = Fcons (Fcons (Qgroup, build_string (gr->gr_name)), attrs);
@@ -7300,18 +7300,25 @@
       procbuf[nread] = '\0';
       p = procbuf;
 
-      p = strchr (p, '(') + 1;
-      q = strchr (p, ')');
+      cmd = NULL;
+      p = strchr (p, '(');
+      if (p != NULL)
+       {
+         q = strrchr (p + 1, ')');
       /* comm */
-      if (q > p)
+         if (q != NULL)
        {
-         memcpy (cmd, p, q - p);
-         cmd[q - p] = '\0';
+             cmd = p + 1;
+             cmdsize = q - cmd;
+           }
+       }
+      if (cmd == NULL)
+       {
+         cmd = "???";
+         cmdsize = 3;
        }
-      else
-       strcpy (cmd, "???");
       /* Command name is encoded in locale-coding-system; decode it.  */
-      cmd_str = make_unibyte_string (cmd, q ? q - p : 3);
+      cmd_str = make_unibyte_string (cmd, cmdsize);
       decoded_cmd = code_convert_string_norecord (cmd_str,
                                                  Vlocale_coding_system, 0);
       attrs = Fcons (Fcons (Qcomm, decoded_cmd), attrs);
@@ -7412,7 +7419,7 @@
   fd = emacs_open (fn, O_RDONLY, 0);
   if (fd >= 0)
     {
-      for (cmdsize = 0; emacs_read (fd, (char *)&c, 1) == 1; cmdsize++)
+      for (cmdsize = 0; emacs_read (fd, &c, 1) == 1; cmdsize++)
        {
          if (isspace (c) || c == '\\')
            cmdsize++;  /* for later quoting, see below */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]