diff --git a/blaze822.c b/blaze822.c index 5a6edd2..a06eb24 100644 --- a/blaze822.c +++ b/blaze822.c @@ -59,8 +59,8 @@ blaze822_date(char *s) { while (iswsp(*s)) s++; - - if (i3("jan")) tm.tm_mon = 0; + + if (i3("jan")) tm.tm_mon = 0; else if (i3("feb")) tm.tm_mon = 1; else if (i3("mar")) tm.tm_mon = 2; else if (i3("apr")) tm.tm_mon = 3; @@ -79,7 +79,7 @@ blaze822_date(char *s) { while (iswsp(*s)) s++; - + if ((c = parse_posint(&s, 1000, 9999)) > 0) { tm.tm_year = c - 1900; } else if ((c = parse_posint(&s, 0, 49)) > 0) { @@ -143,7 +143,7 @@ blaze822_addr(char *s, char **dispo, char **addro) if (addro) *addro = 0; return 0; } - + c = disp; e = disp + sizeof disp - 1; @@ -151,7 +151,7 @@ blaze822_addr(char *s, char **dispo, char **addro) *addr = 0; while (*s && c < e) { - startover: +startover: if (*s == '<') { char *c = addr; char *e = addr + sizeof addr; @@ -188,7 +188,7 @@ blaze822_addr(char *s, char **dispo, char **addro) } else if (*s == '(') { // XXX recurse to conform? s++; - if (!*addr) { // assume: user@host (name) + if (!*addr) { // assume: user@host (name) *c-- = 0; while (c > disp && iswsp(*c)) *c-- = 0; diff --git a/filter.c b/filter.c index 7b86106..480cd52 100644 --- a/filter.c +++ b/filter.c @@ -1,9 +1,9 @@ #include -#include #include +#include #include -#include +#include #include #include #include @@ -24,7 +24,7 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno) sigemptyset(&mask); sigaddset(&mask, SIGPIPE); sigprocmask(SIG_BLOCK, &mask, &orig_mask); - + outlen = 0; output = malloc(outalloc); if (!output) @@ -56,7 +56,7 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno) } close(pipe0[0]); close(pipe1[1]); - + if (pid < 0) { close(pipe0[1]); close(pipe1[0]); @@ -89,7 +89,7 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno) } else if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { fds[0].fd = -1; } - + if (fds[1].revents & POLLOUT) { ssize_t ret = write(fds[1].fd, input, inlen); if (ret > 0) { diff --git a/maddr.c b/maddr.c index def6c6a..d8ac123 100644 --- a/maddr.c +++ b/maddr.c @@ -18,7 +18,7 @@ addr(char *file) { while (*file == ' ' || *file == '\t') file++; - + struct message *msg = blaze822(file); if (!msg) return; @@ -36,7 +36,7 @@ addr(char *file) blaze822_decode_rfc2047(vdec, v, sizeof vdec - 1, "UTF-8"); vdec[sizeof vdec - 1] = 0; v = vdec; - + while ((v = blaze822_addr(v, &disp, &addr))) { if (disp && addr && strcmp(disp, addr) == 0) disp = 0; @@ -64,7 +64,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "ah:")) != -1) - switch(c) { + switch (c) { case 'a': aflag = 1; break; case 'h': hflag = optarg; break; default: diff --git a/magrep.c b/magrep.c index 6acb0a8..3170902 100644 --- a/magrep.c +++ b/magrep.c @@ -67,7 +67,7 @@ match(char *file, char *hdr, char *s) blaze822_mime_action match_part(int depth, struct message *msg, char *body, size_t bodylen) { - (void) depth; + (void)depth; char *ct = blaze822_hdr(msg, "content-type"); @@ -163,7 +163,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "acdim:opqv")) != -1) - switch(c) { + switch (c) { case 'a': aflag = 1; break; case 'c': cflag = 1; break; case 'd': dflag = 1; break; @@ -174,7 +174,7 @@ main(int argc, char *argv[]) case 'q': qflag = 1; break; case 'v': vflag = 1; break; default: - usage: +usage: fprintf(stderr, "Usage: magrep [-c|-o|-p|-q|-m max] [-v] [-i] [-a|-d] header:regex [msgs...]\n"); exit(2); @@ -201,7 +201,7 @@ main(int argc, char *argv[]) blaze822_loop1(":", magrep); else blaze822_loop(argc-optind, argv+optind, magrep); - + if (cflag && !qflag && !mflag) printf("%ld\n", matches); diff --git a/mdeliver.c b/mdeliver.c index 6ac0f7e..580219f 100644 --- a/mdeliver.c +++ b/mdeliver.c @@ -81,9 +81,9 @@ tryagain: snprintf(id, sizeof id, "%ld.M%06ldP%ldQ%ld.%s", (long)tv.tv_sec, (long)tv.tv_usec, (long)getpid(), delivery, host); - + snprintf(tmp, sizeof tmp, "%s/tmp/%s", targetdir, id); - + outfd = open(tmp, O_CREAT | O_WRONLY | O_EXCL, 0666); if (outfd < 0) { if (errno == EEXIST) @@ -151,14 +151,14 @@ tryagain: int i, j; for (i = sizeof statusflags - 1; i >= 0; i--) if (!statusflags[i]) - for (j = i+1; j < (int) sizeof statusflags; j++) + for (j = i+1; j < (int)sizeof statusflags; j++) statusflags[j-1] = statusflags[j]; if (Mflag) { struct message *msg = blaze822_file(tmp); time_t date = -1; char *v; - + if (msg && (v = blaze822_hdr(msg, "date"))) { date = blaze822_date(v); if (date != -1) { @@ -172,8 +172,8 @@ tryagain: } snprintf(dst, sizeof dst, "%s/%s/%s:2,%s", - targetdir, (cflag || is_old) ? "cur" : "new", id, - Xflag ? Xflag : statusflags); + targetdir, (cflag || is_old) ? "cur" : "new", id, + Xflag ? Xflag : statusflags); if (rename(tmp, dst) != 0) return -1; @@ -188,7 +188,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "cMvX:")) != -1) - switch(c) { + switch (c) { case 'c': cflag = 1; break; case 'M': Mflag = 1; break; case 'v': vflag = 1; break; diff --git a/mdirs.c b/mdirs.c index e133ed7..31513c4 100644 --- a/mdirs.c +++ b/mdirs.c @@ -56,10 +56,10 @@ mdirs(char *fpath) if (dotonly && d->d_name[0] != '.') continue; - + mdirs(d->d_name); } - + if (chdir("..") < 0) exit(-1); @@ -71,9 +71,9 @@ main(int argc, char *argv[]) { int c, i; while ((c = getopt(argc, argv, "")) != -1) - switch(c) { + switch (c) { default: - usage: +usage: fprintf(stderr, "Usage: mdirs dirs...\n"); exit(1); } diff --git a/mexport.c b/mexport.c index ef31618..91fa9a6 100644 --- a/mexport.c +++ b/mexport.c @@ -51,7 +51,7 @@ export(char *file) if (e) { s++; snprintf(from, sizeof from, "%.*s", - (int)(e-s), s); + (int)(e-s), s); } } else { // return-path without <> snprintf(from, sizeof from, "%s", v); @@ -66,7 +66,7 @@ export(char *file) char *line = 0; size_t linelen = 0; - + printf("From %s %s", from, ctime(&date)); int in_header = 1; @@ -83,7 +83,7 @@ export(char *file) status = 1; return; } - + if (in_header && line[0] == '\n' && !line[1]) { if (Sflag) { char *flags = strstr(file, ":2,"); @@ -94,21 +94,21 @@ export(char *file) if (strchr(flags, 'S')) putchar('R'); char *ee = strrchr(file, '/'); - if (!ee || + if (!ee || !(ee >= file + 3 && ee[-3] == 'n' && ee[-2] == 'e' && ee[-1] == 'w')) putchar('O'); putchar('\n'); - + fputs("X-Status: ", stdout); if (strchr(flags, 'R')) putchar('A'); if (strchr(flags, 'T')) putchar('D'); if (strchr(flags, 'F')) putchar('F'); putchar('\n'); } - + in_header = 0; } - + // MBOXRD: add first > to >>..>>From char *s = line; while (*s == '>') @@ -132,7 +132,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "S")) != -1) - switch(c) { + switch (c) { case 'S': Sflag = 1; break; default: fprintf(stderr, "Usage: mexport [-S] [msgs...]\n"); @@ -145,6 +145,6 @@ main(int argc, char *argv[]) blaze822_loop1(":", export); else blaze822_loop(argc-optind, argv+optind, export); - + return status; } diff --git a/mflag.c b/mflag.c index 479030c..687ea6e 100644 --- a/mflag.c +++ b/mflag.c @@ -99,7 +99,7 @@ doit: return; } - + skip: if (vflag) printf("%s\n", file); @@ -110,7 +110,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "PRSTDFprstdfX:x:v")) != -1) - switch(c) { + switch (c) { case 'P': case 'R': case 'S': case 'T': case 'D': case 'F': flags[(unsigned int)c] = 1; break; @@ -151,7 +151,7 @@ main(int argc, char *argv[]) blaze822_loop1(":", flag); else blaze822_loop(0, 0, flag); - + return 0; } diff --git a/mflow.c b/mflow.c index 3a465b7..4726fec 100644 --- a/mflow.c +++ b/mflow.c @@ -150,10 +150,10 @@ main() } if (rd > 0 && line[rd-1] == '\n') - line[--rd] = 0; + line[--rd] = 0; if (rd > 0 && line[rd-1] == '\r') - line[--rd] = 0; - + line[--rd] = 0; + quotes = 0; while (*line == '>') { // measure quote depth line++; diff --git a/mgenmid.c b/mgenmid.c index 655df95..a578bcc 100644 --- a/mgenmid.c +++ b/mgenmid.c @@ -44,8 +44,8 @@ int main() hostbuf[sizeof hostbuf - 1] = 0; struct addrinfo hints = { .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM, - .ai_flags = AI_CANONNAME }; + .ai_socktype = SOCK_STREAM, + .ai_flags = AI_CANONNAME }; struct addrinfo *info; if (getaddrinfo(hostbuf, 0, &hints, &info) == 0) { // sanity checks: no (null), at least one dot, @@ -81,7 +81,7 @@ int main() " or add a FQDN to /etc/hosts.\n"); exit(1); } - + struct timeval tp; gettimeofday(&tp, (struct timezone *)0); diff --git a/mhdr.c b/mhdr.c index 5dfd636..cc49c22 100644 --- a/mhdr.c +++ b/mhdr.c @@ -74,7 +74,7 @@ print_addresses(char *s) printf("%s\t", curfile); if (disp && addr) - printf("%s <%s>\n", disp, addr); + printf("%s <%s>\n", disp, addr); else if (addr) printf("%s\n", addr); } @@ -189,7 +189,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "h:ADHMd")) != -1) - switch(c) { + switch (c) { case 'h': hflag = optarg; break; case 'A': Aflag = 1; break; case 'D': Dflag = 1; break; @@ -208,6 +208,6 @@ main(int argc, char *argv[]) blaze822_loop1(".", header); else blaze822_loop(argc-optind, argv+optind, header); - + return status; } diff --git a/minc.c b/minc.c index 21e6585..4e55292 100644 --- a/minc.c +++ b/minc.c @@ -65,10 +65,10 @@ main(int argc, char *argv[]) { int c, i; while ((c = getopt(argc, argv, "q")) != -1) - switch(c) { + switch (c) { case 'q': qflag = 1; break; default: - usage: +usage: fprintf(stderr, "Usage: minc [-q] dirs...\n"); exit(1); } diff --git a/mlist.c b/mlist.c index d796fc7..085fe7d 100644 --- a/mlist.c +++ b/mlist.c @@ -98,11 +98,11 @@ list(char *prefix, char *file) #include struct linux_dirent64 { - ino64_t d_ino; /* 64-bit inode number */ - off64_t d_off; /* 64-bit offset to next structure */ + ino64_t d_ino; /* 64-bit inode number */ + off64_t d_off; /* 64-bit offset to next structure */ unsigned short d_reclen; /* Size of this dirent */ - unsigned char d_type; /* File type */ - char d_name[]; /* Filename (null-terminated) */ + unsigned char d_type; /* File type */ + char d_name[]; /* Filename (null-terminated) */ }; #define BUF_SIZE 1024000 @@ -119,18 +119,18 @@ listdir(char *dir) perror("open"); return; } - + while (1) { nread = syscall(SYS_getdents64, fd, buf, BUF_SIZE); if (nread == -1) { perror("getdents64"); break; } - + if (nread == 0) break; - for (bpos = 0; bpos < nread;) { + for (bpos = 0; bpos < nread; ) { d = (struct linux_dirent64 *)(buf + bpos); if (d->d_type != DT_REG && d->d_type != DT_UNKNOWN) goto next; @@ -224,7 +224,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "PRSTDFprstdfX:x:NnCci")) != -1) - switch(c) { + switch (c) { case 'P': case 'R': case 'S': case 'T': case 'D': case 'F': flags[(unsigned int)c] = 1; break; @@ -245,7 +245,7 @@ main(int argc, char *argv[]) case 'c': Cflag = -1; break; case 'i': iflag = 1; break; default: - usage: +usage: fprintf(stderr, "Usage: mlist [-DFPRST] [-X str]\n" " [-dfprst] [-x str]\n" @@ -256,7 +256,7 @@ main(int argc, char *argv[]) } int i; - + for (i = 0, flagsum = 0, flagset = 0; (size_t)i < sizeof flags; i++) { if (flags[i] != 0) flagset++; diff --git a/mmime.c b/mmime.c index 34749e5..af7c86d 100644 --- a/mmime.c +++ b/mmime.c @@ -134,7 +134,7 @@ gen_attachment(const char *filename, char *content_disposition) return; } - for (s = (char *) filename; *s; s++) { + for (s = (char *)filename; *s; s++) { if (*s < 32 || *s == '"' || *s >= 127 || s - filename > 35) goto rfc2231; if (strchr(" ()<>@,;:\\/[]?=", *s)) @@ -161,9 +161,9 @@ rfc2231: } while (*s && i < 78 - 3) { if (*s <= 32 || *s == '"' || *s > 126) - i += printf("%%%02x", (uint8_t) *s++); + i += printf("%%%02x", (uint8_t)*s++); else - i += printf("%c", (uint8_t) *s++); + i += printf("%c", (uint8_t)*s++); } } @@ -196,7 +196,7 @@ gen_file(char *file, char *ct) file, strerror(r)); return -1; } - + if (strcmp(ct, "mblaze/raw") == 0) goto raw; @@ -291,7 +291,7 @@ print_header(char *line) { while (*e && *e == ' ') e++; for (; *e && *e != ' '; e++) { - if ((uint8_t) *e >= 127) + if ((uint8_t)*e >= 127) highbit++; } @@ -398,7 +398,7 @@ gen_build() printf("Content-Type: text/plain; charset=UTF-8\n"); printf("Content-Disposition: inline\n"); printf("Content-Transfer-Encoding: quoted-printable\n\n"); - + intext = 1; } @@ -470,12 +470,12 @@ main(int argc, char *argv[]) int c; while ((c = getopt(argc, argv, "crt:")) != -1) - switch(c) { + switch (c) { case 'r': rflag = 1; break; case 'c': cflag = 1; break; case 't': tflag = optarg; break; default: - usage: +usage: fprintf(stderr, "Usage: mmime [-c|-r] [-t CONTENT-TYPE] < message\n"); exit(1); diff --git a/mpick.c b/mpick.c index c6b401a..e99f9d5 100644 --- a/mpick.c +++ b/mpick.c @@ -29,17 +29,17 @@ #include #include #include +#include +#include +#include +#include #include #include -#include #include #include #include #include #include -#include -#include -#include #include "blaze822.h" @@ -163,7 +163,7 @@ static int prune; static void ws() { - while (isspace((unsigned char) *pos)) + while (isspace((unsigned char)*pos)) pos++; } @@ -306,7 +306,7 @@ parse_string(char **s) char t; char *e = ++pos; - while (isalnum((unsigned char) *pos) || *pos == '_') + while (isalnum((unsigned char)*pos) || *pos == '_') pos++; if (e == pos) parse_error("invalid environment variable name"); @@ -407,12 +407,12 @@ static int64_t parse_num(int64_t *r) { char *s = pos; - if (isdigit((unsigned char) *pos)) { + if (isdigit((unsigned char)*pos)) { int64_t n; - for (n = 0; isdigit((unsigned char) *pos) && n <= INT64_MAX / 10 - 10; pos++) + for (n = 0; isdigit((unsigned char)*pos) && n <= INT64_MAX / 10 - 10; pos++) n = 10 * n + (*pos - '0'); - if (isdigit((unsigned char) *pos)) + if (isdigit((unsigned char)*pos)) parse_error("number too big: %s", s); if (token("c")) ; else if (token("b")) n *= 512LL; @@ -499,7 +499,7 @@ parse_cmp() e->a.prop = prop; e->b.num = n; return e; - } else if(token("cur")) { + } else if (token("cur")) { struct expr *e = mkexpr(op); e->a.prop = prop; e->b.var = VAR_CUR; @@ -905,7 +905,7 @@ eval(struct expr *e, struct mailinfo *m) case EXPR_REGEX: case EXPR_REGEXI: { const char *s = ""; - switch(e->a.prop) { + switch (e->a.prop) { case PROP_PATH: s = m->fpath; break; case PROP_FROM: s = msg_addr(m, "from", e->extra); break; case PROP_TO: s = msg_addr(m, "to", e->extra); break; @@ -951,7 +951,7 @@ mailfile(char *file) m->sb = 0; m->msg = 0; - while (*m->fpath == ' ' || *m->fpath== '\t') { + while (*m->fpath == ' ' || *m->fpath == '\t') { m->depth++; m->fpath++; } @@ -1079,7 +1079,7 @@ collect(char *file) } else if (thr->cur->m->depth > m->depth) { /* find parent mail */ struct mlist *pl; - for (pl = thr->cur; pl->m->depth >= m->depth; pl--); + for (pl = thr->cur; pl->m->depth >= m->depth; pl--) ; ml->parent = pl; } diff --git a/mscan.c b/mscan.c index 67a4c1d..8d104ad 100644 --- a/mscan.c +++ b/mscan.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -15,7 +16,6 @@ #include #include #include -#include #include "blaze822.h" @@ -280,7 +280,7 @@ oneline(char *file) indent++; file++; } - + struct message *msg = blaze822(file); char *flags = msg ? strstr(file, ":2,") : 0; if (!flags) @@ -492,7 +492,7 @@ main(int argc, char *argv[]) int c; while ((c = getopt(argc, argv, "If:n")) != -1) - switch(c) { + switch (c) { case 'I': Iflag++; break; case 'f': fflag = optarg; break; case 'n': nflag = 1; break; @@ -513,7 +513,7 @@ main(int argc, char *argv[]) struct tm *tm = localtime(&now); curyear = tm->tm_year; - setlocale(LC_ALL, ""); // for wcwidth later + setlocale(LC_ALL, ""); // for wcwidth later if (wcwidth(0xfffd) > 0) replacement = 0xfffd; @@ -545,12 +545,12 @@ main(int argc, char *argv[]) char *v, *d, *a; if ((v = blaze822_hdr(config, "local-mailbox"))) while (alias_idx < (int)(sizeof aliases / sizeof aliases[0]) && - (v = blaze822_addr(v, &d, &a))) + (v = blaze822_addr(v, &d, &a))) if (a) aliases[alias_idx++] = strdup(a); if ((v = blaze822_hdr(config, "alternate-mailboxes"))) while (alias_idx < (int)(sizeof aliases / sizeof aliases[0]) && - (v = blaze822_addr(v, &d, &a))) + (v = blaze822_addr(v, &d, &a))) if (a) aliases[alias_idx++] = strdup(a); if ((v = blaze822_hdr(config, "scan-format"))) diff --git a/msed.c b/msed.c index fe9078c..643fdd8 100644 --- a/msed.c +++ b/msed.c @@ -23,9 +23,9 @@ subst(char *str, char *srch, char *repl, char *flags) int iflag = !!strchr(flags, 'i'); int gflag = !!strchr(flags, 'g'); -#define APP(o,l) do {if(bufe-b<(ssize_t)l) return str; memcpy(b,str+i+o,l); b+=l;} while(0) -#define APPC(c) do {if(b>=bufe) return str; *b++=c;} while(0) - +#define APP(o, l) do { if (bufe-b < (ssize_t)l) return str; memcpy(b, str+i+o, l); b += l; } while (0) +#define APPC(c) do { if (b >= bufe) return str; *b++ = c; } while (0) + regex_t srchrx; regmatch_t pmatch[10]; if (regcomp(&srchrx, srch, iflag ? REG_ICASE : 0) != 0) @@ -52,7 +52,7 @@ subst(char *str, char *srch, char *repl, char *flags) t++; n = *t++ - '0'; } - + APP(pmatch[n].rm_so, pmatch[n].rm_eo - pmatch[n].rm_so); } else if (*t == '\\' && *(t+1)) { @@ -62,7 +62,7 @@ subst(char *str, char *srch, char *repl, char *flags) APPC(*t++); } } - + i += pmatch[0].rm_eo; // advance to end of match if (!gflag) break; @@ -198,7 +198,7 @@ sed(char *file) char *from = strndup(s, t-s-1); char *to = strndup(t, u-t-1); char *flags = strndup(u, e-u); - + char *ov = v; v = strdup(subst(ov, from, to, flags)); free(ov); @@ -231,7 +231,7 @@ sed(char *file) while (*e && (*e == ' ' || *e == '\t' || *e == '\n' || *e == ';')) e++; - + hs = he = 0; if (*e == '/') { e++; @@ -243,49 +243,49 @@ sed(char *file) if (*e) e++; } - + char sep; char *s; char *h = 0; char *v = 0; switch (*e) { - case 'a': - if (he != hs) { - h = strndup(hs, he-hs); - } else { - fprintf(stderr, "msed: used command a without header name\n"); - exit(1); - } + case 'a': + if (he != hs) { + h = strndup(hs, he-hs); + } else { + fprintf(stderr, "msed: used command a without header name\n"); + exit(1); + } - e++; - if (*e == ' ' || *e == '\t' || *e == '\n' || *e == ';' || !*e) { - fprintf(stderr, "msed: no header value for %s\n", h); + e++; + if (*e == ' ' || *e == '\t' || *e == '\n' || *e == ';' || !*e) { + fprintf(stderr, "msed: no header value for %s\n", h); + exit(1); + } else { + sep = *e; + if (!sep) { + fprintf(stderr, "msed: unterminated a command\n"); exit(1); - } else { - sep = *e; - if (!sep) { - fprintf(stderr, "msed: unterminated a command\n"); - exit(1); - } - s = ++e; - while (*e && *e != sep) - e++; - v = strndup(s, e-s); } + s = ++e; + while (*e && *e != sep) + e++; + v = strndup(s, e-s); + } - if (blaze822_chdr(msg, h)) - break; + if (blaze822_chdr(msg, h)) + break; - printhdr(h, 0); - printf(": %s\n", v); + printhdr(h, 0); + printf(": %s\n", v); - break; + break; - case 'c': - case 'd': - case 's': - // ignore here; - break; + case 'c': + case 'd': + case 's': + // ignore here; + break; } while (*e && *e != ';' && *e != '\n') e++; @@ -300,7 +300,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "")) != -1) - switch(c) { + switch (c) { default: fprintf(stderr, "Usage: msed [expr] [msgs...]\n"); exit(1); @@ -313,6 +313,6 @@ main(int argc, char *argv[]) blaze822_loop1(".", sed); else blaze822_loop(argc-optind, argv+optind, sed); - + return 0; } diff --git a/mseq.c b/mseq.c index efe8ec0..e1b1f04 100644 --- a/mseq.c +++ b/mseq.c @@ -2,9 +2,9 @@ #include #include #include -#include #include #include +#include #include #include "blaze822.h" @@ -151,7 +151,7 @@ fix(FILE *out, char *file) return 0; ok: - while(i--) + while (i--) putc(' ', out); fprintf(out, "%s\n", bufptr); return 1; @@ -276,7 +276,7 @@ main(int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "c:frAC:S")) != -1) - switch(c) { + switch (c) { case 'c': cflag = optarg; break; case 'f': fflag = 1; break; case 'r': rflag = 1; break; @@ -284,7 +284,7 @@ main(int argc, char *argv[]) case 'C': Cflag = optarg; break; case 'S': Sflag = 1; break; default: - usage: +usage: fprintf(stderr, "Usage: mseq [-fr] [-c msg] [msgs...]\n" " mseq -S [-fr] < sequence\n" diff --git a/mshow.c b/mshow.c index c431108..d71fe44 100644 --- a/mshow.c +++ b/mshow.c @@ -96,7 +96,7 @@ print_u8recode(char *body, size_t bodylen, char *srcenc) final_char = bufptr[-1]; } - if (r != (size_t)-1) { // done, flush iconv + if (r != (size_t)-1) { // done, flush iconv bufptr = buf; buflen = sizeof buf; r = iconv(ic, 0, 0, &bufptr, &buflen); @@ -338,7 +338,7 @@ choose_alternative(struct message *msg, int depth) blaze822_mime_action reply_mime(int depth, struct message *msg, char *body, size_t bodylen) { - (void) depth; + (void)depth; char *ct = blaze822_hdr(msg, "content-type"); char *mt = mimetype(ct); @@ -367,7 +367,7 @@ reply_mime(int depth, struct message *msg, char *body, size_t bodylen) blaze822_mime_action list_mime(int depth, struct message *msg, char *body, size_t bodylen) { - (void) body; + (void)body; char *ct = blaze822_hdr(msg, "content-type"); if (!ct) @@ -443,7 +443,7 @@ writefile(char *name, char *buf, ssize_t len) blaze822_mime_action extract_mime(int depth, struct message *msg, char *body, size_t bodylen) { - (void) depth; + (void)depth; char *filename = mime_filename(msg); @@ -499,7 +499,7 @@ extract_mime(int depth, struct message *msg, char *body, size_t bodylen) writefile(bufptr, body, bodylen); } } else if (filename && - fnmatch(a, filename, FNM_PATHNAME) == 0) { + fnmatch(a, filename, FNM_PATHNAME) == 0) { // extract by name if (extract_stdout) { if (rflag) { @@ -558,7 +558,7 @@ print_date_header(char *v) printf("Date: "); print_ascii(v, strlen(v)); - + time_t t = blaze822_date(v); if (t == -1) { printf(" (invalid)"); @@ -574,57 +574,57 @@ print_date_header(char *v) else if (d > 60) l = 'm'; else l = 's'; int p = 3; - + int z; - switch(l) { + switch (l) { case 'y': z = d / (60*60*24*7*52); d = d % (60*60*24*7*52); if (z > 0) { - printf("%d year%s", z, z>1 ? "s" : ""); + printf("%d year%s", z, z > 1 ? "s" : ""); if (!--p) break; printf(", "); } - /* FALL THROUGH */ + /* FALL THROUGH */ case 'w': z = d / (60*60*24*7); d = d % (60*60*24*7); if (z > 0) { - printf("%d week%s", z, z>1 ? "s" : ""); + printf("%d week%s", z, z > 1 ? "s" : ""); if (!--p) break; printf(", "); } - /* FALL THROUGH */ + /* FALL THROUGH */ case 'd': z = d / (60*60*24); d = d % (60*60*24); if (z > 0) { - printf("%d day%s", z, z>1 ? "s" : ""); + printf("%d day%s", z, z > 1 ? "s" : ""); if (!--p) break; printf(", "); } - /* FALL THROUGH */ + /* FALL THROUGH */ case 'h': z = d / (60*60); d = d % (60*60); if (z > 0) { - printf("%d hour%s", z, z>1 ? "s" : ""); + printf("%d hour%s", z, z > 1 ? "s" : ""); if (!--p) break; printf(", "); } - /* FALL THROUGH */ + /* FALL THROUGH */ case 'm': z = d / (60); d = d % (60); if (z > 0) { - printf("%d minute%s", z, z>1 ? "s" : ""); + printf("%d minute%s", z, z > 1 ? "s" : ""); if (!--p) break; printf(", "); } - /* FALL THROUGH */ + /* FALL THROUGH */ case 's': z = d; - printf("%d second%s", z, z>1 ? "s" : ""); + printf("%d second%s", z, z > 1 ? "s" : ""); } if (t < now) @@ -728,7 +728,7 @@ main(int argc, char *argv[]) int c; while ((c = getopt(argc, argv, "h:A:qrtHLNx:O:Rn")) != -1) - switch(c) { + switch (c) { case 'h': hflag = optarg; break; case 'A': Aflag = optarg; break; case 'q': qflag = 1; break; diff --git a/msort.c b/msort.c index e364a83..cdb7d4b 100644 --- a/msort.c +++ b/msort.c @@ -1,5 +1,5 @@ -#include #include +#include #include #include @@ -300,7 +300,7 @@ main(int argc, char *argv[]) int c, i; while ((c = getopt(argc, argv, "fdsFMSUIr")) != -1) - switch(c) { + switch (c) { case 'f': addorder(fromorder); break; case 'd': addorder(dateorder); break; case 's': addorder(subjorder); break; diff --git a/mthread.c b/mthread.c index f275826..503b359 100644 --- a/mthread.c +++ b/mthread.c @@ -170,7 +170,7 @@ thread(char *file) parent = me; } } - + v = blaze822_hdr(msg, "in-reply-to"); char *irt; if (v) { @@ -181,7 +181,7 @@ thread(char *file) if (!v) goto out; irt = strndup(m+1, v-m-1); - + if (strcmp(irt, mid) != 0) { parent = midcont(irt); } @@ -278,7 +278,7 @@ find_root(const void *nodep, const VISIT which, const int depth) void find_roots() { - top = malloc (sizeof (struct container)); + top = malloc(sizeof (struct container)); top->msg = 0; top->date = -1; top->file = 0; @@ -387,7 +387,7 @@ print_tree(struct container *c, int depth) else printf("<%s>\n", c->mid); } - + if (c->child) print_tree(c->child, depth+1); } while ((c = c->next)); @@ -400,14 +400,14 @@ main(int argc, char *argv[]) optional = 1; - while ((c = getopt(argc, argv, "S:v")) != -1) - switch(c) { - case 'S': blaze822_loop1(optarg, thread); break; - case 'v': vflag = 1; break; - default: + while ((c = getopt(argc, argv, "S:v")) != -1) + switch (c) { + case 'S': blaze822_loop1(optarg, thread); break; + case 'v': vflag = 1; break; + default: fprintf(stderr, "Usage: mthread [-v] [-S dir] [msgs...]\n"); - exit(1); - } + exit(1); + } optional = 0; diff --git a/pipeto.c b/pipeto.c index 8014584..4392548 100644 --- a/pipeto.c +++ b/pipeto.c @@ -47,7 +47,7 @@ pipeto(const char *cmdline) break; *cp++ = 0; while (*cp == ' ') - cp++; + cp++; } argv[argc] = 0; @@ -96,6 +96,6 @@ pipeclose(pid_t pid) fflush(0); close(1); waitpid(pid, &s, 0); - + return s; } diff --git a/rfc2045.c b/rfc2045.c index a13608c..a0e5470 100644 --- a/rfc2045.c +++ b/rfc2045.c @@ -1,8 +1,8 @@ #include -#include -#include #include +#include +#include #include "blaze822.h" #include "blaze822_priv.h" diff --git a/rfc2047.c b/rfc2047.c index 5f5c2f5..0d5bea5 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -82,7 +82,7 @@ blaze822_decode_b64(char *s, char *e, char **deco, size_t *decleno) *deco = buf; while (s + 4 <= e) { - while (s < e && isfws((unsigned char) *s)) + while (s < e && isfws((unsigned char)*s)) s++; if (s >= e) break; @@ -90,7 +90,7 @@ blaze822_decode_b64(char *s, char *e, char **deco, size_t *decleno) uint32_t v = 0; unsigned char t = 0; - unsigned char c0=s[0], c1=s[1], c2=s[2], c3=s[3]; + unsigned char c0 = s[0], c1 = s[1], c2 = s[2], c3 = s[3]; s += 4; if ((c0 | c1 | c2 | c3) > 127) @@ -273,7 +273,7 @@ nocodeok: } #ifdef TEST -int +int main() { char *r; size_t l; diff --git a/rfc2231.c b/rfc2231.c index f9a508b..c0edaff 100644 --- a/rfc2231.c +++ b/rfc2231.c @@ -39,7 +39,7 @@ blaze822_mime2231_parameter(char *s, char *name, i = 100; goto found_plain; } - + while (i < 100) { snprintf(namenum, sizeof namenum, "%s*%d*", name, i); if (blaze822_mime_parameter(s, namenum, &sbuf, &ebuf)) { @@ -48,13 +48,13 @@ found_extended: if (i == 0 || i == 100) { // extended-initial-value char *encstart = sbuf; sbuf = strchr(sbuf, '\''); - if (!sbuf) + if (!sbuf) return 0; srcenc = strndup(encstart, sbuf - encstart); if (!srcenc) return 0; sbuf = strchr(sbuf+1, '\''); - if (!sbuf) + if (!sbuf) return 0; sbuf++; } @@ -110,7 +110,7 @@ found_plain: size_t dstlen = dst - dststart; dst = dststart; - + int r = iconv(ic, &dst, &dstlen, &tmpend, &tmplen); if (r < 0) { free(tmp); diff --git a/safe_u8putstr.c b/safe_u8putstr.c index 28c541e..e198b54 100644 --- a/safe_u8putstr.c +++ b/safe_u8putstr.c @@ -1,5 +1,5 @@ -#include #include +#include void safe_u8putstr(char *s0, size_t l, FILE *stream) @@ -10,7 +10,7 @@ safe_u8putstr(char *s0, size_t l, FILE *stream) // - rest is assumed to be latin1, and translated into utf8 // - translate CRLF to CR - unsigned char *s = (unsigned char* )s0; + unsigned char *s = (unsigned char *)s0; unsigned char *e = s + l; while (s < e) { @@ -56,13 +56,13 @@ safe_u8putstr(char *s0, size_t l, FILE *stream) f = (s[0]<<24) | (s[1]<<16); else if (e - s == 1) f = (s[0]<<24); - + if ((f & 0xe0c00000) == 0xc0800000) goto u2; else if ((f & 0xf0c0c000) == 0xe0808000) goto u3; else if ((f & 0xf8c0c0c0) == 0xf0808080) { fputc(*s++, stream); -u3: fputc(*s++, stream); -u2: fputc(*s++, stream); +u3: fputc(*s++, stream); +u2: fputc(*s++, stream); fputc(*s, stream); } else { latin1: diff --git a/seq.c b/seq.c index f481f7e..84a77e1 100644 --- a/seq.c +++ b/seq.c @@ -349,7 +349,7 @@ parse_range(char *map, char *a, long *start, long *stop, long cur, long lines) a = b; } if (*start == 0) - *start = strchr("=^_", *a) ? cur : 1; + *start = strchr("=^_", *a) ? cur : 1; while (*a == '^') { a++; @@ -428,7 +428,7 @@ blaze822_seq_next(char *map, char *range, struct blaze822_seq_iter *iter) if (!iter->start) { int ret = parse_range(map, range, &iter->start, &iter->stop, - iter->cur, iter->lines); + iter->cur, iter->lines); if (ret == 1) { fprintf(stderr, "can't parse range: %s\n", range); return 0; diff --git a/slurp.c b/slurp.c index 388f203..fff8624 100644 --- a/slurp.c +++ b/slurp.c @@ -14,7 +14,7 @@ slurp(char *filename, char **bufo, off_t *leno) ssize_t nread = 0; ssize_t n; int r = 0; - + fd = open(filename, O_RDONLY); if (fd < 0) { r = errno;