Re: ecpg tests make failed on Win32/MinGW

Поиск
Список
Период
Сортировка
От William ZHANG
Тема Re: ecpg tests make failed on Win32/MinGW
Дата
Msg-id ebia7c$1al8$1@news.hub.org
обсуждение исходный текст
Ответ на ecpg tests make failed on Win32/MinGW  ("William ZHANG" <uniware@zedware.org>)
Ответы Re: ecpg tests make failed on Win32/MinGW  (Michael Meskes <meskes@postgresql.org>)
Список pgsql-hackers
I have found the cause.

The source file func.pgc is in DOS format, using CRLF(\r\n, or 0x0D0A) as
the newline character(s). That's why I got the output:

$ make func.o
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-
statement -Wendif-labels -fno-strict-aliasing -g  -I./../../include -I../../../.
./../src/interfaces/libpq -I../../include -I../../../../../src/include -I./../..
/include -I../../../../../src/interfaces/libpq -I../../../../../src/include
-I./src/include/port/win32 -DEXEC_BACKEND 
"-I../../../../../src/include/port/win32"  -c -o func.o func.c -MMD -MP -MF .deps/func.Po
func.pgc: In function `main':
func.pgc:18: error: missing terminating " character
func.pgc:22: error: `BEGIN' undeclared (first use in this function)
func.pgc:22: error: (Each undeclared identifier is reported only once
func.pgc:22: error: for each function it appears in.)
func.pgc:22: error: syntax error before "RAISE"
func.pgc:22:16: warning: character constant too long for its type
func.pgc:24: error: `RETURN' undeclared (first use in this function)
func.pgc:26: error: `END' undeclared (first use in this function)
func.pgc:26: error: `$test$' undeclared (first use in this function)
func.pgc:26: error: syntax error before "language"
func.pgc:26: error: missing terminating " character
make: *** [func.o] Error 1

Now I change the file to use UNIX format, using LF(\n, or 0x0A) as the
newline character. Everything is OK then:

$ make func.o
../../preproc/ecpg -I./../../include -o func.c -I. func.pgc
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Winline -Wdeclaration-after-
statement -Wendif-labels -fno-strict-aliasing -g  -I./../../include -I../../../.
./../src/interfaces/libpq -I../../include -I../../../../../src/include -I./../..
/include -I../../../../../src/interfaces/libpq -I../../../../../src/include
-I./src/include/port/win32 -DEXEC_BACKEND 
"-I../../../../../src/include/port/win32"  -c -o func.o func.c -MMD -MP -MF .deps/func.Po

Most of the time, the lexer will recognize differnt kinds of newline
characters in the pgc file (see comments in file pgc.l at about line 237).
But for lines in dollar quoted strings, it will preserve the newline 
characters.
And in output_escaped_str() from preproc/output.c, we will replace  '\n' 
with
'\' and '\n'. Since the input string ends with "\r\n", after the replace, it
becomes '\r', '\', '\n'. That's why I have seen "^M\" in func.c.

Some lines of output from func.c(func.pgc in DOS format, showed in vim):

#line 16 "func.pgc"
^M
^M { ECPGdo(__LINE__, 0, 1, NULL, "create  function My_Table_Check () returns
trigger  as $test$^M\   BEGIN^M\   RAISE WARNING 'Notice: TG_NAME=%, TG WHEN=%', TG_NAME, TG_WHEN;^M\   RETURN NEW;^M\
END; $test$ language plpgsql", ECPGt_EOIT, ECPGt_EORT);
 
#line 24 "func.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 24 "func.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 24 "func.pgc"
^M
^M

Lines of output from func.c(func.pgc in UNIX format):

#line 16 "func.pgc"

 { ECPGdo(__LINE__, 0, 1, NULL, "create  function My_Table_Check () returns
trigger  as $test$\   BEGIN\   RAISE WARNING 'Notice: TG_NAME=%, TG WHEN=%', TG_NAME, TG_WHEN;\   RETURN NEW;\   END;
$test$language plpgsql", ECPGt_EOIT, ECPGt_EORT);
 
#line 24 "func.pgc"

if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 24 "func.pgc"

if (sqlca.sqlcode < 0) sqlprint();}
#line 24 "func.pgc"

Should we modify output_escaped_str() to work around this problem?

-- 
With regards,
William ZHANG




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: 8.2 features status
Следующее
От: "William ZHANG"
Дата:
Сообщение: Re: Bison Version