v201-0007-Build-segscan.c-standalone.patch
text/x-patch
Filename: v201-0007-Build-segscan.c-standalone.patch
Type: text/x-patch
Part: 6
Patch
Format: format-patch
Series: patch v201-0007
Subject: Build segscan.c standalone
| File | + | − |
|---|---|---|
| contrib/seg/.gitignore | 1 | 0 |
| contrib/seg/Makefile | 11 | 4 |
| contrib/seg/segparse.y | 0 | 3 |
| contrib/seg/segscan.l | 15 | 10 |
From 5170d8fac8bbb9e101e10f18ed280e446b305e26 Mon Sep 17 00:00:00 2001
From: John Naylor <john.naylor@postgresql.org>
Date: Sat, 13 Aug 2022 12:00:33 +0700
Subject: [PATCH v201 7/9] Build segscan.c standalone
---
contrib/seg/.gitignore | 1 +
contrib/seg/Makefile | 15 +++++++++++----
contrib/seg/segparse.y | 3 ---
contrib/seg/segscan.l | 25 +++++++++++++++----------
4 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/contrib/seg/.gitignore b/contrib/seg/.gitignore
index 69e73d2096..fa247a4e67 100644
--- a/contrib/seg/.gitignore
+++ b/contrib/seg/.gitignore
@@ -1,3 +1,4 @@
+/segparse.h
/segparse.c
/segscan.c
# Generated subdirectories
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile
index bb63e83506..c6c134b8f1 100644
--- a/contrib/seg/Makefile
+++ b/contrib/seg/Makefile
@@ -4,7 +4,8 @@ MODULE_big = seg
OBJS = \
$(WIN32RES) \
seg.o \
- segparse.o
+ segparse.o \
+ segscan.o
EXTENSION = seg
DATA = seg--1.1.sql seg--1.1--1.2.sql seg--1.2--1.3.sql seg--1.3--1.4.sql \
@@ -29,10 +30,16 @@ include $(top_srcdir)/contrib/contrib-global.mk
endif
-# segscan is compiled as part of segparse
-segparse.o: segscan.c
+# See notes in src/backend/parser/Makefile about the following two rules
+segparse.h: segparse.c
+ touch $@
+
+segparse.c: BISONFLAGS += -d
+
+# Force these dependencies to be known even without dependency info built:
+segparse.o segscan.o: segparse.h
distprep: segparse.c segscan.c
maintainer-clean:
- rm -f segparse.c segscan.c
+ rm -f segparse.h segparse.c segscan.c
diff --git a/contrib/seg/segparse.y b/contrib/seg/segparse.y
index 33e3a9f35f..637eacd1a6 100644
--- a/contrib/seg/segparse.y
+++ b/contrib/seg/segparse.y
@@ -160,6 +160,3 @@ seg_atof(const char *value)
datum = DirectFunctionCall1(float4in, CStringGetDatum(value));
return DatumGetFloat4(datum);
}
-
-
-#include "segscan.c"
diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l
index 5f6595e9eb..db0db1aa70 100644
--- a/contrib/seg/segscan.l
+++ b/contrib/seg/segscan.l
@@ -1,8 +1,15 @@
-%{
+%top{
/*
* A scanner for EMP-style numeric ranges
*/
+#include "postgres.h"
+
+#include "segdata.h"
+#include "segparse.h"
+}
+
+%{
/* LCOV_EXCL_START */
/* No reason to constrain amount of data slurped */
@@ -21,7 +28,6 @@ fprintf_to_ereport(const char *fmt, const char *msg)
/* Handles to the buffer that the lexer uses internally */
static YY_BUFFER_STATE scanbufhandle;
static char *scanbuf;
-static int scanbuflen;
%}
%option 8bit
@@ -42,12 +48,12 @@ float ({integer}|{real})([eE]{integer})?
%%
-{range} yylval.text = yytext; return RANGE;
-{plumin} yylval.text = yytext; return PLUMIN;
-{float} yylval.text = yytext; return SEGFLOAT;
-\< yylval.text = "<"; return EXTENSION;
-\> yylval.text = ">"; return EXTENSION;
-\~ yylval.text = "~"; return EXTENSION;
+{range} seg_yylval.text = yytext; return RANGE;
+{plumin} seg_yylval.text = yytext; return PLUMIN;
+{float} seg_yylval.text = yytext; return SEGFLOAT;
+\< seg_yylval.text = "<"; return EXTENSION;
+\> seg_yylval.text = ">"; return EXTENSION;
+\~ seg_yylval.text = "~"; return EXTENSION;
[ \t\n\r\f]+ /* discard spaces */
. return yytext[0]; /* alert parser of the garbage */
@@ -56,7 +62,7 @@ float ({integer}|{real})([eE]{integer})?
/* LCOV_EXCL_STOP */
void
-yyerror(SEG *result, const char *message)
+seg_yyerror(SEG *result, const char *message)
{
if (*yytext == YY_END_OF_BUFFER_CHAR)
{
@@ -94,7 +100,6 @@ seg_scanner_init(const char *str)
/*
* Make a scan buffer with special termination needed by flex.
*/
- scanbuflen = slen;
scanbuf = palloc(slen + 2);
memcpy(scanbuf, str, slen);
scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
--
2.36.1