General Bug Report: ECPG fails to parse comments correctly

Поиск
Список
Период
Сортировка
От Unprivileged user
Тема General Bug Report: ECPG fails to parse comments correctly
Дата
Msg-id 199905121904.PAA30233@hub.org
обсуждение исходный текст
Список pgsql-bugs
============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name               : Craig Orsinger
Your email address      : orsingerc@epg.lewis.army.mil

Category                : runtime: front-end: C
Severity                : non-critical

Summary: ECPG fails to parse comments correctly

System Configuration
--------------------
  Operating System   : HPUX 10.20 and Linux 2.0.36

  PostgreSQL version : 6.4.2

  Compiler used      : gcc, HP cc

Hardware:
---------
HP 715/100 workstation, 64MB  RAM
NEC Versa LX laptop, 128MB RAM


Versions of other tools:
------------------------
GNU make

--------------------------------------------------------------------------

Problem Description:
--------------------
While trying to compile a function written in
embedded SQL for C, got an error indication of the
form:

test.pgc:30: unbalanced `#endif'

After some trial and error, I discovered that this
message occured if a C preprocessor directive was
placed after the end of a block of code that was
terminated by a comment (see example). Putting the
comment on a separate line cured this difficulty.
The ecpg invocation was of the form:

ecpg test.pgc
gcc -O2 -I$PGDIR/include -c test.c -o test.o

There were no other command line parameters.
"PGDIR" is the root of the PostgreSQL installation.



--------------------------------------------------------------------------

Test Case:
----------
Compile this bit of C source with these commands:

ecpg test.pgc
gcc -O2 -I$PGDIR/include -c test.c -o test.o

/* test.pgc - demonstrate comment-parsing problem */


EXEC SQL INCLUDE sqlca.h ;


int func_we_want( int paramA )
   {
EXEC SQL BEGIN DECLARE SECTION ;
   int retval ;
EXEC SQL END DECLARE SECTION ;

   retval = paramA ;
   return( retval ) ;

   } /* end of 'func_we_want()' */

#ifdef WE_WANT_THIS_FUNC

int func_we_dont_want( int paramA )
   {
EXEC SQL BEGIN DECLARE SECTION ;
   int retval ;
EXEC SQL END DECLARE SECTION ;

   retval = paramA ;
   return( retval ) ;

   } /* end of 'func_we_dont_want()' */

#endif

As written, it will fail. To make it compile correctly,
just insert a newline between the '}' and the "end of .."
comments at the end of each function.


--------------------------------------------------------------------------

Solution:
---------
I'd suggest that you ensure that there is always a
newline after the closing bracket of a block of C
source.


--------------------------------------------------------------------------


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [BUGS] did this ever get integrated ? (for OpenBSD)
Следующее
От: Paul Quirk
Дата:
Сообщение: problem with dates.