From: Clint Adams <schizo@debian.org>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: PATH_MAX and mailstat, part I
Date: Sun, 17 Sep 2000 23:51:09 -0400 [thread overview]
Message-ID: <20000917235109.A6793@dman.com> (raw)
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);
}
next reply other threads:[~2000-09-18 3:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-09-18 3:51 Clint Adams [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20000917235109.A6793@dman.com \
--to=schizo@debian.org \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).