mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
conf: print quoted string more wisely
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
0ee4642a69
commit
8eaa03b7c9
1 changed files with 12 additions and 9 deletions
15
src/conf.c
15
src/conf.c
|
|
@ -1508,6 +1508,7 @@ static int parse_defs(snd_config_t *parent, input_t *input, int skip, int overri
|
||||||
|
|
||||||
static void string_print(char *str, int id, snd_output_t *out)
|
static void string_print(char *str, int id, snd_output_t *out)
|
||||||
{
|
{
|
||||||
|
int q;
|
||||||
unsigned char *p = (unsigned char *)str;
|
unsigned char *p = (unsigned char *)str;
|
||||||
if (!p || !*p) {
|
if (!p || !*p) {
|
||||||
snd_output_puts(out, "''");
|
snd_output_puts(out, "''");
|
||||||
|
|
@ -1549,7 +1550,8 @@ static void string_print(char *str, int id, snd_output_t *out)
|
||||||
snd_output_puts(out, str);
|
snd_output_puts(out, str);
|
||||||
return;
|
return;
|
||||||
quoted:
|
quoted:
|
||||||
snd_output_putc(out, '\'');
|
q = strchr(str, '\'') ? '"' : '\'';
|
||||||
|
snd_output_putc(out, q);
|
||||||
p = (unsigned char *)str;
|
p = (unsigned char *)str;
|
||||||
while (*p) {
|
while (*p) {
|
||||||
int c;
|
int c;
|
||||||
|
|
@ -1579,20 +1581,21 @@ static void string_print(char *str, int id, snd_output_t *out)
|
||||||
snd_output_putc(out, '\\');
|
snd_output_putc(out, '\\');
|
||||||
snd_output_putc(out, 'f');
|
snd_output_putc(out, 'f');
|
||||||
break;
|
break;
|
||||||
case '\'':
|
default:
|
||||||
|
if (c == q) {
|
||||||
snd_output_putc(out, '\\');
|
snd_output_putc(out, '\\');
|
||||||
snd_output_putc(out, c);
|
snd_output_putc(out, c);
|
||||||
break;
|
} else {
|
||||||
default:
|
if (c >= 32 && c <= 126)
|
||||||
if (c >= 32 && c <= 126 && c != '\'')
|
|
||||||
snd_output_putc(out, c);
|
snd_output_putc(out, c);
|
||||||
else
|
else
|
||||||
snd_output_printf(out, "\\%04o", c);
|
snd_output_printf(out, "\\%04o", c);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
snd_output_putc(out, '\'');
|
snd_output_putc(out, q);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void level_print(snd_output_t *out, unsigned int level)
|
static void level_print(snd_output_t *out, unsigned int level)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue