On Fri, Apr 26, 2013 at 01:04:26PM +0200, Stefan Sperling wrote:

Regarding your test program, I have a small nit: You've sent a test
program that uses the es_CO locale, which probably only exists on
your own patched system, so the test program doesn't work elsewhere.
Please consider sending tests programs that work on other peoples'
systems without modification -- just as a matter of courtesy.

Today I began to test symbolic links from es_ES.* to es_CO.* and seems
that can work.  I'll test more and report.

Regarding your fix: I've verified that it works, but I think there
is a better way of fixing this. It seems strange that the citrus
layer is concerned at all with setting the global __mb_cur_max variable,
a variable which is actually in the domain of code in the locale/ directory.

Consider the following idea: We add a new member to struct _citrus_ctype_rec,
called e.g. cc_mb_cur_max, which can be hard-coded to the correct value
during definitions of _citrus_ctype_rec objects we use.

In FreeBSD is done like that with a member __mb_cur_max in the structure
xlocale_ctype.

The generic locale/ code could then set __mb_cur_max based on that
constant value, at the bottom of the _xpg4_setrunelocale() function,
by pulling the correct value out of the rl->rl_citrus_ctype structure.

_citrus_ctype_open() won't have to fiddle with __mb_cur_max anymore,
which also fixes another bug: We currently change __mb_cur_max even if
setting the locale files after _citrus_ctype_open()!

Do you want to try implementing this idea?
I believe this idea would result in a smaller diff, too.

Attached, with reordering of #includes in setrunelocale.c to comply better with style (9).


--
Dios, gracias por tu amor infinito.
-- Vladimir Támara Patiño. http://vtamara.pasosdeJesus.org/
 http://www.pasosdejesus.org/dominio_publico_colombia.html

Index: citrus/citrus_ctype.c
===================================================================
RCS file: /cvs/src/lib/libc/citrus/citrus_ctype.c,v
retrieving revision 1.3
diff -u -r1.3 citrus_ctype.c
--- citrus/citrus_ctype.c       5 Dec 2012 23:19:59 -0000       1.3
+++ citrus/citrus_ctype.c       28 Apr 2013 13:10:48 -0000
@@ -38,10 +38,12 @@
 
 struct _citrus_ctype_rec _citrus_ctype_none = {
        &_citrus_none_ctype_ops,        /* cc_ops */
+       1,                              /* cc_mb_cur_max */
 };
 
 struct _citrus_ctype_rec _citrus_ctype_utf8 = {
        &_citrus_utf8_ctype_ops,        /* cc_ops */
+       _CITRUS_UTF8_MB_CUR_MAX,        /* cc_mb_cur_max */
 };
 
 int
@@ -49,11 +51,9 @@
 {
        if (!strcmp(encname, "NONE")) {
                *rcc = &_citrus_ctype_none;
-               __mb_cur_max = 1;
                return (0);
        } else if (!strcmp(encname, "UTF8")) {
                *rcc = &_citrus_ctype_utf8;
-               __mb_cur_max = _CITRUS_UTF8_MB_CUR_MAX;
                return (0);
        }
 
Index: citrus/citrus_ctype_local.h
===================================================================
RCS file: /cvs/src/lib/libc/citrus/citrus_ctype_local.h,v
retrieving revision 1.3
diff -u -r1.3 citrus_ctype_local.h
--- citrus/citrus_ctype_local.h 6 Jun 2012 16:58:02 -0000       1.3
+++ citrus/citrus_ctype_local.h 28 Apr 2013 13:10:49 -0000
@@ -81,6 +81,7 @@
 
 struct _citrus_ctype_rec {
        struct _citrus_ctype_ops_rec    *cc_ops;
+       size_t  cc_mb_cur_max;
 };
 
 #endif
Index: locale/setrunelocale.c
===================================================================
RCS file: /cvs/src/lib/libc/locale/setrunelocale.c,v
retrieving revision 1.7
diff -u -r1.7 setrunelocale.c
--- locale/setrunelocale.c      5 Dec 2012 23:20:00 -0000       1.7
+++ locale/setrunelocale.c      28 Apr 2013 13:10:49 -0000
@@ -88,18 +88,20 @@
  * SUCH DAMAGE.
  */
 
-#include "rune.h"
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
+#include <locale.h>
 #include <paths.h>
-#include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
+#include <string.h>
 #include <unistd.h>
-#include <locale.h>
-#include <citrus/citrus_ctype.h>
+
+#include "citrus_ctype.h"
+#include "citrus_ctype_local.h"
+#include "rune.h"
 #include "rune_local.h"
 
 struct localetable {
@@ -195,6 +197,7 @@
 
 found:
        _CurrentRuneLocale = rl;
+       __mb_cur_max = rl->rl_citrus_ctype->cc_mb_cur_max;
 
        return 0;
 }

Reply via email to