From 6c0aee6dc3056b078d427d8f53d65991aa728001 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Wed, 20 Oct 2004 12:20:32 +0000 Subject: Fix cast for %02X format string. Fix miscellaneous warnings, reformat one if...else for readibility. svn path=/trunk/; revision=3956 --- rfc2047e.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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); } -- cgit v1.2.3