mirror of https://github.com/encounter/SDL.git
Fixed bug 2082 - SDL stdlib implementation does not force upper case for %X format specifier
norfanin When SDL_vsnprintf handles the %x format specifier, a boolean is set to signal forced lower case. It also should be able to signal forced upper case for the %X specifier. A boolean is not sufficient anymore. The attached patch adds an enum for the three cases: lower, upper and no change.
This commit is contained in:
parent
48aca0b2df
commit
cefffd618f
|
@ -1293,13 +1293,20 @@ int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* FIXME: implement more of the format specifiers */
|
/* FIXME: implement more of the format specifiers */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
SDL_CASE_NOCHANGE,
|
||||||
|
SDL_CASE_LOWER,
|
||||||
|
SDL_CASE_UPPER
|
||||||
|
} SDL_letter_case;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
SDL_bool left_justify;
|
SDL_bool left_justify;
|
||||||
SDL_bool force_sign;
|
SDL_bool force_sign;
|
||||||
SDL_bool force_type;
|
SDL_bool force_type;
|
||||||
SDL_bool pad_zeroes;
|
SDL_bool pad_zeroes;
|
||||||
SDL_bool do_lowercase;
|
SDL_letter_case force_case;
|
||||||
int width;
|
int width;
|
||||||
int radix;
|
int radix;
|
||||||
int precision;
|
int precision;
|
||||||
|
@ -1322,8 +1329,12 @@ SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *str
|
||||||
|
|
||||||
length += SDL_strlcpy(text, string, maxlen);
|
length += SDL_strlcpy(text, string, maxlen);
|
||||||
|
|
||||||
if (info && info->do_lowercase) {
|
if (info) {
|
||||||
SDL_strlwr(text);
|
if (info->force_case == SDL_CASE_LOWER) {
|
||||||
|
SDL_strlwr(text);
|
||||||
|
} else if (info->force_case == SDL_CASE_UPPER) {
|
||||||
|
SDL_strupr(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
@ -1573,9 +1584,12 @@ SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
case 'x':
|
case 'x':
|
||||||
info.do_lowercase = SDL_TRUE;
|
info.force_case = SDL_CASE_LOWER;
|
||||||
/* Fall through to 'X' handling */
|
/* Fall through to 'X' handling */
|
||||||
case 'X':
|
case 'X':
|
||||||
|
if (info.force_case == SDL_CASE_NOCHANGE) {
|
||||||
|
info.force_case = SDL_CASE_UPPER;
|
||||||
|
}
|
||||||
if (info.radix == 10) {
|
if (info.radix == 10) {
|
||||||
info.radix = 16;
|
info.radix = 16;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue