bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for gettext (improved read-po/write-po error handling)


From: Ross Golder
Subject: Patch for gettext (improved read-po/write-po error handling)
Date: Thu, 12 Aug 2004 14:36:57 +0100

Hi Bruno,

I've been hacking on gettext a little bit recently, trying to make it's
parsing (read-po.[ch]) and writing (write-po.[ch]) functions a little
more accessible to other applications.

You see, I am the maintainer of gtranslator, a PO-file editting program
for GNOME. The guy that wrote gtranslator implemented his own
parsing/writing functions, but the implementation isn't all that great
(tbh). To avoid having to re-implement it (poorly) again, I figured it
might be worth re-using the code already available in gettext.

So, you'll have to forgive me for being a bit rusty with my C code, and
a bit of a newbie to gettext, but I've carved out the attached patch
(against gettext CVS). I'd appreciate your opinions on the patch, and
perhaps ideas on how it could be done better.

Basically, at present, it adds a 'report_error' callback, and provides a
default implementation which uses error(_at_line) calls, so that it
behaves largely as it did before. It also effectively moves all the
calls to 'error(_at_line)' out of the parser, back up the stack to the
calling program, and changes the signature of 'po_scan' to return the
number of error, so that the calling program doesn't bomb out if the
parser encounters errors, and can bomb out if it wishes on returning
from the parser.

One drawback (regression) is that it now doesn't bomb out on receiving a
maximum number of errors. I haven't figured out how/where best to do
that yet (get the parser to return prematurely when a counter reaches a
limit), but I assume it shouldn't be too difficult.

Also, in order for third-party applications to make use of these
functions, they need access to some of the headers, such as 'read-po.h',
'write-po.h', and 'message.h'. Again, I don't know if it's the right way
to do this, but I've got another patch here that modifies Makefile.am to
distribute the necessary headers into $prefix/include/gettext-0.0, which
I've hacked my local copy of gtranslator to use to compile.

And finally, when I get that far, I will also need to look into the
'write-po.[ch]' stuff and move any exit calls back up the stack to be
the responsibility of the calling program. I'll send a patch for that,
when I get there :)

Please let me know what you think. 

Cheers,

--
Ross





reply via email to

[Prev in Thread] Current Thread [Next in Thread]