Skip to content

Commit

Permalink
Don't pass the AWK script to itself
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
hugomg committed Jul 25, 2023
1 parent 86f6e01 commit 5fb1c6e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ lzio.o: lzio.c lprefix.h lua.h luaconf.h llimits.h lmem.h lstate.h \
lobject.h ltm.h lzio.h

# The prerequisites must in the same order that we want in the output.
luacore.h: gen-lua-core-h.awk llimits.h lctype.h lopcodes.h lmem.h lobject.h lzio.h ltable.h lfunc.h ltm.h lparser.h llex.h lundump.h lstate.h lcode.h ldebug.h lapi.h ldo.h lgc.h lvm.h lstring.h
awk -f gen-lua-core-h.awk $^ > $@
CORE_HEADERS=llimits.h lctype.h lopcodes.h lmem.h lobject.h lzio.h ltable.h lfunc.h ltm.h lparser.h llex.h lundump.h lstate.h lcode.h ldebug.h lapi.h ldo.h lgc.h lvm.h lstring.h
luacore.h: gen-lua-core-h.awk $(CORE_HEADERS)
awk -f gen-lua-core-h.awk $(CORE_HEADERS) > $@

# (end of Makefile)
14 changes: 1 addition & 13 deletions src/gen-lua-core-h.awk
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@ function is_core_include() {
is_core[substr($0, RSTART+1, RLENGTH-2)]
}

function is_header(name) {
return name ~ /\.h$/
}

BEGIN {
for (i = 1; i < ARGC; i++) {
if (is_header(ARGV[i])) {
is_core[ARGV[i]] = 1
}
is_core[ARGV[i]] = 1
}

print "#ifndef luacore_h"
Expand All @@ -29,12 +23,6 @@ BEGIN {

}

BEGINFILE {
if (!is_header(FILENAME)) {
nextfile
}
}

!is_core_include() { print }

END {
Expand Down

0 comments on commit 5fb1c6e

Please sign in to comment.