mirror of
https://github.com/mpv-player/mpv
synced 2025-04-21 06:42:49 +00:00
cosmetics: parser-cfg.c: reformat
This commit is contained in:
parent
507fa7e2c2
commit
d8374376c0
52
parser-cfg.c
52
parser-cfg.c
@ -16,14 +16,6 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// \defgroup ConfigParsers Config parsers
|
|
||||||
///
|
|
||||||
/// The \ref ConfigParsers make use of the \ref Config to setup the config variables,
|
|
||||||
/// the command line parsers also build the playlist.
|
|
||||||
///@{
|
|
||||||
|
|
||||||
/// \file
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -31,10 +23,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifdef MP_DEBUG
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "parser-cfg.h"
|
#include "parser-cfg.h"
|
||||||
#include "mp_msg.h"
|
#include "mp_msg.h"
|
||||||
@ -73,14 +62,11 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
int prev_mode = config->mode;
|
int prev_mode = config->mode;
|
||||||
m_profile_t *profile = NULL;
|
m_profile_t *profile = NULL;
|
||||||
|
|
||||||
#ifdef MP_DEBUG
|
|
||||||
assert(config != NULL);
|
|
||||||
// assert(conf_list != NULL);
|
|
||||||
#endif
|
|
||||||
mp_msg(MSGT_CFGPARSER, MSGL_V, "Reading config file %s", conffile);
|
mp_msg(MSGT_CFGPARSER, MSGL_V, "Reading config file %s", conffile);
|
||||||
|
|
||||||
if (recursion_depth > MAX_RECURSION_DEPTH) {
|
if (recursion_depth > MAX_RECURSION_DEPTH) {
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_ERR,": too deep 'include'. check your configfiles\n");
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
|
": too deep 'include'. check your configfiles\n");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
} else
|
} else
|
||||||
@ -88,7 +74,8 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
config->mode = M_CONFIG_FILE;
|
config->mode = M_CONFIG_FILE;
|
||||||
|
|
||||||
if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) {
|
if ((line = malloc(MAX_LINE_LEN + 1)) == NULL) {
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_FATAL,"\ncan't get memory for 'line': %s", strerror(errno));
|
mp_msg(MSGT_CFGPARSER, MSGL_FATAL,
|
||||||
|
"\ncan't get memory for 'line': %s", strerror(errno));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
} else
|
} else
|
||||||
@ -127,7 +114,8 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
opt[opt_pos++] = line[line_pos++];
|
opt[opt_pos++] = line[line_pos++];
|
||||||
if (opt_pos >= MAX_OPT_LEN) {
|
if (opt_pos >= MAX_OPT_LEN) {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long option at line %d\n",line_num);
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
|
"too long option at line %d\n", line_num);
|
||||||
errors++;
|
errors++;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto nextline;
|
goto nextline;
|
||||||
@ -135,7 +123,8 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
}
|
}
|
||||||
if (opt_pos == 0) {
|
if (opt_pos == 0) {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_ERR,"parse error at line %d\n",line_num);
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parse error at line %d\n",
|
||||||
|
line_num);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
@ -164,7 +153,8 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
/* check '=' */
|
/* check '=' */
|
||||||
if (line[line_pos++] != '=') {
|
if (line[line_pos++] != '=') {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s needs a parameter at line %d\n",opt,line_num);
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
|
"Option %s needs a parameter at line %d\n", opt, line_num);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
@ -182,7 +172,9 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
param[param_pos++] = line[line_pos++];
|
param[param_pos++] = line[line_pos++];
|
||||||
if (param_pos >= MAX_PARAM_LEN) {
|
if (param_pos >= MAX_PARAM_LEN) {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s has a too long parameter at line %d\n",opt,line_num);
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
|
"Option %s has a too long parameter at line %d\n",
|
||||||
|
opt, line_num);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
errors++;
|
errors++;
|
||||||
goto nextline;
|
goto nextline;
|
||||||
@ -190,7 +182,8 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
}
|
}
|
||||||
line_pos++; /* skip the closing " or ' */
|
line_pos++; /* skip the closing " or ' */
|
||||||
} else {
|
} else {
|
||||||
for (param_pos = 0; isprint(line[line_pos]) && !isspace(line[line_pos])
|
for (param_pos = 0; isprint(line[line_pos])
|
||||||
|
&& !isspace(line[line_pos])
|
||||||
&& line[line_pos] != '#'; /* NOTHING */) {
|
&& line[line_pos] != '#'; /* NOTHING */) {
|
||||||
param[param_pos++] = line[line_pos++];
|
param[param_pos++] = line[line_pos++];
|
||||||
if (param_pos >= MAX_PARAM_LEN) {
|
if (param_pos >= MAX_PARAM_LEN) {
|
||||||
@ -207,7 +200,8 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
/* did we read a parameter? */
|
/* did we read a parameter? */
|
||||||
if (param_pos == 0) {
|
if (param_pos == 0) {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s needs a parameter at line %d\n",opt,line_num);
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
|
"Option %s needs a parameter at line %d\n", opt, line_num);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
@ -226,7 +220,9 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
/* EOL / comment */
|
/* EOL / comment */
|
||||||
if (line[line_pos] != '\0' && line[line_pos] != '#') {
|
if (line[line_pos] != '\0' && line[line_pos] != '#') {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_WARN,"extra characters on line %d: %s\n",line_num, line+line_pos);
|
mp_msg(MSGT_CFGPARSER, MSGL_WARN,
|
||||||
|
"extra characters on line %d: %s\n",
|
||||||
|
line_num, line + line_pos);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,10 +237,14 @@ int m_config_parse_config_file(m_config_t* config, const char *conffile)
|
|||||||
if (tmp < 0) {
|
if (tmp < 0) {
|
||||||
PRINT_LINENUM;
|
PRINT_LINENUM;
|
||||||
if (tmp == M_OPT_UNKNOWN) {
|
if (tmp == M_OPT_UNKNOWN) {
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_WARN,"Warning unknown option %s at line %d\n", opt,line_num);
|
mp_msg(MSGT_CFGPARSER, MSGL_WARN,
|
||||||
|
"Warning unknown option %s at line %d\n",
|
||||||
|
opt, line_num);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Error parsing option %s=%s at line %d\n",opt,param,line_num);
|
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
|
||||||
|
"Error parsing option %s=%s at line %d\n",
|
||||||
|
opt, param, line_num);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
errors++;
|
errors++;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user