Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!pa.dec.com!src.dec.com!Norman Ramsey From: nr@Princeton.EDU (Norman Ramsey) Newsgroups: comp.lang.modula3 Subject: Formatter doesn't flush trailing blanks Message-ID: <9102141802.AA11439@cs.Princeton.EDU> Date: 14 Feb 91 18:02:25 GMT Lines: 70 To: ellis, m3 Cc: nr@Princeton.EDU If the last character of a text is a blank, it doesn't get flushed correctly by Formatter.Flush. Evidence is below. This problem isn't affected by Jorge's fix. I assume that this problem is related to the special treatment of blanks in Formatter.PutChar (they don't get added to t.chars, but instead a special Ref containing only the blank is added). I can't quite puzzle out what's wrongby looking at Formatter.Flush and Formatter.WaitUntilEmpty. Norman nr@hart (22) % m3 Bugs15.mo Formatter.?o nr@hart (23) % a.out Formatter.T: input `prompt> ' emerges as `prompt>'. Formatter.T: input `prompt> ' emerges as ` prompt>'. Formatter.T: input `hello there' emerges as ` hello there'. Formatter.T: input `army boots! ' emerges as `army boots!'. Wr.T: input `prompt> ' emerges as `prompt> '. Wr.T: input `prompt> ' emerges as `prompt> '. Wr.T: input `hello there' emerges as `hello there'. Wr.T: input `army boots! ' emerges as `army boots! '. # To unbundle, "sed '1,/^# To unbundle/d' < thisfile | sh" # Thu Feb 14 12:58:23 EST 1991 echo Bugs15.m3 1>&2 sed 's/^-//' >'Bugs15.m3' <<'End of Bugs15.m3' -MODULE Bugs15 EXPORTS Main; -IMPORT Fmt, Formatter, Stdio, TextWr, Wr; - -VAR - under := TextWr.New(); - wr := Formatter.New(under); - -CONST - test = "prompt> "; - -PROCEDURE Check(msg:TEXT) = -BEGIN - Formatter.PutText(wr,msg); - Formatter.Flush(wr); - Wr.Flush(Formatter.UnderlyingWr(wr)); - - Wr.PutText(Stdio.stdout, - Fmt.F("Formatter.T: input `%s\' emerges as `%s\'.\n",msg,TextWr.To Text(under))); -END Check; - -PROCEDURE Check2(msg:TEXT) = -BEGIN - Wr.PutText(under,msg); - Wr.Flush(under); - - Wr.PutText(Stdio.stdout, - Fmt.F("Wr.T: input `%s\' emerges as `%s\'.\n",msg,TextWr.ToText(un der))); -END Check2; - -BEGIN - Check(test); - Check(test); - Check("hello there"); - Check("army boots! "); - Check2(test); - Check2(test); - Check2("hello there"); - Check2("army boots! "); -END Bugs15. - End of Bugs15.m3