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)
Tue, Nov 26, 10:55 PM
Unknown Object (File)
Wed, Nov 20, 3:44 AM
Unknown Object (File)
Wed, Nov 20, 1:15 AM
Unknown Object (File)
Tue, Nov 19, 7:09 AM
Unknown Object (File)
Mon, Nov 18, 9:24 PM
Unknown Object (File)
Oct 29 2024, 2:25 PM
Unknown Object (File)
Oct 4 2024, 3:21 AM
Unknown Object (File)
Oct 1 2024, 4:15 PM
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.