[M3devel] bug in Wx.ToText, CM3 TEXTs
Mika Nystrom
mika at async.caltech.edu
Fri Apr 24 08:54:46 CEST 2009
Hello Modula-3ers,
These CM3 TEXTs simply won't stop dogging me!
There's a bug that I just fixed in Wx.ToText. I seem not to have
the repository checked out as me again, so could I bother someone
else to commit the change?
Synopsis
--------
Under SRC and P M3, the way you created a new TEXT of a given
size was you imported TextF and allocated a TEXT using
NEW(TEXT, n + 1)
where n is the length of the TEXT you want.
Under CM3, you're supposed to call (e.g.)
Text8.New(n)
Line 171 of Wx.m3 has:
PROCEDURE ToText (t: T): TEXT =
VAR txt := Text8.Create(t.nFull * ChunkSize + t.next + 1); (* line 171 *)
c := t.head; n := 0;
BEGIN
(The code t.nFull + ... + 1 is copied exactly from the older
implementation, and is wrong.)
Fix
---
The 1 needs to be removed, to make:
PROCEDURE ToText (t: T): TEXT =
VAR txt := Text8.Create(t.nFull * ChunkSize + t.next); (* line 171 *)
c := t.head; n := 0;
BEGIN
The path is m3-libs/libbuf/src/Wx.m3
I'm surprised no one has noticed this before. Does no one else use Wx?
Mika
More information about the M3devel
mailing list