7
7
*
8
8
*
9
9
* 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 $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -1185,7 +1185,7 @@ do_help(PsqlSettings *pset, const char *topic)
1185
1185
printf ("%-25s\n" , QL_HELP [i ].cmd );
1186
1186
left_center_right = 'L' ;
1187
1187
break ;
1188
- };
1188
+ }
1189
1189
i ++ ;
1190
1190
}
1191
1191
if (left_center_right != 'L' )
@@ -1649,6 +1649,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
1649
1649
/* We've reached the end of our command input. */
1650
1650
bool success ;
1651
1651
bool in_quote ;
1652
+ bool was_bslash ; /* backslash */
1652
1653
int paren_level ;
1653
1654
char * query_start ;
1654
1655
@@ -1737,7 +1738,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
1737
1738
{
1738
1739
query_start = line ;
1739
1740
xcomment = line ;
1740
- };
1741
+ }
1741
1742
1742
1743
if (line == NULL )
1743
1744
{ /* No more input. Time to quit */
@@ -1774,9 +1775,11 @@ MainLoop(PsqlSettings *pset, FILE *source)
1774
1775
{
1775
1776
int i ;
1776
1777
1778
+ was_bslash = false;
1779
+
1777
1780
for (i = 0 ; i < len ; i ++ )
1778
1781
{
1779
- if (line [i ] == '\\' )
1782
+ if (line [i ] == '\\' && ! in_quote )
1780
1783
{
1781
1784
char hold_char = line [i ];
1782
1785
@@ -1791,7 +1794,7 @@ MainLoop(PsqlSettings *pset, FILE *source)
1791
1794
else
1792
1795
{
1793
1796
strcpy (query , query_start );
1794
- };
1797
+ }
1795
1798
}
1796
1799
line [i ] = hold_char ;
1797
1800
query_start = line + i ;
@@ -1806,32 +1809,32 @@ MainLoop(PsqlSettings *pset, FILE *source)
1806
1809
querySent = false;
1807
1810
}
1808
1811
1812
+ if (was_bslash )
1813
+ was_bslash = false;
1814
+ else if (i > 0 && line [i - 1 ] == '\\' )
1815
+ was_bslash = true;
1816
+
1809
1817
/* inside a quote? */
1810
- if (in_quote && (line [i ] != '\'' ))
1818
+ if (in_quote && (line [i ] != '\'' || was_bslash ))
1811
1819
{
1812
- continue ;
1813
-
1814
- /* inside an extended comment? */
1820
+ /* do nothing */ ;
1815
1821
}
1816
- else if (xcomment != NULL )
1822
+ else if (xcomment != NULL ) /*inside an extended comment?*/
1817
1823
{
1818
1824
if (line [i ] == '*' && line [i + 1 ] == '/' )
1819
1825
{
1820
1826
xcomment = NULL ;
1821
1827
i ++ ;
1822
- };
1823
- continue ;
1824
-
1825
- /* possible backslash command? */
1828
+ }
1826
1829
}
1830
+ /* possible backslash command? */
1827
1831
else if (line [i ] == '/' && line [i + 1 ] == '*' )
1828
1832
{
1829
1833
xcomment = line + i ;
1830
1834
i ++ ;
1831
- continue ;
1832
1835
1833
- /* single-line comment? truncate line */
1834
1836
}
1837
+ /* single-line comment? truncate line */
1835
1838
else if ((line [i ] == '-' && line [i + 1 ] == '-' ) ||
1836
1839
(line [i ] == '/' && line [i + 1 ] == '/' ))
1837
1840
{
@@ -1840,14 +1843,12 @@ MainLoop(PsqlSettings *pset, FILE *source)
1840
1843
fprintf (stdout , "%s\n" , line + i );
1841
1844
line [i ] = '\0' ; /* remove comment */
1842
1845
break ;
1843
-
1844
1846
}
1845
1847
else if (line [i ] == '\'' )
1846
1848
{
1847
1849
in_quote ^= 1 ;
1848
-
1849
- /* semi-colon? then send query now */
1850
1850
}
1851
+ /* semi-colon? then send query now */
1851
1852
else if (!paren_level && line [i ] == ';' )
1852
1853
{
1853
1854
char hold_char = line [i + 1 ];
@@ -1878,10 +1879,10 @@ MainLoop(PsqlSettings *pset, FILE *source)
1878
1879
else if (paren_level && line [i ] == ')' )
1879
1880
{
1880
1881
paren_level -- ;
1881
- };
1882
+ }
1882
1883
}
1883
1884
}
1884
-
1885
+ puts ( line );
1885
1886
/* nothing on line after trimming? then ignore */
1886
1887
if (line [0 ] == '\0' )
1887
1888
{
0 commit comments