X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..a90d420cbe87490c844ae422c966e746d3134b07:/progs/cc-hash.c diff --git a/progs/cc-hash.c b/progs/cc-hash.c index 64fea0ec..6d65f5bd 100644 --- a/progs/cc-hash.c +++ b/progs/cc-hash.c @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -67,9 +68,7 @@ static void puthex(const octet *buf, size_t sz, FILE *fp) static size_t gethex(const char *p, octet *q, size_t sz, char **pp) { size_t i = 0; - while (sz > 0 && - isxdigit((unsigned char)p[0]) && - isxdigit((unsigned char)p[1])) { + while (sz > 0 && ISXDIGIT(p[0]) && ISXDIGIT(p[1])) { char buf[3]; buf[0] = p[0]; buf[1] = p[1]; @@ -164,7 +163,7 @@ const encodeops *getencoding(const char *ename) const encodeops *e; for (e = encodingtab; e->name; e++) { - if (strcmp(ename, e->name) == 0) + if (STRCMP(ename, ==, e->name)) return (e); } return (0); @@ -198,7 +197,7 @@ const gchash *gethash(const char *name) const gchash *const *g, *gg = 0; size_t sz = strlen(name); for (g = ghashtab; *g; g++) { - if (strncmp(name, (*g)->name, sz) == 0) { + if (STRNCMP(name, ==, (*g)->name, sz)) { if ((*g)->name[sz] == 0) { gg = *g; break; @@ -292,7 +291,7 @@ int fhash(fhashstate *fh, const char *file, void *buf) size_t n; fprogress ff; - if (!file || strcmp(file, "-") == 0) + if (!file || STRCMP(file, ==, "-")) fp = stdin; else if ((fp = fopen(file, fh->f & FHF_BINARY ? "rb" : "r")) == 0) return (-1); @@ -303,7 +302,7 @@ int fhash(fhashstate *fh, const char *file, void *buf) if (fh->f & FHF_JUNK) { p = file; - if (strncmp(p, "./", 2) == 0) p += 2; + if (STRNCMP(p, ==, "./", 2)) p += 2; q = p; ffhe = &fh->ents; for (;;) { @@ -311,7 +310,7 @@ int fhash(fhashstate *fh, const char *file, void *buf) n = q - p; for (; *ffhe; ffhe = &(*ffhe)->next) { fhe = *ffhe; - if (strncmp(p, fhe->name, n) == 0 && fhe->name[n] == 0) + if (STRNCMP(p, ==, fhe->name, n) && fhe->name[n] == 0) goto found; } fhe = xmalloc(offsetof(struct fhent, name) + n + 1); @@ -383,10 +382,10 @@ static int fhjunk(struct fhjunk *fhj, struct fhent *ents) n++; } while (errno = 0, (d = readdir(dp)) != 0) { - if (strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) + if (STRCMP(d->d_name, ==, ".") || STRCMP(d->d_name, ==, "..")) continue; for (fhe = ents; fhe; fhe = fhe->next) { - if (strcmp(d->d_name, fhe->name) == 0) goto found; + if (STRCMP(d->d_name, ==, fhe->name)) goto found; } fhj->d->len = n; dstr_puts(fhj->d, d->d_name); @@ -464,17 +463,17 @@ int hfparse(hfpctx *hfp) if (*p == '#') { p++; if ((q = str_getword(&p)) == 0) return (HF_BAD); - if (strcmp(q, "hash") == 0) { + if (STRCMP(q, ==, "hash")) { if ((q = str_getword(&p)) == 0) return (HF_BAD); if ((gch = gethash(q)) == 0) return (HF_BAD); hfp->gch = gch; return (HF_HASH); - } else if (strcmp(q, "encoding") == 0) { + } else if (STRCMP(q, ==, "encoding")) { if ((q = str_getword(&p)) == 0) return (HF_BAD); if ((ee = getencoding(q)) == 0) return (HF_BAD); hfp->ee = ee; return (HF_ENC); - } else if (strcmp(q, "escape") == 0) { + } else if (STRCMP(q, ==, "escape")) { hfp->f |= HFF_ESCAPE; return (HF_ESC); } @@ -556,7 +555,7 @@ int getstring(void *in, dstr *d, unsigned f) again: ch = nextch(in); - while (isspace(ch)) + while (ISSPACE(ch)) ch = nextch(in); if (ch == '#') { do ch = nextch(in); while (ch != '\n' && ch != eofch); @@ -605,7 +604,7 @@ again: if (ch == q) break; - if (!q && isspace(ch)) + if (!q && ISSPACE(ch)) break; /* --- Otherwise contribute and continue --- */ @@ -649,7 +648,7 @@ void putstring(FILE *fp, const char *p, unsigned f) qq = 0; for (q = p; *q; q++) { - if (isspace((unsigned char)*q)) { + if (ISSPACE(*q)) { qq = '\"'; break; }