[m-rev.] diff: html_format.m cleanup

Zoltan Somogyi zs at csse.unimelb.edu.au
Wed Oct 4 17:03:41 AEST 2006


deep_profiler/html_format.m:
	Make use of 80 column width, and replace a couple of uses of DCGs with
	state variables.

Zoltan.

cvs diff: Diffing .
Index: html_format.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/html_format.m,v
retrieving revision 1.13
diff -u -b -r1.13 html_format.m
--- html_format.m	29 Mar 2006 08:07:40 -0000	1.13
+++ html_format.m	4 Oct 2006 06:45:32 -0000
@@ -309,14 +309,12 @@
         BoxToggle = ""
     ),
     ( list.member(toggle_inactive_modules, RelevantToggles) ->
-        InactiveModuleToggle =
-            footer_inactive_modules_toggle(Cmd, Pref, Deep)
+        InactiveModuleToggle = footer_inactive_modules_toggle(Cmd, Pref, Deep)
     ;
         InactiveModuleToggle = ""
     ),
     ( list.member(toggle_inactive_procs, RelevantToggles) ->
-        InactiveProcsToggle =
-            footer_inactive_procs_toggle(Cmd, Pref, Deep)
+        InactiveProcsToggle = footer_inactive_procs_toggle(Cmd, Pref, Deep)
     ;
         InactiveProcsToggle = ""
     ),
@@ -388,8 +386,7 @@
         Port1Pref = Pref ^ pref_fields := Port1Fields,
         Port1Msg = "No port counts",
         Port1Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Port1Pref, Deep, Cmd)),
-            s(Port1Msg)])
+            [s(deep_cmd_pref_to_url(Port1Pref, Deep, Cmd)), s(Port1Msg)])
     ),
     ( Fields ^ port_fields = port ->
         Port2Toggle = ""
@@ -398,8 +395,7 @@
         Port2Pref = Pref ^ pref_fields := Port2Fields,
         Port2Msg = "Port counts",
         Port2Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Port2Pref, Deep, Cmd)),
-            s(Port2Msg)])
+            [s(deep_cmd_pref_to_url(Port2Pref, Deep, Cmd)), s(Port2Msg)])
     ),
     ( Fields ^ time_fields = no_time ->
         Time1Toggle = ""
@@ -408,8 +404,7 @@
         Time1Pref = Pref ^ pref_fields := Time1Fields,
         Time1Msg = "No time info",
         Time1Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Time1Pref, Deep, Cmd)),
-            s(Time1Msg)])
+            [s(deep_cmd_pref_to_url(Time1Pref, Deep, Cmd)), s(Time1Msg)])
     ),
     ( Fields ^ time_fields = ticks ->
         Time2Toggle = ""
@@ -418,8 +413,7 @@
         Time2Pref = Pref ^ pref_fields := Time2Fields,
         Time2Msg = "Ticks",
         Time2Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Time2Pref, Deep, Cmd)),
-            s(Time2Msg)])
+            [s(deep_cmd_pref_to_url(Time2Pref, Deep, Cmd)), s(Time2Msg)])
     ),
     ( Fields ^ time_fields = time ->
         Time3Toggle = ""
@@ -428,8 +422,7 @@
         Time3Pref = Pref ^ pref_fields := Time3Fields,
         Time3Msg = "Times",
         Time3Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Time3Pref, Deep, Cmd)),
-            s(Time3Msg)])
+            [s(deep_cmd_pref_to_url(Time3Pref, Deep, Cmd)), s(Time3Msg)])
     ),
     ( Fields ^ time_fields = ticks_and_time ->
         Time4Toggle = ""
@@ -438,8 +431,7 @@
         Time4Pref = Pref ^ pref_fields := Time4Fields,
         Time4Msg = "Ticks and times",
         Time4Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Time4Pref, Deep, Cmd)),
-            s(Time4Msg)])
+            [s(deep_cmd_pref_to_url(Time4Pref, Deep, Cmd)), s(Time4Msg)])
     ),
     ( Fields ^ time_fields = time_and_percall ->
         Time5Toggle = ""
@@ -448,8 +440,7 @@
         Time5Pref = Pref ^ pref_fields := Time5Fields,
         Time5Msg = "Times and per-call times",
         Time5Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Time5Pref, Deep, Cmd)),
-            s(Time5Msg)])
+            [s(deep_cmd_pref_to_url(Time5Pref, Deep, Cmd)), s(Time5Msg)])
     ),
     ( Fields ^ time_fields = ticks_and_time_and_percall ->
         Time6Toggle = ""
@@ -459,8 +450,7 @@
         Time6Pref = Pref ^ pref_fields := Time6Fields,
         Time6Msg = "Ticks and times and per-call times",
         Time6Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Time6Pref, Deep, Cmd)),
-            s(Time6Msg)])
+            [s(deep_cmd_pref_to_url(Time6Pref, Deep, Cmd)), s(Time6Msg)])
     ),
     ( Fields ^ alloc_fields = no_alloc ->
         Alloc1Toggle = ""
@@ -469,8 +459,7 @@
         Alloc1Pref = Pref ^ pref_fields := Alloc1Fields,
         Alloc1Msg = "No allocations",
         Alloc1Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Alloc1Pref, Deep, Cmd)),
-            s(Alloc1Msg)])
+            [s(deep_cmd_pref_to_url(Alloc1Pref, Deep, Cmd)), s(Alloc1Msg)])
     ),
     ( Fields ^ alloc_fields = alloc ->
         Alloc2Toggle = ""
@@ -479,8 +468,7 @@
         Alloc2Pref = Pref ^ pref_fields := Alloc2Fields,
         Alloc2Msg = "Allocations",
         Alloc2Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Alloc2Pref, Deep, Cmd)),
-            s(Alloc2Msg)])
+            [s(deep_cmd_pref_to_url(Alloc2Pref, Deep, Cmd)), s(Alloc2Msg)])
     ),
     ( Fields ^ alloc_fields = alloc_and_percall ->
         Alloc3Toggle = ""
@@ -489,8 +477,7 @@
         Alloc3Pref = Pref ^ pref_fields := Alloc3Fields,
         Alloc3Msg = "Allocations and per-call allocations",
         Alloc3Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Alloc3Pref, Deep, Cmd)),
-            s(Alloc3Msg)])
+            [s(deep_cmd_pref_to_url(Alloc3Pref, Deep, Cmd)), s(Alloc3Msg)])
     ),
     ( Fields ^ memory_fields = no_memory ->
         Memory1Toggle = ""
@@ -499,8 +486,7 @@
         Memory1Pref = Pref ^ pref_fields := Memory1Fields,
         Memory1Msg = "No memory info",
         Memory1Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Memory1Pref, Deep, Cmd)),
-            s(Memory1Msg)])
+            [s(deep_cmd_pref_to_url(Memory1Pref, Deep, Cmd)), s(Memory1Msg)])
     ),
     ( Fields ^ memory_fields = memory(words) ->
         Memory2Toggle = ""
@@ -509,8 +495,7 @@
         Memory2Pref = Pref ^ pref_fields := Memory2Fields,
         Memory2Msg = "Words",
         Memory2Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Memory2Pref, Deep, Cmd)),
-            s(Memory2Msg)])
+            [s(deep_cmd_pref_to_url(Memory2Pref, Deep, Cmd)), s(Memory2Msg)])
     ),
     ( Fields ^ memory_fields = memory(bytes) ->
         Memory3Toggle = ""
@@ -519,8 +504,7 @@
         Memory3Pref = Pref ^ pref_fields := Memory3Fields,
         Memory3Msg = "Bytes",
         Memory3Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Memory3Pref, Deep, Cmd)),
-            s(Memory3Msg)])
+            [s(deep_cmd_pref_to_url(Memory3Pref, Deep, Cmd)), s(Memory3Msg)])
     ),
     ( Fields ^ memory_fields = memory_and_percall(words) ->
         Memory4Toggle = ""
@@ -530,8 +514,7 @@
         Memory4Pref = Pref ^ pref_fields := Memory4Fields,
         Memory4Msg = "Words and per-call words",
         Memory4Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Memory4Pref, Deep, Cmd)),
-            s(Memory4Msg)])
+            [s(deep_cmd_pref_to_url(Memory4Pref, Deep, Cmd)), s(Memory4Msg)])
     ),
     ( Fields ^ memory_fields = memory_and_percall(bytes) ->
         Memory5Toggle = ""
@@ -541,15 +524,13 @@
         Memory5Pref = Pref ^ pref_fields := Memory5Fields,
         Memory5Msg = "Bytes and per-call bytes",
         Memory5Toggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Memory5Pref, Deep, Cmd)),
-            s(Memory5Msg)])
+            [s(deep_cmd_pref_to_url(Memory5Pref, Deep, Cmd)), s(Memory5Msg)])
     ),
     ( Fields = default_fields ->
         DefaultMsg  = "Restore defaults",
         DefaultPref = Pref ^ pref_fields := default_fields,
         DefaultToggle = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(DefaultPref, Deep, Cmd)),
-            s(DefaultMsg)])
+            [s(deep_cmd_pref_to_url(DefaultPref, Deep, Cmd)), s(DefaultMsg)])
     ;
         DefaultToggle = ""
     ),
@@ -717,11 +698,9 @@
     ),
     HTML =
         string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Pref1, Deep, Cmd)),
-            s(Msg1)]) ++
+            [s(deep_cmd_pref_to_url(Pref1, Deep, Cmd)), s(Msg1)]) ++
         string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Pref2, Deep, Cmd)),
-            s(Msg2)]).
+            [s(deep_cmd_pref_to_url(Pref2, Deep, Cmd)), s(Msg2)]).
 
 %-----------------------------------------------------------------------------%
 
@@ -788,40 +767,35 @@
     ( CostKind \= calls ->
         MsgCalls = "Sort by calls",
         ToggleCalls = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(calls, InclDesc, Scope)),
-            s(MsgCalls)])
+            [s(UpdateCriteria(calls, InclDesc, Scope)), s(MsgCalls)])
     ;
         ToggleCalls = ""
     ),
     ( CostKind \= redos ->
         MsgRedos = "Sort by redos",
         ToggleRedos = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(redos, InclDesc, Scope)),
-            s(MsgRedos)])
+            [s(UpdateCriteria(redos, InclDesc, Scope)), s(MsgRedos)])
     ;
         ToggleRedos = ""
     ),
     ( CostKind \= time ->
         MsgTime = "Sort by time",
         ToggleTime = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(time, InclDesc, Scope)),
-            s(MsgTime)])
+            [s(UpdateCriteria(time, InclDesc, Scope)), s(MsgTime)])
     ;
         ToggleTime = ""
     ),
     ( CostKind \= allocs ->
         MsgAllocs = "Sort by allocations",
         ToggleAllocs = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(allocs, InclDesc, Scope)),
-            s(MsgAllocs)])
+            [s(UpdateCriteria(allocs, InclDesc, Scope)), s(MsgAllocs)])
     ;
         ToggleAllocs = ""
     ),
     ( CostKind \= words ->
         MsgWords = "Sort by words",
         ToggleWords = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(words, InclDesc, Scope)),
-            s(MsgWords)])
+            [s(UpdateCriteria(words, InclDesc, Scope)), s(MsgWords)])
     ;
         ToggleWords = ""
     ),
@@ -829,27 +803,23 @@
         InclDesc = self,
         MsgDesc = "Include descendants",
         ToggleDesc = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(CostKind, self_and_desc, Scope)),
-            s(MsgDesc)])
+            [s(UpdateCriteria(CostKind, self_and_desc, Scope)), s(MsgDesc)])
     ;
         InclDesc = self_and_desc,
         MsgDesc = "Exclude descendants",
         ToggleDesc = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(CostKind, self, Scope)),
-            s(MsgDesc)])
+            [s(UpdateCriteria(CostKind, self, Scope)), s(MsgDesc)])
     ),
     (
         Scope = per_call,
         MsgScope = "Count overall cost",
         ToggleScope = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(CostKind, InclDesc, overall)),
-            s(MsgScope)])
+            [s(UpdateCriteria(CostKind, InclDesc, overall)), s(MsgScope)])
     ;
         Scope = overall,
         MsgScope = "Count per-call cost",
         ToggleScope = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(UpdateCriteria(CostKind, InclDesc, per_call)),
-            s(MsgScope)])
+            [s(UpdateCriteria(CostKind, InclDesc, per_call)), s(MsgScope)])
     ),
     Toggles = ToggleCalls ++ ToggleRedos ++ ToggleTime ++ ToggleAllocs
         ++ ToggleWords ++ ToggleDesc ++ ToggleScope.
@@ -873,8 +843,7 @@
         Pref = Pref0 ^ pref_inactive := inactive_items(Procs, show)
     ),
     HTML = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Pref, Deep, Cmd)),
-            s(Msg)]).
+        [s(deep_cmd_pref_to_url(Pref, Deep, Cmd)), s(Msg)]).
 
 :- func footer_inactive_procs_toggle(cmd, preferences, deep) = string.
 
@@ -890,8 +859,7 @@
         Pref = Pref0 ^ pref_inactive := inactive_items(show, Modules)
     ),
     HTML = string.format("<A HREF=""%s"">%s</A>\n",
-            [s(deep_cmd_pref_to_url(Pref, Deep, Cmd)),
-            s(Msg)]).
+        [s(deep_cmd_pref_to_url(Pref, Deep, Cmd)), s(Msg)]).
 
 %-----------------------------------------------------------------------------%
 
@@ -966,30 +934,25 @@
         Source = WrapFunc("Source", by_context),
         FirstRow0 =
             "<TR>\n" ++
-            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n",
-                [s(Source)]) ++
-            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n",
-                [s(ProcName)])
+            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n", [s(Source)]) ++
+            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n", [s(ProcName)])
     ;
         IdFields = rank_proc,
         FirstRow0 =
             "<TR>\n" ++
             "<TH ALIGN=LEFT ROWSPAN=2>Rank\n" ++
-            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n",
-                [s(ProcName)])
+            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n", [s(ProcName)])
     ;
         IdFields = rank_module,
         FirstRow0 =
             "<TR>\n" ++
             "<TH ALIGN=LEFT ROWSPAN=2>Rank\n" ++
-            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n",
-                [s(ModuleName)])
+            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n", [s(ModuleName)])
     ;
         IdFields = proc,
         FirstRow0 =
             "<TR>\n" ++
-            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n",
-                [s(ProcName)])
+            string.format("<TH ALIGN=LEFT ROWSPAN=2>%s\n", [s(ProcName)])
     ),
     SecondRow0 = "<TR>\n",
     ( show_port_counts(Fields) = yes ->
@@ -1011,8 +974,7 @@
         TicksSelfOverall = WrapFunc("Self",
             by_cost(time, self, overall)),
         TicksSelfHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(TicksSelfOverall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(TicksSelfOverall)]),
         TicksSelfFields = 1
     ;
         TicksSelfHeading = "",
@@ -1020,15 +982,12 @@
     ),
     ( show_times(Fields) = yes ->
         ( show_quanta(Fields) = yes ->
-            TimeSelfOverall = WrapFunc("Time",
-                by_cost(time, self, overall))
+            TimeSelfOverall = WrapFunc("Time", by_cost(time, self, overall))
         ;
-            TimeSelfOverall = WrapFunc("Self",
-                by_cost(time, self, overall))
+            TimeSelfOverall = WrapFunc("Self", by_cost(time, self, overall))
         ),
         TimeSelfHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(TimeSelfOverall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(TimeSelfOverall)]),
         TimeSelfFields = 1
     ;
         TimeSelfHeading = "",
@@ -1042,11 +1001,9 @@
         TimeSelfPercentFields = 0
     ),
     ( show_per_times(Fields) = yes ->
-        TimeSelfPerCall = WrapFunc("/call",
-            by_cost(time, self, per_call)),
+        TimeSelfPerCall = WrapFunc("/call", by_cost(time, self, per_call)),
         TimeSelfPerCallHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(TimeSelfPerCall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(TimeSelfPerCall)]),
         TimeSelfPerCallFields = 1
     ;
         TimeSelfPerCallHeading = "",
@@ -1056,8 +1013,7 @@
         TicksTotalOverall = WrapFunc("Total",
             by_cost(time, self_and_desc, overall)),
         TicksTotalHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(TicksTotalOverall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(TicksTotalOverall)]),
         TicksTotalFields = 1
     ;
         TicksTotalHeading = "",
@@ -1072,8 +1028,7 @@
                 by_cost(time, self_and_desc, overall))
         ),
         TimeTotalHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(TimeTotalOverall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(TimeTotalOverall)]),
         TimeTotalFields = 1
     ;
         TimeTotalHeading = "",
@@ -1093,8 +1048,7 @@
         TimeTotalPerCall = WrapFunc("/call",
             by_cost(time, self_and_desc, per_call)),
         TimeTotalPerCallHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(TimeTotalPerCall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(TimeTotalPerCall)]),
         TimeTotalPerCallFields = 1
     ;
         TimeTotalPerCallHeading = "",
@@ -1112,19 +1066,14 @@
         TimeTotalPercentHeading ++ TimeTotalPerCallHeading,
     ( show_quanta(Fields) = yes, show_times(Fields) = yes ->
         FirstRow2 = FirstRow1 ++
-            string.format(
-                "<TH COLSPAN=%d>Clock ticks and times\n",
+            string.format("<TH COLSPAN=%d>Clock ticks and times\n",
                 [i(TimeFields)])
     ; show_quanta(Fields) = yes ->
         FirstRow2 = FirstRow1 ++
-            string.format(
-                "<TH COLSPAN=%d>Clock ticks\n",
-                [i(TimeFields)])
+            string.format("<TH COLSPAN=%d>Clock ticks\n", [i(TimeFields)])
     ; show_times(Fields) = yes ->
         FirstRow2 = FirstRow1 ++
-            string.format(
-                "<TH COLSPAN=%d>Time\n",
-                [i(TimeFields)])
+            string.format("<TH COLSPAN=%d>Time\n", [i(TimeFields)])
     ;
         FirstRow2 = FirstRow1
     ),
@@ -1132,8 +1081,7 @@
         AllocsSelfOverall = WrapFunc("Self",
             by_cost(allocs, self, overall)),
         AllocsSelfHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(AllocsSelfOverall)]) ++
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(AllocsSelfOverall)]) ++
             "<TH ALIGN=RIGHT>%\n",
         AllocsSelfFields = 2
     ;
@@ -1144,8 +1092,7 @@
         AllocsSelfPerCall = WrapFunc("/call",
             by_cost(allocs, self, per_call)),
         AllocsSelfPerCallHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(AllocsSelfPerCall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(AllocsSelfPerCall)]),
         AllocsSelfPerCallFields = 1
     ;
         AllocsSelfPerCallHeading = "",
@@ -1155,8 +1102,7 @@
         AllocsTotalOverall = WrapFunc("Total",
             by_cost(allocs, self_and_desc, overall)),
         AllocsTotalHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(AllocsTotalOverall)]) ++
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(AllocsTotalOverall)]) ++
             "<TH ALIGN=RIGHT>%\n",
         AllocsTotalFields = 2
     ;
@@ -1167,8 +1113,7 @@
         AllocsTotalPerCall = WrapFunc("/call",
             by_cost(allocs, self_and_desc, per_call)),
         AllocsTotalPerCallHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(AllocsTotalPerCall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(AllocsTotalPerCall)]),
         AllocsTotalPerCallFields = 1
     ;
         AllocsTotalPerCallHeading = "",
@@ -1182,8 +1127,7 @@
         AllocsTotalHeading ++ AllocsTotalPerCallHeading,
     ( show_alloc(Fields) = yes ->
         FirstRow3 = FirstRow2 ++
-            string.format(
-                "<TH COLSPAN=%d>Memory allocations\n",
+            string.format("<TH COLSPAN=%d>Memory allocations\n",
                 [i(AllocsFields)])
     ;
         FirstRow3 = FirstRow2
@@ -1192,8 +1136,7 @@
         MemorySelfOverall = WrapFunc("Self",
             by_cost(words, self, overall)),
         MemorySelfHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(MemorySelfOverall)]) ++
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(MemorySelfOverall)]) ++
             "<TH ALIGN=RIGHT>%\n",
         MemorySelfFields = 2
     ;
@@ -1204,8 +1147,7 @@
         MemorySelfPerCall = WrapFunc("/call",
             by_cost(words, self, per_call)),
         MemorySelfPerCallHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(MemorySelfPerCall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(MemorySelfPerCall)]),
         MemorySelfPerCallFields = 1
     ;
         MemorySelfPerCallHeading = "",
@@ -1215,8 +1157,7 @@
         MemoryTotalOverall = WrapFunc("Total",
             by_cost(words, self_and_desc, overall)),
         MemoryTotalHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(MemoryTotalOverall)]) ++
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(MemoryTotalOverall)]) ++
             "<TH ALIGN=RIGHT>%\n",
         MemoryTotalFields = 2
     ;
@@ -1227,8 +1168,7 @@
         MemoryTotalPerCall = WrapFunc("/call",
             by_cost(words, self_and_desc, per_call)),
         MemoryTotalPerCallHeading =
-            string.format("<TH ALIGN=RIGHT>%s\n",
-                [s(MemoryTotalPerCall)]),
+            string.format("<TH ALIGN=RIGHT>%s\n", [s(MemoryTotalPerCall)]),
         MemoryTotalPerCallFields = 1
     ;
         MemoryTotalPerCallHeading = "",
@@ -1244,14 +1184,12 @@
         (
             Units = words,
             FirstRow4 = FirstRow3 ++
-                string.format(
-                    "<TH COLSPAN=%d>Memory words\n",
+                string.format("<TH COLSPAN=%d>Memory words\n",
                     [i(MemoryFields)])
         ;
             Units = bytes,
             FirstRow4 = FirstRow3 ++
-                string.format(
-                    "<TH COLSPAN=%d>Memory bytes\n",
+                string.format("<TH COLSPAN=%d>Memory bytes\n",
                     [i(MemoryFields)])
         )
     ;
@@ -1953,25 +1891,35 @@
 
 escape_html_string(String) = EscapedString :-
     string.to_char_list(String, Chars),
-    escape_html_chars(Chars, EscapedChars, []),
+    escape_html_chars(Chars, [], EscapedChars),
     string.from_char_list(EscapedChars, EscapedString).
 
-:- pred escape_html_chars(list(char)::in, list(char)::out, list(char)::in)
+    % escape_html_chars(Chars, !EscChars):
+    %
+    % Put an escaped form of all the characters in Chars in front of
+    % !.EscChars, yielding !:EscChars.
+    %
+:- pred escape_html_chars(list(char)::in, list(char)::in, list(char)::out)
     is det.
 
-escape_html_chars([]) --> [].
-escape_html_chars([Char | Chars]) -->
-    escape_html_char(Char),
-    escape_html_chars(Chars).
-
-:- pred escape_html_char(char::in, list(char)::out, list(char)::in) is det.
-
-escape_html_char(Char) -->
-    ( { special_html_char(Char, String) } ->
-        { string.to_char_list(String, Chars) },
-        insert(Chars)
+escape_html_chars([], !EscChars).
+escape_html_chars([Char | Chars], !EscChars) :-
+    escape_html_chars(Chars, !EscChars),
+    escape_html_char(Char, !EscChars).
+
+    % escape_html_char(Char, !EscChars):
+    %
+    % Put an escaped form of the character Char in front of !.EscChars,
+    % yielding !:EscChars.
+    %
+:- pred escape_html_char(char::in, list(char)::in, list(char)::out) is det.
+
+escape_html_char(Char, !EscChars) :-
+    ( special_html_char(Char, String) ->
+        string.to_char_list(String, Chars),
+        list.append(Chars, !EscChars)
     ;
-        [Char]
+        !:EscChars = [Char | !.EscChars]
     ).
 
 :- pred special_html_char(char::in, string::out) is semidet.
@@ -1980,11 +1928,6 @@
 special_html_char('<', "<").
 special_html_char('>', ">").
 
-:- pred insert(list(T)::in, list(T)::out, list(T)::in) is det.
-
-insert(NewChars, Chars, Chars0) :-
-    list.append(NewChars, Chars0, Chars).
-
 %-----------------------------------------------------------------------------%
 :- end_module html_format.
 %-----------------------------------------------------------------------------%
cvs diff: Diffing notes
--------------------------------------------------------------------------
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