? config.log ? config.cache ? config.status ? GNUmakefile ? src/GNUmakefile ? src/Makefile.global ? src/log ? src/Makefile.custom ? src/crtags ? src/backend/postgres ? src/backend/catalog/genbki.sh ? src/backend/catalog/global1.bki.source ? src/backend/catalog/global1.description ? src/backend/catalog/local1_template1.bki.source ? src/backend/catalog/local1_template1.description ? src/backend/port/Makefile ? src/backend/utils/Gen_fmgrtab.sh ? src/bin/initdb/initdb ? src/bin/initlocation/initlocation ? src/bin/ipcclean/ipcclean ? src/bin/pg_ctl/pg_ctl ? src/bin/pg_dump/Makefile ? src/bin/pg_dump/pg_dump ? src/bin/pg_id/pg_id ? src/bin/pg_passwd/pg_passwd ? src/bin/pg_version/Makefile ? src/bin/pg_version/pg_version ? src/bin/pgaccess/pgaccess ? src/bin/pgtclsh/mkMakefile.tcldefs.sh ? src/bin/pgtclsh/mkMakefile.tkdefs.sh ? src/bin/pgtclsh/pgtclsh ? src/bin/pgtclsh/Makefile.tkdefs ? src/bin/pgtclsh/Makefile.tcldefs ? src/bin/pgtclsh/pgtksh ? src/bin/psql/psql ? src/bin/psql/Makefile ? src/bin/scripts/createlang ? src/include/version.h ? src/include/config.h ? src/include/parser/parse.h ? src/include/utils/fmgroids.h ? src/interfaces/Makefile ? src/interfaces/ecpg/lib/Makefile ? src/interfaces/ecpg/lib/libecpg.so.3.1.1 ? src/interfaces/ecpg/preproc/Makefile ? src/interfaces/ecpg/preproc/ecpg ? src/interfaces/libpgeasy/Makefile ? src/interfaces/libpgeasy/libpgeasy.so.2.1 ? src/interfaces/libpgtcl/Makefile ? src/interfaces/libpgtcl/libpgtcl.so.2.1 ? src/interfaces/libpq/Makefile ? src/interfaces/libpq/libpq.so.2.1 ? src/interfaces/libpq++/Makefile ? src/interfaces/odbc/GNUmakefile ? src/interfaces/perl5/GNUmakefile ? src/interfaces/python/GNUmakefile ? src/pl/Makefile ? src/pl/plperl/GNUmakefile ? src/pl/plpgsql/src/Makefile ? src/pl/plpgsql/src/mklang.sql ? src/pl/plpgsql/src/libplpgsql.so.1.0 ? src/pl/tcl/mkMakefile.tcldefs.sh ? src/pl/tcl/Makefile.tcldefs ? src/test/regress/GNUmakefile Index: src/bin/psql/mainloop.c =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/psql/mainloop.c,v retrieving revision 1.31 diff -c -r1.31 mainloop.c *** src/bin/psql/mainloop.c 2000/06/29 16:27:57 1.31 --- src/bin/psql/mainloop.c 2000/06/30 18:02:06 *************** *** 44,50 **** bool success; volatile char in_quote; /* == 0 for no in_quote */ ! volatile bool xcomment; /* in extended comment */ volatile int paren_level; unsigned int query_start; volatile int count_eof = 0; --- 44,50 ---- bool success; volatile char in_quote; /* == 0 for no in_quote */ ! volatile bool in_xcomment; /* in extended comment */ volatile int paren_level; unsigned int query_start; volatile int count_eof = 0; *************** *** 80,86 **** exit(EXIT_FAILURE); } ! xcomment = false; in_quote = 0; paren_level = 0; slashCmdStatus = CMD_UNKNOWN; /* set default */ --- 80,86 ---- exit(EXIT_FAILURE); } ! in_xcomment = false; in_quote = 0; paren_level = 0; slashCmdStatus = CMD_UNKNOWN; /* set default */ *************** *** 123,129 **** resetPQExpBuffer(query_buf); /* reset parsing state */ ! xcomment = false; in_quote = 0; paren_level = 0; count_eof = 0; --- 123,129 ---- resetPQExpBuffer(query_buf); /* reset parsing state */ ! in_xcomment = false; in_quote = 0; paren_level = 0; count_eof = 0; *************** *** 147,153 **** line = xstrdup(query_buf->data); resetPQExpBuffer(query_buf); /* reset parsing state since we are rescanning whole line */ ! xcomment = false; in_quote = 0; paren_level = 0; slashCmdStatus = CMD_UNKNOWN; --- 147,153 ---- line = xstrdup(query_buf->data); resetPQExpBuffer(query_buf); /* reset parsing state since we are rescanning whole line */ ! in_xcomment = false; in_quote = 0; paren_level = 0; slashCmdStatus = CMD_UNKNOWN; *************** *** 168,174 **** prompt_status = PROMPT_SINGLEQUOTE; else if (in_quote && in_quote == '"') prompt_status = PROMPT_DOUBLEQUOTE; ! else if (xcomment) prompt_status = PROMPT_COMMENT; else if (paren_level) prompt_status = PROMPT_PAREN; --- 168,174 ---- prompt_status = PROMPT_SINGLEQUOTE; else if (in_quote && in_quote == '"') prompt_status = PROMPT_DOUBLEQUOTE; ! else if (in_xcomment) prompt_status = PROMPT_COMMENT; else if (paren_level) prompt_status = PROMPT_PAREN; *************** *** 296,337 **** bslash_count = 0; rescan: ! /* start of extended comment? */ ! if (line[i] == '/' && line[i + thislen] == '*') { ! xcomment = true; ! ADVANCE_1; } /* in extended comment? */ ! else if (xcomment) { if (line[i] == '*' && line[i + thislen] == '/') { ! xcomment = false; ADVANCE_1; } } - - /* single-line comment? truncate line */ - else if (line[i] == '-' && line[i + thislen] == '-') - { - line[i] = '\0'; /* remove comment */ - break; - } ! /* in quote? */ ! else if (in_quote) { ! /* end of quote */ ! if (line[i] == in_quote && bslash_count % 2 == 0) ! in_quote = '\0'; } /* start of quote */ else if (!was_bslash && (line[i] == '\'' || line[i] == '"')) in_quote = line[i]; /* count nested parentheses */ else if (line[i] == '(') --- 296,345 ---- bslash_count = 0; rescan: ! /* ! * It is important to place the in_* test routines ! * before the in_* detection routines. ! * i.e. we have to test if we are in a quote before ! * testing for comments. bjm 2000-06-30 ! */ ! ! /* in quote? */ ! if (in_quote) { ! /* end of quote */ ! if (line[i] == in_quote && bslash_count % 2 == 0) ! in_quote = '\0'; } /* in extended comment? */ ! else if (in_xcomment) { if (line[i] == '*' && line[i + thislen] == '/') { ! in_xcomment = false; ADVANCE_1; } } ! /* start of extended comment? */ ! else if (line[i] == '/' && line[i + thislen] == '*') { ! in_xcomment = true; ! ADVANCE_1; } /* start of quote */ else if (!was_bslash && (line[i] == '\'' || line[i] == '"')) in_quote = line[i]; + + + /* single-line comment? truncate line */ + else if (line[i] == '-' && line[i + thislen] == '-') + { + line[i] = '\0'; /* remove comment */ + break; + } /* count nested parentheses */ else if (line[i] == '(')