Skip to content

Commit

Permalink
Install standard library files in $(datadir)/re2c/stdlib and search f…
Browse files Browse the repository at this point in the history
…or include files in this location.

This fixes bug #253 "re2c should install unicode_categories.re somewhere"
(reported by Wesley W. Terpstra).
  • Loading branch information
skvadrik committed Aug 7, 2019
1 parent 2715620 commit c3880fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# flags
# do *not* add CXXFLAGS here, add them in configure.ac

# stdlib directory
stdlibdir = $(datadir)/re2c/stdlib

# do not add compiler options/warnings here, add them in configure.ac
AM_CXXFLAGS = $(CXXFLAGSDEFAULT)
AM_CXXFLAGS += -DRE2C_STDLIB_DIR='"$(stdlibdir)/"'
if DEBUG
AM_CXXFLAGS += -DRE2C_DEBUG
endif

RE2CFLAGS = -br -W

# binary
Expand Down Expand Up @@ -257,6 +262,9 @@ re2c_SRC_DOC_EXT = \
DOC = doc/re2c.1
man_MANS = $(DOC)

# include files (stdlib)
dist_stdlib_DATA = include/unicode_categories.re

EXTRA_DIST = \
$(re2c_BOOT) \
$(re2c_CUSTOM) \
Expand All @@ -267,7 +275,6 @@ EXTRA_DIST = \
autogen.sh \
genhelp.sh \
examples \
include \
test

CLEANFILES = \
Expand Down
6 changes: 6 additions & 0 deletions src/parse/input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ bool Input::open(const std::string &filename, const std::string *parent
path = incpaths[i] + name;
file = fopen(path.c_str(), "rb");
}

// if user-defined include paths failed, try stdlib path
if (!file) {
path = RE2C_STDLIB_DIR + name;
file = fopen(path.c_str(), "rb");
}
}

if (!file) {
Expand Down

0 comments on commit c3880fc

Please sign in to comment.