mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-25 22:04:49 -05:00
Rationalise null pointer checks in both decode_codepage functions, so
that decode_codepage(NULL) and decode_codepage("") both return the default character set. [originally from svn r9961]
This commit is contained in:
parent
f9f93584c2
commit
61e555ec79
@ -265,7 +265,7 @@ const char *cp_enumerate(int index)
|
|||||||
|
|
||||||
int decode_codepage(char *cp_name)
|
int decode_codepage(char *cp_name)
|
||||||
{
|
{
|
||||||
if (!*cp_name)
|
if (!cp_name || !*cp_name)
|
||||||
return CS_UTF8;
|
return CS_UTF8;
|
||||||
return charset_from_localenc(cp_name);
|
return charset_from_localenc(cp_name);
|
||||||
}
|
}
|
||||||
|
@ -1016,10 +1016,9 @@ int decode_codepage(char *cp_name)
|
|||||||
int codepage = -1;
|
int codepage = -1;
|
||||||
CPINFO cpinfo;
|
CPINFO cpinfo;
|
||||||
|
|
||||||
if (!*cp_name)
|
if (!cp_name || !*cp_name)
|
||||||
return CP_UTF8; /* default */
|
return CP_UTF8; /* default */
|
||||||
|
|
||||||
if (cp_name && *cp_name)
|
|
||||||
for (cpi = cp_list; cpi->name; cpi++) {
|
for (cpi = cp_list; cpi->name; cpi++) {
|
||||||
s = cp_name;
|
s = cp_name;
|
||||||
d = cpi->name;
|
d = cpi->name;
|
||||||
@ -1047,7 +1046,6 @@ int decode_codepage(char *cp_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cp_name && *cp_name) {
|
|
||||||
d = cp_name;
|
d = cp_name;
|
||||||
if (tolower(d[0]) == 'c' && tolower(d[1]) == 'p')
|
if (tolower(d[0]) == 'c' && tolower(d[1]) == 'p')
|
||||||
d += 2;
|
d += 2;
|
||||||
@ -1064,7 +1062,6 @@ int decode_codepage(char *cp_name)
|
|||||||
codepage = GetOEMCP();
|
codepage = GetOEMCP();
|
||||||
if (codepage > 65535)
|
if (codepage > 65535)
|
||||||
codepage = -2;
|
codepage = -2;
|
||||||
}
|
|
||||||
|
|
||||||
break_break:;
|
break_break:;
|
||||||
if (codepage != -1) {
|
if (codepage != -1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user