- invoke fix-info-dir via /sbin/postshell where possible to avoid extra /bin/sh dep
[packages/conflib.git] / conflib-locale.patch
CommitLineData
387164d0
MM
1diff -ur conflib-0.4.5-/src/cl_assign.c conflib-0.4.5/src/cl_assign.c
2--- conflib-0.4.5-/src/cl_assign.c Fri Oct 9 19:03:57 1998
3+++ conflib-0.4.5/src/cl_assign.c Sat Oct 20 21:45:42 2001
4@@ -93,6 +93,45 @@
5 "Value %s doesn't match %s %s.",
6 val,what,var->rangeexp);
7 }
8+
9+static int
10+cl_in_current_locale(const char *varname)
11+{
12+ static const char *locale = NULL;
13+ static int locale_len = 0;
14+ static int locale_first_len = 0;
15+ char *p;
16+
17+ if (locale == NULL) {
18+ const char *lp;
19+
20+ if ((locale = getenv("LC_MESSAGES")) == NULL &&
21+ (locale = getenv("LC_ALL")) == NULL &&
22+ (locale = getenv("LANG")) == NULL)
23+ locale = "C";
24+ locale_len = strlen(locale);
25+ for (lp = locale; *lp; lp++, locale_first_len++)
26+ if (*lp == '_')
27+ break;
28+ }
29+
30+ p = strchr(varname, '(');
31+ if (p == NULL)
32+ return 1; /* yes */
33+ p++;
34+ if (strcmp(p, "POSIX)") == 0 ||
35+ strcmp(p, "C)") == 0)
36+ return 1; /* yes */
37+ if (strncmp(p, locale, locale_first_len) == 0 &&
38+ p[locale_first_len] == ')' &&
39+ p[locale_first_len+1] == 0)
40+ return 2; /* yes, better */
41+ if (strncmp(p, locale, locale_len) == 0 &&
42+ p[locale_len] == ')' &&
43+ p[locale_len+1] == 0)
44+ return 3; /* yes, even better */
45+ return 0;
46+}
47
48 int
49 cl_assign(cl_file_t *conf, cl_var_t *KonfTab,
50@@ -102,6 +141,7 @@
51 const cl_enum_t *enump;
52 int override=0;
53 int append=0;
54+ char *nameptr = NULL;
55 if (0==strncmp(varname,"override ",9)) {
56 varname+=9;
57 override=1;
58@@ -111,6 +151,15 @@
59 append=1;
60 }
61
62+ if ((conf->mode&' ') == 0 && strchr(varname, ')')) {
63+ if (cl_in_current_locale(varname) == 0)
64+ return 0;
65+ nameptr = strdup(varname);
66+ *strchr(nameptr, '(') = 0;
67+ varname = nameptr;
68+ override = 1;
69+ }
70+
71 for(Vp=KonfTab;Vp->varname;Vp++)
72 {
73 char c1=tolower(*varname);
74@@ -125,7 +174,7 @@
75 {
76 Vp=cl_unalias(conf,KonfTab,Vp);
77 if (!Vp)
78- return 1;
79+ goto return_1;
80 }
81 if (Vp->flags & CL_WARNING) {
82 cl_warning(CL_WARN(conf,Vp),"variable %s should not be used",
83@@ -139,7 +188,7 @@
84 if (cl_fnmatch(Vp->rangeexp,value)!=0)
85 {
86 cl_as_dontmatch(conf,Vp,"wildcard", value);
87- return 0;
88+ goto return_0;
89 }
90 }
91 else
92@@ -151,12 +200,12 @@
93 cl_warning(CL_ERR(conf,Vp),
94 "cannot compile regular expression %s",
95 Vp->rangeexp);
96- return -1;
97+ goto return_m1;
98 }
99 if (regexec(&exp,value,0,NULL,0)!=0)
100 {
101 cl_as_dontmatch(conf,Vp,"regular expression", value);
102- return 0;
103+ goto return_0;
104 }
105 #else
106