#8 Fix failing tests with fake readline

open
nobody
None
5
2011-03-30
2011-03-30
Christopher Head
No

With the fake readline() function, data is stored in the static "saved" variable between one line and the next. Unfortunately, if the next call is not to readline() but to getny(), as it is near the end of the third test case in test/edit, the crucial "y" character will already have been read into "saved", but getny() doesn't know anything about "saved". The best solution available under the circumstances (assuming one wishes to continue having getny() not require the user to press ENTER) seems to be to have readline() only read one byte at a time from the input. The attached patch does this (of course "saved" is now unnecessary and has been removed); thus, any bytes after the newline are left in the kernel's input buffer and delivered to subsequent code properly.

Discussion

  • The patch

     
    Attachments
  • "diff2" is an alternate patch which is more invasive (touches a lot more lines), but makes the readline() function smaller, simpler, and more efficient by taking advantage of the knowledge that it's only reading one byte at a time. "diff2" obsoletes patch 3259499, but "diff" does not.

     
  • The more invasive patch

     
    Attachments