Skip to content

Commit

Permalink
gnulib: make use of regex module
Browse files Browse the repository at this point in the history
basically followed the output of gnulib-tool;

$ gnulib-tool --source-base=gnulib --no-vc-files --import regex
Module list with included dependencies (indented):
...
You may need to add #include directives for the following .h files.
  #include <regex.h>

You may need to use the following Makefile variables when linking.
Use them in <program>_LDADD when linking a program, or
in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.
  $(LIBTHREAD)
  $(LIB_HARD_LOCALE)
  $(LIB_MBRTOWC)
  $(LIB_SETLOCALE_NULL)
  $(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise

Don't forget to
  - add "gnulib/Makefile" to AC_CONFIG_FILES in ./configure.ac,
  - mention "gnulib" in SUBDIRS in Makefile.am,
  - mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am,
  - mention "m4/gnulib-cache.m4" in EXTRA_DIST in Makefile.am,
  - replace AC_PROG_CC_C99 with AC_PROG_CC in ./configure.ac,
  - invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC_C99,
  - invoke gl_INIT in ./configure.ac.
$
  • Loading branch information
hirooih committed Jun 6, 2021
1 parent 8e3e01c commit 03e0fc9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 59 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Expand Up @@ -98,3 +98,13 @@ Units/**/Makefile.in
Tmain/dist.m4
Units/dist.m4
VALGRIND.tmp.core.*
gnulib/inttypes.h
gnulib/langinfo.h
gnulib/libgnu.a
gnulib/limits.h
gnulib/locale.h
gnulib/stdlib.h
gnulib/unistd.h
gnulib/wchar.h
gnulib/wctype.h
gnulib/sys/types.h
23 changes: 10 additions & 13 deletions Makefile.am
@@ -1,3 +1,7 @@
ACLOCAL_AMFLAGS = -I m4
#AM_CPPFLAGS = -I$(top_builddir)/gnulib -I$(top_srcdir)/gnulib
DEFAULT_INCLUDES = -I$(top_srcdir)/gnulib
SUBDIRS = gnulib

include $(top_srcdir)/source.mak

Expand All @@ -12,8 +16,6 @@ EXTRA_DIST = README.md autogen.sh \
makefiles/list-optlib2c-input.mak misc/optlib2c \
.ctags.d/exclusion.ctags .dir-locals.el .editorconfig .gdbinit .gitignore \
.indent.pro .uncrustify.cfg \
gnu_regex/README.txt gnu_regex/regcomp.c gnu_regex/regexec.c \
gnu_regex/regex_internal.c gnu_regex/regex_internal.h \
misc/ctags-optlib-mode.el \
misc/mk-interactive-request.sh misc/roundtrip misc/tinst \
$(PACKCC_FILES) \
Expand All @@ -30,7 +32,7 @@ EXTRA_DIST = README.md autogen.sh \
man/Makefile man/README man/tags.5.rst \
makefiles/list-txt2cstr-input.mak misc/txt2cstr \
$(PEG_INPUT) $(OPTLIB2C_INPUT) $(TXT2CSTR_INPUT) \
docs Tmain Units
docs Tmain Units m4/gnulib-cache.m4

CLEANFILES =
MOSTLYCLEANFILES =
Expand Down Expand Up @@ -66,23 +68,16 @@ readtags_CPPFLAGS = -I. -I$(srcdir) -I$(srcdir)/main -I$(srcdir)/libreadtags
readtags_CFLAGS = $(COVERAGE_CFLAGS) $(WARNING_CFLAGS)
dist_readtags_SOURCES = $(READTAGS_SRCS) $(READTAGS_HEADS)
readtags_CPPFLAGS += -DREADTAGS_DSL -I$(srcdir)/dsl
readtags_LDADD = gnulib/libgnu.a
dist_readtags_SOURCES += $(READTAGS_DSL_SRCS) $(READTAGS_DSL_HEADS)
if !HAVE_REGCOMP
readtags_CPPFLAGS += $(REGCOMP_CPPFLAGS)
dist_readtags_SOURCES += $(REGEX_SRCS) $(REGEX_HEADS)
endif

endif

if !HAVE_FNMATCH
LIB_SRCS += $(FNMATCH_SRCS)
LIB_HEADS += $(FNMATCH_HEADS)
endif

if !HAVE_REGCOMP
LIB_SRCS += $(REGEX_SRCS)
LIB_HEADS += $(REGEX_HEADS)
endif

if HAVE_LIBXML
PARSER_SRCS += $(XML_SRCS)
PARSER_HEADS += $(XML_HEADS)
Expand All @@ -108,7 +103,6 @@ if HAVE_STRNLEN
libctags_a_CPPFLAGS += -DUSE_SYSTEM_STRNLEN
endif
libctags_a_CPPFLAGS+= $(FNMATCH_CPPFLAGS)
libctags_a_CPPFLAGS+= $(REGCOMP_CPPFLAGS)
libctags_a_CPPFLAGS+= -DHAVE_REPOINFO_H

libctags_a_CFLAGS =
Expand Down Expand Up @@ -177,6 +171,7 @@ dist_libctags_a_SOURCES = $(ALL_LIB_HEADS) $(ALL_LIB_SRCS)
ctags_CPPFLAGS = $(libctags_a_CPPFLAGS)
ctags_CFLAGS = $(libctags_a_CFLAGS)
ctags_LDADD = libctags.a
ctags_LDADD += gnulib/libgnu.a
ctags_LDADD += $(LIBXML_LIBS)
ctags_LDADD += $(JANSSON_LIBS)
ctags_LDADD += $(LIBYAML_LIBS)
Expand All @@ -199,6 +194,7 @@ endif
mini_geany_CPPFLAGS = $(libctags_a_CPPFLAGS)
mini_geany_CFLAGS = $(libctags_a_CFLAGS)
mini_geany_LDADD = libctags.a
mini_geany_LDADD += gnulib/libgnu.a
mini_geany_LDADD += $(LIBXML_LIBS)
mini_geany_LDADD += $(JANSSON_LIBS)
mini_geany_LDADD += $(LIBYAML_LIBS)
Expand All @@ -211,6 +207,7 @@ optscript_CPPFLAGS = $(libctags_a_CPPFLAGS)
optscript_CFLAGS = $(libctags_a_CFLAGS)
optscript_LDADD = libctags.a
# TODO: remove these dependencies from optscript command.
optscript_LDADD += gnulib/libgnu.a
optscript_LDADD += $(LIBXML_LIBS)
optscript_LDADD += $(JANSSON_LIBS)
optscript_LDADD += $(LIBYAML_LIBS)
Expand Down
55 changes: 11 additions & 44 deletions configure.ac
Expand Up @@ -6,7 +6,7 @@

# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.59])
AC_PREREQ([2.64])
AC_INIT([universal-ctags],[5.9.0])

if ! test -e "${srcdir}/config.h.in"; then
Expand Down Expand Up @@ -98,9 +98,6 @@ AH_TEMPLATE([ICONV_USE_LIB_PREFIX],
AH_TEMPLATE([TMPDIR],
[If you wish to change the directory in which temporary files are stored,
define this label to the directory desired.])
AH_TEMPLATE([CHECK_REGCOMP],
[Define this label if you wish to check the regcomp() function at run time
for correct behavior. This function is currently broken on Cygwin.])
AH_TEMPLATE([NON_CONST_PUTENV_PROTOTYPE],
[Define this is you have a prototype for putenv() in <stdlib.h>, but
doesn't declare its argument as "const char *".])
Expand Down Expand Up @@ -249,6 +246,10 @@ AM_CONDITIONAL(ENABLE_DEBUGGING, [test "x$enable_debugging" = "xyes"])

AC_PROG_CC
AC_PROG_CC_C99
# For gnulib.
# Typically, this is immediately after AC_PROG_CC, ...
gl_EARLY

AC_PROG_RANLIB
AC_C_BIGENDIAN

Expand Down Expand Up @@ -529,6 +530,11 @@ PRETTY_ARG_VAR([EXTRA_CFLAGS], [extra C compiler flags],
PRETTY_ARG_VAR([WARNING_CFLAGS], [C compiler warning flags],
[-Wall])

# For gnulib.
# Place it further down in the file, typically where you normally check for
# header files or functions.
gl_INIT

# Checks for library functions
# ----------------------------
AC_CHECK_FUNCS(fnmatch,[have_fnmatch=yes],[
Expand Down Expand Up @@ -586,45 +592,6 @@ if test "$have_setenv" != yes ; then
fi
fi

dnl
dnl
dnl Check regcomp
dnl
dnl If it is found but broken, abort with a message.
dnl If it is found but cannot be test brokenness, define CHECK_REGCOMP.
dnl If it is not found, use bundled implementation.
dnl
dnl If CHECK_REGCOMP is defined, ctags itself check the brokenness at runtime
dnl (cross-compiling is assumed here).
dnl
dnl
dnl The final result can be check with ./ctags --list-features.
dnl
dnl
AC_CHECK_FUNCS(regcomp,[
AC_MSG_CHECKING(if regcomp works)
AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h>
#include <regex.h>
int main(void) {
regex_t patbuf;
return (regcomp (&patbuf, "/hello/", 0) != 0);
}
])],[regcomp_works=yes],[regcomp_works=no],[AC_DEFINE(CHECK_REGCOMP)])
AC_MSG_RESULT($regcomp_works)
if test no = "$regcomp_works"; then
AC_MSG_ERROR([regcomp() on this system is broken.])
fi
have_regcomp=yes
],[
dnl Using bundled regex implementation
AC_LIBOBJ([regex])
REGCOMP_CPPFLAGS="-I${srcdir}/gnu_regex -D__USE_GNU"
AC_DEFINE(HAVE_REGCOMP)
have_regcomp=no])
AC_SUBST([REGCOMP_CPPFLAGS])
AM_CONDITIONAL([HAVE_REGCOMP], [test "xyes" = "x$have_regcomp"])

have_scandir=no
AC_CHECK_FUNCS(scandir,have_scandir=yes)

Expand Down Expand Up @@ -821,7 +788,7 @@ fi

AC_CHECK_FUNCS(mblen)

AC_CONFIG_FILES([Makefile
AC_CONFIG_FILES([Makefile gnulib/Makefile
man/ctags.1.rst
man/ctags-client-tools.7.rst
man/ctags-incompatibilities.7.rst
Expand Down
5 changes: 3 additions & 2 deletions source.mak
Expand Up @@ -347,8 +347,9 @@ ALL_SRCS = $(ALL_LIB_SRCS) $(CMDLINE_SRCS)
ENVIRONMENT_HEADS =
ENVIRONMENT_SRCS =

REGEX_HEADS = gnu_regex/regex.h
REGEX_SRCS = gnu_regex/regex.c
# only for non-Autotool configuration (mk_mingw.mak and mk_mvc.mak)
REGEX_HEADS = gnulib/regex.h
REGEX_SRCS = gnulib/regex.c
REGEX_OBJS = $(REGEX_SRCS:.c=.$(OBJEXT))

FNMATCH_HEADS = fnmatch/fnmatch.h
Expand Down

0 comments on commit 03e0fc9

Please sign in to comment.