Quoteing steven.jenkins / ieee.org, on Fri, Jan 30, 2004 at 12:47:49AM +0900: > ts wrote: > > Probably the good question is : what is a line ? do the "line" separator > > belong to the line or not ? > > I suppose any language can define it any way. But it seems clear that > much of the Ruby library is modeled after C and Unix (which are defined > by international standards). In ISO C, the newline is removed from the > string returned by gets(). > On the other hand, C doesn't let you redefine the input line separator. Modelled after, but supposed to be easier to use than C, and gets() is widely considered to be a mistake by even C programmers. The C IO library has some apis that strip newlines, and some that don't, and its a common source of bugs and confusion, not profitably emulated. For your amusement, here's some of the comments from the GNU C library docs: Line-Oriented Input =================== Since many programs interpret input on the basis of lines, it is convenient to have functions to read a line of text from a stream. Standard C has functions to do this, but they aren't very safe: null characters and even (for `gets') long lines can confuse them. So the GNU library provides the nonstandard `getline' function that makes it easy to read lines reliably. Another GNU extension, `getdelim', generalizes `getline'. It reads a delimited record, defined as everything through the next occurrence of a specified delimiter character. .... - Deprecated function: char * gets (char *S) The function `gets' reads characters from the stream `stdin' up to the next newline character, and stores them in the string S. The newline character is discarded (note that this differs from the behavior of `fgets', which copies the newline character into the string). If `gets' encounters a read error or end-of-file, it returns a null pointer; otherwise it returns S. *Warning:* The `gets' function is *very dangerous* because it provides no protection against overflowing the string S. The GNU library includes it for compatibility only. You should *always* use `fgets' or `getline' instead. To remind you of this, the linker (if using GNU `ld') will issue a warning whenever you use `gets'.