Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
bc0fec0a
Commit
bc0fec0a
authored
Sep 09, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: move duplicate check to _read_name_value()
config_add_block_param() cannot fail, which makes it easier to use.
parent
e3eca82c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
17 deletions
+16
-17
conf.c
src/conf.c
+13
-14
conf.h
src/conf.h
+2
-2
run_encoder.c
test/run_encoder.c
+1
-1
No files found.
src/conf.c
View file @
bc0fec0a
...
...
@@ -223,20 +223,13 @@ void config_global_check(void)
}
}
bool
void
config_add_block_param
(
struct
config_param
*
param
,
const
char
*
name
,
const
char
*
value
,
int
line
,
GError
**
error_r
)
const
char
*
value
,
int
line
)
{
struct
block_param
*
bp
;
bp
=
config_get_block_param
(
param
,
name
);
if
(
bp
!=
NULL
)
{
g_set_error
(
error_r
,
config_quark
(),
0
,
"
\"
%s
\"
first defined on line %i, and "
"redefined on line %i
\n
"
,
name
,
bp
->
line
,
line
);
return
false
;
}
assert
(
config_get_block_param
(
param
,
name
)
==
NULL
);
param
->
num_block_params
++
;
...
...
@@ -250,8 +243,6 @@ config_add_block_param(struct config_param * param, const char *name,
bp
->
value
=
g_strdup
(
value
);
bp
->
line
=
line
;
bp
->
used
=
false
;
return
true
;
}
static
bool
...
...
@@ -283,8 +274,16 @@ config_read_name_value(struct config_param *param, char *input, unsigned line,
return
false
;
}
return
config_add_block_param
(
param
,
name
,
value
,
line
,
error_r
);
const
struct
block_param
*
bp
=
config_get_block_param
(
param
,
name
);
if
(
bp
!=
NULL
)
{
g_set_error
(
error_r
,
config_quark
(),
0
,
"
\"
%s
\"
is duplicate, first defined on line %i"
,
name
,
bp
->
line
);
return
false
;
}
config_add_block_param
(
param
,
name
,
value
,
line
);
return
true
;
}
static
struct
config_param
*
...
...
src/conf.h
View file @
bc0fec0a
...
...
@@ -210,8 +210,8 @@ G_GNUC_MALLOC
struct
config_param
*
config_new_param
(
const
char
*
value
,
int
line
);
bool
void
config_add_block_param
(
struct
config_param
*
param
,
const
char
*
name
,
const
char
*
value
,
int
line
,
GError
**
error_r
);
const
char
*
value
,
int
line
);
#endif
test/run_encoder.c
View file @
bc0fec0a
...
...
@@ -75,7 +75,7 @@ int main(int argc, char **argv)
}
param
=
config_new_param
(
NULL
,
-
1
);
config_add_block_param
(
param
,
"quality"
,
"5.0"
,
-
1
,
NULL
);
config_add_block_param
(
param
,
"quality"
,
"5.0"
,
-
1
);
encoder
=
encoder_init
(
plugin
,
param
,
&
error
);
if
(
encoder
==
NULL
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment