Re: Tutorial
Peter Bortas <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CA+NK+AAepNLMVCWm28rnWe9Ztcgn=J82PgdTDKeKZT8jON=kkg@mail.gmail.com> |
On Thu, Dec 8, 2016 at 7:08 PM, Chris Angelico <[email protected]> wrote: > On Fri, Dec 9, 2016 at 3:32 AM, Peter Bortas <[email protected]> wrote: >> Since I happened to have my Windows VM console up: I can confirm this >> behavior in the default Hilfe: >> >>> Stdio.stdin->gets(); >> foo >> (1) Result: "foo\r" >> >> That seems rather useless. It would break the API to fix it, but on >> the other hand gets() is one of those functions you almost only use in >> tutorials. > > Would it break the API? I mean, conceptually, it's retrieving a string > terminated by end-of-line. On Windows, "end-of-line" is often "\r\n". > Perhaps the solution is for gets to always strip off a trailing \r? > Bear in mind that this also applies to files that have CRLF endings, > not just stdin. I normally get around it by trimming whites, but it'd > be nice for it to just work. It would not break the documented API, but it would change what gets() returns on all OS. Maybe someone somewhere is feeding gets() with deliberate \r's at the end. To clarify: I am argumenting for breaking it though. Maybe even before 8.2. Speaking of silly functions, has anyone ever used ->ngets()? -- Peter Bortas