summaryrefslogtreecommitdiff
path: root/locale/weight.h
diff options
context:
space:
mode:
Diffstat (limited to 'locale/weight.h')
-rw-r--r--locale/weight.h47
1 files changed, 39 insertions, 8 deletions
diff --git a/locale/weight.h b/locale/weight.h
index 424e493209..76e6537762 100644
--- a/locale/weight.h
+++ b/locale/weight.h
@@ -43,21 +43,42 @@ typedef struct weight_t
/* The following five macros grant access to the values in the
collate locale file that do not depend on byte order. */
-#define collate_nrules \
+#ifndef USE_IN_EXTENDED_LOCALE_MODEL
+# define collate_nrules \
(_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES))
-#define collate_hash_size \
+# define collate_hash_size \
(_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_SIZE))
-#define collate_hash_layers \
+# define collate_hash_layers \
(_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_HASH_LAYERS))
-#define collate_undefined \
+# define collate_undefined \
(_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_UNDEFINED))
-#define collate_rules \
+# define collate_rules \
((u_int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_RULES))
-
static __inline int get_weight (const STRING_TYPE **str, weight_t *result);
static __inline int
get_weight (const STRING_TYPE **str, weight_t *result)
+#else
+# define collate_nrules \
+ current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].word
+# define collate_hash_size \
+ current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_SIZE)].word
+# define collate_hash_layers \
+ current->values[_NL_ITEM_INDEX (_NL_COLLATE_HASH_LAYERS)].word
+# define collate_undefined \
+ current->values[_NL_ITEM_INDEX (_NL_COLLATE_UNDEFINED)].word
+# define collate_rules \
+ ((u_int32_t *) current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULES)].string)
+
+static __inline int get_weight (const STRING_TYPE **str, weight_t *result,
+ struct locale_data *current,
+ const u_int32_t *__collate_table,
+ const u_int32_t *__collate_extra);
+static __inline int
+get_weight (const STRING_TYPE **str, weight_t *result,
+ struct locale_data *current, const u_int32_t *__collate_table,
+ const u_int32_t *__collate_extra)
+#endif
{
unsigned int ch = *((USTRING_TYPE *) (*str))++;
size_t slot;
@@ -150,7 +171,17 @@ get_weight (const STRING_TYPE **str, weight_t *result)
the string at once. The following macro constructs a double linked
list of this information. It is a macro because we use `alloca'
and we use a double linked list because of the backward collation
- order. */
+ order.
+
+ We have this strange extra macro since the functions which use the
+ given locale (not the global one) canot use the global tables. */
+#ifndef USE_IN_EXTENDED_LOCALE_MODEL
+# define call_get_weight(strp, newp) get_weight ((strp), (newp))
+#else
+# define call_get_weight(strp, newp) \
+ get_weight ((strp), (newp), current, collate_table, collate_extra)
+#endif
+
#define get_string(str, forw, backw) \
do \
{ \
@@ -169,6 +200,6 @@ get_weight (const STRING_TYPE **str, weight_t *result)
newp->next = NULL; \
backw = newp; \
} \
- while (get_weight (&str, newp) == 0); \
+ while (call_get_weight (&str, newp) == 0); \
} \
while (0)