[m-rev.] More readable C code

Ben Schmidt b.schmidt at ugrad.unimelb.edu.au
Thu Jan 18 23:26:23 AEDT 2007


Estimated hours taken: 0
Branches: main

compiler/mlds_to_c.m:
	Output array and structure initialisers with more traditional/readable
	linebreaks and indentation.




Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.209
diff -u -r1.209 mlds_to_c.m
--- compiler/mlds_to_c.m	16 Jan 2007 16:22:29 -0000	1.209
+++ compiler/mlds_to_c.m	18 Jan 2007 12:19:34 -0000
@@ -1666,6 +1666,8 @@
      io.write_string("{\n", !IO),
      io.write_list(FieldInits, ",\n", 
mlds_output_initializer_body(Indent + 1),
          !IO),
+    io.write_string("\n", !IO),
+    mlds_indent(Indent, !IO),
      io.write_string("}", !IO).
  mlds_output_initializer_body(Indent, init_array(ElementInits), !IO) :-
      % Standard ANSI/ISO C does not allow empty arrays. But the MLDS does.
@@ -1678,14 +1680,16 @@
      io.write_string("{\n", !IO),
      (
          ElementInits = [],
-        mlds_indent(Indent, !IO),
+        mlds_indent(Indent + 1, !IO),
          io.write_string("0", !IO)
      ;
          ElementInits = [_ | _],
          io.write_list(ElementInits, ",\n",
              mlds_output_initializer_body(Indent + 1), !IO)
      ),
-    io.write_string(" }", !IO).
+    io.write_string("\n", !IO),
+    mlds_indent(Indent, !IO),
+    io.write_string("}", !IO).

 
%-----------------------------------------------------------------------------%
  %
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list