summaryrefslogtreecommitdiff
path: root/source3/intl
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-09-24 02:46:59 +0000
committerTim Potter <tpot@samba.org>2003-09-24 02:46:59 +0000
commit43004ba8830874a8ab02bc755b1e99160af982b5 (patch)
tree55fd275ddd79c41eea0b895e7345ff5b24e26726 /source3/intl
parent238cac9581bb24555bfe8e4d5724c03e9594447b (diff)
downloadsamba-43004ba8830874a8ab02bc755b1e99160af982b5.tar.gz
samba-43004ba8830874a8ab02bc755b1e99160af982b5.tar.bz2
samba-43004ba8830874a8ab02bc755b1e99160af982b5.zip
Another round of merges from 3.0:
>Fix return of result. Patch from Yasuma Takeda <yasuma@miraclelinux.com> >Jeremy. >Applied Monyo's patch for bug #412 which allows \n characters to >appear in msg strings. >Put in some DEBUGs for swat language selection. Part of bug 456. (This used to be commit 0105b72db85141da30746c06ad7f5cec15bf9640)
Diffstat (limited to 'source3/intl')
-rw-r--r--source3/intl/lang_tdb.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c
index f12b9b6f15..5409ce6619 100644
--- a/source3/intl/lang_tdb.c
+++ b/source3/intl/lang_tdb.c
@@ -58,6 +58,8 @@ static BOOL load_msg(const char *msg_file)
if (*msgstr == 0) {
msgstr = msgid;
}
+ all_string_sub(msgid, "\\n", "\n", 0);
+ all_string_sub(msgstr, "\\n", "\n", 0);
key.dptr = msgid;
key.dsize = strlen(msgid)+1;
data.dptr = msgstr;
@@ -99,10 +101,12 @@ BOOL lang_tdb_init(const char *lang)
struct stat st;
static int initialised;
time_t loadtime;
+ BOOL result = False;
/* we only want to init once per process, unless given
an override */
- if (initialised && !lang) return True;
+ if (initialised && !lang)
+ return True;
if (initialised) {
/* we are re-initialising, free up any old init */
@@ -121,41 +125,49 @@ BOOL lang_tdb_init(const char *lang)
}
/* if no lang then we don't translate */
- if (!lang) return True;
+ if (!lang)
+ return True;
asprintf(&msg_path, "%s.msg", lib_path((const char *)lang));
if (stat(msg_path, &st) != 0) {
/* the msg file isn't available */
- free(msg_path);
- return False;
+ DEBUG(10, ("lang_tdb_init: %s: %s", msg_path,
+ strerror(errno)));
+ goto done;
}
-
asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang);
+ DEBUG(10, ("lang_tdb_init: loading %s\n", path));
+
tdb = tdb_open_log(path, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644);
if (!tdb) {
tdb = tdb_open_log(path, 0, TDB_DEFAULT, O_RDONLY, 0);
- free(path);
- free(msg_path);
- if (!tdb) return False;
+ if (!tdb) {
+ DEBUG(10, ("lang_tdb_init: %s: %s\n", path,
+ strerror(errno)));
+ goto done;
+ }
current_lang = strdup(lang);
- return True;
+ result = True;
+ goto done;
}
- free(path);
-
loadtime = tdb_fetch_int32(tdb, "/LOADTIME/");
if (loadtime == -1 || loadtime < st.st_mtime) {
load_msg(msg_path);
tdb_store_int32(tdb, "/LOADTIME/", (int)time(NULL));
}
- free(msg_path);
current_lang = strdup(lang);
+ result = True;
- return True;
+ done:
+ SAFE_FREE(msg_path);
+ SAFE_FREE(path);
+
+ return result;
}
/* translate a msgid to a message string in the current language