Re: Desirable behavior of read-line procedure ?

From: Shiro Kawai <shiro_at_sqush.squareusa.com>
Date: Mon, 25 May 1998 14:21:47 -1000

> ==
> STk-3.99.1/Src/port.c :
> ==
> PRIMITIVE STk_read_line(SCM port)
> {
> :
> for (i = 0; ; i++) {
> switch (c = Getc(f)) {
> case EOF: if (i == 0) { free(buff); return STk_eof_object; }
> case '\r': i--; continue;
> case '\n': res = STk_makestrg(i, buff); free(buff); return res;
> default: if (i == size) {
> size += size / 2;
> buff = must_realloc(buff, size);
> :
> ==

Apparently this should be:

    for (i = 0; ; i++) {
      switch (c = Getc(f)) {
        case EOF: if (i == 0) { free(buff); return STk_eof_object; }
        case '\n': res = STk_makestrg(i, buff); free(buff); return res;
        case '\r': i--; continue;
        default: if (i == size) {
               size += size / 2;
               buff = must_realloc(buff, size);


I looked at the source of 3.1.1 and found it used fallthough from EOF
case into '\n' case (and had no '\r' case).

--
Shiro KAWAI
  Square USA Inc.   Honolulu Studio R&D division
#"The most important things are the hardest things to say" --- Stephen King
Received on Tue May 26 1998 - 01:14:44 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST