[m-rev.] diff: avoid debugger abort on unbalanced quote
Zoltan Somogyi
zs at cs.mu.OZ.AU
Tue Jan 27 08:17:14 AEDT 2004
trace/mercury_trace_internal.m:
When the input contains an unmatched quote or backslash, which can
happen when the user accidentally types ctrl-D, do not abort, which can
lose a long debugging session. Instead, just print a message.
tests/debugger/cmd_quote.{inp,exp}:
Update this test case to test the new functionality.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/cmd_quote.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/cmd_quote.exp,v
retrieving revision 1.2
diff -u -b -r1.2 cmd_quote.exp
--- tests/debugger/cmd_quote.exp 17 Jan 2003 05:56:52 -0000 1.2
+++ tests/debugger/cmd_quote.exp 23 Jan 2004 20:37:42 -0000
@@ -38,4 +38,6 @@
Unknown command ` .'. Give the command `help' for help.
mdb> '\ \\\''
Unknown command ` \''. Give the command `help' for help.
-mdb> quit -y
+mdb> '
+> unmatched quote.
+mdb> mdb: are you sure you want to quit?
\ No newline at end of file
Index: tests/debugger/cmd_quote.inp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/cmd_quote.inp,v
retrieving revision 1.1
diff -u -b -r1.1 cmd_quote.inp
--- tests/debugger/cmd_quote.inp 25 Feb 2002 03:52:49 -0000 1.1
+++ tests/debugger/cmd_quote.inp 23 Jan 2004 13:37:23 -0000
@@ -22,4 +22,4 @@
'foo\''
\ \ \ .
'\ \\\''
-quit -y
+'
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.165
diff -u -b -r1.165 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 20 Jan 2004 09:13:23 -0000 1.165
+++ trace/mercury_trace_internal.c 23 Jan 2004 13:32:40 -0000
@@ -619,9 +619,10 @@
static const char *MR_trace_read_help_text(void);
static const char *MR_trace_parse_line(char *line,
char ***words, int *word_max, int *word_count);
-static int MR_trace_break_into_words(char *line,
- char ***words_ptr, int *word_max_ptr);
-static int MR_trace_break_off_one_word(char *line, int char_pos);
+static const char *MR_trace_break_into_words(char *line, char ***words_ptr,
+ int *word_max_ptr, int *word_count_ptr);
+static const char *MR_trace_break_off_one_word(char *line, int char_pos,
+ int *new_char_pos_ptr);
static void MR_trace_expand_aliases(char ***words,
int *word_max, int *word_count);
static MR_bool MR_trace_source(const char *filename, MR_bool ignore_errors);
@@ -6166,18 +6167,22 @@
{
char **raw_words;
int raw_word_max;
- char raw_word_count;
+ int raw_word_count;
static char count_buf[MR_NUMBER_LEN + 1];
char *s;
int i;
+ const char *problem;
/*
** Handle a possible number prefix on the first word on the line,
** separating it out into a word on its own.
*/
- raw_word_count = MR_trace_break_into_words(line,
- &raw_words, &raw_word_max);
+ problem = MR_trace_break_into_words(line, &raw_words, &raw_word_max,
+ &raw_word_count);
+ if (problem != NULL) {
+ return problem;
+ }
if (raw_word_count > 0 && MR_isdigit(*raw_words[0])) {
i = 0;
@@ -6242,13 +6247,16 @@
** and it is the responsibility of the caller to MR_free() it when appropriate.
*/
-static int
-MR_trace_break_into_words(char *line, char ***words_ptr, int *word_max_ptr)
+static const char *
+MR_trace_break_into_words(char *line, char ***words_ptr, int *word_max_ptr,
+ int *word_count)
{
int word_max;
char **words;
int token_number;
int char_pos;
+ int new_char_pos;
+ const char *problem;
token_number = 0;
char_pos = 0;
@@ -6265,20 +6273,26 @@
if (line[char_pos] == '\0') {
*words_ptr = words;
*word_max_ptr = word_max;
- return token_number;
+ *word_count = token_number;
+ return NULL;
}
MR_ensure_big_enough(token_number, word, char *,
MR_INIT_WORD_COUNT);
words[token_number] = line + char_pos;
- char_pos = MR_trace_break_off_one_word(line, char_pos);
+ problem = MR_trace_break_off_one_word(line, char_pos,
+ &new_char_pos);
+ if (problem != NULL) {
+ return problem;
+ }
+ char_pos = new_char_pos;
token_number++;
}
}
-static int
-MR_trace_break_off_one_word(char *line, int char_pos)
+static const char *
+MR_trace_break_off_one_word(char *line, int char_pos, int *new_char_pos_ptr)
{
int lag = 0;
MR_bool quoted = MR_FALSE;
@@ -6298,10 +6312,7 @@
lag++;
char_pos++;
if (line[char_pos] == '\0') {
- MR_fatal_error(
- "MR_trace_break_off_one_word: "
- "unhandled backslash");
- }
+ return "bad backslash"; }
}
if (lag) {
@@ -6312,7 +6323,7 @@
}
if (quoted) {
- MR_fatal_error("MR_trace_break_off_one_word: unmatched quote");
+ return "unmatched quote";
}
line[char_pos - lag] = '\0';
@@ -6320,7 +6331,8 @@
char_pos++;
}
- return char_pos;
+ *new_char_pos_ptr = char_pos;
+ return NULL;
}
static void
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list