On Mon, Mar 26, 2007 at 02:39:34PM +0800, Rogelio Serrano wrote: > im just wondering if anybody else besides me is thinking of a gettext rewrite. > > or is catgets a better thing to do?
catgets is a much better design, and the obvious implementation is absolutely tiny (like 1k of machine code, at most). i'm planning on writing one for my libc implementation since i want to support most or all of susv3. however, all the applications i know use gettext instead, so catgets has little practical purpose except for trying to convince application authors to use it. gettext cannot be made efficient; you always need at least one strcmp per lookup to make sure you got the right hit. this is inherent in using strings as keys. it also means that the catalogue file for each language must duplicate all the english strings, which wastes a huge amount of space. this trouble _can_ be avoided if you're willing to sacrifice compatibility of message catalogues between different versions of your application. you could choose a hash function based on the set of english strings in your application, such that there are no collisions. this is always possible for a fixed set of strings and very practical if the set is reasonably small. then, you can simply use the hashes as indices into the message catalogue files as if you were using catgets instead of gettext. some precaution should be taken to ensure that the hash function for the application binary and the catalogue file match. rich _______________________________________________ busybox mailing list [email protected] http://busybox.net/cgi-bin/mailman/listinfo/busybox
