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

Function regerror

compat/regex/regcomp.c:553–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551#endif
552
553/* Returns a message corresponding to an error code, ERRCODE, returned
554 from either regcomp or regexec. We don't use PREG here. */
555
556size_t
557regerror(int errcode, const regex_t *__restrict preg,
558 char *__restrict errbuf, size_t errbuf_size)
559{
560 const char *msg;
561 size_t msg_size;
562
563 if (BE (errcode < 0
564 || errcode >= (int) (sizeof (__re_error_msgid_idx)
565 / sizeof (__re_error_msgid_idx[0])), 0))
566 /* Only error codes returned by the rest of the code should be passed
567 to this routine. If we are given anything else, or if other regex
568 code generates an invalid error code, then the program has a bug.
569 Dump core so we can fix it. */
570 abort ();
571
572 msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
573
574 msg_size = strlen (msg) + 1; /* Includes the null. */
575
576 if (BE (errbuf_size != 0, 1))
577 {
578 if (BE (msg_size > errbuf_size, 0))
579 {
580 memcpy (errbuf, msg, errbuf_size - 1);
581 errbuf[errbuf_size - 1] = 0;
582 }
583 else
584 memcpy (errbuf, msg, msg_size);
585 }
586
587 return msg_size;
588}

Callers 8

compile_fixed_regexpFunction · 0.85
compile_regexpFunction · 0.85
parse_locFunction · 0.85
parse_range_funcnameFunction · 0.85
regcomp_or_dieFunction · 0.85
patch_update_fileFunction · 0.85
cmd__regexFunction · 0.85

Calls

no outgoing calls

Tested by 1

cmd__regexFunction · 0.68