From: Matthias Andree Date: Wed, 20 Oct 2004 12:20:32 +0000 (-0000) Subject: Fix cast for %02X format string. X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=6c0aee6dc3056b078d427d8f53d65991aa728001;p=~andy%2Ffetchmail Fix cast for %02X format string. Fix miscellaneous warnings, reformat one if...else for readibility. svn path=/trunk/; revision=3956 --- diff --git a/rfc2047e.c b/rfc2047e.c index 44f1ad0c..922fe7a9 100644 --- a/rfc2047e.c +++ b/rfc2047e.c @@ -67,7 +67,7 @@ static char *encode_words(char *const *words, int nwords, const char *charset) } if (*u == ' ') { *t++ = '_'; continue; } if (strchr(encchars, *u)) { *t++ = *u; continue; } - sprintf(t, "=%02X", (unsigned char)*u); + sprintf(t, "=%02X", (unsigned int)((unsigned char)*u)); t += 3; } } @@ -112,14 +112,14 @@ char *rfc2047e(const char *string, const char *charset) { l = strcspn(r, ws); words[idx] = xmalloc(l+1); memcpy(words[idx], r, l); - words[idx][l] = 0; + words[idx][l] = '\0'; idx++; r += l; if (!*r) break; l = strspn(r, ws); words[idx] = xmalloc(l+1); memcpy(words[idx], r, l); - words[idx][l] = 0; + words[idx][l] = '\0'; idx++; r += l; } @@ -145,11 +145,12 @@ char *rfc2047e(const char *string, const char *charset) { free(words[idx]); words[idx] = tmp; for (i = idx + 1; i <= end; i++) - words[i][0] = 0; + words[i][0] = '\0'; idx = end + 2; } - for (idx = l = 0; idx < count; idx++) { + l = 0; + for (idx = 0; idx < count; idx++) { l += strlen(words[idx]); } @@ -179,7 +180,10 @@ char *rfc2047e(const char *string, const char *charset) { t = stpcpy(t, words[i+1]); } tmp = strrchr(out, '\n'); - if (!tmp) tmp = out; else tmp++; + if (tmp == NULL) + tmp = out; + else + tmp++; l = strlen(tmp); }