Bug 56030

Summary: give getopt error codes for localisation
Product: APR Reporter: Mattias Engdegård <mattiase>
Component: APRAssignee: Apache Portable Runtime bugs mailinglist <bugs>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: HEAD   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: apr-getopt-error-code.patch

Description Mattias Engdegård 2014-01-18 14:50:39 UTC
Created attachment 31227 [details]
apr-getopt-error-code.patch

The error messages of getopt are tricky to localise properly, since they are served as fprintf-like function invocations only. Since there is only very few distinct messages, the best solution is to introduce some sort of codes that the application can do whatever it wants with.

Here is a patch that does exactly that. It is entirely source and, by virtue of a slightly sleazy hack, binary compatible. That hack can be eliminated if we get to break binary compatibility; source compatibility would still be retained. I'd suggest using the hack in 1.x and doing it cleanly (by adding a apr_getopt_t member) in 2.x.

The getopt code is ancient and it shows: nobody would have exposed a struct like that in an API design today, but it's what we have to work with.

Please review, and tell me if I should supply a commit message, CHANGES addition and so on. The patch is textually against trunk, although it contains the compatibility hack mentioned above only needed in 1.x.
Comment 1 Mattias Engdegård 2014-01-18 14:51:51 UTC
Comment on attachment 31227 [details]
apr-getopt-error-code.patch

Attachment properly marked as patch in Bugzilla.