Re: bug in read-lines: skips empty lines
Raymond Martin <[email protected]> Mon, 13 Feb 2006 17:56:04 +0000
| Newsgroups | gmane.lisp.lush.devel |
|---|---|
| Message-ID | <[email protected]> |
On Monday 13 February 2006 17:10, Ralf Juengling wrote: > > read-lines should return an empty string for an empty line. > Here is a fix that works on a unix platform: > > --- orig/lsh/libc/shell.lsh > +++ mod/lsh/libc/shell.lsh > @@ -75,8 +75,9 @@ > (de read-lines(f) > (reading f > (let ((ans ())) > - (while (<> (skip-char "\n\r\f") "\e") > - (setq ans (cons (read-string) ans))) > + (while (<> (skip-char "") "\e") > + (setq ans (cons (read-string) ans)) > + (read-string 1)) ;; need a function 'read-newline' here > (reverse ans)))) > Isn't the function name "read-lines" something of a misnomer. Shouldn't it be more like "read-file-lines", it only works with a filename/descriptor and does not match with "write-lines" (for which a "write-file-lines" might also be appropriate). In addition, some of these functions are defined in libc/shell.lsh when they are clearly string manipulation functions (e.g. in a file like libstd/string.lsh) that can be used separately from a shell. For instance, I am writing some text processing functions which have no need of anything from the shell. Raymond __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642