[m-dev.] diff: fix a quoting bug

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Mar 24 13:23:51 AEDT 2000


compiler/rtti_out.m:
	Fix a bug that generated unquoted C strings in the RTTI data
	structures.

tests/hard_coded/rtti_strings.{m,exp}:
	Test case for the fix.

tests/hard_coded/Mmakefile:
	Enable the test case.

Zoltan.

cvs diff: Diffing .
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/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.2
diff -u -b -r1.2 rtti_out.m
--- compiler/rtti_out.m	2000/03/20 08:03:23	1.2
+++ compiler/rtti_out.m	2000/03/22 08:49:59
@@ -45,7 +45,7 @@
 
 :- implementation.
 
-:- import_module llds, prog_out, options, globals.
+:- import_module llds, prog_out, c_util, options, globals.
 :- import_module string, list, require, std_util.
 
 %-----------------------------------------------------------------------------%
@@ -77,14 +77,14 @@
 	output_generic_rtti_data_defn_start(RttiTypeId, field_names(Ordinal),
 		DeclSet0, DeclSet),
 	io__write_string(" = {\n"),
-	output_maybe_strings(MaybeNames),
+	output_maybe_quoted_strings(MaybeNames),
 	io__write_string("};\n").
 output_rtti_data_defn(enum_functor_desc(RttiTypeId, FunctorName, Ordinal),
 		DeclSet0, DeclSet) -->
 	output_generic_rtti_data_defn_start(RttiTypeId,
 		enum_functor_desc(Ordinal), DeclSet0, DeclSet),
 	io__write_string(" = {\n\t"""),
-	io__write_string(FunctorName),
+	c_util__output_quoted_string(FunctorName),
 	io__write_string(""",\n\t"),
 	io__write_int(Ordinal),
 	io__write_string("\n};\n").
@@ -94,7 +94,7 @@
 	output_generic_rtti_data_defn_start(RttiTypeId, notag_functor_desc,
 		DeclSet1, DeclSet),
 	io__write_string(" = {\n\t"""),
-	io__write_string(FunctorName),
+	c_util__output_quoted_string(FunctorName),
 	io__write_string(""",\n\t (MR_PseudoTypeInfo) "),
 	output_rval(ArgType),
 	io__write_string("\n};\n").
@@ -122,7 +122,7 @@
 	output_generic_rtti_data_defn_start(RttiTypeId,
 		du_functor_desc(Ordinal), DeclSet3, DeclSet),
 	io__write_string(" = {\n\t"""),
-	io__write_string(FunctorName),
+	c_util__output_quoted_string(FunctorName),
 	io__write_string(""",\n\t"),
 	io__write_int(Arity),
 	io__write_string(",\n\t"),
@@ -231,9 +231,9 @@
 	output_maybe_code_addr(Init),
 	io__write_string(",\n\t"""),
 	{ prog_out__sym_name_to_string(Module, ModuleName) },
-	io__write_string(ModuleName),
+	c_util__output_quoted_string(ModuleName),
 	io__write_string(""",\n\t"""),
-	io__write_string(Type),
+	c_util__output_quoted_string(Type),
 	io__write_string(""",\n\t"),
 	io__write_int(Version),
 	io__write_string(",\n\t"),
@@ -433,7 +433,7 @@
 	io__write_string(ConstStr),
 
 	{ rtti_name_c_type(RttiName, CType, Suffix) },
-	io__write_string(CType),
+	c_util__output_quoted_string(CType),
 	io__write_string(" "),
 	output_rtti_addr(RttiTypeId, RttiName),
 	io__write_string(Suffix).
@@ -554,26 +554,26 @@
 	{ rtti__addr_to_string(RttiTypeId, RttiName, Str) },
 	io__write_string(Str).
 
-:- pred output_maybe_string(maybe(string)::in,
+:- pred output_maybe_quoted_string(maybe(string)::in,
 	io__state::di, io__state::uo) is det.
 
-output_maybe_string(MaybeName) -->
+output_maybe_quoted_string(MaybeName) -->
 	(
 		{ MaybeName = yes(Name) },
 		io__write_string(""""),
-		io__write_string(Name),
+		c_util__output_quoted_string(Name),
 		io__write_string("""")
 	;
 		{ MaybeName = no },
 		io__write_string("NULL")
 	).
 
-:- pred output_maybe_strings(list(maybe(string))::in,
+:- pred output_maybe_quoted_strings(list(maybe(string))::in,
 	io__state::di, io__state::uo) is det.
 
-output_maybe_strings(MaybeNames) -->
+output_maybe_quoted_strings(MaybeNames) -->
 	io__write_string("\t"),
-	io__write_list(MaybeNames, ",\n\t", output_maybe_string),
+	io__write_list(MaybeNames, ",\n\t", output_maybe_quoted_string),
 	io__write_string("\n").
 
 :- pred output_exist_locn(exist_typeinfo_locn::in,
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
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/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
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/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/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
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
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/hard_coded
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.79
diff -u -b -r1.79 Mmakefile
--- tests/hard_coded/Mmakefile	2000/03/21 04:54:37	1.79
+++ tests/hard_coded/Mmakefile	2000/03/22 07:13:50
@@ -97,6 +97,7 @@
 	reverse_arith \
 	rnd \
 	rtc_bug \
+	rtti_strings \
 	shift_test \
 	space \
 	string_alignment \
Index: tests/hard_coded/rtti_strings.exp
===================================================================
RCS file: rtti_strings.exp
diff -N rtti_strings.exp
--- /dev/null	Thu Sep  2 15:00:04 1999
+++ rtti_strings.exp	Wed Mar 22 20:02:01 2000
@@ -0,0 +1 @@
+const(no) /\ const(yes)
Index: tests/hard_coded/rtti_strings.m
===================================================================
RCS file: rtti_strings.m
diff -N rtti_strings.m
--- /dev/null	Thu Sep  2 15:00:04 1999
+++ rtti_strings.m	Wed Mar 22 20:01:54 2000
@@ -0,0 +1,27 @@
+% The 22 March 2000 version of the compiler generated C code that contained
+% strings that were not properly quoted in the RTTI structures of the type
+% below, due to the backslashes in the function names.
+
+:- module rtti_strings.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module bool.
+
+:- type boolean_constraint
+	--->	const(bool)
+	;	boolean_constraint =:= boolean_constraint
+	;	boolean_constraint /\ boolean_constraint
+	;	boolean_constraint \/ boolean_constraint
+	;	boolean_constraint `implies` boolean_constraint
+	;	not(boolean_constraint).
+
+main -->
+	io__write(const(no) /\ const(yes)),
+	io__write_string("\n").
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
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
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list