[PATCH 2/2] Add a script to check whether week, first_weekday, first_workday in glibc agrees with CLDR.
Mike FABIAN
mfabian@redhat.com
Sat Nov 21 14:26:24 GMT 2026
Carlos O'Donell <carlos@redhat.com> さんはかきました:
> On 9/23/26 5:38 AM, Mike FABIAN wrote:
>> See: https://github.com/unicode-org/cldr/blob/main/common/supplemental/supplementalData.xml
>> Run of check script:
>> $ ./cldr_week_data_check.py
>> ../../../cldr/common/supplemental/supplementalData.xml
>> '../locales/*_[A-Z][A-Z]'
>
> Note this excludes '@' modifiers?
I improved this in v2 to include '@' modifiers.
>> + text = path.read_text(encoding='utf-8')
>
> OK. Abort if non-UTF-8. We promise UTF-8 today in all locale files.
Yes, it will fail if it tries to load invalid UTF-8 but that should not
happen.
>> + lc_time = extract_lc_time(text)
>> + if lc_time is None:
>> + print(f'WARNING: {path.name}: no LC_TIME section')
>> + return
>
> If you exit without checking CLDR, this should be printed as a script error.
>
> Suggest:
> f'ERROR: ...'
Fixed.
> Suggest:
> Function should return non-zero exit code and propagate up.
I count the number of locales with problems not and print the number of
checked locales and the number of locales with problems at the end.
>> + if copy_locale is not None:
>> + copy_territory = copy_locale[-2:]
>
> Assumes locale with territory?
I made this work for locales without territory like eo, tok, syr, ... as
well now.
>> + if expected_min_days != expected_value(min_days, copy_territory):
>> + print(f'WARNING {path.name}: LC_TIME copied from {copy_locale} but expected CLDR minDays differs.')
>> + if expected_first_weekday != expected_value(first_day, copy_territory):
>> + print(f'WARNING {path.name}: LC_TIME copied from {copy_locale} but expected CLDR firstDay differs.')
>> + if expected_workday != expected_first_workday(weekend_end, copy_territory):
>> + print(f'WARNING {path.name}: LC_TIME copied from {copy_locale} but expected CLDR weekendEnd differs.')
>
> Add ":" to each WARNING for consistent grepping.
Done.
>> + return
>> + # Check that all three values exist.
>> + missing = []
>> + if locale_min_days is None:
>> + missing.append('week')
>> + if locale_first_weekday is None:
>> + missing.append('first_weekday')
>> + if locale_first_workday is None:
>> + missing.append('first_workday')
>> + if missing:
>> + print(f'WARNING: {path.name}: missing ' + ', '.join(missing))
>> + return
>
> OK. We return before the CLDR comparison check, but we do that because the script doesn't
> assume any default as present in ld-time.c. Which is fine because it keeps the script from
> having to track the defaults.
>
> Suggest:
> f'ERROR: {path.name}: missing (default used)'
Fixed in v2.
>> + ('first_day', first_day),
>> + ('weekend_start', weekend_start),
>> + ('weekend_end', weekend_end),
>> + ):
>> + if '001' not in values:
>> + raise ValueError(f'{name} has no CLDR 001 default')
>
> Add comment that glibc doesn't use weekend_start, but that we parse
> the CLDR data just to make sure it's well formed.
Comment added.
>> + for filename in sorted(glob.glob(locale_pattern)):
>> + check_locale(
>> + filename,
>> + min_days=min_days,
>> + first_day=first_day,
>> + weekend_end=weekend_end,
>> + )
>> +
>
> We should be able to put this into a check and use 0 for success, non-zero for failure.
Done, number check_locale() returns 0 for success now, 1 for failure,
the number of failed locales is counted now.
--
Mike FABIAN <mfabian@redhat.com>
He/Him/His
睡眠不足はいい仕事の敵だ。
More information about the Libc-alpha
mailing list