mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
conf-parser: make use of pa_strip() wherever applicable
This commit is contained in:
parent
f1af7a02d1
commit
0c7c9653b1
1 changed files with 2 additions and 29 deletions
|
|
@ -73,33 +73,6 @@ static int next_assignment(
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns non-zero when c is contained in s */
|
|
||||||
static int in_string(char c, const char *s) {
|
|
||||||
pa_assert(s);
|
|
||||||
|
|
||||||
for (; *s; s++)
|
|
||||||
if (*s == c)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove all whitepsapce from the beginning and the end of *s. *s may
|
|
||||||
* be modified. */
|
|
||||||
static char *strip(char *s) {
|
|
||||||
char *b = s+strspn(s, WHITESPACE);
|
|
||||||
char *e, *l = NULL;
|
|
||||||
|
|
||||||
for (e = b; *e; e++)
|
|
||||||
if (!in_string(*e, WHITESPACE))
|
|
||||||
l = e;
|
|
||||||
|
|
||||||
if (l)
|
|
||||||
*(l+1) = 0;
|
|
||||||
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse a variable assignment line */
|
/* Parse a variable assignment line */
|
||||||
static int parse_line(const char *filename, unsigned line, char **section, const pa_config_item *t, char *l, void *userdata) {
|
static int parse_line(const char *filename, unsigned line, char **section, const pa_config_item *t, char *l, void *userdata) {
|
||||||
char *e, *c, *b;
|
char *e, *c, *b;
|
||||||
|
|
@ -116,7 +89,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
|
||||||
char *path = NULL, *fn;
|
char *path = NULL, *fn;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
fn = strip(b+9);
|
fn = pa_strip(b+9);
|
||||||
if (!pa_is_path_absolute(fn)) {
|
if (!pa_is_path_absolute(fn)) {
|
||||||
const char *k;
|
const char *k;
|
||||||
if ((k = strrchr(filename, '/'))) {
|
if ((k = strrchr(filename, '/'))) {
|
||||||
|
|
@ -155,7 +128,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
|
||||||
*e = 0;
|
*e = 0;
|
||||||
e++;
|
e++;
|
||||||
|
|
||||||
return next_assignment(filename, line, *section, t, strip(b), strip(e), userdata);
|
return next_assignment(filename, line, *section, t, pa_strip(b), pa_strip(e), userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Go through the file and parse each line */
|
/* Go through the file and parse each line */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue