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:
@@ -114,16 +114,7 @@ E void FDECL(tty_startup, (int *, int *));
|
|||||||
#ifndef NO_TERMS
|
#ifndef NO_TERMS
|
||||||
E void NDECL(tty_shutdown);
|
E void NDECL(tty_shutdown);
|
||||||
#endif
|
#endif
|
||||||
#if defined(apollo)
|
E int FDECL(xputc, (int));
|
||||||
/* Apollos don't widen old-style function definitions properly -- they try to
|
|
||||||
* be smart and use the prototype, or some such strangeness. So we have to
|
|
||||||
* define UNWIDENDED_PROTOTYPES (in tradstdc.h), which makes CHAR_P below a
|
|
||||||
* char. But the tputs termcap call was compiled as if xputc's argument
|
|
||||||
* actually would be expanded. So here, we have to make an exception. */
|
|
||||||
E void FDECL(xputc, (int));
|
|
||||||
#else
|
|
||||||
E void FDECL(xputc, (CHAR_P));
|
|
||||||
#endif
|
|
||||||
E void FDECL(xputs, (const char *));
|
E void FDECL(xputs, (const char *));
|
||||||
#if defined(SCREEN_VGA) || defined(SCREEN_8514)
|
#if defined(SCREEN_VGA) || defined(SCREEN_8514)
|
||||||
E void FDECL(xputg, (int, int, unsigned));
|
E void FDECL(xputg, (int, int, unsigned));
|
||||||
|
|||||||
@@ -571,8 +571,10 @@ const char *s;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void xputc(ch) /* write out character (and attribute) */
|
/* same signature as 'putchar()' with potential failure result ignored */
|
||||||
char ch;
|
int
|
||||||
|
xputc(ch) /* write out character (and attribute) */
|
||||||
|
int ch;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char attribute;
|
char attribute;
|
||||||
@@ -591,16 +593,17 @@ char ch;
|
|||||||
vesa_xputc(ch, attribute);
|
vesa_xputc(ch, attribute);
|
||||||
#endif /*SCREEN_VESA*/
|
#endif /*SCREEN_VESA*/
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void xputg(glyphnum, ch,
|
/* write out a glyph picture at current location */
|
||||||
special) /* write out a glyph picture at current location */
|
void xputg(glyphnum, ch, special)
|
||||||
int glyphnum;
|
int glyphnum;
|
||||||
int ch;
|
int ch;
|
||||||
unsigned special;
|
unsigned special;
|
||||||
{
|
{
|
||||||
if (!iflags.grmode || !iflags.tile_view) {
|
if (!iflags.grmode || !iflags.tile_view) {
|
||||||
xputc((char) ch);
|
(void) xputc((char) ch);
|
||||||
#ifdef SCREEN_VGA
|
#ifdef SCREEN_VGA
|
||||||
} else if (iflags.grmode && iflags.usevga) {
|
} else if (iflags.grmode && iflags.usevga) {
|
||||||
vga_xputg(glyphnum, ch, special);
|
vga_xputg(glyphnum, ch, special);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ int FDECL(tgetnum, (const char *));
|
|||||||
char *FDECL(tgetstr, (const char *, char **));
|
char *FDECL(tgetstr, (const char *, char **));
|
||||||
char *FDECL(tgoto, (const char *, int, int));
|
char *FDECL(tgoto, (const char *, int, int));
|
||||||
char *FDECL(tparam, (const char *, char *, int, int, int, int, int));
|
char *FDECL(tparam, (const char *, char *, int, int, int, int, int));
|
||||||
void FDECL(tputs, (const char *, int, int (*)()));
|
void FDECL(tputs, (const char *, int, int (*)(int)));
|
||||||
|
|
||||||
/* local support data */
|
/* local support data */
|
||||||
static char *tc_entry;
|
static char *tc_entry;
|
||||||
@@ -502,9 +502,10 @@ int row, col, row2, col2;
|
|||||||
/* send a string to the terminal, possibly padded with trailing NULs */
|
/* send a string to the terminal, possibly padded with trailing NULs */
|
||||||
void
|
void
|
||||||
tputs(string, range, output_func)
|
tputs(string, range, output_func)
|
||||||
const char *string; /* characters to output */
|
const char *string; /* characters to output */
|
||||||
int range; /* number of lines affected, used for `*' delays */
|
int range; /* number of lines affected, used for `*' delays */
|
||||||
int (*output_func)(); /* actual output routine; return value ignored */
|
int FDECL((*output_func),(int)); /* actual output routine;
|
||||||
|
* return value ignored */
|
||||||
{
|
{
|
||||||
register int c, num = 0;
|
register int c, num = 0;
|
||||||
register const char *p = string;
|
register const char *p = string;
|
||||||
|
|||||||
@@ -530,12 +530,14 @@ int x, y;
|
|||||||
set_console_cursor(x, y);
|
set_console_cursor(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* same signature as 'putchar()' with potential failure result ignored */
|
||||||
|
int
|
||||||
xputc(ch)
|
xputc(ch)
|
||||||
char ch;
|
int ch;
|
||||||
{
|
{
|
||||||
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
|
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
|
||||||
xputc_core(ch);
|
xputc_core((char) ch);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -543,7 +545,7 @@ xputs(s)
|
|||||||
const char *s;
|
const char *s;
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
int slen = strlen(s);
|
int slen = (int) strlen(s);
|
||||||
|
|
||||||
if (ttyDisplay)
|
if (ttyDisplay)
|
||||||
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
|
set_console_cursor(ttyDisplay->curx, ttyDisplay->cury);
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ int mode;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
xputc(ch)
|
xputc(ch)
|
||||||
char ch;
|
int ch;
|
||||||
{
|
{
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -495,12 +495,10 @@ tty_end_screen()
|
|||||||
/* Cursor movements */
|
/* Cursor movements */
|
||||||
|
|
||||||
/* Note to overlay tinkerers. The placement of this overlay controls the
|
/* Note to overlay tinkerers. The placement of this overlay controls the
|
||||||
location
|
location of the function xputc(). This function is not currently in
|
||||||
of the function xputc(). This function is not currently in trampoli.[ch]
|
trampoli.[ch] files for what is deemed to be performance reasons. If
|
||||||
files for what is deemed to be performance reasons. If this define is
|
this define is moved and or xputc() is taken out of the ROOT overlay,
|
||||||
moved
|
then action must be taken in trampoli.[ch]. */
|
||||||
and or xputc() is taken out of the ROOT overlay, then action must be taken
|
|
||||||
in trampoli.[ch]. */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nocmov(x, y)
|
nocmov(x, y)
|
||||||
@@ -528,7 +526,7 @@ int x, y;
|
|||||||
cmov(x, y);
|
cmov(x, y);
|
||||||
} else {
|
} else {
|
||||||
while ((int) ttyDisplay->cury < y) {
|
while ((int) ttyDisplay->cury < y) {
|
||||||
xputc('\n');
|
(void) xputc('\n');
|
||||||
ttyDisplay->curx = 0;
|
ttyDisplay->curx = 0;
|
||||||
ttyDisplay->cury++;
|
ttyDisplay->cury++;
|
||||||
}
|
}
|
||||||
@@ -561,16 +559,27 @@ register int x, y;
|
|||||||
ttyDisplay->curx = x;
|
ttyDisplay->curx = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See note above. xputc() is a special function. */
|
/* See note above. xputc() is a special function for overlays. */
|
||||||
void
|
int
|
||||||
xputc(c)
|
xputc(c)
|
||||||
#if defined(apollo)
|
int c; /* actually char, but explicitly specify its widened type */
|
||||||
int c;
|
|
||||||
#else
|
|
||||||
char c;
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
(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
|
void
|
||||||
@@ -579,13 +588,9 @@ const char *s;
|
|||||||
{
|
{
|
||||||
#ifndef TERMLIB
|
#ifndef TERMLIB
|
||||||
(void) fputs(s, stdout);
|
(void) fputs(s, stdout);
|
||||||
#else
|
|
||||||
#if defined(NHSTDC) || defined(ULTRIX_PROTO)
|
|
||||||
tputs(s, 1, (int (*) ()) xputc);
|
|
||||||
#else
|
#else
|
||||||
tputs(s, 1, xputc);
|
tputs(s, 1, xputc);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -599,7 +604,7 @@ cl_end()
|
|||||||
/* this looks terrible, especially on a slow terminal
|
/* this looks terrible, especially on a slow terminal
|
||||||
but is better than nothing */
|
but is better than nothing */
|
||||||
while (cx < CO) {
|
while (cx < CO) {
|
||||||
xputc(' ');
|
(void) xputc(' ');
|
||||||
cx++;
|
cx++;
|
||||||
}
|
}
|
||||||
tty_curs(BASE_WINDOW, (int) ttyDisplay->curx + 1,
|
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
|
/* BUG: if the padding character is visible, as it is on the 5620
|
||||||
then this looks terrible. */
|
then this looks terrible. */
|
||||||
if (flags.null) {
|
if (flags.null) {
|
||||||
|
tputs(
|
||||||
#ifdef TERMINFO
|
#ifdef TERMINFO
|
||||||
/* cbosgd!cbcephus!pds for SYS V R2 */
|
"$<50>",
|
||||||
#ifdef NHSTDC
|
|
||||||
tputs("$<50>", 1, (int (*) ()) xputc);
|
|
||||||
#else
|
#else
|
||||||
tputs("$<50>", 1, xputc);
|
"50",
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if defined(NHSTDC) || defined(ULTRIX_PROTO)
|
|
||||||
tputs("50", 1, (int (*) ()) xputc);
|
|
||||||
#else
|
|
||||||
tputs("50", 1, xputc);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
1, xputc);
|
||||||
|
|
||||||
} else if (ospeed > 0 && ospeed < SIZE(tmspc10) && nh_CM) {
|
} else if (ospeed > 0 && ospeed < SIZE(tmspc10) && nh_CM) {
|
||||||
/* delay by sending cm(here) an appropriate number of times */
|
/* delay by sending cm(here) an appropriate number of times */
|
||||||
register int cmlen =
|
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;
|
register int i = 500 + tmspc10[ospeed] / 2;
|
||||||
|
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
@@ -794,7 +792,7 @@ cl_eos() /* free after Robert Viduya */
|
|||||||
|
|
||||||
while (cy <= LI - 2) {
|
while (cy <= LI - 2) {
|
||||||
cl_end();
|
cl_end();
|
||||||
xputc('\n');
|
(void) xputc('\n');
|
||||||
cy++;
|
cy++;
|
||||||
}
|
}
|
||||||
cl_end();
|
cl_end();
|
||||||
|
|||||||
Reference in New Issue
Block a user