From: markus schnalke Date: Tue, 20 Mar 2012 20:07:58 +0000 (+0100) Subject: anno: Undid the ``preserve argument hack''. X-Git-Tag: mmh-thesis-end~286 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=88a0787554de9c618e657c31940e734178a25730;p=mmh anno: Undid the ``preserve argument hack''. --- diff --git a/h/prototypes.h b/h/prototypes.h index 46a89ce..ff38dd3 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -138,7 +138,7 @@ int strncasecmp(const char *s1, const char *s2, size_t n); /* ** prototypes for some routines in uip */ -int annotate(char *, char *, char *, int, int, int); +int annotate(char *, char *, char *, int, int, int, int); void annolist(char *, char *, char *, int); void annopreserve(int); int distout(char *, char *, char *); diff --git a/uip/anno.c b/uip/anno.c index aacd826..e97afbf 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -80,6 +80,7 @@ int main(int argc, char **argv) { int datesw = 1; + int preserve = 0; int msgnum; char *cp, *maildir; unsigned char *comp = NULL; @@ -178,11 +179,11 @@ main(int argc, char **argv) continue; case PRESERVESW: /* preserve access and modification times on annotated message */ - annopreserve(1); + preserve = 1; continue; case NOPRESERVESW: /* don't preserve access and modification times on annotated message (default) */ - annopreserve(0); + preserve = 0; continue; } } @@ -225,7 +226,7 @@ main(int argc, char **argv) if (list) annolist(m_name(msgnum), comp, text, number); else - annotate(m_name(msgnum), comp, text, datesw, delete, append); + annotate(m_name(msgnum), comp, text, datesw, delete, append, preserve); } } diff --git a/uip/annosbr.c b/uip/annosbr.c index 99422e6..d1e39b0 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -19,18 +19,10 @@ */ static int annosbr(int, char *, char *, char *, int, int, int); -/* -** This "local" global and the annopreserve() function are a hack that -** allows additional functionality to be added to anno without piling -** on yet another annotate() argument. -*/ - -/* set to preserve access and modification times on annotated message */ -static int preserve_actime_and_modtime = 0; int annotate(char *file, char *comp, char *text, int datesw, - int delete, int append) + int delete, int append, int preserve) { int i, fd; struct utimbuf b; @@ -51,7 +43,7 @@ annotate(char *file, char *comp, char *text, int datesw, if (stat(file, &s) == -1) { advise("can't get access and modification times for %s", file); - preserve_actime_and_modtime = 0; + preserve = 0; } b.actime = s.st_atime; @@ -59,7 +51,7 @@ annotate(char *file, char *comp, char *text, int datesw, i = annosbr(fd, file, comp, text, datesw, delete, append); - if (preserve_actime_and_modtime && utime(file, &b) == -1) + if (preserve && utime(file, &b) == -1) advise("can't set access and modification times for %s", file); lkclose(fd, file); @@ -150,17 +142,6 @@ annolist(char *file, char *comp, char *text, int number) return; } -/* -** Set the preserve-times flag. This hack eliminates the need for an -** additional argument to annotate(). -*/ -void -annopreserve(int preserve) -{ - preserve_actime_and_modtime = preserve; - return; -} - static int annosbr(int fd, char *file, char *comp, char *text, int datesw, int delete, int append) diff --git a/uip/forw.c b/uip/forw.c index 031c191..8992b33 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -288,7 +288,7 @@ add_forw_hdr(char *draft) strncat(buffer, m_name(msgnum), sizeof(buffer)-strlen(buffer)-1); } - annotate(draft, attach_hdr, buffer, 0, -2, 1); + annotate(draft, attach_hdr, buffer, 0, -2, 1, 0); } diff --git a/uip/repl.c b/uip/repl.c index 469bdd9..1a0e143 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -596,7 +596,7 @@ finished: snprintf(buffer, sizeof buffer, "+%s %s", mp->foldpath, m_name(mp->lowsel)); - annotate(drft, attach_hdr, buffer, 0, -2, 1); + annotate(drft, attach_hdr, buffer, 0, -2, 1, 0); } /* return dynamically allocated buffers */ diff --git a/uip/whatnow.c b/uip/whatnow.c index afe4129..761fea1 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -388,13 +388,13 @@ main(int argc, char **argv) if (*shell == '/') annotate(drft, attach_hdr, shell, 0, - -2, 1); + -2, 1, 0); else { sprintf(file, "%s/%s", cwd, shell); annotate(drft, attach_hdr, file, 0, - -2, 1); + -2, 1, 0); } } @@ -442,7 +442,7 @@ main(int argc, char **argv) n = atoi(*arguments); annotate(drft, attach_hdr, NULL, 0, - n, 1); + n, 1, 0); for (argp = arguments + 1; *argp != NULL; argp++) { if (atoi(*argp) > n) { @@ -474,7 +474,7 @@ main(int argc, char **argv) != NULL) { *(strchr(shell, '\n')) = '\0'; annotate(drft, attach_hdr, shell, - 0, 0, 1); + 0, 0, 1, 0); } pclose(f); } else {