diff options
Diffstat (limited to 'contrib/seg')
-rw-r--r-- | contrib/seg/Makefile | 14 | ||||
-rwxr-xr-x | contrib/seg/seg-validate.pl | 56 | ||||
-rw-r--r-- | contrib/seg/seg.c | 7 | ||||
-rw-r--r-- | contrib/seg/segscan.l | 8 | ||||
-rwxr-xr-x | contrib/seg/sort-segments.pl | 29 |
5 files changed, 55 insertions, 59 deletions
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile index d84934c67f..fb9c5765c3 100644 --- a/contrib/seg/Makefile +++ b/contrib/seg/Makefile @@ -25,20 +25,6 @@ endif # segscan is compiled as part of segparse segparse.o: segscan.c -segparse.c: segparse.y -ifdef BISON - $(BISON) $(BISONFLAGS) -o $@ $< -else - @$(missing) bison $< $@ -endif - -segscan.c: segscan.l -ifdef FLEX - $(FLEX) $(FLEXFLAGS) -o'$@' $< -else - @$(missing) flex $< $@ -endif - distprep: segparse.c segscan.c maintainer-clean: diff --git a/contrib/seg/seg-validate.pl b/contrib/seg/seg-validate.pl index 9272936aef..cb3fb9a099 100755 --- a/contrib/seg/seg-validate.pl +++ b/contrib/seg/seg-validate.pl @@ -2,12 +2,12 @@ $integer = '[+-]?[0-9]+'; $real = '[+-]?[0-9]+\.[0-9]+'; -$RANGE = '(\.\.)(\.)?'; -$PLUMIN = q(\'\+\-\'); -$FLOAT = "(($integer)|($real))([eE]($integer))?"; +$RANGE = '(\.\.)(\.)?'; +$PLUMIN = q(\'\+\-\'); +$FLOAT = "(($integer)|($real))([eE]($integer))?"; $EXTENSION = '<|>|~'; -$boundary = "($EXTENSION)?$FLOAT"; +$boundary = "($EXTENSION)?$FLOAT"; $deviation = $FLOAT; $rule_1 = $boundary . $PLUMIN . $deviation; @@ -18,25 +18,33 @@ $rule_5 = $boundary; print "$rule_5\n"; -while (<>) { -# s/ +//g; - if ( /^($rule_1)$/ ) { - print; - } - elsif ( /^($rule_2)$/ ) { - print; - } - elsif ( /^($rule_3)$/ ) { - print; - } - elsif ( /^($rule_4)$/ ) { - print; - } - elsif ( /^($rule_5)$/ ) { - print; - } - else { - print STDERR "error in $_\n"; - } +while (<>) +{ + + # s/ +//g; + if (/^($rule_1)$/) + { + print; + } + elsif (/^($rule_2)$/) + { + print; + } + elsif (/^($rule_3)$/) + { + print; + } + elsif (/^($rule_4)$/) + { + print; + } + elsif (/^($rule_5)$/) + { + print; + } + else + { + print STDERR "error in $_\n"; + } } diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c index 0cf9853060..0807e238f1 100644 --- a/contrib/seg/seg.c +++ b/contrib/seg/seg.c @@ -52,13 +52,6 @@ PG_FUNCTION_INFO_V1(seg_lower); PG_FUNCTION_INFO_V1(seg_upper); PG_FUNCTION_INFO_V1(seg_center); -Datum seg_in(PG_FUNCTION_ARGS); -Datum seg_out(PG_FUNCTION_ARGS); -Datum seg_size(PG_FUNCTION_ARGS); -Datum seg_lower(PG_FUNCTION_ARGS); -Datum seg_upper(PG_FUNCTION_ARGS); -Datum seg_center(PG_FUNCTION_ARGS); - /* ** GiST support methods */ diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l index 2d71cc66a0..a3e685488a 100644 --- a/contrib/seg/segscan.l +++ b/contrib/seg/segscan.l @@ -10,7 +10,13 @@ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ #undef fprintf -#define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg))) +#define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg) + +static void +fprintf_to_ereport(const char *fmt, const char *msg) +{ + ereport(ERROR, (errmsg_internal("%s", msg))); +} /* Handles to the buffer that the lexer uses internally */ static YY_BUFFER_STATE scanbufhandle; diff --git a/contrib/seg/sort-segments.pl b/contrib/seg/sort-segments.pl index 62cdfb1ffd..a465468d5b 100755 --- a/contrib/seg/sort-segments.pl +++ b/contrib/seg/sort-segments.pl @@ -2,19 +2,22 @@ # this script will sort any table with the segment data type in its last column -while (<>) { - chomp; - push @rows, $_; +while (<>) +{ + chomp; + push @rows, $_; } -foreach ( sort { - @ar = split("\t", $a); - $valA = pop @ar; - $valA =~ s/[~<> ]+//g; - @ar = split("\t", $b); - $valB = pop @ar; - $valB =~ s/[~<> ]+//g; - $valA <=> $valB -} @rows ) { - print "$_\n";; +foreach ( + sort { + @ar = split("\t", $a); + $valA = pop @ar; + $valA =~ s/[~<> ]+//g; + @ar = split("\t", $b); + $valB = pop @ar; + $valB =~ s/[~<> ]+//g; + $valA <=> $valB + } @rows) +{ + print "$_\n"; } |