aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-10 21:46:37 -0700
committerUlrich Sibiller <uli42@gmx.de>2016-10-19 21:40:28 +0200
commitd2671c285e1923acae674ef9390a3f8bf23c11b3 (patch)
tree1298ec41d4720210b88550bae0eabf78a5b42c23
parent22377a799a141ba6b1e43b83de4a506b36a842a4 (diff)
downloadnx-libs-d2671c285e1923acae674ef9390a3f8bf23c11b3.tar.gz
nx-libs-d2671c285e1923acae674ef9390a3f8bf23c11b3.tar.bz2
nx-libs-d2671c285e1923acae674ef9390a3f8bf23c11b3.zip
Constify lc_name argument to _XlcLocaleDirName() & _XlcLocaleLibDirName()
Makes code considerably less crufty and clears gcc warnings: XlcDL.c: In function '_XlcDynamicLoad': XlcDL.c:384:44: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] XlcDL.c:386:51: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
-rw-r--r--nx-X11/lib/X11/XlcDL.c6
-rw-r--r--nx-X11/lib/X11/XlcPubI.h4
-rw-r--r--nx-X11/lib/X11/lcFile.c86
3 files changed, 35 insertions, 61 deletions
diff --git a/nx-X11/lib/X11/XlcDL.c b/nx-X11/lib/X11/XlcDL.c
index 2bef4ac12..18fb3e3b1 100644
--- a/nx-X11/lib/X11/XlcDL.c
+++ b/nx-X11/lib/X11/XlcDL.c
@@ -381,9 +381,9 @@ _XlcDynamicLoad(const char *lc_name)
if (lc_name == NULL) return (XLCd)NULL;
- if (_XlcLocaleDirName(lc_dir, BUFSIZE, (char *)lc_name) == (char *)NULL)
+ if (_XlcLocaleDirName(lc_dir, BUFSIZE, lc_name) == NULL)
return (XLCd)NULL;
- if (_XlcLocaleLibDirName(lc_lib_dir, BUFSIZE, (char *)lc_name) == (char*)NULL)
+ if (_XlcLocaleLibDirName(lc_lib_dir, BUFSIZE, lc_name) == NULL)
return (XLCd)NULL;
resolve_object(lc_dir, lc_name);
@@ -510,7 +510,7 @@ _XDynamicUnRegisterIMInstantiateCallback(
XPointer client_data)
{
char lc_dir[BUFSIZE];
- char *lc_name;
+ const char *lc_name;
dynamicUnregisterProcp im_unregisterIM = (dynamicUnregisterProcp)NULL;
Bool ret_flag = False;
int count;
diff --git a/nx-X11/lib/X11/XlcPubI.h b/nx-X11/lib/X11/XlcPubI.h
index f41e3442a..44d0d086c 100644
--- a/nx-X11/lib/X11/XlcPubI.h
+++ b/nx-X11/lib/X11/XlcPubI.h
@@ -207,13 +207,13 @@ extern int _XlcResolveI18NPath(
extern char *_XlcLocaleLibDirName(
char* /* dir_name */,
size_t, /* dir_len */
- char* /* lc_name */
+ const char* /* lc_name */
);
extern char *_XlcLocaleDirName(
char* /* dir_name */,
size_t, /* dir_len */
- char* /* lc_name */
+ const char* /* lc_name */
);
extern XPointer _XlcCreateLocaleDataBase(
diff --git a/nx-X11/lib/X11/lcFile.c b/nx-X11/lib/X11/lcFile.c
index 65ea652d0..91773a0a8 100644
--- a/nx-X11/lib/X11/lcFile.c
+++ b/nx-X11/lib/X11/lcFile.c
@@ -615,14 +615,14 @@ _XlcResolveI18NPath(char *buf, int buf_len)
}
char *
-_XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name)
+_XlcLocaleDirName(char *dir_name, size_t dir_len, const char *lc_name)
{
- char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
+ char dir[PATH_MAX], buf[PATH_MAX];
int i, n;
char *args[NUM_LOCALEDIR];
static char locale_alias[] = LOCALE_ALIAS;
- char *target_name = (char*)0;
- char *target_dir = (char*)0;
+ char *target_name = NULL;
+ char *target_dir = NULL;
char *nlc_name = NULL;
static char* last_dir_name = 0;
static size_t last_dir_len = 0;
@@ -637,6 +637,8 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name)
xlocaledir (dir, PATH_MAX);
n = _XlcParsePath(dir, args, 256);
for (i = 0; i < n; ++i) {
+ char *name = NULL;
+
if (args[i] == NULL)
continue;
@@ -651,18 +653,15 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name)
}
}
- /* If name is not an alias, use lc_name for locale.dir search */
- if (name == NULL)
- name = lc_name;
-
/* look at locale.dir */
target_dir = args[i];
if (snprintf(buf, PATH_MAX, "%s/locale.dir", target_dir) < PATH_MAX) {
- target_name = resolve_name(name, buf, RtoL);
+ /* If name is not an alias, use lc_name for locale.dir search */
+ target_name = resolve_name(name ? name : lc_name, buf, RtoL);
}
- if (name != lc_name)
- Xfree(name);
+ Xfree(name);
+ name = NULL;
if (target_name != NULL) {
char *p = 0;
if ((p = strstr(target_name, "/XLC_LOCALE"))) {
@@ -672,27 +671,15 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name)
Xfree(target_name);
target_name = NULL;
}
- name = NULL;
}
if (nlc_name) Xfree(nlc_name);
- if (target_name == NULL) {
+ if (target_name == NULL)
/* vendor locale name == Xlocale name, no expansion of alias */
- target_dir = args[0];
- target_name = lc_name;
- }
- /* snprintf(dir_name, dir_len, "%s/%", target_dir, target_name); */
- strncpy(dir_name, target_dir, dir_len - 1);
- if (strlen(target_dir) >= dir_len - 1) {
- dir_name[dir_len - 1] = '\0';
- } else {
- strcat(dir_name, "/");
- strncat(dir_name, target_name, dir_len - strlen(dir_name) - 1);
- if (strlen(target_name) >= dir_len - strlen(dir_name) - 1)
- dir_name[dir_len - 1] = '\0';
- }
- if (target_name != lc_name)
- Xfree(target_name);
+ snprintf(dir_name, dir_len, "%s/%s", args[0], lc_name);
+ else
+ snprintf(dir_name, dir_len, "%s/%s", target_dir, target_name);
+ Xfree(target_name);
if (last_dir_name != 0)
Xfree (last_dir_name);
@@ -707,14 +694,14 @@ _XlcLocaleDirName(char *dir_name, size_t dir_len, char *lc_name)
}
char *
-_XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
+_XlcLocaleLibDirName(char *dir_name, size_t dir_len, const char *lc_name)
{
- char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
+ char dir[PATH_MAX], buf[PATH_MAX];
int i, n;
char *args[NUM_LOCALEDIR];
static char locale_alias[] = LOCALE_ALIAS;
- char *target_name = (char*)0;
- char *target_dir = (char*)0;
+ char *target_name = NULL;
+ char *target_dir = NULL;
char *nlc_name = NULL;
static char* last_dir_name = 0;
static size_t last_dir_len = 0;
@@ -729,6 +716,8 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
xlocalelibdir (dir, PATH_MAX);
n = _XlcParsePath(dir, args, 256);
for (i = 0; i < n; ++i) {
+ char *name = NULL;
+
if (args[i] == NULL)
continue;
@@ -743,18 +732,15 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
}
}
- /* If name is not an alias, use lc_name for locale.dir search */
- if (name == NULL)
- name = lc_name;
-
/* look at locale.dir */
target_dir = args[i];
if (snprintf(buf, PATH_MAX, "%s/locale.dir", target_dir) < PATH_MAX) {
- target_name = resolve_name(name, buf, RtoL);
+ /* If name is not an alias, use lc_name for locale.dir search */
+ target_name = resolve_name(name ? name : lc_name, buf, RtoL);
}
- if (name != lc_name)
- Xfree(name);
+ Xfree(name);
+ name = NULL;
if (target_name != NULL) {
char *p = 0;
if ((p = strstr(target_name, "/XLC_LOCALE"))) {
@@ -764,27 +750,15 @@ _XlcLocaleLibDirName(char *dir_name, size_t dir_len, char *lc_name)
Xfree(target_name);
target_name = NULL;
}
- name = NULL;
}
if (nlc_name) Xfree(nlc_name);
- if (target_name == NULL) {
+ if (target_name == NULL)
/* vendor locale name == Xlocale name, no expansion of alias */
- target_dir = args[0];
- target_name = lc_name;
- }
- /* snprintf(dir_name, dir_len, "%s/%", target_dir, target_name); */
- strncpy(dir_name, target_dir, dir_len - 1);
- if (strlen(target_dir) >= dir_len - 1) {
- dir_name[dir_len - 1] = '\0';
- } else {
- strcat(dir_name, "/");
- strncat(dir_name, target_name, dir_len - strlen(dir_name) - 1);
- if (strlen(target_name) >= dir_len - strlen(dir_name) - 1)
- dir_name[dir_len - 1] = '\0';
- }
- if (target_name != lc_name)
- Xfree(target_name);
+ snprintf(dir_name, dir_len, "%s/%s", args[0], lc_name);
+ else
+ snprintf(dir_name, dir_len, "%s/%s", target_dir, target_name);
+ Xfree(target_name);
if (last_dir_name != 0)
Xfree (last_dir_name);