Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify error handling of tty_putc #245

Closed
wants to merge 1 commit into from
Closed

Simplify error handling of tty_putc #245

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 17, 2017

putc returns EOF on errors, not ERR (although both are defined as -1) ...

@mptre
Copy link
Owner

mptre commented Sep 17, 2017

The ERR -> EOF looks good. tty_putc does not perform any error
handling since it's used with tputs(3), quoting the manual:

... putc is a putchar-like routine to which the characters are passed,
one at a time.

I don't know if it's advised to perform error handling inside putc if
tputs relies on getting EOF back and perform any internal cleanup.

@ghost
Copy link
Author

ghost commented Sep 17, 2017

if tputs relies on getting EOF back and perform any internal cleanup.

http://pubs.opengroup.org/onlinepubs/7908799/xcurses/putp.html says:

The tputs() function ignores the return value of putfunc.

quoting man putc here:

fputc(), putc() and putchar() return the character written as an unsigned char cast to an int or EOF on error.

@mptre
Copy link
Owner

mptre commented Sep 18, 2017

Well then, thanks! Tweaked and committed as 1585928.

@mptre mptre closed this Sep 18, 2017
@ghost ghost deleted the ttyputc branch September 18, 2017 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant