Compare commits

...

1 Commits

Author SHA1 Message Date
coah
bcac9db8a2 MSL: locale data, file_io 4/4 (worker f5f4a391) 2026-09-30 06:16:59 +00:00
5 changed files with 331 additions and 3 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 91.56% | 80.70% | 56.95% | 88.70% |
| 91.59% | 80.73% | 56.95% | 88.75% |
units 758/1027 complete, functions 11604/12563 matched.
units 758/1027 complete, functions 11608/12563 matched.
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
<!-- progress:end -->

View File

@@ -41,3 +41,48 @@ scanf: all four functions have zero ctxdiff differences, code 5484/5484 and data
strtold: __strtold has 1277/1277 instructions and strtod 44/44, both zero differences. Removed the imported inline qualifier from the public strtod wrapper so the real target symbol is emitted. Code 5284/5284 and data 112/112.
Exception metadata settings change only owned NonMatching units; configure.py status flags remain NonMatching. Clean gates require the original DOL SHA1 and zero baseline regressions. Raw instruction-exact counts can be lower than objdiff exact counts because the varargs conditional branch to an external register-save helper is compared without relocation normalization by gate.py. These counts are reported separately; they were not patched or hidden.
printf::double2hex: aggregate exponent format initialized at declaration: 238/242 instructions, 227 positional diffs; restored.
printf::double2hex: initialize exponent integer fields before byte flags: 241/242 instructions, 127 positional diffs; restored.
printf::double2hex: use integer nibble temporary with explicit final narrowing: 239/242 instructions, 123 positional diffs; restored.
printf::__pformatter: move parsed format declaration after output buffer: 511/535 instructions, 367 positional diffs; restored.
printf::__pformatter: initialize parsed format before first parse: 516/535 instructions, 505 positional diffs; restored.
printf::__pformatter: separate next-format pointer from parsed cursor: 511/535 instructions, 367 positional diffs; restored.
wprintf::double2hex: aggregate exponent format initialized at declaration: 238/242 instructions, 227 positional diffs; restored.
wprintf::double2hex: initialize exponent integer fields before byte flags: 241/242 instructions, 127 positional diffs; restored.
wprintf::double2hex: use integer nibble temporary with explicit final narrowing: 239/242 instructions, 123 positional diffs; restored.
wprintf::__wpformatter: move parsed format declaration after output buffer: 567/593 instructions, 519 positional diffs; restored.
wprintf::__wpformatter: initialize parsed format before first parse: 572/593 instructions, 562 positional diffs; restored.
wprintf::__wpformatter: separate next-format pointer from parsed cursor: 567/593 instructions, 519 positional diffs; restored.
printf::printf: finish varargs lifetime with va_end: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::printf: return through named result temporary: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::printf: move va_start to first actual formatting use: 50/50 instructions, 1 positional diffs; restored.
printf::fprintf: finish varargs lifetime with va_end: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::fprintf: return through named result temporary: compile rejected: ninja: build stopped: subcommand failed.; restored.
printf::fprintf: move va_start to first actual formatting use: 49/49 instructions, 1 positional diffs; restored.
printf::printf: finish varargs lifetime / initialize controller first: 50/50 instructions, 1 positional diffs; restored.
printf::printf: hoist argument list / named result: 50/50 instructions, 1 positional diffs; restored.
printf::printf: argument-list pointer / delay va_start: 50/50 instructions, 1 positional diffs; restored.
printf::fprintf: finish varargs lifetime / initialize controller first: 49/49 instructions, 1 positional diffs; restored.
printf::fprintf: hoist argument list / named result: 49/49 instructions, 1 positional diffs; restored.
printf::fprintf: argument-list pointer / delay va_start: 49/49 instructions, 1 positional diffs; restored.
printf::snprintf: finish varargs lifetime / initialize controller first: 54/54 instructions, 1 positional diffs; restored.
printf::snprintf: hoist argument list / named result: 54/54 instructions, 1 positional diffs; restored.
printf::snprintf: argument-list pointer / delay va_start: 54/54 instructions, 1 positional diffs; restored.
printf::sprintf: finish varargs lifetime / initialize controller first: 52/52 instructions, 1 positional diffs; restored.
printf::sprintf: hoist argument list / named result: 52/52 instructions, 1 positional diffs; restored.
printf::sprintf: argument-list pointer / delay va_start: 52/52 instructions, 1 positional diffs; restored.
wprintf::swprintf: finish varargs lifetime / initialize controller first: 55/55 instructions, 1 positional diffs; restored.
wprintf::swprintf: hoist argument list / named result: 55/55 instructions, 1 positional diffs; restored.
wprintf::swprintf: argument-list pointer / delay va_start: 55/55 instructions, 11 positional diffs; restored.
time::emit: finish varargs lifetime / initialize controller first: 43/43 instructions, 1 positional diffs; restored.
time::emit: hoist argument list / named result: 43/43 instructions, 1 positional diffs; restored.
time::emit: argument-list pointer / delay va_start: 42/43 instructions, 34 positional diffs; restored.
printf data: 139/148 relocation entries agree by target function and addend; dispatch-table entries in the unmatched formatter still differ. Generated jump-table data is retained, without manual entries or symbol mappings.
wprintf data: 139/148 relocation entries agree by target function and addend; dispatch-table entries in the unmatched formatter still differ. Generated jump-table data is retained, without manual entries or symbol mappings.
printf double2hex: moved exponent-format initialization after exponent extraction: 241/242 instructions; FP aggregate copies remained; restored.
wprintf double2hex: moved exponent-format initialization after exponent extraction: 241/242 instructions; FP aggregate copies remained; restored.
printf data: changed zero comparison literal to long double, matching the argument type and sharing its zero constant with float2str. .sdata2 now 8 bytes, 100%, versus 16 emitted bytes previously. Instruction scores unchanged.
time data: literal pool, calendar tables and BSS already agree. Target has nine exception-index records; source includes exception records for real public asctime/ctime functions absent in the extracted target. Retained the functions rather than suppressing output.
locale: restored the C locale components, collation table and ordinary literals in source order; all 792 data bytes exact. No target code functions exist.
file_io: implemented fclose, fflush, __msl_strnicmp and __msl_itoa in object order using FILE fields and named arithmetic temporaries; all four have zero ctxdiff differences, 928 code bytes and 60 metadata bytes exact.

View File

@@ -0,0 +1,160 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
enum file_kinds { file_closed, file_disk, file_console, file_unavailable };
enum io_states { neutral, writing, reading, rereading };
enum io_modes { io_read = 1, io_write = 2, io_append = 4 };
extern int __flush_all(void);
extern int __flush_buffer(FILE*, size_t*);
#pragma exceptions on
int fclose(FILE* file)
{
int flush_result, close_result;
if (file == NULL)
return -1;
if (file->mode.file_kind == file_closed)
return 0;
flush_result = fflush(file);
close_result = (*file->close_proc)(file->handle);
file->mode.file_kind = file_closed;
file->handle = 0;
if (file->state.free_buffer)
free((FILE*)file->buffer);
return (flush_result || close_result) ? -1 : 0;
}
int fflush(FILE* file)
{
int pos;
if (file == NULL)
{
return __flush_all();
}
if (file->state.error != 0 || file->mode.file_kind == file_closed)
{
return -1;
}
if (file->mode.io_mode == io_read)
{
return 0;
}
if (file->state.io_state >= rereading)
{
file->state.io_state = reading;
}
if (file->state.io_state == reading)
{
file->buffer_len = 0;
}
if (file->state.io_state != writing)
{
file->state.io_state = neutral;
return 0;
}
if (file->mode.file_kind != file_disk)
{
pos = 0;
}
else
{
pos = ftell(file);
}
if (__flush_buffer(file, NULL) != 0)
{
file->state.error = 1;
file->buffer_len = 0;
return -1;
}
file->state.io_state = neutral;
file->pos = pos;
file->buffer_len = 0;
return 0;
}
int __msl_strnicmp(const char* str1, const char* str2, int n)
{
int i;
char c1, c2;
for (i = 0; i < n; i++)
{
c1 = tolower(*str1++);
c2 = tolower(*str2++);
if (c1 < c2)
return -1;
if (c1 > c2)
return 1;
if (c1 == '\0')
return 0;
}
return 0;
}
char* __msl_itoa(int value, char* str, unsigned int base)
{
int negative;
int length;
char c;
int start;
int end;
negative = 0;
length = 0;
if (value < 0)
{
value = -value;
negative = 1;
}
do
{
int digit = value % base;
if (digit > 9)
str[length++] = digit + 0x37;
else
str[length++] = digit + 0x30;
value /= base;
} while (value != 0);
if (negative != 0)
str[length++] = '-';
str[length++] = '\0';
start = 0;
end = strlen(str) - 1;
while (start < end)
{
c = str[start];
str[start++] = str[end];
str[end--] = c;
}
return str;
}

View File

@@ -0,0 +1,123 @@
#include <internal/locale.h>
#include <limits.h>
#include <stddef.h>
extern int __mbtowc_noconv(wchar_t*, const char*, size_t);
extern int __wctomb_noconv(char*, wchar_t);
struct lconv __lconv = {
".",
"",
"",
"",
"",
"",
"",
"",
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
};
extern const unsigned short __ctype_mapC[256];
extern const unsigned char __upper_mapC[256];
extern const unsigned char __lower_mapC[256];
extern const unsigned short __wctype_mapC[256];
extern const wchar_t __wupper_mapC[256];
extern const wchar_t __wlower_mapC[256];
struct _loc_ctype_cmpt _loc_ctyp_C = {
"C",
__ctype_mapC,
__upper_mapC,
__lower_mapC,
__wctype_mapC,
__wupper_mapC,
__wlower_mapC,
__mbtowc_noconv,
__wctomb_noconv
};
unsigned short char_coll_tableC[96] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 17, 18, 19, 20, 21, 22, 23, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71,
73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 24, 25, 26, 27, 28, 0, 44, 46, 48, 50, 52, 54, 56,
58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 29, 30, 31, 32, 0,
};
struct _loc_coll_cmpt _loc_coll_C = {
"C",
' ',
110,
0,
char_coll_tableC,
NULL
};
struct _loc_mon_cmpt _loc_mon_C = {
"C",
"",
"",
"",
"",
"",
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
"",
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX,
CHAR_MAX
};
struct _loc_num_cmpt _loc_num_C = {
"C",
".",
"",
""
};
struct _loc_time_cmpt _loc_tim_C = {
"C",
"AM|PM",
"%a %b %e %T %Y",
"%I:%M:%S %p",
"%m/%d/%y",
"%T",
"Sun|Sunday|Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday",
"Jan|January|Feb|February|Mar|March|Apr|April|May|May|Jun|June|Jul|July|Aug|August|Sep|September|Oct|October|Nov|"
"November|Dec|December",
""
};
struct __locale _current_locale = {
NULL,
"C",
&_loc_coll_C,
&_loc_ctyp_C,
&_loc_mon_C,
&_loc_num_C,
&_loc_tim_C
};

View File

@@ -545,7 +545,7 @@ static char* double2hex(long double num, char* buff, print_format format) {
form.digits = 0x20;
__num2dec(&form, num, &dec);
if (fabs(num) == 0.0) {
if (fabs(num) == 0.0L) {
p = buff - 6;
strcpy(p, "0x0p0");
return p;