C-style update: Unified comment, retvals in order, remove trailing spaces

Changed function name for `clicon_debug` functions
This commit is contained in:
Olof hagsand 2023-10-22 18:04:47 +02:00
parent 6e314dd96f
commit 62348fc9c7
204 changed files with 6047 additions and 4904 deletions

View file

@ -107,7 +107,7 @@ object.
#define _YYERROR(msg) {clicon_err(OE_JSON, 0, "YYERROR %s '%s' %d", (msg), clixon_json_parsetext, _JY->jy_linenum); YYERROR;}
/* add _yy to error parameters */
#define YY_(msgid) msgid
#define YY_(msgid) msgid
#include "clixon_config.h"
@ -137,7 +137,7 @@ object.
/* Enable for debugging, steals some cycles otherwise */
#if 0
#define _PARSE_DEBUG(s) clicon_debug(1,(s))
#define _PARSE_DEBUG(s) clixon_debug(1,(s))
#else
#define _PARSE_DEBUG(s)
#endif
@ -148,14 +148,14 @@ extern int clixon_json_parseget_lineno (void);
also called from yacc generated code *
*/
void
void
clixon_json_parseerror(void *_jy,
char *s)
char *s)
{
clicon_err(OE_JSON, 0, "json_parse: line %d: %s at or before: '%s'",
_JY->jy_linenum ,
s,
clixon_json_parsetext);
clicon_err(OE_JSON, 0, "json_parse: line %d: %s at or before: '%s'",
_JY->jy_linenum,
s,
clixon_json_parsetext);
if (_JY->jy_cbuf_str)
cbuf_free(_JY->jy_cbuf_str);
return;
@ -164,7 +164,7 @@ clixon_json_parseerror(void *_jy,
int
json_parse_init(clixon_json_yacc *jy)
{
// clicon_debug_init(2, NULL);
// clixon_debug_init(2, NULL);
return 0;
}
@ -173,8 +173,9 @@ json_parse_exit(clixon_json_yacc *jy)
{
return 0;
}
/*! Create xml object from json object name (eg "string")
*
* Split name into prefix:name (extended JSON RFC7951)
*/
static int
@ -186,7 +187,7 @@ json_current_new(clixon_json_yacc *jy,
char *prefix = NULL;
char *id = NULL;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
/* Find colon separator and if found split into prefix:name */
if (nodeid_split(name, &prefix, &id) < 0)
goto done;
@ -213,8 +214,8 @@ json_current_new(clixon_json_yacc *jy,
static int
json_current_pop(clixon_json_yacc *jy)
{
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if (jy->jy_current)
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if (jy->jy_current)
jy->jy_current = xml_parent(jy->jy_current);
return 0;
}
@ -224,7 +225,7 @@ json_current_clone(clixon_json_yacc *jy)
{
cxobj *xn;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if (jy->jy_current == NULL){
return -1;
}
@ -243,7 +244,6 @@ json_current_clone(clixon_json_yacc *jy)
maybe_prefixed_name = strdup(name);
}
json_current_new(jy, maybe_prefixed_name);
if (maybe_prefixed_name)
free(maybe_prefixed_name);
}
@ -251,31 +251,31 @@ json_current_clone(clixon_json_yacc *jy)
}
static int
json_current_body(clixon_json_yacc *jy,
json_current_body(clixon_json_yacc *jy,
char *value)
{
int retval = -1;
cxobj *xn;
clicon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
clixon_debug(CLIXON_DBG_DETAIL, "%s", __FUNCTION__);
if ((xn = xml_new("body", jy->jy_current, CX_BODY)) == NULL)
goto done;
goto done;
if (value && xml_value_append(xn, value) < 0)
goto done;
goto done;
retval = 0;
done:
return retval;
}
%}
%}
%%
/*
*/
/* top: json -> value is also possible */
json : value J_EOF { _PARSE_DEBUG("json->value"); YYACCEPT; }
json : value J_EOF { _PARSE_DEBUG("json->value"); YYACCEPT; }
;
value : J_TRUE { json_current_body(_JY, "true"); _PARSE_DEBUG("value->TRUE");}
@ -296,7 +296,7 @@ objlist : pair { _PARSE_DEBUG("objlist->pair");}
| objlist ',' pair { _PARSE_DEBUG("objlist->objlist , pair");}
;
pair : string { json_current_new(_JY, cbuf_get($1));cbuf_free($1); _JY->jy_cbuf_str = NULL;} ':'
pair : string { json_current_new(_JY, cbuf_get($1));cbuf_free($1); _JY->jy_cbuf_str = NULL;} ':'
value { json_current_pop(_JY);}{ _PARSE_DEBUG("pair->string : value");}
;
@ -325,7 +325,7 @@ ustring : ustring J_STRING
_JY->jy_cbuf_str = cb;
cbuf_append_str(cb,$1);
$$=cb;
}
}
;
number : J_NUMBER { $$ = $1; }