Skip to content

Commit

Permalink
Issue #126: even more warnings fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-richard committed Mar 24, 2016
1 parent b03c398 commit 14011ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 5 additions & 4 deletions contrib/punycode/punycode.c
Expand Up @@ -39,7 +39,7 @@ static punycode_uint decode_digit(punycode_uint cp)

static char encode_digit(punycode_uint d, int flag)
{
return d + 22 + 75 * (d < 26) - ((flag != 0) << 5);
return char(d + 22 + 75 * (d < 26) - ((flag != 0) << 5));
/* 0..25 map to ASCII a..z or A..Z */
/* 26..35 map to ASCII 0..9 */
}
Expand All @@ -59,7 +59,7 @@ static char encode_digit(punycode_uint d, int flag)
static char encode_basic(punycode_uint bcp, int flag)
{
bcp -= (bcp - 97 < 26) << 5;
return bcp + ((!flag && (bcp - 65 < 26)) << 5);
return char(bcp + ((!flag && (bcp - 65 < 26)) << 5));
}

/*** Platform-specific constants ***/
Expand Down Expand Up @@ -109,8 +109,9 @@ enum punycode_status punycode_encode(
for (j = 0; j < input_length; ++j) {
if (basic(input[j])) {
if (max_out - out < 2) return punycode_big_output;
output[out++] =
case_flags ? encode_basic(input[j], case_flags[j]) : input[j];
output[out++] = char(
case_flags ? encode_basic(input[j], case_flags[j]) : input[j]
);
}
/* else if (input[j] < n) return punycode_bad_input; */
/* (not needed for Punycode with unsigned code points) */
Expand Down
12 changes: 8 additions & 4 deletions src/vmime/charsetConverter_idna.cpp
Expand Up @@ -115,11 +115,13 @@ void charsetConverter_idna::convert(const string& in, string& out, status* st)
if (st)
st->inputBytesRead = in.length();

punycode_uint inputLen = static_cast <punycode_uint>(unichars.size());

std::vector <char> output(inUTF8.length() * 2);
punycode_uint outputLen = output.size();
punycode_uint outputLen = static_cast <punycode_uint>(output.size());

const punycode_status status = punycode_encode
(unichars.size(), &unichars[0], /* case_flags */ NULL, &outputLen, &output[0]);
(inputLen, &unichars[0], /* case_flags */ NULL, &outputLen, &output[0]);

if (status == punycode_success)
{
Expand Down Expand Up @@ -148,11 +150,13 @@ void charsetConverter_idna::convert(const string& in, string& out, status* st)
return;
}

punycode_uint inputLen = static_cast <punycode_uint>(in.length() - 4);

std::vector <punycode_uint> output(in.length() - 4);
punycode_uint outputLen = output.size();
punycode_uint outputLen = static_cast <punycode_uint>(output.size());

const punycode_status status = punycode_decode
(in.length() - 4, &in[4], &outputLen, &output[0], /* case_flags */ NULL);
(inputLen, &in[4], &outputLen, &output[0], /* case_flags */ NULL);

if (st)
st->inputBytesRead = in.length();
Expand Down

0 comments on commit 14011ca

Please sign in to comment.