MCPcopy Create free account
hub / github.com/coreboot/coreboot / regerror

Function regerror

util/kconfig/regex.c:4872–4911  ·  view source on GitHub ↗
(errcode, preg, errbuf, errbuf_size)

Source from the content-addressed store, hash-verified

4870 from either regcomp or regexec. We don't use PREG here. */
4871
4872size_t
4873regerror (errcode, preg, errbuf, errbuf_size)
4874 int errcode;
4875 const regex_t *preg;
4876 char *errbuf;
4877 size_t errbuf_size;
4878{
4879 const char *msg;
4880 size_t msg_size;
4881
4882 if (errcode < 0
4883 || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0])))
4884 /* Only error codes returned by the rest of the code should be passed
4885 to this routine. If we are given anything else, or if other regex
4886 code generates an invalid error code, then the program has a bug.
4887 Dump core so we can fix it. */
4888 abort ();
4889
4890 msg = re_error_msg[errcode];
4891
4892 /* POSIX doesn't require that we do anything in this case, but why
4893 not be nice. */
4894 if (! msg)
4895 msg = "Success";
4896
4897 msg_size = strlen (msg) + 1; /* Includes the null. */
4898
4899 if (errbuf_size != 0)
4900 {
4901 if (msg_size > errbuf_size)
4902 {
4903 strncpy (errbuf, msg, errbuf_size - 1);
4904 errbuf[errbuf_size - 1] = 0;
4905 }
4906 else
4907 strcpy (errbuf, msg);
4908 }
4909
4910 return msg_size;
4911}
4912
4913
4914/* Free dynamically allocated space used by PREG. */

Callers 2

compile_reg_exprFunction · 0.85
compile_reg_exprFunction · 0.85

Calls 4

strlenFunction · 0.85
abortFunction · 0.50
strncpyFunction · 0.50
strcpyFunction · 0.50

Tested by

no test coverage detected