mirror of
https://github.com/samba-team/samba.git
synced 2025-02-04 17:47:26 +03:00
Merge from 3.0:
>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 0871be2bfad8bfa5d4f0ff78e732c1073055da2e)
This commit is contained in:
parent
cd5c595ccd
commit
981c82b16e
@ -176,16 +176,47 @@ BOOL lang_tdb_init(const char *lang)
|
|||||||
const char *lang_msg(const char *msgid)
|
const char *lang_msg(const char *msgid)
|
||||||
{
|
{
|
||||||
TDB_DATA key, data;
|
TDB_DATA key, data;
|
||||||
|
char *p, *q, *msgid_quoted;
|
||||||
|
int count;
|
||||||
|
|
||||||
lang_tdb_init(NULL);
|
lang_tdb_init(NULL);
|
||||||
|
|
||||||
if (!tdb) return msgid;
|
if (!tdb) return msgid;
|
||||||
|
|
||||||
key.dptr = (char *)msgid;
|
/* Due to the way quotes in msgids are escaped in the msg file we
|
||||||
key.dsize = strlen(msgid)+1;
|
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);
|
data = tdb_fetch(tdb, key);
|
||||||
|
|
||||||
|
free(msgid_quoted);
|
||||||
|
|
||||||
/* if the message isn't found then we still need to return a pointer
|
/* if the message isn't found then we still need to return a pointer
|
||||||
that can be freed. Pity. */
|
that can be freed. Pity. */
|
||||||
if (!data.dptr)
|
if (!data.dptr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user