anno: Undid the ``preserve argument hack''.
authormarkus schnalke <meillo@marmaro.de>
Tue, 20 Mar 2012 20:07:58 +0000 (21:07 +0100)
committermarkus schnalke <meillo@marmaro.de>
Tue, 20 Mar 2012 20:07:58 +0000 (21:07 +0100)
h/prototypes.h
uip/anno.c
uip/annosbr.c
uip/forw.c
uip/repl.c
uip/whatnow.c

index 46a89ce..ff38dd3 100644 (file)
@@ -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 *);
index aacd826..e97afbf 100644 (file)
@@ -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);
                }
        }
 
index 99422e6..d1e39b0 100644 (file)
 */
 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)
index 031c191..8992b33 100644 (file)
@@ -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);
 }
 
 
index 469bdd9..1a0e143 100644 (file)
@@ -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 */
index afe4129..761fea1 100644 (file)
@@ -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 {