diff options
-rw-r--r-- | blaze822.c | 32 | ||||
-rw-r--r-- | filter.c | 8 | ||||
-rw-r--r-- | mdirs.c | 4 | ||||
-rw-r--r-- | mexport.c | 8 | ||||
-rw-r--r-- | mflag.c | 8 | ||||
-rw-r--r-- | mgenmid.c | 12 | ||||
-rw-r--r-- | minc.c | 2 | ||||
-rw-r--r-- | mlist.c | 22 | ||||
-rw-r--r-- | mmime.c | 4 | ||||
-rw-r--r-- | mscan.c | 8 | ||||
-rw-r--r-- | msed.c | 24 | ||||
-rw-r--r-- | mseq.c | 6 | ||||
-rw-r--r-- | mshow.c | 20 | ||||
-rw-r--r-- | msort.c | 8 | ||||
-rw-r--r-- | mytimegm.c | 130 | ||||
-rw-r--r-- | rfc2045.c | 4 | ||||
-rw-r--r-- | seq.c | 14 |
17 files changed, 157 insertions, 157 deletions
diff --git a/blaze822.c b/blaze822.c index d15f4c9..1154e3d 100644 --- a/blaze822.c +++ b/blaze822.c @@ -19,19 +19,19 @@ static long parse_posint(char **s, size_t minn, size_t maxn) { - long n; - char *end; + long n; + char *end; - errno = 0; - n = strtol(*s, &end, 10); - if (errno) + errno = 0; + n = strtol(*s, &end, 10); + if (errno) return -1; - if (n < (long)minn || n > (long)maxn) { + if (n < (long)minn || n > (long)maxn) { errno = ERANGE; return -1; - } - *s = end; - return n; + } + *s = end; + return n; } time_t @@ -60,7 +60,7 @@ 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; @@ -111,12 +111,12 @@ blaze822_date(char *s) { s++; if ((c = parse_posint(&s, 0, 10000)) < 0) goto fail; if (neg) { - tm.tm_hour += c / 100; - tm.tm_min += c % 100; + tm.tm_hour += c / 100; + tm.tm_min += c % 100; } else { - tm.tm_hour -= c / 100; - tm.tm_min -= c % 100; - } + tm.tm_hour -= c / 100; + tm.tm_min -= c % 100; + } } tm.tm_isdst = -1; @@ -183,7 +183,7 @@ blaze822_addr(char *s, char **dispo, char **addro) } else if (*s == '(') { 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 87e48ca..7c64bcb 100644 --- a/filter.c +++ b/filter.c @@ -1,4 +1,4 @@ -#include <poll.h> +#include <poll.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -86,11 +86,11 @@ filter(char *input, size_t inlen, char *cmd, char **outputo, size_t *outleno) } // ok to fail when closed already - close(pipe0[1]); - close(pipe1[0]); + close(pipe0[1]); + close(pipe1[0]); int status; - waitpid(pid, &status, 0); + waitpid(pid, &status, 0); *outputo = output; *outleno = outlen; diff --git a/mdirs.c b/mdirs.c index 4213924..e133ed7 100644 --- a/mdirs.c +++ b/mdirs.c @@ -19,7 +19,7 @@ void mdirs(char *fpath) { DIR *dir; - struct dirent *d; + struct dirent *d; struct stat st; dir = opendir(fpath); @@ -63,7 +63,7 @@ mdirs(char *fpath) if (chdir("..") < 0) exit(-1); - closedir(dir); + closedir(dir); } int diff --git a/mexport.c b/mexport.c index 7c31609..60a986d 100644 --- a/mexport.c +++ b/mexport.c @@ -29,8 +29,8 @@ export(char *file) char from[1024] = "nobody"; - char *v; - if ((v = blaze822_hdr(msg, "return-path")) || + char *v; + if ((v = blaze822_hdr(msg, "return-path")) || (v = blaze822_hdr(msg, "x-envelope-from"))) { char *s = strchr(v, '<'); char *e = strchr(s, '>'); @@ -39,10 +39,10 @@ export(char *file) memcpy(from, s, e-s); from[e-s] = 0; } - } + } time_t date = -1; - if ((v = blaze822_hdr(msg, "date"))) { + if ((v = blaze822_hdr(msg, "date"))) { date = blaze822_date(v); } diff --git a/mflag.c b/mflag.c index 73941d2..852caa9 100644 --- a/mflag.c +++ b/mflag.c @@ -117,11 +117,11 @@ main(int argc, char *argv[]) case 'p': case 'r': case 's': case 't': case 'd': case 'f': flags[(unsigned int)uc(c)] = -1; break; - case 'X': + case 'X': while (*optarg) flags[(unsigned int)*optarg++] = 1; break; - case 'x': + case 'x': while (*optarg) flags[(unsigned int)*optarg++] = -1; break; @@ -129,8 +129,8 @@ main(int argc, char *argv[]) default: fprintf(stderr, "Usage: mflag [-DFPRST] [-X str]\n" - " [-dfprst] [-x str]\n" - " [-v] [msgs...]\n" + " [-dfprst] [-x str]\n" + " [-v] [msgs...]\n" ); exit(1); } diff --git a/mgenmid.c b/mgenmid.c index a9b878b..7464daa 100644 --- a/mgenmid.c +++ b/mgenmid.c @@ -103,14 +103,14 @@ fallback: rnd |= (1LL << 63); // set highest bit to force full width - putchar('<'); + putchar('<'); printb36(((uint64_t)tp.tv_sec << 16) + (tp.tv_nsec >> 16)); - putchar('.'); + putchar('.'); printb36(rnd); - putchar('@'); + putchar('@'); fputs(host, stdout); - putchar('>'); - putchar('\n'); + putchar('>'); + putchar('\n'); - return 0; + return 0; } diff --git a/minc.c b/minc.c index a8e6cb9..7246763 100644 --- a/minc.c +++ b/minc.c @@ -19,7 +19,7 @@ void inc(char *dir) { DIR *fd; - struct dirent *d; + struct dirent *d; char src[PATH_MAX]; char dst[PATH_MAX]; diff --git a/mlist.c b/mlist.c index 4e40eb5..82eea73 100644 --- a/mlist.c +++ b/mlist.c @@ -93,11 +93,11 @@ list(char *prefix, char *file) #include <sys/syscall.h> 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 @@ -144,7 +144,7 @@ void listdir(char *dir) { DIR *fd; - struct dirent *d; + struct dirent *d; fd = opendir(dir); if (!fd) @@ -222,11 +222,11 @@ main(int argc, char *argv[]) case 'p': case 'r': case 's': case 't': case 'd': case 'f': flags[(unsigned int)uc(c)] = -1; break; - case 'X': + case 'X': while (*optarg) flags[(unsigned int)*optarg++] = 1; break; - case 'x': + case 'x': while (*optarg) flags[(unsigned int)*optarg++] = -1; break; @@ -239,14 +239,14 @@ main(int argc, char *argv[]) usage: fprintf(stderr, "Usage: mlist [-DFPRST] [-X str]\n" - " [-dfprst] [-x str]\n" - " [-N | -n | -C | -c]\n" - " [-i] [dirs...]\n" + " [-dfprst] [-x str]\n" + " [-N | -n | -C | -c]\n" + " [-i] [dirs...]\n" ); exit(1); } - int i; + int i; for (i = 0, flagsum = 0, flagset = 0; (size_t)i < sizeof flags; i++) { if (flags[i] != 0) diff --git a/mmime.c b/mmime.c index 4f2dd4f..78bd757 100644 --- a/mmime.c +++ b/mmime.c @@ -104,8 +104,8 @@ int gen_qp(uint8_t *s, off_t size, int maxlinelen, int header) static const char * basenam(const char *s) { - char *r = strrchr(s, '/'); - return r ? r + 1 : s; + char *r = strrchr(s, '/'); + return r ? r + 1 : s; } int gen_file(char *file, char *ct) diff --git a/mscan.c b/mscan.c index 2a2c543..992148d 100644 --- a/mscan.c +++ b/mscan.c @@ -143,7 +143,7 @@ fmt_date(struct message *msg, int w, int iso) else if (tm->tm_yday != curyday) strftime(date, sizeof date, "%a %b %e", tm); else - strftime(date, sizeof date, "%a %H:%M", tm); + strftime(date, sizeof date, "%a %H:%M", tm); } return date; @@ -173,7 +173,7 @@ fmt_subject(struct message *msg, char *file, int strip) i++; continue; } else if (strncasecmp("re:", subjdec+i, 3) == 0 || - strncasecmp("aw:", subjdec+i, 3) == 0) { + strncasecmp("aw:", subjdec+i, 3) == 0) { i += 3; continue; } else if (strncasecmp("fwd:", subjdec+i, 4) == 0) { @@ -198,7 +198,7 @@ fmt_from(struct message *msg) if (!msg) return ""; - if ((v = blaze822_hdr(msg, "from"))) { + if ((v = blaze822_hdr(msg, "from"))) { blaze822_decode_rfc2047(fromdec, v, sizeof fromdec - 1, "UTF-8"); fromdec[sizeof fromdec - 1] = 0; from = fromdec; @@ -505,7 +505,7 @@ main(int argc, char *argv[]) curyear = tm->tm_year; curyday = tm->tm_yday; - setlocale(LC_ALL, ""); // for wcwidth later + setlocale(LC_ALL, ""); // for wcwidth later if (wcwidth(0xfffd) > 0) replacement = 0xfffd; diff --git a/msed.c b/msed.c index 20a720b..5c82745 100644 --- a/msed.c +++ b/msed.c @@ -80,17 +80,17 @@ subst(char *str, char *srch, char *repl, char *flags) void printhdr(char *hdr, int rest) { - int uc = 1; + int uc = 1; - while (*hdr && *hdr != ':') { - putc(uc ? toupper(*hdr) : *hdr, stdout); - uc = (*hdr == '-'); - hdr++; - } + while (*hdr && *hdr != ':') { + putc(uc ? toupper(*hdr) : *hdr, stdout); + uc = (*hdr == '-'); + hdr++; + } - if (rest) { - printf("%s\n", hdr); - } + if (rest) { + printf("%s\n", hdr); + } } void @@ -101,7 +101,7 @@ sed(char *file) return; char *h = 0; - while ((h = blaze822_next_header(msg, h))) { + while ((h = blaze822_next_header(msg, h))) { regex_t headerrx; char headersel[1024]; @@ -215,7 +215,7 @@ sed(char *file) printf(": %s\n", v); free(v); } - } + } // loop, do all a// @@ -283,7 +283,7 @@ sed(char *file) } while (*e && *e != ';' && *e != '\n') e++; - } + } printf("\n"); fwrite(blaze822_body(msg), 1, blaze822_bodylen(msg), stdout); diff --git a/mseq.c b/mseq.c index 00ec844..4ceacf2 100644 --- a/mseq.c +++ b/mseq.c @@ -273,9 +273,9 @@ main(int argc, char *argv[]) usage: fprintf(stderr, "Usage: mseq [-fr] [-c msg] [msgs...]\n" - " mseq -S [-fr] < sequence\n" - " mseq -A [-fr] < sequence\n" - " mseq -C msg\n" + " mseq -S [-fr] < sequence\n" + " mseq -A [-fr] < sequence\n" + " mseq -C msg\n" ); exit(1); } diff --git a/mshow.c b/mshow.c index 4342ed2..38242f9 100644 --- a/mshow.c +++ b/mshow.c @@ -93,7 +93,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); @@ -389,8 +389,8 @@ static int extract_stdout; static const char * basenam(const char *s) { - char *r = strrchr(s, '/'); - return r ? r + 1 : s; + char *r = strrchr(s, '/'); + return r ? r + 1 : s; } static int @@ -702,16 +702,16 @@ main(int argc, char *argv[]) case 'O': Oflag = optarg; break; case 'R': Rflag = 1; break; case 'n': nflag = 1; break; - default: + default: fprintf(stderr, "Usage: mshow [-h headers] [-A mimetypes] [-qrHL] [msgs...]\n" - " mshow -x msg parts...\n" - " mshow -O msg parts...\n" - " mshow -t msgs...\n" - " mshow -R msg\n" + " mshow -x msg parts...\n" + " mshow -O msg parts...\n" + " mshow -t msgs...\n" + " mshow -R msg\n" ); - exit(1); - } + exit(1); + } if (xflag) { // extract extract(xflag, argc-optind, argv+optind, 0); diff --git a/msort.c b/msort.c index 323717a..e364a83 100644 --- a/msort.c +++ b/msort.c @@ -78,10 +78,10 @@ fetch_from(char *file) char *v = blaze822_hdr(msg, "from"); if (v) { char *disp, *addr; - blaze822_addr(v, &disp, &addr); - if (disp) - from = strdup(disp); - else if (addr) + blaze822_addr(v, &disp, &addr); + if (disp) + from = strdup(disp); + else if (addr) from = strdup(addr); } diff --git a/mytimegm.c b/mytimegm.c index 3d3fccd..7b63b2f 100644 --- a/mytimegm.c +++ b/mytimegm.c @@ -5,82 +5,82 @@ static long long __year_to_secs(long long year, int *is_leap) { - if (year-2ULL <= 136) { - int y = year; - int leaps = (y-68)>>2; - if (!((y-68)&3)) { - leaps--; - if (is_leap) *is_leap = 1; - } else if (is_leap) *is_leap = 0; - return 31536000*(y-70) + 86400*leaps; - } + if (year-2ULL <= 136) { + int y = year; + int leaps = (y-68)>>2; + if (!((y-68)&3)) { + leaps--; + if (is_leap) *is_leap = 1; + } else if (is_leap) *is_leap = 0; + return 31536000*(y-70) + 86400*leaps; + } - int cycles, centuries, leaps, rem; + int cycles, centuries, leaps, rem; - cycles = (year-100) / 400; - rem = (year-100) % 400; - if (rem < 0) { - cycles--; - rem += 400; - } - if (!rem) { - *is_leap = 1; - centuries = 0; - leaps = 0; - } else { - if (rem >= 200) { - if (rem >= 300) centuries = 3, rem -= 300; - else centuries = 2, rem -= 200; - } else { - if (rem >= 100) centuries = 1, rem -= 100; - else centuries = 0; - } - if (!rem) { - *is_leap = 0; - leaps = 0; - } else { - leaps = rem / 4U; - rem %= 4U; - *is_leap = !rem; - } - } + cycles = (year-100) / 400; + rem = (year-100) % 400; + if (rem < 0) { + cycles--; + rem += 400; + } + if (!rem) { + *is_leap = 1; + centuries = 0; + leaps = 0; + } else { + if (rem >= 200) { + if (rem >= 300) centuries = 3, rem -= 300; + else centuries = 2, rem -= 200; + } else { + if (rem >= 100) centuries = 1, rem -= 100; + else centuries = 0; + } + if (!rem) { + *is_leap = 0; + leaps = 0; + } else { + leaps = rem / 4U; + rem %= 4U; + *is_leap = !rem; + } + } - leaps += 97*cycles + 24*centuries - *is_leap; + leaps += 97*cycles + 24*centuries - *is_leap; - return (year-100) * 31536000LL + leaps * 86400LL + 946684800 + 86400; + return (year-100) * 31536000LL + leaps * 86400LL + 946684800 + 86400; } static int __month_to_secs(int month, int is_leap) { - static const int secs_through_month[] = { - 0, 31*86400, 59*86400, 90*86400, - 120*86400, 151*86400, 181*86400, 212*86400, - 243*86400, 273*86400, 304*86400, 334*86400 }; - int t = secs_through_month[month]; - if (is_leap && month >= 2) t+=86400; - return t; + static const int secs_through_month[] = { + 0, 31*86400, 59*86400, 90*86400, + 120*86400, 151*86400, 181*86400, 212*86400, + 243*86400, 273*86400, 304*86400, 334*86400 }; + int t = secs_through_month[month]; + if (is_leap && month >= 2) t+=86400; + return t; } time_t tm_to_secs(const struct tm *tm) { - int is_leap; - long long year = tm->tm_year; - int month = tm->tm_mon; - if (month >= 12 || month < 0) { - int adj = month / 12; - month %= 12; - if (month < 0) { - adj--; - month += 12; - } - year += adj; - } - long long t = __year_to_secs(year, &is_leap); - t += __month_to_secs(month, is_leap); - t += 86400LL * (tm->tm_mday-1); - t += 3600LL * tm->tm_hour; - t += 60LL * tm->tm_min; - t += tm->tm_sec; - return t; + int is_leap; + long long year = tm->tm_year; + int month = tm->tm_mon; + if (month >= 12 || month < 0) { + int adj = month / 12; + month %= 12; + if (month < 0) { + adj--; + month += 12; + } + year += adj; + } + long long t = __year_to_secs(year, &is_leap); + t += __month_to_secs(month, is_leap); + t += 86400LL * (tm->tm_mday-1); + t += 3600LL * tm->tm_hour; + t += 60LL * tm->tm_min; + t += tm->tm_sec; + return t; } diff --git a/rfc2045.c b/rfc2045.c index fec445d..a13608c 100644 --- a/rfc2045.c +++ b/rfc2045.c @@ -13,7 +13,7 @@ char textplain[] = "text/plain; charset=US-ASCII"; int blaze822_check_mime(struct message *msg) { - char *v = blaze822_hdr(msg, "mime-version"); + char *v = blaze822_hdr(msg, "mime-version"); if (v && v[0] && v[0] == '1' && v[1] && v[1] == '.' && @@ -35,7 +35,7 @@ blaze822_mime_body(struct message *msg, *bodyleno = 0; *bodychunko = 0; return 0; - } + } char *ct = blaze822_hdr(msg, "content-type"); char *cte = blaze822_hdr(msg, "content-transfer-encoding"); diff --git a/seq.c b/seq.c index 4fd6c28..f1fb6b1 100644 --- a/seq.c +++ b/seq.c @@ -72,19 +72,19 @@ struct msgnum { int msgnumorder(const void *a, const void *b) { - struct msgnum *ia = (struct msgnum *)a; - struct msgnum *ib = (struct msgnum *)b; + struct msgnum *ia = (struct msgnum *)a; + struct msgnum *ib = (struct msgnum *)b; - return strcmp(ia->file, ib->file); + return strcmp(ia->file, ib->file); } long blaze822_seq_find(char *file) { struct msgnum key, **result; - key.file = file; + key.file = file; - if (!(result = tfind(&key, &msgnums, msgnumorder))) + if (!(result = tfind(&key, &msgnums, msgnumorder))) return 0; return (*result)->pos; @@ -128,7 +128,7 @@ blaze822_seq_load(char *map) char * blaze822_seq_cur(void) { - static char b[PATH_MAX]; + static char b[PATH_MAX]; char *override = getenv("MAILDOT"); if (override) @@ -455,7 +455,7 @@ static long iterdir(char *dir, void (*cb)(char *)) { DIR *fd, *fd2; - struct dirent *d; + struct dirent *d; long i = 0; |