Multiple nested greedy quantifiers can cause to increase complexity of
the regular expression so that the matching in the cmock_header_parser
would take multiple minutes.
Fixed by removing one of the quantifiers that seems not to be needed.
If an option is passed via CLI, it cannot be passed with an
empty value because the Regex makes it to match 1 or more
characters.
For example, arguments `--mock_prefix=""` and `--mock_prefix=`
are invalid, because they don't match the regex and are not
recognized as options, so they're treated as files to mock.
Changing the regex to match 0 or more characters for the option
value, instead of 1 or more, solves the problem.
This reverts commit 7fbeb40965.
This causes compilation warnings / errors when a project uses
-Wmissing-prototypes compilation flags for safety reasons:
.../test/mocks/mock_logMessages.c:685:6: warning: no previous prototype for ‘CMockExpectParameters_log_message’ [-Wmissing-prototypes]
685 | void CMockExpectParameters_log_message(CMOCK_log_message_CALL_INSTANCE* cmock_call_instance, const char* logMessage, int messageID, severity_t severityIn)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
etc.
Signed-off-by: André Draszik <git@andred.net>
Compiling a source base / test with Wsign-conversion enabled, gives
the following warning:
build/test/mocks/mock_logMessages.c: In function ‘countLogMessages’:
build/test/mocks/mock_logMessages.c:749:26: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
749 | cmock_call_instance->ReturnThruPtr_fileIn_Size);
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
The ReturnThruPtr_XXX_Size is used as argument to a call to memcpy(),
which expects size_t (unsigned) for a good reason. The size leading
to this call is being determined using sizeof(), so there appears
no reason to ever convert this to (signed) int.
Stop converting size_t to int, and thereby fix the compiler
warning.
Signed-off-by: André Draszik <git@andred.net>