summaryrefslogtreecommitdiff
path: root/src/nonstd
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-28 14:22:04 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-28 14:22:04 -0500
commitf777999710878dc9c5cdea3b297c0c1ccd934adc (patch)
tree2d37c4cdd8487d563487caa58fa60ef946b8d5fb /src/nonstd
parent5608b687ac1a10b1cc525d8e61d0abfce2f5737d (diff)
clean up internal locale stuff
Diffstat (limited to 'src/nonstd')
-rw-r--r--src/nonstd/__load_locale.c4
-rw-r--r--src/nonstd/_locale.h (renamed from src/nonstd/__load_locale.h)12
-rw-r--r--src/nonstd/locale-internal.ref2
-rw-r--r--src/nonstd/struct_locale_t.c27
4 files changed, 31 insertions, 14 deletions
diff --git a/src/nonstd/__load_locale.c b/src/nonstd/__load_locale.c
new file mode 100644
index 00000000..193aa333
--- /dev/null
+++ b/src/nonstd/__load_locale.c
@@ -0,0 +1,4 @@
+#include <nonstd/locale.h>
+
+#define __load_locale(_loc, _mask, _name) \
+ ((char * (*)(struct __locale *, int, const char *))__libc(LOAD_LOCALE))(_loc, _mask, _name)
diff --git a/src/nonstd/__load_locale.h b/src/nonstd/_locale.h
index 16709870..40e66548 100644
--- a/src/nonstd/__load_locale.h
+++ b/src/nonstd/_locale.h
@@ -6,12 +6,14 @@
#include "nonstd/locale.h"
#include "nonstd/ctype.h"
+/*
#define LC_COLLATE_MASK (1<<0)
#define LC_CTYPE_MASK (1<<1)
#define LC_MONETARY_MASK (1<<2)
#define LC_NUMERIC_MASK (1<<3)
#define LC_TIME_MASK (1<<4)
#define LC_MESSAGES_MASK (1<<5)
+*/
#define stringreplace(_old, _new) do { \
_old = realloc(_old, strlen(_new) + 1); \
@@ -21,7 +23,7 @@
strcpy(_old, _new); \
} while (0)
-char * __load_locale(struct __locale_t *loc, int mask, const char *name)
+static char * (__load_locale)(struct __locale_t *loc, int mask, const char *name)
{
char localepath[FILENAME_MAX] = "/lib/locale/";
strcat(localepath, name);
@@ -46,16 +48,16 @@ char * __load_locale(struct __locale_t *loc, int mask, const char *name)
loc->ctattr = realloc(loc->ctattr, CHAR_MAX);
for (i = 0; i < 32; i++) {
- loc->ctattr[i] = CNTRL;
+ loc->ctattr[i] = CT_CNTRL;
}
for (i = 'a'; i < 'z'; i++) {
- loc->ctattr[i] = LOWER;
+ loc->ctattr[i] = CT_LOWER;
}
for (i = 'A'; i < 'Z'; i++) {
- loc->ctattr[i] = UPPER;
+ loc->ctattr[i] = CT_UPPER;
}
for (i = '0'; i < '9'; i++) {
- loc->ctattr[i] = DIGIT | XDIGIT;
+ loc->ctattr[i] = CT_DIGIT | CT_XDIGIT;
}
/* others */
diff --git a/src/nonstd/locale-internal.ref b/src/nonstd/locale-internal.ref
new file mode 100644
index 00000000..d795ee8f
--- /dev/null
+++ b/src/nonstd/locale-internal.ref
@@ -0,0 +1,2 @@
+#include <nonstd/locale.h>
+REFERENCE(<nonstd/internal.h>)
diff --git a/src/nonstd/struct_locale_t.c b/src/nonstd/struct_locale_t.c
index 1981bd8d..5487ae6a 100644
--- a/src/nonstd/struct_locale_t.c
+++ b/src/nonstd/struct_locale_t.c
@@ -1,22 +1,31 @@
#include <nonstd/locale.h>
struct __locale_t {
- int mask;
- char *all;
- char *collate;
- unsigned char *collation;
- char *ctype;
- unsigned char *ctattr;
- unsigned char *ctoupper;
- unsigned char *ctolower;
- char *message;
+ char all[UCHAR_MAX];
+
+ char ctype[UCHAR_MAX];
+ struct {
+ unsigned char ctattr[UCHAR_MAX + 1];
+ unsigned char ctoupper[UCHAR_MAX + 1];
+ unsigned char ctolower[UCHAR_MAX + 1];
+ } lc_ctype;
+
+ char collate[UCHAR_MAX];
+ struct collation {
+ char * sequence;
+ int weight;
+ } *lc_collate;
+
+ char messages[UCHAR_MAX];
struct {
char *yesexpr;
char *noexpr;
} lc_messages;
+
char *monetary;
char *numeric;
struct lconv mn;
+
char *time;
struct {
char *abday[7];