Skip to content

Commit

Permalink
Some miscellaneous changes from my Meson investigation (libusual#49)
Browse files Browse the repository at this point in the history
* Use ISO C __typeof__ instead of GNU C typeof

I don't see any reason this has to be the GNU variant.

* Factor out the pgutil_kwlookup gperf generation

This makes it easier to share code with Meson builds.

* Update pgutil_kwlookup.h
  • Loading branch information
tristan957 authored Jan 16, 2024
1 parent f8d49e2 commit 204eae0
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 175 deletions.
14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,14 @@ dox:

PG_CONFIG ?= pg_config
KWLIST = $(shell $(PG_CONFIG) --includedir-server)/parser/kwlist.h
GPERF = gperf -m5

# requires 8.4+
kws:
@test -f "$(KWLIST)" || { echo "kwlist.h not found"; exit 1; }
grep '^PG_KEYWORD' "$(KWLIST)" \
| grep -v UNRESERVED \
| sed 's/.*"\(.*\)",.*, *\(.*\)[)].*/\1/' \
>> usual/pgutil_kwlookup.gp

kwh:
$(GPERF) usual/pgutil_kwlookup.g \
| sed '/^#line/d' \
> usual/pgutil_kwlookup.h
./mk/gen-pgutil_kwlookup_gp.sh "$(KWLIST)" >> usual/pgutil_kwlookup.gp

kwh: usual/pgutil_kwlookup.g
./mk/gen-pgutil_kwlookup_h.sh $^ > usual/pgutil_kwlookup.h

sizes: all
size `find .objs -name '.libs' -prune -o -name '*.o' -print | sort`
Expand Down
5 changes: 5 additions & 0 deletions mk/gen-pgutil_kwlookup_gp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

grep '^PG_KEYWORD' "$1" \
| grep -v UNRESERVED \
| sed 's/.*"\(.*\)",.*, *\(.*\)[)].*/\1/'
4 changes: 4 additions & 0 deletions mk/gen-pgutil_kwlookup_h.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

gperf -m5 "$1" \
| sed '/^#line/d'
2 changes: 1 addition & 1 deletion usual/pgutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ struct StrList *pg_parse_array(const char *pgarr, CxMem *cx)
#define long uintptr_t

/* include gperf code */
const char *pg_keyword_lookup_real(const char *str, unsigned int len);
const char *pg_keyword_lookup_real(const char *str, size_t len);
#include <usual/pgutil_kwlookup.h>

bool pg_is_reserved_word(const char *str)
Expand Down
Loading

0 comments on commit 204eae0

Please sign in to comment.