mirror of
https://github.com/postgres/postgres.git
synced 2025-11-19 13:42:17 +03:00
Build all Flex files standalone
The proposed Meson build system will need a way to ignore certain
generated files in order to coexist with the autoconf build system,
and C files generated by Flex which are #include'd into .y files make
this more difficult. In similar vein to 72b1e3a21, arrange for all Flex
C files to compile to their own .o targets.
Reviewed by Andres Freund
Discussion: https://www.postgresql.org/message-id/20220810171935.7k5zgnjwqzalzmtm%40awork3.anarazel.de
Discussion: https://www.postgresql.org/message-id/CAFBsxsF8Gc2StS3haXofshHCzqNMRXiSxvQEYGwnFsTmsdwNeg@mail.gmail.com
This commit is contained in:
1
src/backend/utils/adt/.gitignore
vendored
1
src/backend/utils/adt/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/jsonpath_gram.h
|
||||
/jsonpath_gram.c
|
||||
/jsonpath_scan.c
|
||||
|
||||
@@ -57,6 +57,7 @@ OBJS = \
|
||||
jsonpath.o \
|
||||
jsonpath_exec.o \
|
||||
jsonpath_gram.o \
|
||||
jsonpath_scan.o \
|
||||
like.o \
|
||||
like_support.o \
|
||||
lockfuncs.o \
|
||||
@@ -119,11 +120,17 @@ OBJS = \
|
||||
xid8funcs.o \
|
||||
xml.o
|
||||
|
||||
# See notes in src/backend/parser/Makefile about the following two rules
|
||||
jsonpath_gram.h: jsonpath_gram.c
|
||||
touch $@
|
||||
|
||||
jsonpath_gram.c: BISONFLAGS += -d
|
||||
|
||||
jsonpath_scan.c: FLEXFLAGS = -CF -p -p
|
||||
jsonpath_scan.c: FLEX_NO_BACKUP=yes
|
||||
|
||||
# jsonpath_scan is compiled as part of jsonpath_gram
|
||||
jsonpath_gram.o: jsonpath_scan.c
|
||||
# Force these dependencies to be known even without dependency info built:
|
||||
jsonpath_gram.o jsonpath_scan.o: jsonpath_gram.h
|
||||
|
||||
# jsonpath_gram.c and jsonpath_scan.c are in the distribution tarball,
|
||||
# so they are not cleaned here.
|
||||
|
||||
@@ -18,26 +18,11 @@
|
||||
|
||||
#include "catalog/pg_collation.h"
|
||||
#include "fmgr.h"
|
||||
#include "jsonpath_internal.h"
|
||||
#include "miscadmin.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "regex/regex.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/jsonpath.h"
|
||||
|
||||
/* struct JsonPathString is shared between scan and gram */
|
||||
typedef struct JsonPathString
|
||||
{
|
||||
char *val;
|
||||
int len;
|
||||
int total;
|
||||
} JsonPathString;
|
||||
|
||||
union YYSTYPE;
|
||||
|
||||
/* flex 2.5.4 doesn't bother with a decl for this */
|
||||
int jsonpath_yylex(union YYSTYPE *yylval_param);
|
||||
int jsonpath_yyparse(JsonPathParseResult **result);
|
||||
void jsonpath_yyerror(JsonPathParseResult **result, const char *message);
|
||||
|
||||
static JsonPathParseItem *makeItemType(JsonPathItemType type);
|
||||
static JsonPathParseItem *makeItemString(JsonPathString *s);
|
||||
@@ -593,13 +578,3 @@ jspConvertRegexFlags(uint32 xflags)
|
||||
|
||||
return cflags;
|
||||
}
|
||||
|
||||
/*
|
||||
* jsonpath_scan.l is compiled as part of jsonpath_gram.y. Currently, this is
|
||||
* unavoidable because jsonpath_gram does not create a .h file to export its
|
||||
* token symbols. If these files ever grow large enough to be worth compiling
|
||||
* separately, that could be fixed; but for now it seems like useless
|
||||
* complication.
|
||||
*/
|
||||
|
||||
#include "jsonpath_scan.c"
|
||||
|
||||
32
src/backend/utils/adt/jsonpath_internal.h
Normal file
32
src/backend/utils/adt/jsonpath_internal.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* jsonpath_internal.h
|
||||
* Private definitions for jsonpath scanner & parser
|
||||
*
|
||||
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/backend/utils/adt/jsonpath_internal.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef JSONPATH_INTERNAL_H
|
||||
#define JSONPATH_INTERNAL_H
|
||||
|
||||
/* struct JsonPathString is shared between scan and gram */
|
||||
typedef struct JsonPathString
|
||||
{
|
||||
char *val;
|
||||
int len;
|
||||
int total;
|
||||
} JsonPathString;
|
||||
|
||||
#include "utils/jsonpath.h"
|
||||
#include "jsonpath_gram.h"
|
||||
|
||||
extern int jsonpath_yylex(YYSTYPE *yylval_param);
|
||||
extern int jsonpath_yyparse(JsonPathParseResult **result);
|
||||
extern void jsonpath_yyerror(JsonPathParseResult **result, const char *message);
|
||||
|
||||
#endif /* JSONPATH_INTERNAL_H */
|
||||
@@ -1,4 +1,4 @@
|
||||
%{
|
||||
%top{
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* jsonpath_scan.l
|
||||
@@ -17,9 +17,18 @@
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
/*
|
||||
* NB: include jsonpath_gram.h only AFTER including jsonpath_internal.h,
|
||||
* because jsonpath_internal.h contains the declaration for JsonPathString.
|
||||
*/
|
||||
#include "jsonpath_internal.h"
|
||||
#include "jsonpath_gram.h"
|
||||
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "nodes/pg_list.h"
|
||||
}
|
||||
|
||||
%{
|
||||
static JsonPathString scanstring;
|
||||
|
||||
/* Handles to the buffer that the lexer uses internally */
|
||||
@@ -142,9 +151,9 @@ hex_fail \\x{hex_dig}{0,1}
|
||||
|
||||
<xnq,xq,xvq>{hex_char} { parseHexChar(yytext); }
|
||||
|
||||
<xnq,xq,xvq>{unicode}*{unicodefail} { yyerror(NULL, "invalid unicode sequence"); }
|
||||
<xnq,xq,xvq>{unicode}*{unicodefail} { jsonpath_yyerror(NULL, "invalid unicode sequence"); }
|
||||
|
||||
<xnq,xq,xvq>{hex_fail} { yyerror(NULL, "invalid hex character sequence"); }
|
||||
<xnq,xq,xvq>{hex_fail} { jsonpath_yyerror(NULL, "invalid hex character sequence"); }
|
||||
|
||||
<xnq,xq,xvq>{unicode}+\\ {
|
||||
/* throw back the \\, and treat as unicode */
|
||||
@@ -154,9 +163,9 @@ hex_fail \\x{hex_dig}{0,1}
|
||||
|
||||
<xnq,xq,xvq>\\. { addchar(false, yytext[1]); }
|
||||
|
||||
<xnq,xq,xvq>\\ { yyerror(NULL, "unexpected end after backslash"); }
|
||||
<xnq,xq,xvq>\\ { jsonpath_yyerror(NULL, "unexpected end after backslash"); }
|
||||
|
||||
<xq,xvq><<EOF>> { yyerror(NULL, "unexpected end of quoted string"); }
|
||||
<xq,xvq><<EOF>> { jsonpath_yyerror(NULL, "unexpected end of quoted string"); }
|
||||
|
||||
<xq>\" {
|
||||
yylval->str = scanstring;
|
||||
@@ -178,7 +187,7 @@ hex_fail \\x{hex_dig}{0,1}
|
||||
|
||||
<xc>\* { }
|
||||
|
||||
<xc><<EOF>> { yyerror(NULL, "unexpected end of comment"); }
|
||||
<xc><<EOF>> { jsonpath_yyerror(NULL, "unexpected end of comment"); }
|
||||
|
||||
\&\& { return AND_P; }
|
||||
|
||||
@@ -244,10 +253,10 @@ hex_fail \\x{hex_dig}{0,1}
|
||||
return INT_P;
|
||||
}
|
||||
|
||||
{realfail} { yyerror(NULL, "invalid numeric literal"); }
|
||||
{integer_junk} { yyerror(NULL, "trailing junk after numeric literal"); }
|
||||
{decimal_junk} { yyerror(NULL, "trailing junk after numeric literal"); }
|
||||
{real_junk} { yyerror(NULL, "trailing junk after numeric literal"); }
|
||||
{realfail} { jsonpath_yyerror(NULL, "invalid numeric literal"); }
|
||||
{integer_junk} { jsonpath_yyerror(NULL, "trailing junk after numeric literal"); }
|
||||
{decimal_junk} { jsonpath_yyerror(NULL, "trailing junk after numeric literal"); }
|
||||
{real_junk} { jsonpath_yyerror(NULL, "trailing junk after numeric literal"); }
|
||||
|
||||
\" {
|
||||
addchar(true, '\0');
|
||||
|
||||
@@ -16,6 +16,7 @@ override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
|
||||
|
||||
OBJS = \
|
||||
guc.o \
|
||||
guc-file.o \
|
||||
help_config.o \
|
||||
pg_config.o \
|
||||
pg_controldata.o \
|
||||
@@ -37,10 +38,6 @@ endif
|
||||
|
||||
include $(top_srcdir)/src/backend/common.mk
|
||||
|
||||
# guc-file is compiled as part of guc
|
||||
guc.o: guc-file.c
|
||||
|
||||
# Note: guc-file.c is not deleted by 'make clean',
|
||||
# since we want to ship it in distribution tarballs.
|
||||
clean:
|
||||
@rm -f lex.yy.c
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*-pgsql-c-*- */
|
||||
%top{
|
||||
/*
|
||||
* Scanner for the configuration file
|
||||
*
|
||||
@@ -7,8 +7,6 @@
|
||||
* src/backend/utils/misc/guc-file.l
|
||||
*/
|
||||
|
||||
%{
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -19,8 +17,12 @@
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "miscadmin.h"
|
||||
#include "storage/fd.h"
|
||||
#include <sys/stat.h>
|
||||
#include "utils/memutils.h"
|
||||
}
|
||||
|
||||
|
||||
%{
|
||||
/*
|
||||
* flex emits a yy_fatal_error() function that it calls in response to
|
||||
* critical errors like malloc failure, file I/O errors, and detection of
|
||||
|
||||
@@ -13333,5 +13333,3 @@ check_default_with_oids(bool *newval, void **extra, GucSource source)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "guc-file.c"
|
||||
|
||||
Reference in New Issue
Block a user