bug in PG_VERSION_NUM patch

Поиск
Список
Период
Сортировка
Искать

bug in PG_VERSION_NUM patch

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
cvs tip configure is giving a warning:

checking for flags to link embedded Perl...   /usr/lib64/perl5/5.8.6/x86_64-linux-thread-multi/auto/DynaLoader/DynaLoader.a -L/usr/lib64/perl5/5.8.6/x86_64-linux-thread-multi/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
gawk: warning: escape sequence `\.' treated as plain `.'
checking for library containing setproctitle... no

Evidently gawk is not happy about

$AWK -F'\.' '{printf \"%d%02d%02d\", $1, $2, (NF >= 3) ? $3 : 0}'`"

		regards, tom lane

Re: bug in PG_VERSION_NUM patch

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Tom Lane wrote:
> cvs tip configure is giving a warning:
> 
> checking for flags to link embedded Perl...   /usr/lib64/perl5/5.8.6/x86_64-linux-thread-multi/auto/DynaLoader/DynaLoader.a -L/usr/lib64/perl5/5.8.6/x86_64-linux-thread-multi/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
> gawk: warning: escape sequence `\.' treated as plain `.'
> checking for library containing setproctitle... no
> 
> Evidently gawk is not happy about
> 
> $AWK -F'\.' '{printf \"%d%02d%02d\", $1, $2, (NF >= 3) ? $3 : 0}'`"

OK, I reread the manual page:
      As  each input record is read, gawk splits the record into      fields, using the value of the FS variable  as  the  field      separator.   If FS is a single character, fields are sepa-      rated by that character.  If FS is the null  string,  then      each  individual character becomes a separate field.  Oth-      erwise, FS is expected to be a  full  regular  expression.

Turns out -F is a regex only if it is more than one character.  Fixed by
changing it to '.'.  Applied.

--  Bruce Momjian   http://candle.pha.pa.us SRA OSS, Inc.   http://www.sraoss.com
 + If your life is a hard drive, Christ can be your backup. +

Re: bug in PG_VERSION_NUM patch

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> OK, I reread the manual page:

>        As  each input record is read, gawk splits the record into
>        fields, using the value of the FS variable  as  the  field
>        separator.   If FS is a single character, fields are sepa-
>        rated by that character.  If FS is the null  string,  then
>        each  individual character becomes a separate field.  Oth-
>        erwise, FS is expected to be a  full  regular  expression.

Hpmh.  The HPUX man page for plain awk says
         -F fs          Specify regular expression used to separate                        fields.  The default is to recognize space and tab                        characters, and to discard leading spaces and                        tabs.  If the -F option is used, leading input                        field separators are no longer discarded.

which makes me think we are treading on mighty thin ice here --- there
are lots of different versions of awk around, and some of them are
probably going to treat -F '.' as a regexp.

I'd suggest splitting the input with something more standardized.
Perhaps

sed 's/\./ /g' | $AWK '{printf ...
		regards, tom lane

Re: bug in PG_VERSION_NUM patch

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Tom Lane wrote:
> Bruce Momjian  writes:
> > OK, I reread the manual page:
> 
> >        As  each input record is read, gawk splits the record into
> >        fields, using the value of the FS variable  as  the  field
> >        separator.   If FS is a single character, fields are sepa-
> >        rated by that character.  If FS is the null  string,  then
> >        each  individual character becomes a separate field.  Oth-
> >        erwise, FS is expected to be a  full  regular  expression.
> 
> Hpmh.  The HPUX man page for plain awk says
> 
>           -F fs          Specify regular expression used to separate
>                          fields.  The default is to recognize space and tab
>                          characters, and to discard leading spaces and
>                          tabs.  If the -F option is used, leading input
>                          field separators are no longer discarded.
> 
> which makes me think we are treading on mighty thin ice here --- there
> are lots of different versions of awk around, and some of them are
> probably going to treat -F '.' as a regexp.
> 
> I'd suggest splitting the input with something more standardized.
> Perhaps
> 
> sed 's/\./ /g' | $AWK '{printf ...

Good idea, new code applied:
# Supply a numeric version string for use by 3rd party add-ons# awk -F is a regex on some platforms, and not on others, so make "." a tabPG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |tr '.' '	' |$AWK '{printf \"%d%02d%02d\", $1, $2, (NF >= 3) ? $3 : 0}'`"AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number])

--  Bruce Momjian   http://candle.pha.pa.us SRA OSS, Inc.   http://www.sraoss.com
 + If your life is a hard drive, Christ can be your backup. +

Re: bug in PG_VERSION_NUM patch

От:
Andrew - Supernews <andrew+nonews@supernews.com>
Дата:
On 2006-02-28, Tom Lane  wrote:
> Bruce Momjian  writes:
>> OK, I reread the manual page:
>
>>        As  each input record is read, gawk splits the record into
>>        fields, using the value of the FS variable  as  the  field
>>        separator.   If FS is a single character, fields are sepa-
>>        rated by that character.  If FS is the null  string,  then
>>        each  individual character becomes a separate field.  Oth-
>>        erwise, FS is expected to be a  full  regular  expression.
>
> Hpmh.  The HPUX man page for plain awk says
>
>           -F fs          Specify regular expression used to separate
>                          fields.  The default is to recognize space and tab
>                          characters, and to discard leading spaces and
>                          tabs.  If the -F option is used, leading input
>                          field separators are no longer discarded.
>
> which makes me think we are treading on mighty thin ice here --- there
> are lots of different versions of awk around, and some of them are
> probably going to treat -F '.' as a regexp.

Nope. Both the widespread awks (gawk and the "true awk") treat -F.
exactly as it is defined in the standard: the value "." is assigned to FS,
which is treated as a regexp only if it is more than one character long.

It is true that this aspect of FS isn't always made clear in manpages; note
that FS=" " (the default) also has a special meaning.

The relevent text from the spec:
An extended regular expression can be used to separate fields byusing the -F ERE option or by assigning a string containing theexpression to the built-in variable FS. The default value of theFS variable shall be a single . The following describes FSbehavior: 1. If FS is a null string, the behavior is unspecified. 2. If FS is a single character:  a. If FS is , skip leading and trailing s; fields     shall be delimited by sets of one or more s.  b. Otherwise, if FS is any other character c, fields shall be     delimited by each single occurrence of c. 3. Otherwise, the string value of FS shall be considered to be an    extended regular expression.  Each occurrence of a sequence    matching the extended regular expression shall delimit fields.

-- 
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

FAQ