88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.19 1997/09/08 03:20:04 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.20 1997/09/12 09:01:46 vadim Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414*/
@@ -303,6 +303,7 @@ CurScanPosition(void)
303303#endif /* !defined(FLEX_SCANNER) */
304304
305305#ifdef FLEX_SCANNER
306+ static bool end_of_buf =false ;
306307/* input routine for flex to read input from a string instead of a file */
307308int
308309myinput (char * buf,int max)
@@ -320,17 +321,28 @@ myinput(char* buf, int max)
320321memcpy (buf, parseString, copylen);
321322buf[copylen] =' \0 ' ;
322323parseCh = parseString;
324+ end_of_buf =false ;
323325return copylen;
324326}
325327else
328+ {
329+ end_of_buf =true ;
326330return 0 ;/* end of string */
331+ }
327332}
328333
329334int
330335CurScanPosition (void )
331336{
332- printf (" current position is %d\n " , yy_c_buf_p - yy_current_buffer->yy_ch_buf - yyleng);
333- return (yy_c_buf_p - yy_current_buffer->yy_ch_buf - yyleng);
337+ int spos;
338+
339+ if ( end_of_buf )
340+ spos =strlen (parseString) -strlen (yytext);
341+ else
342+ spos = yy_c_buf_p - yy_current_buffer->yy_ch_buf - yyleng;
343+
344+ printf (" current position is %d\n " , spos);
345+ return (spos);
334346}
335347
336348#endif /* FLEX_SCANNER */