Page MenuHomeFreeBSD

sort: Fix message catalogue usage
ClosedPublic

Authored by markj on Jan 28 2022, 4:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 20 2024, 11:15 AM
Unknown Object (File)
Feb 15 2024, 5:47 AM
Unknown Object (File)
Feb 1 2024, 7:07 AM
Unknown Object (File)
Jan 17 2024, 8:35 PM
Unknown Object (File)
Dec 20 2023, 4:14 AM
Unknown Object (File)
Oct 17 2023, 3:24 PM
Unknown Object (File)
Oct 16 2023, 4:50 AM
Unknown Object (File)
Oct 13 2023, 8:01 AM
Subscribers

Details

Summary
  • Check that catopen() succeeded before calling catclose(). musl will crash in the latter if the catalogue descriptor is -1.
  • Keep the message catalogue open for most of sort(1)'s actual operation.
  • Don't use catgets(3) to print error messages if catopen(3) had failed.

I'm not sure how useful NLS support is, given that error messages are
available only in English and Hungarian, and support for the latter was
seemingly mostly broken. I suppose it serves as a useful example.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Jan 28 2022, 4:22 PM

Code changes look reasonable to me, but I've never used the NLS APIs. Since there is already an ifdef, maybe it makes sense to disable it for BOOTSTRAPPING? Will the bootstrap tools be able to load the catalog?

This revision is now accepted and ready to land.Jan 28 2022, 4:38 PM

Change looks good even if we decide to set WITHOUT_NLS for bootstrapping

Code changes look reasonable to me, but I've never used the NLS APIs. Since there is already an ifdef, maybe it makes sense to disable it for BOOTSTRAPPING? Will the bootstrap tools be able to load the catalog?

It may be possible in principle for bootstrap tools to find the catalogue, but it definitely doesn't work today. So it probably makes sense to disable NLS when bootstrapping, but OTOH this change is sufficient and fixes problems on FreeBSD. For instance, before the change we have:

$ LC_MESSAGES=hu_HU.ISO8859-2 sort -M -n
sort: n:M: mutually exclusive flags

and after:

$ LC_MESSAGES=hu_HU.ISO8859-2 sort -M -n
sort: n:M: egymst kizr opcik

which seems correct-ish according to Google. :)

This revision was automatically updated to reflect the committed changes.