Bill Pringlemeir wrote: > Everything looks ok when it is explained. Maybe if anyone revisits > the file they could consider, > > void prop_load_from_file( > prop_set_t *ps, const gchar *dir, const gchar *filename) > ... > char * saved_local = setlocale(LC_CTYPE, NULL); > setlocale(LC_CTYPE,"C"); > > /* Parse the file.... */ > ... > > setlocale(LC_CTYPE, saved_local); > > /* Set the property */
I've thought about this option but dislike instinctively. I don't know whether it's good practice to switch forth and back between different locales. I don't want to break the code for any platform (even if it were a platform bug) that might have a problem with this. E.g., IIRC, Solaris had a problem with switching (back) to the C locale. At least, strftime() did still localize the date. Also, currently setlocale() is never used if ENABLE_NLS is undefined. > I have no experience with "setlocale()"; maybe it takes a long time to > execute? No idea, but this shouldn't be a problem because it happens at startup only once for config_gnet and another time for config_gui. > Pre-scanning the string for 7-bit only before parsing might also look > a little cleaner. But this would be slower. Not necessarily but speed shouldn't be of any concern here. > Maybe a macro incorporating "isascii()" would help. It looks like > "isascii()" was just used with all "isXXXX()" functions to prevent any > sort of locale mischief; but it is a little confusing if you didn't > write it. Although I think the "isXXXX()" are a step forward. I've added such macros, made the function a little more readable and added a couple of comments. There are similar macros in GLib 2.x but since GTKG must compile against GLib 1.2 I didn't use them and there is no g_ascii_blank() macro anyway. I've also added a formal descpription of the format. The function isn't very strict in that it ignores invalid lines and trailing data... Christian
pgpYZGgy2a3qY.pgp
Description: PGP signature
