diff options
author | Tim Potter <tpot@samba.org> | 2003-09-26 01:24:09 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2003-09-26 01:24:09 +0000 |
commit | f83d4ba428f585698d53b0f1f928714ef14ff4f0 (patch) | |
tree | 308a8054696e878ff0ec5466b16de007eb1a9011 /source3/intl | |
parent | dc5ba6c819d6e2428dec8b149410ebfd4fcfc573 (diff) | |
download | samba-f83d4ba428f585698d53b0f1f928714ef14ff4f0.tar.gz samba-f83d4ba428f585698d53b0f1f928714ef14ff4f0.tar.bz2 samba-f83d4ba428f585698d53b0f1f928714ef14ff4f0.zip |
Allow d_printf() to handle strings with escaped quotation marks since the
msg file includes the escape character.
Fixes bug #489.
(This used to be commit 8ce279e47184623e74f795294ffba842e4f2e848)
Diffstat (limited to 'source3/intl')
-rw-r--r-- | source3/intl/lang_tdb.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c index 5409ce6619..af70b529ff 100644 --- a/source3/intl/lang_tdb.c +++ b/source3/intl/lang_tdb.c @@ -176,16 +176,47 @@ BOOL lang_tdb_init(const char *lang) const char *lang_msg(const char *msgid) { TDB_DATA key, data; + char *p, *q, *msgid_quoted; + int count; lang_tdb_init(NULL); if (!tdb) return msgid; - key.dptr = (char *)msgid; - key.dsize = strlen(msgid)+1; + /* Due to the way quotes in msgids are escaped in the msg file we + must replace " with \" before doing a lookup in the tdb. */ + + count = 0; + + for(p = msgid; *p; p++) { + if (*p == '\"') + count++; + } + + if (!(msgid_quoted = malloc(strlen(msgid) + count + 1))) + return msgid; + + /* string_sub() is unsuitable here as it replaces some punctuation + chars with underscores. */ + + for(p = msgid, q = msgid_quoted; *p; p++) { + if (*p == '\"') { + *q = '\\'; + q++; + } + *q = *p; + q++; + } + + *q = 0; + + key.dptr = (char *)msgid_quoted; + key.dsize = strlen(msgid_quoted)+1; data = tdb_fetch(tdb, key); + free(msgid_quoted); + /* if the message isn't found then we still need to return a pointer that can be freed. Pity. */ if (!data.dptr) |