tty xputc()
Another part of github issue 227. Casting a function pointer when passing it to another function is iffy when lying about the return type. tputs() expects a routine which returns int, so give it one. Other xputc() usage is equivalent to putchar(), so define xputc() with the same function signature as that has. The tputs() declarations in system.h should probably be changed (third argument is a function which takes an int rather than unspecified parameters) but I've left them alone. I made that change to tputs() in sys/share/tclib.c though. NT and MSDOS changes are untested. tclib.c compiles ok with clang- as-gcc on OSX but hasn't been tested with the port that uses it (VMS).
This commit is contained in:
@@ -495,12 +495,10 @@ tty_end_screen()
|
||||
/* Cursor movements */
|
||||
|
||||
/* Note to overlay tinkerers. The placement of this overlay controls the
|
||||
location
|
||||
of the function xputc(). This function is not currently in trampoli.[ch]
|
||||
files for what is deemed to be performance reasons. If this define is
|
||||
moved
|
||||
and or xputc() is taken out of the ROOT overlay, then action must be taken
|
||||
in trampoli.[ch]. */
|
||||
location of the function xputc(). This function is not currently in
|
||||
trampoli.[ch] files for what is deemed to be performance reasons. If
|
||||
this define is moved and or xputc() is taken out of the ROOT overlay,
|
||||
then action must be taken in trampoli.[ch]. */
|
||||
|
||||
void
|
||||
nocmov(x, y)
|
||||
@@ -528,7 +526,7 @@ int x, y;
|
||||
cmov(x, y);
|
||||
} else {
|
||||
while ((int) ttyDisplay->cury < y) {
|
||||
xputc('\n');
|
||||
(void) xputc('\n');
|
||||
ttyDisplay->curx = 0;
|
||||
ttyDisplay->cury++;
|
||||
}
|
||||
@@ -561,16 +559,27 @@ register int x, y;
|
||||
ttyDisplay->curx = x;
|
||||
}
|
||||
|
||||
/* See note above. xputc() is a special function. */
|
||||
void
|
||||
/* See note above. xputc() is a special function for overlays. */
|
||||
int
|
||||
xputc(c)
|
||||
#if defined(apollo)
|
||||
int c;
|
||||
#else
|
||||
char c;
|
||||
#endif
|
||||
int c; /* actually char, but explicitly specify its widened type */
|
||||
{
|
||||
(void) putchar(c);
|
||||
/*
|
||||
* Note: xputc() as a direct all to putchar() doesn't make any
|
||||
* sense _if_ putchar() is a function. But if it is a macro, an
|
||||
* overlay configuration would want to avoid hidden code bloat
|
||||
* from multiple putchar() expansions. And it gets passed as an
|
||||
* argument to tputs() so we have to guarantee an actual function
|
||||
* (while possibly lacking ANSI's (func) syntax to override macro).
|
||||
*
|
||||
* xputc() used to be declared as 'void xputc(c) char c; {}' but
|
||||
* avoiding the proper type 'int' just to avoid (void) casts when
|
||||
* ignoring the result can't have been sufficent reason to add it.
|
||||
* It also had '#if apollo' conditional to have the arg be int.
|
||||
* Matching putchar()'s declaration and using explicit casts where
|
||||
* warranted is more robust, so we're just a jacket around that.
|
||||
*/
|
||||
return putchar(c);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -579,13 +588,9 @@ const char *s;
|
||||
{
|
||||
#ifndef TERMLIB
|
||||
(void) fputs(s, stdout);
|
||||
#else
|
||||
#if defined(NHSTDC) || defined(ULTRIX_PROTO)
|
||||
tputs(s, 1, (int (*) ()) xputc);
|
||||
#else
|
||||
tputs(s, 1, xputc);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -599,7 +604,7 @@ cl_end()
|
||||
/* this looks terrible, especially on a slow terminal
|
||||
but is better than nothing */
|
||||
while (cx < CO) {
|
||||
xputc(' ');
|
||||
(void) xputc(' ');
|
||||
cx++;
|
||||
}
|
||||
tty_curs(BASE_WINDOW, (int) ttyDisplay->curx + 1,
|
||||
@@ -754,25 +759,18 @@ tty_delay_output()
|
||||
/* BUG: if the padding character is visible, as it is on the 5620
|
||||
then this looks terrible. */
|
||||
if (flags.null) {
|
||||
tputs(
|
||||
#ifdef TERMINFO
|
||||
/* cbosgd!cbcephus!pds for SYS V R2 */
|
||||
#ifdef NHSTDC
|
||||
tputs("$<50>", 1, (int (*) ()) xputc);
|
||||
"$<50>",
|
||||
#else
|
||||
tputs("$<50>", 1, xputc);
|
||||
#endif
|
||||
#else
|
||||
#if defined(NHSTDC) || defined(ULTRIX_PROTO)
|
||||
tputs("50", 1, (int (*) ()) xputc);
|
||||
#else
|
||||
tputs("50", 1, xputc);
|
||||
#endif
|
||||
"50",
|
||||
#endif
|
||||
1, xputc);
|
||||
|
||||
} else if (ospeed > 0 && ospeed < SIZE(tmspc10) && nh_CM) {
|
||||
/* delay by sending cm(here) an appropriate number of times */
|
||||
register int cmlen =
|
||||
strlen(tgoto(nh_CM, ttyDisplay->curx, ttyDisplay->cury));
|
||||
(int) strlen(tgoto(nh_CM, ttyDisplay->curx, ttyDisplay->cury));
|
||||
register int i = 500 + tmspc10[ospeed] / 2;
|
||||
|
||||
while (i > 0) {
|
||||
@@ -794,7 +792,7 @@ cl_eos() /* free after Robert Viduya */
|
||||
|
||||
while (cy <= LI - 2) {
|
||||
cl_end();
|
||||
xputc('\n');
|
||||
(void) xputc('\n');
|
||||
cy++;
|
||||
}
|
||||
cl_end();
|
||||
|
||||
Reference in New Issue
Block a user