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

Function re_comp

compat/regex/regcomp.c:689–734  ·  view source on GitHub ↗

Make these definitions weak in libc, so POSIX programs can redefine these names if they don't use our functions, and still use regcomp/regexec above without link errors. */

(s)

Source from the content-addressed store, hash-verified

687
688char *
689# ifdef _LIBC
690/* Make these definitions weak in libc, so POSIX programs can redefine
691 these names if they don't use our functions, and still use
692 regcomp/regexec above without link errors. */
693weak_function
694# endif
695re_comp (s)
696 const char *s;
697{
698 reg_errcode_t ret;
699 char *fastmap;
700
701 if (!s)
702 {
703 if (!re_comp_buf.buffer)
704 return gettext ("No previous regular expression");
705 return 0;
706 }
707
708 if (re_comp_buf.buffer)
709 {
710 fastmap = re_comp_buf.fastmap;
711 re_comp_buf.fastmap = NULL;
712 __regfree (&re_comp_buf);
713 memset (&re_comp_buf, '\0', sizeof (re_comp_buf));
714 re_comp_buf.fastmap = fastmap;
715 }
716
717 if (re_comp_buf.fastmap == NULL)
718 {
719 re_comp_buf.fastmap = (char *) malloc (SBC_MAX);
720 if (re_comp_buf.fastmap == NULL)
721 return (char *) gettext (__re_error_msgid
722 + __re_error_msgid_idx[(int) REG_ESPACE]);
723 }
724
725 /* Since `re_exec' always passes NULL for the `regs' argument, we
726 don't need to initialize the pattern buffer fields which affect it. */
727
728 /* Match anchors at newlines. */
729 re_comp_buf.newline_anchor = 1;
730
731 ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options);
732
733 if (!ret)
734 return NULL;
735
736 /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
737 return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);

Callers

nothing calls this directly

Calls 1

re_compile_internalFunction · 0.85

Tested by

no test coverage detected