Relayouted all switch statements: case aligns with switch.
[mmh] / uip / annosbr.c
index db74870..e8c03e1 100644 (file)
@@ -17,7 +17,7 @@
 /*
 ** static prototypes
 */
-static int annosbr (int, char *, char *, char *, int, int, int, int);
+static int annosbr(int, char *, char *, char *, int, int, int, int);
 
 /*
 ** This "local" global and the annopreserve() function are a hack that
@@ -29,7 +29,7 @@ static int annosbr (int, char *, char *, char *, int, int, int, int);
 static int preserve_actime_and_modtime = 0;
 
 int
-annotate (char *file, char *comp, char *text, int inplace, int datesw,
+annotate(char *file, char *comp, char *text, int inplace, int datesw,
        int delete, int append)
 {
        int i, fd;
@@ -37,14 +37,14 @@ annotate (char *file, char *comp, char *text, int inplace, int datesw,
        struct stat s;
 
        /* open and lock the file to be annotated */
-       if ((fd = lkopen (file, O_RDWR, 0)) == NOTOK) {
+       if ((fd = lkopen(file, O_RDWR, 0)) == NOTOK) {
                switch (errno) {
-                       case ENOENT:
-                               break;
+               case ENOENT:
+                       break;
 
-                       default:
-                               admonish (file, "unable to lock and open");
-                               break;
+               default:
+                       admonish(file, "unable to lock and open");
+                       break;
                }
                return 1;
        }
@@ -57,12 +57,12 @@ annotate (char *file, char *comp, char *text, int inplace, int datesw,
        b.actime = s.st_atime;
        b.modtime = s.st_mtime;
 
-       i = annosbr (fd, file, comp, text, inplace, datesw, delete, append);
+       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);
 
-       lkclose (fd, file);
+       lkclose(fd, file);
        return i;
 }
 
@@ -113,7 +113,7 @@ annolist(char *file, char *comp, char *text, int number)
 
                for (n = 0, cp = field; (c = getc(fp)) != EOF; *cp++ = c) {
                        if (c == '\n' && (c = getc(fp)) != ' ' && c != '\t') {
-                               (void)ungetc(c, fp);
+                               ungetc(c, fp);
                                c = '\n';
                                break;
                        }
@@ -133,19 +133,19 @@ annolist(char *file, char *comp, char *text, int number)
                                ;
 
                        if (number)
-                               (void)printf("%d\t", ++count);
+                               printf("%d\t", ++count);
 
-                       if (text == (char *)0 && (sp = strrchr(cp, '/')) != (char *)0)
+                       if (text == NULL && (sp = strrchr(cp, '/')) != NULL)
                                cp = sp + 1;
 
-                       (void)printf("%s\n", cp);
+                       printf("%s\n", cp);
                }
 
        } while (*field != '\0' && *field != '-');
 
        /* Clean up. */
        free(field);
-       (void)fclose(fp);
+       fclose(fp);
 
        return;
 }
@@ -162,7 +162,7 @@ annopreserve(int preserve)
 }
 
 static int
-annosbr (int fd, char *file, char *comp, char *text, int inplace,
+annosbr(int fd, char *file, char *comp, char *text, int inplace,
        int datesw, int delete, int append)
 {
        int mode, tmpfd;
@@ -178,10 +178,10 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
        int length;  /* length of field name */
        int n;  /* number of bytes written */
 
-       mode = fstat (fd, &st) != NOTOK ? (st.st_mode & 0777) : m_gmprot ();
+       mode = fstat(fd, &st) != NOTOK ? (st.st_mode & 0777) : m_gmprot();
 
-       strncpy (tmpfil, m_mktemp2(file, "annotate", NULL, &tmp), sizeof(tmpfil));
-       chmod (tmpfil, mode);
+       strncpy(tmpfil, m_mktemp2(file, "annotate", NULL, &tmp), sizeof(tmpfil));
+       chmod(tmpfil, mode);
 
        /*
        ** We're going to need to copy some of the message file to the
@@ -247,7 +247,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
 
                        for (n = 0, cp = field; (c = getc(fp)) != EOF; *cp++ = c) {
                                if (c == '\n' && (c = getc(fp)) != ' ' && c != '\t') {
-                                       (void)ungetc(c, fp);
+                                       ungetc(c, fp);
                                        c = '\n';
                                        break;
                                }
@@ -297,7 +297,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
 
                        if (strncasecmp(field, comp, length) == 0 && field[length] == ':') {
                                if (delete == 0) {
-                                       if (text == (char *)0)
+                                       if (text == NULL)
                                                break;
 
                                        for (cp = field + length + 1; *cp == ' ' || *cp == '\t'; cp++)
@@ -308,7 +308,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
                                                                break;
                                        }
                                        else {
-                                               if ((sp = strrchr(cp, '/')) != (char *)0)
+                                               if ((sp = strrchr(cp, '/')) != NULL)
                                                        cp = sp + 1;
 
                                                if (strcmp(cp, text) == 0)
@@ -357,13 +357,13 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
                                rewind(fp);
 
                        else {
-                               (void)putc(c, tmp);
+                               putc(c, tmp);
 
                                while ((c = getc(fp)) != EOF) {
-                                       (void)putc(c, tmp);
+                                       putc(c, tmp);
 
                                        if (c == '\n') {
-                                               (void)ungetc(c = getc(fp), fp);
+                                               ungetc(c = getc(fp), fp);
 
                                                if (c == '\n' || c == '-')
                                                        break;
@@ -373,7 +373,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
                }
 
                if (datesw)
-                       fprintf (tmp, "%s: %s\n", comp, dtimenow (0));
+                       fprintf(tmp, "%s: %s\n", comp, dtimenow(0));
                if ((cp = text)) {
                        do {
                                while (*cp == ' ' || *cp == '\t')
@@ -382,14 +382,14 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
                                while (*cp && *cp++ != '\n')
                                        continue;
                                if (cp - sp)
-                                       fprintf (tmp, "%s: %*.*s", comp, (int)(cp - sp), (int)(cp - sp), sp);
+                                       fprintf(tmp, "%s: %*.*s", comp, (int)(cp - sp), (int)(cp - sp), sp);
                        } while (*cp);
                        if (cp[-1] != '\n' && cp != text)
-                               putc ('\n', tmp);
+                               putc('\n', tmp);
                }
        }
 
-       fflush (tmp);
+       fflush(tmp);
 
        /*
        ** We've been messing with the input file position.  Move the
@@ -403,14 +403,14 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
                        adios(NULL, "can't seek.");
        }
 
-       cpydata (fd, fileno (tmp), file, tmpfil);
-       fclose (tmp);
+       cpydata(fd, fileno(tmp), file, tmpfil);
+       fclose(tmp);
 
        if (inplace) {
-               if ((tmpfd = open (tmpfil, O_RDONLY)) == NOTOK)
-                       adios (tmpfil, "unable to open for re-reading");
+               if ((tmpfd = open(tmpfil, O_RDONLY)) == NOTOK)
+                       adios(tmpfil, "unable to open for re-reading");
 
-               lseek (fd, (off_t) 0, SEEK_SET);
+               lseek(fd, (off_t) 0, SEEK_SET);
 
                /*
                **  We're making the file shorter if we're deleting a
@@ -421,25 +421,26 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
                if (delete >= -1 && ftruncate(fd, 0) == -1)
                        adios(tmpfil, "unable to truncate.");
 
-               cpydata (tmpfd, fd, tmpfil, file);
-               close (tmpfd);
-               unlink (tmpfil);
+               cpydata(tmpfd, fd, tmpfil, file);
+               close(tmpfd);
+               unlink(tmpfil);
        } else {
-               strncpy (buffer, m_backup (file), sizeof(buffer));
-               if (rename (file, buffer) == NOTOK) {
+               strncpy(buffer, m_backup(file), sizeof(buffer));
+               if (rename(file, buffer) == NOTOK) {
                        switch (errno) {
-                               case ENOENT:  /* unlinked early - no annotations */
-                                       unlink (tmpfil);
-                                       break;
+                       case ENOENT:  /* unlinked early - no annotations */
+                               unlink(tmpfil);
+                               break;
 
-                               default:
-                                       admonish (buffer, "unable to rename %s to", file);
-                                       break;
+                       default:
+                               admonish(buffer, "unable to rename %s to",
+                                               file);
+                               break;
                        }
                        return 1;
                }
-               if (rename (tmpfil, file) == NOTOK) {
-                       admonish (file, "unable to rename %s to", tmpfil);
+               if (rename(tmpfil, file) == NOTOK) {
+                       admonish(file, "unable to rename %s to", tmpfil);
                        return 1;
                }
        }
@@ -451,7 +452,7 @@ annosbr (int fd, char *file, char *comp, char *text, int inplace,
        */
 
        if (delete >= -1)
-               (void)fclose(fp);
+               fclose(fp);
 
        return 0;
 }