- fix: added error detection for block removal error (error in one file influenced evaluation in following files)
This commit is contained in:
@@ -53,7 +53,7 @@ STATIC char* main_outputDir = NULL;
|
||||
int evaluateEntry(const char *filepath, const struct stat *info, const int typeflag, struct FTW *pathinfo)
|
||||
{
|
||||
regmatch_t matchGroup[MAIN_MAX_MATCHGROUP_FILENAME];
|
||||
char* noSuffix = NULL;
|
||||
char *noSuffix = NULL;
|
||||
if (!main_recurse && 1 < pathinfo->level)
|
||||
{
|
||||
return 0;
|
||||
|
@@ -45,6 +45,11 @@ STATIC regex_t regXproto;
|
||||
STATIC regex_t regXprefix;
|
||||
STATIC regex_t regXparameter;
|
||||
|
||||
// line evaluation related variables
|
||||
STATIC uint32_t cfile_parser_removeCommentHelper = 0;
|
||||
STATIC uint32_t cfile_parser_removeBraceHelper = 0;
|
||||
STATIC char *cfile_parser_parameterStorage = NULL;
|
||||
|
||||
int8_t cfile_parser_init()
|
||||
{
|
||||
if (0 > regcomp(®X, FUNCTION_BASE, (REG_EXTENDED | REG_NEWLINE)))
|
||||
@@ -398,7 +403,6 @@ STATIC int8_t cBlockRemoval(char *aLine, const char *aBlockStart, const char *aB
|
||||
*/
|
||||
STATIC int8_t removeCcomments(char *aLine)
|
||||
{
|
||||
static uint32_t helper = 0;
|
||||
char *comment = NULL;
|
||||
|
||||
if (NULL == aLine)
|
||||
@@ -415,7 +419,7 @@ STATIC int8_t removeCcomments(char *aLine)
|
||||
comment = NULL;
|
||||
}
|
||||
|
||||
return cBlockRemoval(aLine, CPARS_COMMENT_BLOCK_START, CPARS_COMMENT_BLOCK_END, &helper, true);
|
||||
return cBlockRemoval(aLine, CPARS_COMMENT_BLOCK_START, CPARS_COMMENT_BLOCK_END, &cfile_parser_removeCommentHelper, true);
|
||||
}
|
||||
|
||||
STATIC int8_t evaluateParameter(char *aParameter, cfunction_t *aFunction)
|
||||
@@ -467,8 +471,6 @@ STATIC int8_t evaluateParameter(char *aParameter, cfunction_t *aFunction)
|
||||
*/
|
||||
STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
{
|
||||
static char *parameterStorage = NULL;
|
||||
static uint32_t braceHelper = 0;
|
||||
const size_t maxGroup = CFILE_PARSER_MAX_REGEX_MATCHING_GROUPS;
|
||||
regmatch_t matchGroup[maxGroup];
|
||||
bool functionEnd = false;
|
||||
@@ -478,7 +480,7 @@ STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (0 != cBlockRemoval(aLine, "{", "}", &braceHelper, false))
|
||||
if (0 != cBlockRemoval(aLine, "{", "}", &cfile_parser_removeBraceHelper, false))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -571,7 +573,7 @@ STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
xmallocStrlcpy(&cfile_parser_function->name, &aLine[matchGroup[2].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 2));
|
||||
if (XREGEX_IS_MATCHGROUP(matchGroup, 3))
|
||||
{
|
||||
xmallocStrlcat(¶meterStorage, &aLine[matchGroup[3].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 3));
|
||||
xmallocStrlcat(&cfile_parser_parameterStorage, &aLine[matchGroup[3].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 3));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -579,7 +581,7 @@ STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
{
|
||||
if (XREGEX_IS_MATCHGROUP(matchGroup, 1))
|
||||
{
|
||||
xmallocStrlcat(¶meterStorage, &aLine[matchGroup[1].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 1));
|
||||
xmallocStrlcat(&cfile_parser_parameterStorage, &aLine[matchGroup[1].rm_so], XREGEX_SIZEOF_MATCHGROUP(matchGroup, 1));
|
||||
}
|
||||
if (functionEnd)
|
||||
{
|
||||
@@ -601,9 +603,9 @@ STATIC cfunction_t* cfile_parser_evaluateLine(char *aLine)
|
||||
// return evaluated function
|
||||
if (0 == cfile_parser_functionLine)
|
||||
{
|
||||
evaluateParameter(parameterStorage, cfile_parser_function);
|
||||
free(parameterStorage);
|
||||
parameterStorage = NULL;
|
||||
evaluateParameter(cfile_parser_parameterStorage, cfile_parser_function);
|
||||
free(cfile_parser_parameterStorage);
|
||||
cfile_parser_parameterStorage = NULL;
|
||||
cfunction_t *funTemp = cfile_parser_function;
|
||||
cfile_parser_function = NULL;
|
||||
return funTemp;
|
||||
@@ -648,5 +650,25 @@ int8_t cfile_parser(char *aPath, cfunction_list_t *aList)
|
||||
|
||||
free(fileLine);
|
||||
(void) fclose(fdesc);
|
||||
|
||||
// error detection for block removal
|
||||
if (0 != cfile_parser_removeCommentHelper || 0 != cfile_parser_removeBraceHelper)
|
||||
{
|
||||
DEBUG_LOG_APPEND(1, "Helper (%d/%d) %s %s\n", cfile_parser_removeCommentHelper, cfile_parser_removeBraceHelper, gnu_basename(aPath),
|
||||
cfile_parser_parameterStorage);
|
||||
cfile_parser_removeCommentHelper = 0;
|
||||
cfile_parser_removeBraceHelper = 0;
|
||||
return -2;
|
||||
}
|
||||
|
||||
// error detection for function parameter detection
|
||||
if (NULL != cfile_parser_parameterStorage)
|
||||
{
|
||||
DEBUG_LOG_APPEND(1, "Function parameter not free: %s\n", cfile_parser_parameterStorage);
|
||||
free(cfile_parser_parameterStorage);
|
||||
cfile_parser_parameterStorage = NULL;
|
||||
return -3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -277,6 +277,14 @@ int stubser_createStub(char *path, char* aNoSuffix, char *aOutput)
|
||||
if (0 != ret)
|
||||
{
|
||||
printf(STUB_CONSOLE_PARSE_ERROR_S2, gnu_basename(path), ret);
|
||||
if (-2 == ret)
|
||||
{
|
||||
printf(" Block removal error\n");
|
||||
}
|
||||
else if (-3 == ret)
|
||||
{
|
||||
printf(" Function parameter detection error\n");
|
||||
}
|
||||
ret = -1;
|
||||
goto end_stubser_createStub;
|
||||
}
|
||||
|
Reference in New Issue
Block a user