mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
conf: improve the tabulator level prints
Do not use per char loop, but compose a string. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
829fbf5065
commit
5766e54fbe
1 changed files with 10 additions and 8 deletions
18
src/conf.c
18
src/conf.c
|
|
@ -1595,6 +1595,14 @@ static void string_print(char *str, int id, snd_output_t *out)
|
||||||
snd_output_putc(out, '\'');
|
snd_output_putc(out, '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void level_print(snd_output_t *out, unsigned int level)
|
||||||
|
{
|
||||||
|
char a[level + 1];
|
||||||
|
memset(a, '\t', level);
|
||||||
|
a[level] = '\0';
|
||||||
|
snd_output_puts(out, a);
|
||||||
|
}
|
||||||
|
|
||||||
static int _snd_config_save_children(snd_config_t *config, snd_output_t *out,
|
static int _snd_config_save_children(snd_config_t *config, snd_output_t *out,
|
||||||
unsigned int level, unsigned int joins);
|
unsigned int level, unsigned int joins);
|
||||||
|
|
||||||
|
|
@ -1602,7 +1610,6 @@ static int _snd_config_save_node_value(snd_config_t *n, snd_output_t *out,
|
||||||
unsigned int level)
|
unsigned int level)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
unsigned int k;
|
|
||||||
switch (n->type) {
|
switch (n->type) {
|
||||||
case SND_CONFIG_TYPE_INTEGER:
|
case SND_CONFIG_TYPE_INTEGER:
|
||||||
snd_output_printf(out, "%ld", n->u.integer);
|
snd_output_printf(out, "%ld", n->u.integer);
|
||||||
|
|
@ -1625,9 +1632,7 @@ static int _snd_config_save_node_value(snd_config_t *n, snd_output_t *out,
|
||||||
err = _snd_config_save_children(n, out, level + 1, 0);
|
err = _snd_config_save_children(n, out, level + 1, 0);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
for (k = 0; k < level; ++k) {
|
level_print(out, level);
|
||||||
snd_output_putc(out, '\t');
|
|
||||||
}
|
|
||||||
snd_output_putc(out, '}');
|
snd_output_putc(out, '}');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1647,7 +1652,6 @@ static void id_print(snd_config_t *n, snd_output_t *out, unsigned int joins)
|
||||||
static int _snd_config_save_children(snd_config_t *config, snd_output_t *out,
|
static int _snd_config_save_children(snd_config_t *config, snd_output_t *out,
|
||||||
unsigned int level, unsigned int joins)
|
unsigned int level, unsigned int joins)
|
||||||
{
|
{
|
||||||
unsigned int k;
|
|
||||||
int err;
|
int err;
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
assert(config && out);
|
assert(config && out);
|
||||||
|
|
@ -1660,9 +1664,7 @@ static int _snd_config_save_children(snd_config_t *config, snd_output_t *out,
|
||||||
return err;
|
return err;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (k = 0; k < level; ++k) {
|
level_print(out, level);
|
||||||
snd_output_putc(out, '\t');
|
|
||||||
}
|
|
||||||
id_print(n, out, joins);
|
id_print(n, out, joins);
|
||||||
#if 0
|
#if 0
|
||||||
snd_output_putc(out, ' ');
|
snd_output_putc(out, ' ');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue