[Kernel] Fix wide-printf functions not processing %ws format correctly
This would break strings like memory://%.*ws, because the %ws would set FF_IsWide, but FF_IsWide is actually treated as an "is opposite encoding" flag. Since the function is already wide, that flag would make it think it's opposite encoding and it'd try reading the param as ASCII instead of Unicode...
This commit is contained in:
parent
086c28e55d
commit
811825afab
|
@ -49,6 +49,9 @@ enum FormatFlags {
|
|||
FF_IsWide = 1 << 9,
|
||||
FF_IsSigned = 1 << 10,
|
||||
FF_ForceLeadingZero = 1 << 11,
|
||||
// IsWide gets used as an "is opposite encoding" flag, but this flag means
|
||||
// it's definitely wide
|
||||
FF_IsAlwaysWide = 1 << 12,
|
||||
};
|
||||
|
||||
enum ArgumentSize {
|
||||
|
@ -292,7 +295,7 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
|||
state = FS_Type;
|
||||
continue;
|
||||
} else if (c == 'w') {
|
||||
flags |= FF_IsWide;
|
||||
flags |= (FF_IsWide | FF_IsAlwaysWide);
|
||||
state = FS_Type;
|
||||
continue;
|
||||
} else if (c == 'I') {
|
||||
|
@ -337,7 +340,7 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
|||
// functions and with C in wprintf functions."
|
||||
is_wide = false;
|
||||
} else {
|
||||
is_wide = ((flags & FF_IsWide) != 0) ^ wide;
|
||||
is_wide = (((flags & FF_IsWide) != 0) ^ wide) || (flags & FF_IsAlwaysWide) != 0;
|
||||
}
|
||||
|
||||
auto value = args.get32();
|
||||
|
@ -552,7 +555,7 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
|||
// functions and with S in wprintf functions."
|
||||
is_wide = false;
|
||||
} else {
|
||||
is_wide = ((flags & (FF_IsWide)) != 0) ^ wide;
|
||||
is_wide = (((flags & (FF_IsWide)) != 0) ^ wide) || (flags & FF_IsAlwaysWide) != 0;
|
||||
}
|
||||
int32_t length;
|
||||
|
||||
|
|
Loading…
Reference in New Issue