Bug 606 : readStringUntil broken in Network library (same flavour as Bug 96 in Serial library)
Last modified: 2007-09-13 18:09



Assigned To:

Attachment Type Created Size Actions
illustrates bug 606 in readStringUntil function of Network library application/octet-stream 2007-08-07 14:12 1.82 KB

Description:   Opened: 2007-08-07 09:10
I am using Processing 0125 and Mac OS X 10.4.10 (PowerPC)

The "readStringUntil" function currently drops any data in the buffer after the "interesting"
character. So if, for example, two lines are read into the buffer before readStringUntil('\n')
gets called, the first line is returned and the second vanishes.

A very similar (or the same??) bug was reported as "Bug 96" for readBytesUntil in the Serial
library back in 2005.


-- djones

p.s. Here is the patch posted by fry / stendahl back in 2005.
I haven't tried it, but maybe it will also fix this bug
when inserted into the corresponding code in the Network library.

Here's a patch (is this the right place for this sort of thing, btw?):

Index: serial/Serial.java
RCS file: /cvsroot/processing/processing/serial/Serial.java,v
retrieving revision 1.2
diff -r1.2 Serial.java
< bufferIndex = 0; // rewind
< bufferLast = 0;
> bufferIndex += length;
> if (bufferIndex == bufferLast) {
> bufferIndex = 0; // rewind
> bufferLast = 0;
> }
Additional Comment #1 From djones 2007-08-07 14:12
illustrates bug 606 in readStringUntil function of Network library

This program connects to the FTP server (port 21) on the localhost
and sends "help" to get back a list of commands.

The program calls the buggy "readStringUntil" function, which results in the
list of commands being truncated and not displayed properly.

The program illustrates a workaround by calling a special version of
readBytesUntil with 2 arguments and displaying the correct results.

The errors in the source code are obvious in Client.java (Network library) and
Serial.java (Serial library) and a patch has already been posted in the Bug
Database for bug #96.

There are several different versions of readBytes and readStrings, and I
suspect someone previously fixed one version, but not the others, leaving this
lingering bug.

I hope it will get fixed soon.

-- David Jones
Additional Comment #2 From fry 2007-08-28 18:56
thanks for the report, will try to get that fixed for the next release.
Additional Comment #3 From fry 2007-09-13 18:09
thanks for tracking this down, now fixed for 0126.