From b48edd74d12c7d37514b298806e37a5dc9791f8d Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Wed, 14 Oct 1998 16:05:01 +0000 Subject: Make genbki.sh a configureable shell program to allow auto-detection of the proper cpp program. --- src/backend/catalog/genbki.sh | 281 --------------------------------------- src/backend/catalog/genbki.sh.in | 275 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 275 insertions(+), 281 deletions(-) delete mode 100644 src/backend/catalog/genbki.sh create mode 100644 src/backend/catalog/genbki.sh.in (limited to 'src') diff --git a/src/backend/catalog/genbki.sh b/src/backend/catalog/genbki.sh deleted file mode 100644 index 906fe504b87..00000000000 --- a/src/backend/catalog/genbki.sh +++ /dev/null @@ -1,281 +0,0 @@ -#!/bin/sh -#------------------------------------------------------------------------- -# -# genbki.sh-- -# shell script which generates .bki files from specially formatted .h -# files. These .bki files are used to initialize the postgres template -# database. -# -# Copyright (c) 1994, Regents of the University of California -# -# -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh,v 1.13 1998/08/25 17:36:18 momjian Exp $ -# -# NOTES -# non-essential whitespace is removed from the generated file. -# if this is ever a problem, then the sed script at the very -# end can be changed into another awk script or something smarter.. -# -#------------------------------------------------------------------------- -trap "rm -f /tmp/genbki.tmp" 0 1 2 3 15 - -# make sure it is empty ->/tmp/genbki.tmp - -PATH=$PATH:/lib:/usr/ccs/lib:/usr/ccs/lbin # to find cpp -cpp /dev/null >/dev/null 2>&1 -if [ "$?" -ne 0 ] -then echo "Can't find cpp. Exiting." 1>&2 - exit 1 -fi - -BKIOPTS='' -if [ $? != 0 ] -then - echo `basename $0`: Bad option - exit 1 -fi - -for opt in $* -do - case $opt in - -D) BKIOPTS="$BKIOPTS -D$2"; shift; shift;; - -D*) BKIOPTS="$BKIOPTS $1";shift;; - --) shift; break;; - esac -done - -# ---------------- -# collect nodefiles -# ---------------- -SYSFILES='' -x=1 -numargs=$# -while test $x -le $numargs ; do - SYSFILES="$SYSFILES $1" - x=`expr $x + 1` - shift -done - -# Get NAMEDATALEN and OIDNAMELEN from postgres_ext.h -NAMEDATALEN=`grep '#define.*NAMEDATALEN' ../../include/postgres_ext.h | awk '{ print $3 }'` -OIDNAMELEN=`grep '#define.*OIDNAMELEN' ../../include/postgres_ext.h | awk '{ print $3 }'` - -# ---------------- -# strip comments and trash from .h before we generate -# the .bki file... -# ---------------- -# also, change Oid to oid. -- AY 8/94. -# also, change NameData to name. -- jolly 8/21/95. -# put multi-line start/end comments on a separate line -# -cat $SYSFILES | \ -sed -e 's;/\*.*\*/;;g' \ - -e 's;/\*;\ -/*\ -;g' \ - -e 's;\*/;\ -*/\ -;g' | # we must run a new sed here to see the newlines we added -sed -e "s/;[ ]*$//g" \ - -e "s/^[ ]*//" \ - -e "s/[ ]Oid/\ oid/g" \ - -e "s/[ ]NameData/\ name/g" \ - -e "s/^Oid/oid/g" \ - -e "s/^NameData/\name/g" \ - -e "s/(NameData/(name/g" \ - -e "s/(Oid/(oid/g" \ - -e "s/NAMEDATALEN/$NAMEDATALEN/g" \ - -e "s/OIDNAMELEN/$OIDNAMELEN/g" | \ -awk ' -# ---------------- -# now use awk to process remaining .h file.. -# -# nc is the number of catalogs -# inside is a variable set to 1 when we are scanning the -# contents of a catalog definition. -# inserting_data is a flag indicating when we are processing DATA lines. -# (i.e. have a relation open and need to close it) -# ---------------- -BEGIN { - inside = 0; - raw = 0; - bootstrap = 0; - nc = 0; - reln_open = 0; - comment_level = 0; -} - -# ---------------- -# Anything in a /* .. */ block should be ignored. -# Blank lines also go. -# Note that any /* */ comment on a line by itself was removed from the line -# by the sed above. -# ---------------- -/^\/\*/ { comment_level += 1; next; } -/^\*\// { comment_level -= 1; next; } -comment_level > 0 { next; } - -/^[ ]*$/ { next; } - -# ---------------- -# anything in a BKI_BEGIN .. BKI_END block should be passed -# along without interpretation. -# ---------------- -/^BKI_BEGIN/ { raw = 1; next; } -/^BKI_END/ { raw = 0; next; } -raw == 1 { print; next; } - -# ---------------- -# DATA() statements should get passed right through after -# stripping off the DATA( and the ) on the end. -# ---------------- -/^DATA\(/ { - data = substr($0, 6, length($0) - 6); - print data; - nf = 1; - oid = 0; - while (nf <= NF-3) - { - if ($nf == "OID" && $(nf+1) == "=") - { - oid = $(nf+2); - break; - } - nf++; - } - next; -} - -/^DESCR\(/ { - if (oid != 0) - { - data = substr($0, 8, length($0) - 9); - if (data != "") - printf "%d %s\n", oid, data >> "/tmp/genbki.tmp"; - } - next; -} - -/^DECLARE_INDEX\(/ { -# ---- -# end any prior catalog data insertions before starting a define index -# ---- - if (reln_open == 1) { -# print "show"; - print "close " catalog; - reln_open = 0; - } - - data = substr($0, 15, length($0) - 15); - print "declare index " data -} - -/^BUILD_INDICES/ { print "build indices"; } - -# ---------------- -# CATALOG() definitions take some more work. -# ---------------- -/^CATALOG\(/ { -# ---- -# end any prior catalog data insertions before starting a new one.. -# ---- - if (reln_open == 1) { -# print "show"; - print "close " catalog; - reln_open = 0; - } - -# ---- -# get the name of the new catalog -# ---- - pos = index($1,")"); - catalog = substr($1,9,pos-9); - - if ($0 ~ /BOOTSTRAP/) { - bootstrap = 1; - } - - i = 1; - inside = 1; - nc++; - next; -} - -# ---------------- -# process the contents of the catalog definition -# -# attname[ x ] contains the attribute name for attribute x -# atttype[ x ] contains the attribute type fot attribute x -# ---------------- -inside == 1 { -# ---- -# ignore a leading brace line.. -# ---- - if ($1 ~ /\{/) - next; - -# ---- -# if this is the last line, then output the bki catalog stuff. -# ---- - if ($1 ~ /}/) { - if (bootstrap) { - print "create bootstrap " catalog; - } else { - print "create " catalog; - } - print "\t("; - - for (j=1; j&2 - -# ---------------- -# all done -# ---------------- -exit 0 diff --git a/src/backend/catalog/genbki.sh.in b/src/backend/catalog/genbki.sh.in new file mode 100644 index 00000000000..3eb219e3868 --- /dev/null +++ b/src/backend/catalog/genbki.sh.in @@ -0,0 +1,275 @@ +#!/bin/sh +#------------------------------------------------------------------------- +# +# genbki.sh-- +# shell script which generates .bki files from specially formatted .h +# files. These .bki files are used to initialize the postgres template +# database. +# +# Copyright (c) 1994, Regents of the University of California +# +# +# IDENTIFICATION +# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh.in,v 1.1 1998/10/14 16:05:01 thomas Exp $ +# +# NOTES +# non-essential whitespace is removed from the generated file. +# if this is ever a problem, then the sed script at the very +# end can be changed into another awk script or something smarter.. +# +#------------------------------------------------------------------------- +trap "rm -f /tmp/genbki.tmp" 0 1 2 3 15 + +# make sure it is empty +>/tmp/genbki.tmp + +if [ $? != 0 ] +then + echo `basename $0`: Bad option + exit 1 +fi + +BKIOPTS='' + +for opt in $* +do + case $opt in + -D) BKIOPTS="$BKIOPTS -D$2"; shift; shift;; + -D*) BKIOPTS="$BKIOPTS $1";shift;; + --) shift; break;; + esac +done + +# ---------------- +# collect nodefiles +# ---------------- +SYSFILES='' +x=1 +numargs=$# +while test $x -le $numargs ; do + SYSFILES="$SYSFILES $1" + x=`expr $x + 1` + shift +done + +# Get NAMEDATALEN and OIDNAMELEN from postgres_ext.h +NAMEDATALEN=`grep '#define.*NAMEDATALEN' ../../include/postgres_ext.h | awk '{ print $3 }'` +OIDNAMELEN=`grep '#define.*OIDNAMELEN' ../../include/postgres_ext.h | awk '{ print $3 }'` + +# ---------------- +# strip comments and trash from .h before we generate +# the .bki file... +# ---------------- +# also, change Oid to oid. -- AY 8/94. +# also, change NameData to name. -- jolly 8/21/95. +# put multi-line start/end comments on a separate line +# +cat $SYSFILES | \ +sed -e 's;/\*.*\*/;;g' \ + -e 's;/\*;\ +/*\ +;g' \ + -e 's;\*/;\ +*/\ +;g' | # we must run a new sed here to see the newlines we added +sed -e "s/;[ ]*$//g" \ + -e "s/^[ ]*//" \ + -e "s/[ ]Oid/\ oid/g" \ + -e "s/[ ]NameData/\ name/g" \ + -e "s/^Oid/oid/g" \ + -e "s/^NameData/\name/g" \ + -e "s/(NameData/(name/g" \ + -e "s/(Oid/(oid/g" \ + -e "s/NAMEDATALEN/$NAMEDATALEN/g" \ + -e "s/OIDNAMELEN/$OIDNAMELEN/g" | \ +awk ' +# ---------------- +# now use awk to process remaining .h file.. +# +# nc is the number of catalogs +# inside is a variable set to 1 when we are scanning the +# contents of a catalog definition. +# inserting_data is a flag indicating when we are processing DATA lines. +# (i.e. have a relation open and need to close it) +# ---------------- +BEGIN { + inside = 0; + raw = 0; + bootstrap = 0; + nc = 0; + reln_open = 0; + comment_level = 0; +} + +# ---------------- +# Anything in a /* .. */ block should be ignored. +# Blank lines also go. +# Note that any /* */ comment on a line by itself was removed from the line +# by the sed above. +# ---------------- +/^\/\*/ { comment_level += 1; next; } +/^\*\// { comment_level -= 1; next; } +comment_level > 0 { next; } + +/^[ ]*$/ { next; } + +# ---------------- +# anything in a BKI_BEGIN .. BKI_END block should be passed +# along without interpretation. +# ---------------- +/^BKI_BEGIN/ { raw = 1; next; } +/^BKI_END/ { raw = 0; next; } +raw == 1 { print; next; } + +# ---------------- +# DATA() statements should get passed right through after +# stripping off the DATA( and the ) on the end. +# ---------------- +/^DATA\(/ { + data = substr($0, 6, length($0) - 6); + print data; + nf = 1; + oid = 0; + while (nf <= NF-3) + { + if ($nf == "OID" && $(nf+1) == "=") + { + oid = $(nf+2); + break; + } + nf++; + } + next; +} + +/^DESCR\(/ { + if (oid != 0) + { + data = substr($0, 8, length($0) - 9); + if (data != "") + printf "%d %s\n", oid, data >> "/tmp/genbki.tmp"; + } + next; +} + +/^DECLARE_INDEX\(/ { +# ---- +# end any prior catalog data insertions before starting a define index +# ---- + if (reln_open == 1) { +# print "show"; + print "close " catalog; + reln_open = 0; + } + + data = substr($0, 15, length($0) - 15); + print "declare index " data +} + +/^BUILD_INDICES/ { print "build indices"; } + +# ---------------- +# CATALOG() definitions take some more work. +# ---------------- +/^CATALOG\(/ { +# ---- +# end any prior catalog data insertions before starting a new one.. +# ---- + if (reln_open == 1) { +# print "show"; + print "close " catalog; + reln_open = 0; + } + +# ---- +# get the name of the new catalog +# ---- + pos = index($1,")"); + catalog = substr($1,9,pos-9); + + if ($0 ~ /BOOTSTRAP/) { + bootstrap = 1; + } + + i = 1; + inside = 1; + nc++; + next; +} + +# ---------------- +# process the contents of the catalog definition +# +# attname[ x ] contains the attribute name for attribute x +# atttype[ x ] contains the attribute type fot attribute x +# ---------------- +inside == 1 { +# ---- +# ignore a leading brace line.. +# ---- + if ($1 ~ /\{/) + next; + +# ---- +# if this is the last line, then output the bki catalog stuff. +# ---- + if ($1 ~ /}/) { + if (bootstrap) { + print "create bootstrap " catalog; + } else { + print "create " catalog; + } + print "\t("; + + for (j=1; j&2 + +# ---------------- +# all done +# ---------------- +exit 0 -- cgit v1.2.3