After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 725591 - Address format should not be translated
Address format should not be translated
Status: RESOLVED FIXED
Product: geocode-glib
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: geocode-glib maintainer(s)
geocode-glib maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-03-03 16:00 UTC by Marcus Lundblad
Modified: 2015-01-15 13:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Determine addressformat automatically (2.67 KB, patch)
2014-03-09 18:30 UTC, Marcus Lundblad
none Details | Review
Detect nl_langinfo support (676 bytes, patch)
2014-03-10 11:37 UTC, Marcus Lundblad
accepted-commit_now Details | Review
Use nl_langinfo to format address (2.47 KB, patch)
2014-03-10 11:38 UTC, Marcus Lundblad
needs-work Details | Review
Remove from POTFILES.in (450 bytes, patch)
2014-03-10 11:38 UTC, Marcus Lundblad
committed Details | Review
reverse: clean up patch for locale-dependent address format (2.44 KB, patch)
2014-03-10 20:42 UTC, Marcus Lundblad
rejected Details | Review
Determine address format using nl_langinfo. (2.51 KB, patch)
2014-03-10 21:20 UTC, Marcus Lundblad
none Details | Review
Remove file no longer using translated strings. (494 bytes, patch)
2014-03-10 21:20 UTC, Marcus Lundblad
none Details | Review
reverse: clean up patch for locale-dependent address format (2.44 KB, patch)
2014-03-10 21:20 UTC, Marcus Lundblad
none Details | Review
Add detection of nl_langinfo support. (3.27 KB, patch)
2014-03-10 21:26 UTC, Marcus Lundblad
needs-work Details | Review
reverse: derive address format from locale. (2.44 KB, patch)
2014-03-10 21:56 UTC, Marcus Lundblad
committed Details | Review
reverse: only use _NL_ADDRESS_POSTAL_FMT on glibc (1.01 KB, patch)
2014-03-12 15:36 UTC, Marcus Lundblad
rejected Details | Review
Revert "reverse: Derive address format from locale" (2.25 KB, patch)
2014-03-12 22:22 UTC, Allison Karlitskaya (desrt)
committed Details | Review
Revert "l10n: Update POTFILES.in" (556 bytes, patch)
2014-03-17 20:20 UTC, Jonas Danielsson
committed Details | Review
reverse: Derive street address format from locale (4.06 KB, patch)
2015-01-06 13:31 UTC, Jonas Danielsson
none Details | Review
Derive street address format from locale (4.09 KB, patch)
2015-01-06 13:36 UTC, Jonas Danielsson
none Details | Review
Derive street address format from locale (4.30 KB, patch)
2015-01-06 13:49 UTC, Jonas Danielsson
needs-work Details | Review
Derive street address format from locale (4.70 KB, patch)
2015-01-06 21:18 UTC, Jonas Danielsson
none Details | Review
Derive street address format from locale (4.70 KB, patch)
2015-01-06 21:20 UTC, Jonas Danielsson
accepted-commit_now Details | Review
Derive street address format from locale (4.75 KB, patch)
2015-01-07 06:49 UTC, Jonas Danielsson
none Details | Review
Derive street address format from locale (4.73 KB, patch)
2015-01-07 07:27 UTC, Jonas Danielsson
needs-work Details | Review
Derive street address format from locale (4.72 KB, patch)
2015-01-07 19:18 UTC, Jonas Danielsson
committed Details | Review
test-gcglib: Add test of address format (2.16 KB, patch)
2015-01-08 06:52 UTC, Jonas Danielsson
committed Details | Review
test: Fix compilation on non-glibc platforms (1.33 KB, patch)
2015-01-15 12:34 UTC, Bastien Nocera
rejected Details | Review

Description Marcus Lundblad 2014-03-03 16:00:09 UTC
Related to the following bug against "Damned lies":
https://bugzilla.gnome.org/show_bug.cgi?id=725578

There is one string marked as translateable in geocode-glib/geocode-reverse.c

Address formats are country-specific rather than language-dependent.
Maybe it would be possible to derive this returned address string from the LC_ADDRESS locale component?
Comment 1 Zeeshan Ali 2014-03-03 19:14:11 UTC
(In reply to comment #0)
> Related to the following bug against "Damned lies":
> https://bugzilla.gnome.org/show_bug.cgi?id=725578
> 
> There is one string marked as translateable in geocode-glib/geocode-reverse.c
> 
> Address formats are country-specific rather than language-dependent.
> Maybe it would be possible to derive this returned address string from the
> LC_ADDRESS locale component?

Sure. How do you use that?
Comment 2 Marcus Lundblad 2014-03-09 18:30:48 UTC
Created attachment 271367 [details] [review]
Determine addressformat automatically

I added a patch that uses nl_langinfo to determine the addressformat.
I have manually tested running gnome-maps against the locally compiled library (using LD_LIBRARY_PATH). Using the patched library I get the streetnumber after the streename in a lookup using an sv_SE.UTF-8 locale, and before the streetname using en_US.UTF-8.
I have also pushed the changes to my github account here:
https://github.com/mlundblad/geocode-glib.git
Comment 3 Marcus Lundblad 2014-03-10 11:37:29 UTC
Created attachment 271419 [details] [review]
Detect nl_langinfo support
Comment 4 Marcus Lundblad 2014-03-10 11:38:05 UTC
Created attachment 271420 [details] [review]
Use nl_langinfo to format address
Comment 5 Marcus Lundblad 2014-03-10 11:38:29 UTC
Created attachment 271421 [details] [review]
Remove from POTFILES.in
Comment 6 Zeeshan Ali 2014-03-10 11:55:45 UTC
Review of attachment 271419 [details] [review]:

ack (. is redundant in commit).
Comment 7 Zeeshan Ali 2014-03-10 12:01:05 UTC
Review of attachment 271420 [details] [review]:

::: geocode-glib/geocode-reverse.c
@@ +28,3 @@
 #include <libsoup/soup.h>
 #include <config.h>
+#ifdef HAVE_LANGINFO_H

I wonder if we really need this? Which platforms langinfo isn't available for/on?

@@ +120,3 @@
 
+static gboolean
+_geocode_is_number_after_street (void)

'_geocode_' prefix is used only for functions that are not static but not part of public API.

@@ +132,3 @@
+
+  if (s != NULL && h != NULL) {
+    /* return true if %h comes after %s in the format string */

The code is almost as readable/explanatory as these comments so I wouldn't include them.

@@ +186,3 @@
+				char *name = g_strdup_printf ("%s %s", 
+					number_after ? value : house_number,
+					number_after ? house_number : value);

you want to align the 'number_after' to first arg here.
Comment 8 Zeeshan Ali 2014-03-10 12:03:19 UTC
Review of attachment 271421 [details] [review]:

ACK otherwise but please try to follow these guidelines for commit logs: https://wiki.gnome.org/Git/CommitMessages
Comment 9 Marcus Lundblad 2014-03-10 20:42:09 UTC
Created attachment 271474 [details] [review]
reverse: clean up patch for locale-dependent address format

Remove unnessesary #ifdef for <langinfo.h>.
Remove redundant comments. Use proper function name for local function.
Some indentation fixes.
Comment 10 Zeeshan Ali 2014-03-10 21:08:43 UTC
Review of attachment 271474 [details] [review]:

Ouch, you don't want an additional patch to correct your previous patch but rather provide new version of the previous patch.
Comment 11 Marcus Lundblad 2014-03-10 21:20:49 UTC
Created attachment 271475 [details] [review]
Determine address format using nl_langinfo.
Comment 12 Marcus Lundblad 2014-03-10 21:20:53 UTC
Created attachment 271476 [details] [review]
Remove file no longer using translated strings.
Comment 13 Marcus Lundblad 2014-03-10 21:20:57 UTC
Created attachment 271477 [details] [review]
reverse: clean up patch for locale-dependent address format

Remove unnessesary #ifdef for <langinfo.h>.
Remove redundant comments. Use proper function name for local function.
Some indentation fixes.
Comment 14 Marcus Lundblad 2014-03-10 21:26:22 UTC
Created attachment 271479 [details] [review]
Add detection of nl_langinfo support.

Determine address format using nl_langinfo.

https://bugzilla.gnome.org/show_bug.cgi?id=725591

Remove file no longer using translated strings.

https://bugzilla.gnome.org/show_bug.cgi?id=725591

reverse: clean up patch for locale-dependent address format

Remove unnessesary #ifdef for <langinfo.h>.
Remove redundant comments. Use proper function name for local function.
Some indentation fixes.
Comment 15 Zeeshan Ali 2014-03-10 21:42:37 UTC
Review of attachment 271479 [details] [review]:

<zeenix> ah, you marked "Remove file no longer using translated strings." obsolete too
<zeenix> mlundblad: thats not obsolete afaict
<zeenix> oh
<zeenix> you did squash everything together :(
<zeenix> <zeenix> mlundblad: you first gotta use `git rebase -i origin/master` and then squash the appropriate patches
<zeenix> appropriate -> the old and new version of the patch
<zeenix> mlundblad: and you also need to merge the commit log rather than appending them all together
Comment 16 Marcus Lundblad 2014-03-10 21:56:03 UTC
Created attachment 271483 [details] [review]
reverse: derive address format from locale.

Determine address format using nl_langinfo.
Remove unnessesary #ifdef for <langinfo.h>.
Remove redundant comments. Use proper function name for local function.
Some indentation fixes.
Comment 17 Zeeshan Ali 2014-03-10 22:35:05 UTC
Patches pushed with minor changes.
Comment 18 Allison Karlitskaya (desrt) 2014-03-12 13:52:22 UTC
Unconditional use of (private!) _NL_ADDRESS_POSTAL_FMT broke the build on FreeBSD.
Comment 19 Zeeshan Ali 2014-03-12 14:05:31 UTC
<desrt> zeenix: it doesn't build on !linux
<zeenix> ah :)
<desrt> and i think it may even break on linux some day
<desrt> since you're using a private symbol
<zeenix> desrt: mlundblad told me its supposed to at least work on posix
<desrt> definitely not...
<desrt> here is the list of nl_langinfo queries that posix supports: http://pubs.opengroup.org/onlinepubs/007904875/basedefs/langinfo.h.html
Comment 20 Marcus Lundblad 2014-03-12 15:36:58 UTC
Created attachment 271611 [details] [review]
reverse: only use _NL_ADDRESS_POSTAL_FMT on glibc

Conditionally check for GNU libc for the _NL_ADDRESS_FMT constant.
Short-circuite to the default address format of housenumber before
street name otherwise.
Comment 21 Zeeshan Ali 2014-03-12 15:47:19 UTC
Review of attachment 271611 [details] [review]:

Well we are still using internal API so we can't be sure it'll even keep working against glibc. Also this means that this will not work at all for non-glibc cases.

I'd rather we just revert the previous patch and get translators to translate this one string.
Comment 22 Allison Karlitskaya (desrt) 2014-03-12 16:02:04 UTC
I mentioned on IRC that I'm not sure that this is internal API on account of the fact that nothing seems to use it internally, aside from the commandline tool.

It could be that this is meant to be a proper GNU extension -- I can't really find documentation about (the consumer side of) it anywhere, though.
Comment 23 Allison Karlitskaya (desrt) 2014-03-12 22:22:28 UTC
Created attachment 271662 [details] [review]
Revert "reverse: Derive address format from locale"

This reverts commit 029c421d32647e4ab6fbbfa669947c24a27e69fe.
Comment 24 Allison Karlitskaya (desrt) 2014-03-12 22:23:21 UTC
Comment on attachment 271662 [details] [review]
Revert "reverse: Derive address format from locale"

Attachment 271662 [details] pushed as 55d7e80 - Revert "reverse: Derive address format from locale"

Reverted with Zeeshan's ACK (via IRC).
Comment 25 Jonas Danielsson 2014-03-17 20:20:13 UTC
Created attachment 272204 [details] [review]
Revert "l10n: Update POTFILES.in"

This reverts commit 684555176c33091a336268870c19a436a1be35bb.
Comment 26 Jonas Danielsson 2014-03-17 20:20:45 UTC
We also need to revert the removal of geocode-reverse from POTFILES.in.
Comment 27 Jonas Danielsson 2014-03-17 20:21:20 UTC
Attachment 272204 [details] pushed as a95f1ba - Revert "l10n: Update POTFILES.in"
Comment 28 Jonas Danielsson 2014-03-17 20:21:55 UTC
(Ack from Zeeshan via chat)
Comment 29 Jonas Danielsson 2014-12-19 07:24:00 UTC
So I am re-opening this. 

I would like this functionality, either if we can find a proper way of getting the postal_fmt field or if we can do something purely based on a list of LOCALE?
Comment 30 Jonas Danielsson 2014-12-19 07:33:38 UTC
Like looking through this list and see if it there could be easy classification: http://lh.2xlibre.net/values/postal_fmt/
Comment 31 Bastien Nocera 2015-01-05 14:34:21 UTC
(In reply to comment #29)
> So I am re-opening this. 
> 
> I would like this functionality, either if we can find a proper way of getting
> the postal_fmt field or if we can do something purely based on a list of
> LOCALE?

I don't understand the question here. _NL_ADDRESS_POSTAL_FMT should contain all the information necessary to format the address, but the metadata given back by the service might not exactly match the fields used by _NL_ADDRESS_POSTAL_FMT...

What exactly do you expect to happen? Full support for the spec? It looks doable although it probably needs to be cleaned up (look at the number of address formats that don't include a country name for example).
Comment 32 Jonas Danielsson 2015-01-05 14:37:44 UTC
(In reply to comment #31)
> (In reply to comment #29)
> > So I am re-opening this. 
> > 
> > I would like this functionality, either if we can find a proper way of getting
> > the postal_fmt field or if we can do something purely based on a list of
> > LOCALE?
> 
> I don't understand the question here. _NL_ADDRESS_POSTAL_FMT should contain all
> the information necessary to format the address, but the metadata given back by
> the service might not exactly match the fields used by
> _NL_ADDRESS_POSTAL_FMT...
> 
> What exactly do you expect to happen? Full support for the spec? It looks
> doable although it probably needs to be cleaned up (look at the number of
> address formats that don't include a country name for example).

See above, we can not use _NL_ADDRESS_POSTAL_FMT, since it is private API, and I cannot find a proper way to get that postal format string. Only the locale tool uses it, it seemed, and they reference the private API.

This broke FreeBSD. So what I was thinking was getting a list of locales that have the number before the street, or the other way around, whichever is the shorter list. And from that have logic to format the <house number> <street name> pair.
Comment 33 Jonas Danielsson 2015-01-05 14:39:45 UTC
(In reply to comment #32)
> (In reply to comment #31)
> > (In reply to comment #29)
> > > So I am re-opening this. 
> > > 
> > > I would like this functionality, either if we can find a proper way of getting
> > > the postal_fmt field or if we can do something purely based on a list of
> > > LOCALE?
> > 
> > I don't understand the question here. _NL_ADDRESS_POSTAL_FMT should contain all
> > the information necessary to format the address, but the metadata given back by
> > the service might not exactly match the fields used by
> > _NL_ADDRESS_POSTAL_FMT...
> > 
> > What exactly do you expect to happen? Full support for the spec? It looks
> > doable although it probably needs to be cleaned up (look at the number of
> > address formats that don't include a country name for example).
> 
> See above, we can not use _NL_ADDRESS_POSTAL_FMT, since it is private API, and
> I cannot find a proper way to get that postal format string. Only the locale
> tool uses it, it seemed, and they reference the private API.
> 
> This broke FreeBSD. So what I was thinking was getting a list of locales that
> have the number before the street, or the other way around, whichever is the
> shorter list. And from that have logic to format the <house number> <street
> name> pair.

All I want, for now is the correct ordering of <house number> and <street name>. Number before street or number after street.

This became personal since I added my own address and want it formatted in a way that is familiar for me :)
Comment 34 Bastien Nocera 2015-01-05 14:45:05 UTC
(In reply to comment #32)
> (In reply to comment #31)
> > (In reply to comment #29)
> > > So I am re-opening this. 
> > > 
> > > I would like this functionality, either if we can find a proper way of getting
> > > the postal_fmt field or if we can do something purely based on a list of
> > > LOCALE?
> > 
> > I don't understand the question here. _NL_ADDRESS_POSTAL_FMT should contain all
> > the information necessary to format the address, but the metadata given back by
> > the service might not exactly match the fields used by
> > _NL_ADDRESS_POSTAL_FMT...
> > 
> > What exactly do you expect to happen? Full support for the spec? It looks
> > doable although it probably needs to be cleaned up (look at the number of
> > address formats that don't include a country name for example).
> 
> See above, we can not use _NL_ADDRESS_POSTAL_FMT, since it is private API, and
> I cannot find a proper way to get that postal format string. Only the locale
> tool uses it, it seemed, and they reference the private API.

I don't think it's private API, it's a GNU only API most likely. Given that the information from the page you linked above is from glibc's locale data, I'm pretty sure using the data from the glibc locale information is fine.

> This broke FreeBSD.

That's because FreeBSD doesn't use the glibc.

#ifndef _NL_ADDRESS_POSTAL_FMT
  // Do default FreeBSD thing
#else
  // Get info
#endif

> So what I was thinking was getting a list of locales that
> have the number before the street, or the other way around, whichever is the
> shorter list. And from that have logic to format the <house number> <street
> name> pair.

Which is information that you can already have when using the glibc. If something exists on FreeBSD to do that, it can be implemented later, in the meanwhile, I'm not sure it's interesting to start copying data from glibc's locales just for FreeBSD's benefit.
Comment 35 Jonas Danielsson 2015-01-05 14:49:20 UTC
(In reply to comment #34)
> (In reply to comment #32)
> > (In reply to comment #31)
> > > (In reply to comment #29)
> > > > So I am re-opening this. 
> > > > 
> > > > I would like this functionality, either if we can find a proper way of getting
> > > > the postal_fmt field or if we can do something purely based on a list of
> > > > LOCALE?
> > > 
> > > I don't understand the question here. _NL_ADDRESS_POSTAL_FMT should contain all
> > > the information necessary to format the address, but the metadata given back by
> > > the service might not exactly match the fields used by
> > > _NL_ADDRESS_POSTAL_FMT...
> > > 
> > > What exactly do you expect to happen? Full support for the spec? It looks
> > > doable although it probably needs to be cleaned up (look at the number of
> > > address formats that don't include a country name for example).
> > 
> > See above, we can not use _NL_ADDRESS_POSTAL_FMT, since it is private API, and
> > I cannot find a proper way to get that postal format string. Only the locale
> > tool uses it, it seemed, and they reference the private API.
> 
> I don't think it's private API, it's a GNU only API most likely. Given that the
> information from the page you linked above is from glibc's locale data, I'm
> pretty sure using the data from the glibc locale information is fine.
> 
> > This broke FreeBSD.
> 
> That's because FreeBSD doesn't use the glibc.
> 
> #ifndef _NL_ADDRESS_POSTAL_FMT
>   // Do default FreeBSD thing
> #else
>   // Get info
> #endif
> 
> > So what I was thinking was getting a list of locales that
> > have the number before the street, or the other way around, whichever is the
> > shorter list. And from that have logic to format the <house number> <street
> > name> pair.
> 
> Which is information that you can already have when using the glibc. If
> something exists on FreeBSD to do that, it can be implemented later, in the
> meanwhile, I'm not sure it's interesting to start copying data from glibc's
> locales just for FreeBSD's benefit.

Sure that works for me. Thanks!
Comment 36 Jonas Danielsson 2015-01-06 13:31:31 UTC
Created attachment 293920 [details] [review]
reverse: Derive street address format from locale

Determine street address format using nl_langinfo.
Comment 37 Jonas Danielsson 2015-01-06 13:33:14 UTC
The patch is Marcus' slightly refactored. And also uses the function for set_street_address.
Comment 38 Jonas Danielsson 2015-01-06 13:36:05 UTC
Created attachment 293922 [details] [review]
Derive street address format from locale

Determine street address format using nl_langinfo.
This is only possible on the GNU C library atm.
Comment 39 Jonas Danielsson 2015-01-06 13:49:33 UTC
Created attachment 293924 [details] [review]
Derive street address format from locale

Determine street address format using nl_langinfo.
This is only possible on the GNU C library atm.
Comment 40 Bastien Nocera 2015-01-06 14:52:50 UTC
Review of attachment 293924 [details] [review]:

::: geocode-glib/geocode-glib.c
@@ +192,3 @@
+
+gboolean
+_geocode_object_is_number_after_street (void)

This whole function could be cached, as the locale isn't likely to change during runtime (actually, it can't change).

You can use g_once() for that.

@@ +201,3 @@
+  gchar *h;
+
+  addr_format = nl_langinfo (_NL_ADDRESS_POSTAL_FMT);

Check if addr_format is NULL, just in case (C locale?)

@@ +202,3 @@
+
+  addr_format = nl_langinfo (_NL_ADDRESS_POSTAL_FMT);
+  s = g_strstr_len (addr_format, -1, "%s");

Can you add a link to the definition of those values (%s and %h)?
Comment 41 Jonas Danielsson 2015-01-06 21:18:55 UTC
Created attachment 293978 [details] [review]
Derive street address format from locale

Determine street address format using nl_langinfo.
This is only possible on the GNU C library atm.
Comment 42 Jonas Danielsson 2015-01-06 21:20:01 UTC
Created attachment 293979 [details] [review]
Derive street address format from locale

Determine street address format using nl_langinfo.
This is only possible on the GNU C library atm.
Comment 43 Bastien Nocera 2015-01-06 21:43:05 UTC
Review of attachment 293979 [details] [review]:

Looks good otherwise.

::: geocode-glib/geocode-glib.c
@@ +194,3 @@
+is_number_after_street (gpointer data)
+{
+	static gboolean retval;

No need to make it static, is_number_after_street() should only get called once.

::: geocode-glib/geocode-reverse.c
@@ +155,3 @@
                         } else if (house_number != NULL && g_strcmp0 (members[i], "road") == 0) {
+                                gboolean number_after;
+                                char * name;

char *name, not char * name
Comment 44 Jonas Danielsson 2015-01-07 06:28:58 UTC
Review of attachment 293979 [details] [review]:

::: geocode-glib/geocode-glib.c
@@ +194,3 @@
+is_number_after_street (gpointer data)
+{
+	static gboolean retval;

Well, yeah.

The reason I did this is because g_once wants to return gpointer and I want to return boolean. So by returning the address of the gboolean I get a pointer. But I do not want to return the address of a local variable, and I didn't want to allocate a boolean. So I thought that if I use a static local variable then the scoping would allow me to return the address.

Do you have a nicer way of me of doing this? Should I use GINT_TO_GPOINTER in some way?

The g_once test in glib/tests/once.c does sort of a mix :)

static gpointer
do_once (gpointer data)
{
    static gint i = 0;

    i++;

    return GINT_TO_POINTER (i);
}

But that might be static just to verify it gets called only once.

I see that gedit has a GBOOLEAN_TO_GPOINTER macro in gedit-utils.h:

#define GBOOLEAN_TO_POINTER(i) (GINT_TO_POINTER ((i) ? 2 : 1))

Should I use something like that?
Comment 45 Jonas Danielsson 2015-01-07 06:49:52 UTC
Created attachment 294005 [details] [review]
Derive street address format from locale

Determine street address format using nl_langinfo.
This is only possible on the GNU C library atm.
Comment 46 Jonas Danielsson 2015-01-07 07:27:20 UTC
Created attachment 294006 [details] [review]
Derive street address format from locale

Determine street address format using nl_langinfo.
This is only possible on the GNU C library atm.
Comment 47 Bastien Nocera 2015-01-07 15:46:59 UTC
Review of attachment 294006 [details] [review]:

::: geocode-glib/geocode-glib.c
@@ +216,3 @@
+
+ out:
+	return GINT_TO_POINTER (retval ? 2 : 1);

GINT_TO_POINTER(retval) will be enough.

@@ +228,3 @@
+
+	g_once (&once, is_number_after_street, NULL);
+	return (GPOINTER_TO_INT (once.retval) == 2);

And the "== 2" won't be necessary.
Comment 48 Bastien Nocera 2015-01-07 15:51:27 UTC
(In reply to comment #44)
> Review of attachment 293979 [details] [review]:
> 
> ::: geocode-glib/geocode-glib.c
> @@ +194,3 @@
> +is_number_after_street (gpointer data)
> +{
> +    static gboolean retval;
> 
> Well, yeah.
> 
> The reason I did this is because g_once wants to return gpointer and I want to
> return boolean. So by returning the address of the gboolean I get a pointer.
> But I do not want to return the address of a local variable, and I didn't want
> to allocate a boolean. So I thought that if I use a static local variable then
> the scoping would allow me to return the address.
> 
> Do you have a nicer way of me of doing this? Should I use GINT_TO_GPOINTER in
> some way?

GINT_TO_POINTER() is the right way to do things, yes.

> The g_once test in glib/tests/once.c does sort of a mix :)

It does that to ensure that do_once is only called once :)
<snip>
> But that might be static just to verify it gets called only once.

Yes :)

> I see that gedit has a GBOOLEAN_TO_GPOINTER macro in gedit-utils.h:
> 
> #define GBOOLEAN_TO_POINTER(i) (GINT_TO_POINTER ((i) ? 2 : 1))
> 
> Should I use something like that?

That's not necessary. In gedit's case, it's used to avoid possible problems with the inability to differentiate between FALSE (0 or NULL in pointer form) with a missing item in a hashtable:
ret = GPOINTER_TO_INT(g_hash_table_lookup (ht, key));
cannot differentiate between "FALSE" being in the hashtable and the key not being in the hashtable.
Comment 49 Jonas Danielsson 2015-01-07 19:18:37 UTC
Created attachment 294053 [details] [review]
Derive street address format from locale

Determine street address format using nl_langinfo.
This is only possible on the GNU C library atm.
Comment 50 Bastien Nocera 2015-01-07 23:31:33 UTC
Review of attachment 294053 [details] [review]:

Looks good, you just need a test case for test-gcglib now!
Comment 51 Jonas Danielsson 2015-01-08 06:52:07 UTC
Created attachment 294074 [details] [review]
test-gcglib: Add test of address format

Test the ordering of house number and street name.
Comment 52 Bastien Nocera 2015-01-08 07:46:31 UTC
Review of attachment 294074 [details] [review]:

Looks good!
Comment 53 Ting-Wei Lan 2015-01-15 08:21:57 UTC
Attachment 294074 [details] breaks on FreeBSD because of LC_ADDRESS.
Comment 54 Bastien Nocera 2015-01-15 12:34:53 UTC
Created attachment 294594 [details] [review]
test: Fix compilation on non-glibc platforms
Comment 55 Bastien Nocera 2015-01-15 12:37:04 UTC
Comment on attachment 294594 [details] [review]
test: Fix compilation on non-glibc platforms

See bug 742957
Comment 56 Jonas Danielsson 2015-01-15 12:41:23 UTC
Does not the patch in bug 742957 cover this?
Comment 57 Ting-Wei Lan 2015-01-15 13:12:21 UTC
Yes, it is fixed now.