X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/80f396c977d664dfb8d29411a3cd64393764c166..63621a81d16ab743de6b57d47578a9a2c670ad22:/uip/annosbr.c diff --git a/uip/annosbr.c b/uip/annosbr.c index 3e4ae808..20719804 100644 --- a/uip/annosbr.c +++ b/uip/annosbr.c @@ -1,6 +1,4 @@ - -/* - * annosbr.c -- prepend annotation to messages +/* annosbr.c -- prepend annotation to messages * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -10,6 +8,8 @@ #include #include #include +#include "sbr/lock_file.h" +#include "sbr/m_mktemp.h" #include #include @@ -17,7 +17,7 @@ /* * static prototypes */ -static int annosbr (int, char *, char *, char *, int, int, int, int); +static int annosbr (int, char *, char *, char *, bool, bool, int, bool); /* * This "local" global and the annopreserve() function are a hack that allows additional @@ -27,7 +27,7 @@ static int annosbr (int, char *, char *, char *, int, int, int, int); static int preserve_actime_and_modtime = 0; /* set to preserve access and modification times on annotated message */ int -annotate (char *file, char *comp, char *text, int inplace, int datesw, int delete, int append) +annotate (char *file, char *comp, char *text, bool inplace, bool datesw, int delete, bool append) { int i, fd; struct utimbuf b; @@ -52,7 +52,7 @@ annotate (char *file, char *comp, char *text, int inplace, int datesw, int delet } if (stat(file, &s) == -1) { - advise("can't get access and modification times for %s", file); + inform("can't get access and modification times for %s", file); preserve_actime_and_modtime = 0; } @@ -62,7 +62,7 @@ annotate (char *file, char *comp, char *text, int inplace, int datesw, int delet i = annosbr (fd, file, comp, text, inplace, datesw, delete, append); if (preserve_actime_and_modtime && utime(file, &b) == -1) - advise("can't set access and modification times for %s", file); + inform("can't set access and modification times for %s", file); lkclosedata (fd, file); return i; @@ -70,7 +70,7 @@ annotate (char *file, char *comp, char *text, int inplace, int datesw, int delet /* * Produce a listing of all header fields (annotations) whose field name matches - * comp. Number the listing if number is set. Treate the field bodies as path + * comp. Number the listing if number is set. Treat the field bodies as path * names and just output the last component unless text is non-NULL. We don't * care what text is set to. */ @@ -140,7 +140,7 @@ annolist(char *file, char *comp, char *text, int number) if (number) (void)printf("%d\t", ++count); - if (text == NULL && (sp = strrchr(cp, '/')) != (char *)0) + if (text == NULL && (sp = strrchr(cp, '/'))) cp = sp + 1; puts(cp); @@ -155,8 +155,6 @@ annolist(char *file, char *comp, char *text, int number) free(field); (void)fclose(fp); - - return; } /* @@ -167,11 +165,10 @@ void annopreserve(int preserve) { preserve_actime_and_modtime = preserve; - return; } static int -annosbr (int fd, char *file, char *comp, char *text, int inplace, int datesw, int delete, int append) +annosbr (int fd, char *file, char *comp, char *text, bool inplace, bool datesw, int delete, bool append) { int mode, tmpfd; char *cp, *sp; @@ -202,7 +199,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, int datesw, in * as they're read in. This buffer is grown as needed later. */ - if (delete >= -1 || append != 0) { + if (delete >= -1 || append) { if ((fp = fdopen(fd, "r")) == NULL) adios(NULL, "unable to fdopen file."); @@ -405,7 +402,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace, int datesw, in if ((tmpfd = open (tmpfil, O_RDONLY)) == NOTOK) adios (tmpfil, "unable to open for re-reading"); - lseek (fd, (off_t) 0, SEEK_SET); + lseek(fd, 0, SEEK_SET); /* * We're making the file shorter if we're deleting a header field