diff --git a/contrib/libdiff/lib/diff_output.c b/contrib/libdiff/lib/diff_output.c --- a/contrib/libdiff/lib/diff_output.c +++ b/contrib/libdiff/lib/diff_output.c @@ -75,8 +75,8 @@ foreach_diff_atom(atom, start_atom, count) { off_t outlen = 0; int i, ch, nbuf = 0; - unsigned int len = atom->len; - unsigned char buf[DIFF_OUTPUT_BUF_SIZE + 1 /* '\n' */]; + size_t len = atom->len, wlen; + char buf[DIFF_OUTPUT_BUF_SIZE + 1 /* '\n' */]; size_t n; n = strlcpy(buf, prefix, sizeof(buf)); @@ -97,19 +97,19 @@ if (rc) return rc; if (nbuf >= DIFF_OUTPUT_BUF_SIZE) { - rc = fwrite(buf, 1, nbuf, dest); - if (rc != nbuf) + wlen = fwrite(buf, 1, nbuf, dest); + if (wlen != nbuf) return errno; - outlen += rc; + outlen += wlen; nbuf = 0; } buf[nbuf++] = ch; } buf[nbuf++] = '\n'; - rc = fwrite(buf, 1, nbuf, dest); - if (rc != nbuf) + wlen = fwrite(buf, 1, nbuf, dest); + if (wlen != nbuf) return errno; - outlen += rc; + outlen += wlen; if (outinfo) { ARRAYLIST_ADD(offp, outinfo->line_offsets); if (offp == NULL) @@ -253,7 +253,7 @@ } static bool -is_function_prototype(unsigned char ch) +is_function_prototype(char ch) { return (isalpha((unsigned char)ch) || ch == '_' || ch == '$' || ch == '-' || ch == '+'); @@ -268,7 +268,7 @@ { struct diff_atom *start_atom, *atom; const struct diff_data *data; - unsigned char buf[DIFF_FUNCTION_CONTEXT_SIZE]; + char buf[DIFF_FUNCTION_CONTEXT_SIZE]; const char *state = NULL; int rc, i, ch; @@ -285,7 +285,7 @@ rc = get_atom_byte(&ch, atom, 0); if (rc) return rc; - buf[0] = (unsigned char)ch; + buf[0] = ch; if (!is_function_prototype(buf[0])) continue; for (i = 1; i < atom->len && i < sizeof(buf) - 1; i++) { @@ -294,7 +294,7 @@ return rc; if (ch == '\n') break; - buf[i] = (unsigned char)ch; + buf[i] = ch; } buf[i] = '\0'; if (begins_with(buf, "private:")) {