zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: PATH_MAX and mailstat, part I
@ 2000-09-18  3:51 Clint Adams
  2000-09-18  4:09 ` PATCH: PATH_MAX and mailstat, part II Clint Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Clint Adams @ 2000-09-18  3:51 UTC (permalink / raw)
  To: zsh-workers

This makes 'file' be dynamically allocated in mailstat.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.16
diff -u -r1.16 utils.c
--- Src/utils.c	2000/09/18 03:36:22	1.16
+++ Src/utils.c	2000/09/18 03:49:16
@@ -3789,8 +3789,8 @@
        struct stat             st_ret, st_tmp;
        static struct stat      st_new_last, st_ret_last;
        char                    dir[PATH_MAX * 2];
-       char                    file[PATH_MAX * 2];
-       int                     i, l;
+       char                    *file;
+       int                     i;
        time_t                  atime = 0, mtime = 0;
 
        /* First see if it's a directory. */
@@ -3832,28 +3832,26 @@
                return 0;
        }
        st_new_last = st_tmp;
-
+       
        /* Loop over new/ and cur/ */
        for (i = 0; i < 2; i++) {
-               sprintf(dir, "%s/%s", path, i ? "cur" : "new");
-               sprintf(file, "%s/", dir);
-               l = strlen(file);
+	   sprintf(dir, "%s/%s", path, i ? "cur" : "new");
                if ((dd = opendir(dir)) == NULL)
-                       return 0;
+		   return 0;
                while ((fn = readdir(dd)) != NULL) {
-                       if (fn->d_name[0] == '.' ||
-                           strlen(fn->d_name) + l >= sizeof(file))
-                               continue;
-                       strcpy(file + l, fn->d_name);
-                       if (stat(file, &st_tmp) != 0)
-                               continue;
-                       st_ret.st_size += st_tmp.st_size;
-                       st_ret.st_blocks++;
-                       if (st_tmp.st_atime != st_tmp.st_mtime &&
-                           st_tmp.st_atime > atime)
-                               atime = st_tmp.st_atime;
-                       if (st_tmp.st_mtime > mtime)
-                               mtime = st_tmp.st_mtime;
+		   if (fn->d_name[0] == '.')
+		       continue;
+
+		   file = zhtricat(dir, "/", fn->d.name);
+		   if (stat(file, &st_tmp) != 0)
+		       continue;
+		   st_ret.st_size += st_tmp.st_size;
+		   st_ret.st_blocks++;
+		   if (st_tmp.st_atime != st_tmp.st_mtime &&
+		       st_tmp.st_atime > atime)
+		       atime = st_tmp.st_atime;
+		   if (st_tmp.st_mtime > mtime)
+		       mtime = st_tmp.st_mtime;
                }
                closedir(dd);
        }


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-09-19 16:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-18  3:51 PATCH: PATH_MAX and mailstat, part I Clint Adams
2000-09-18  4:09 ` PATCH: PATH_MAX and mailstat, part II Clint Adams
2000-09-18  6:39   ` PATCH: Redo a couple of PATH_MAX changes Bart Schaefer
2000-09-18 17:21     ` PATCH: bin_ln - PATH_MAX Clint Adams
2000-09-19  3:18       ` Bart Schaefer
2000-09-19 15:23         ` PATCH: files module " Clint Adams
2000-09-19 16:19           ` PATCH: whence " Clint Adams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).