You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/14 09:10:36 UTC

[GitHub] [incubator-nuttx] fjpanag opened a new issue, #7308: ungetc does not respect EOF.

fjpanag opened a new issue, #7308:
URL: https://github.com/apache/incubator-nuttx/issues/7308

   The function `ungetc()` does not respect the `EOF` character.  
   If you try to unget an `EOF`, it will indeed be added into the `fs_ungotten[]` buffer, instead of returning with error.
   
   Consider the following snippet:
   ```c
   
   /* Get a character from a stream. */
   
   int c = getc(f);
   
   /* There were no characters to read. c == EOF */
   
   assert(c == EOF);
   
   /* ungetc does not detect this! It thinks its a normal character! */
   
   ungetc(c, f);
   
   /* Try to read a character again. It should be EOF. */
   
   assert(getc(f) == EOF);
   
   /* ERROR! getc() didn't return EOF! */
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on issue #7308: ungetc does not respect EOF.

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on issue #7308:
URL: https://github.com/apache/incubator-nuttx/issues/7308#issuecomment-1278728226

   Reread description again. All is clear


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 closed issue #7308: ungetc does not respect EOF.

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 closed issue #7308: ungetc does not respect EOF.
URL: https://github.com/apache/incubator-nuttx/issues/7308


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on issue #7308: ungetc does not respect EOF.

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on issue #7308:
URL: https://github.com/apache/incubator-nuttx/issues/7308#issuecomment-1278726551

   According to https://en.cppreference.com/w/c/io/ungetc
   `If ch equals EOF, the operation fails and the stream is not affected.`. So what is wrong with current behavior? Maybe I'm missing something from a description.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org