77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.97 1997/09/19 03:42:39 momjian Exp $
10+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.98 1997/09/23 19:47:59 momjian Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -1185,7 +1185,7 @@ do_help(PsqlSettings *pset, const char *topic)
11851185printf ("%-25s\n" ,QL_HELP [i ].cmd );
11861186left_center_right = 'L' ;
11871187break ;
1188- };
1188+ }
11891189i ++ ;
11901190}
11911191if (left_center_right != 'L' )
@@ -1649,6 +1649,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
16491649/* We've reached the end of our command input. */
16501650bool success ;
16511651bool in_quote ;
1652+ bool was_bslash ;/* backslash */
16521653int paren_level ;
16531654char * query_start ;
16541655
@@ -1737,7 +1738,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
17371738{
17381739query_start = line ;
17391740xcomment = line ;
1740- };
1741+ }
17411742
17421743if (line == NULL )
17431744{/* No more input. Time to quit */
@@ -1774,9 +1775,11 @@ MainLoop(PsqlSettings *pset, FILE *source)
17741775{
17751776int i ;
17761777
1778+ was_bslash = false;
1779+
17771780for (i = 0 ;i < len ;i ++ )
17781781{
1779- if (line [i ]== '\\' )
1782+ if (line [i ]== '\\' && ! in_quote )
17801783{
17811784char hold_char = line [i ];
17821785
@@ -1791,7 +1794,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
17911794else
17921795{
17931796strcpy (query ,query_start );
1794- };
1797+ }
17951798}
17961799line [i ]= hold_char ;
17971800query_start = line + i ;
@@ -1806,32 +1809,32 @@ MainLoop(PsqlSettings *pset, FILE *source)
18061809querySent = false;
18071810}
18081811
1812+ if (was_bslash )
1813+ was_bslash = false;
1814+ else if (i > 0 && line [i - 1 ]== '\\' )
1815+ was_bslash = true;
1816+
18091817/* inside a quote? */
1810- if (in_quote && (line [i ]!= '\'' ))
1818+ if (in_quote && (line [i ]!= '\'' || was_bslash ))
18111819{
1812- continue ;
1813-
1814- /* inside an extended comment? */
1820+ /* do nothing */ ;
18151821}
1816- else if (xcomment != NULL )
1822+ else if (xcomment != NULL )/*inside an extended comment?*/
18171823{
18181824if (line [i ]== '*' && line [i + 1 ]== '/' )
18191825{
18201826xcomment = NULL ;
18211827i ++ ;
1822- };
1823- continue ;
1824-
1825- /* possible backslash command? */
1828+ }
18261829}
1830+ /* possible backslash command? */
18271831else if (line [i ]== '/' && line [i + 1 ]== '*' )
18281832{
18291833xcomment = line + i ;
18301834i ++ ;
1831- continue ;
18321835
1833- /* single-line comment? truncate line */
18341836}
1837+ /* single-line comment? truncate line */
18351838else if ((line [i ]== '-' && line [i + 1 ]== '-' )||
18361839 (line [i ]== '/' && line [i + 1 ]== '/' ))
18371840{
@@ -1840,14 +1843,12 @@ MainLoop(PsqlSettings *pset, FILE *source)
18401843fprintf (stdout ,"%s\n" ,line + i );
18411844line [i ]= '\0' ;/* remove comment */
18421845break ;
1843-
18441846}
18451847else if (line [i ]== '\'' )
18461848{
18471849in_quote ^=1 ;
1848-
1849- /* semi-colon? then send query now */
18501850}
1851+ /* semi-colon? then send query now */
18511852else if (!paren_level && line [i ]== ';' )
18521853{
18531854char hold_char = line [i + 1 ];
@@ -1878,10 +1879,10 @@ MainLoop(PsqlSettings *pset, FILE *source)
18781879else if (paren_level && line [i ]== ')' )
18791880{
18801881paren_level -- ;
1881- };
1882+ }
18821883}
18831884}
1884-
1885+ puts ( line );
18851886/* nothing on line after trimming? then ignore */
18861887if (line [0 ]== '\0' )
18871888{