$NetBSD: patch-ex__vput_c,v 1.1 2012/12/28 03:03:09 dholland Exp $ - declare local functions static - declare void functions void - avoid implicit int - return values from non-void functions - silence warnings about && and || precedence - silence warnings about braces - fix up function pointer casting mess --- ex_vput.c~ 2012-12-27 21:58:42.000000000 +0000 +++ ex_vput.c @@ -88,14 +88,14 @@ static char sccsid[] = "@(#)ex_vput.c 1. #define vquot(c) (c == quotsp) #endif /* BIT8 */ -int vmaktop __P((int, cell *)); -int vnpins __P((int)); -int vrigid __P((void)); -int vneedpos __P((int)); -int vishft __P((void)); -int viin __P((int)); -int godm __P((void)); -int enddm __P((void)); +static void vmaktop __P((int, cell *)); +static void vnpins __P((int)); +static void vrigid __P((void)); +static void vneedpos __P((int)); +static void vishft __P((void)); +static void viin __P((int)); +static void godm __P((void)); +static void enddm __P((void)); /* * Deal with the screen, clearing, cursor positioning, putting characters @@ -103,6 +103,7 @@ int enddm __P((void)); * Really hard stuff here is utilizing insert character operations * on intelligent terminals which differs widely from terminal to terminal. */ +void vclear() { @@ -122,6 +123,7 @@ vclear() /* * Clear memory. */ +void vclrcell(cp, i) register cell *cp; register int i; @@ -135,6 +137,7 @@ vclrcell(cp, i) /* * Clear a physical display line, high level. */ +void vclrlin(l, tp) int l; line *tp; @@ -155,6 +158,7 @@ vclrlin(l, tp) /* * Clear to the end of the current physical line */ +void vclreol() { register int i, j; @@ -169,7 +173,7 @@ vclreol() i = WCOLS - destcol; tp = vtube[destline] + destcol; if (CE) { - if (IN && *tp || !ateopr()) { + if ((IN && *tp) || !ateopr()) { vcsync(); vputp(CE, 1); } @@ -200,6 +204,7 @@ vclreol() * If work here is being held off, just remember, in * heldech, if work needs to be done, don't do anything. */ +void vclrech(didphys) bool didphys; { @@ -252,6 +257,7 @@ vclrech(didphys) * the state variable splitw so we wont rollup * when we move the cursor there. */ +void fixech() { @@ -266,6 +272,7 @@ fixech() /* * Put the cursor ``before'' cp. */ +void vcursbef(cp) register char *cp; { @@ -279,6 +286,7 @@ vcursbef(cp) /* * Put the cursor ``at'' cp. */ +void vcursat(cp) register char *cp; { @@ -292,6 +300,7 @@ vcursat(cp) /* * Put the cursor ``after'' cp. */ +void vcursaft(cp) register char *cp; { @@ -303,6 +312,7 @@ vcursaft(cp) * Fix the cursor to be positioned in the correct place * to accept a command. */ +void vfixcurs() { @@ -313,6 +323,7 @@ vfixcurs() * Compute the column position implied by the cursor at ``nc'', * and move the cursor there. */ +void vsetcurs(nc) register char *nc; { @@ -328,6 +339,7 @@ vsetcurs(nc) /* * Move the cursor invisibly, i.e. only remember to do it. */ +void vigoto(y, x) int y, x; { @@ -340,6 +352,7 @@ vigoto(y, x) * Move the cursor to the position implied by any previous * vigoto (or low level hacking with destcol/destline as in readecho). */ +void vcsync() { @@ -349,6 +362,7 @@ vcsync() /* * Goto column x of the current line. */ +void vgotoCL(x) register int x; { @@ -362,8 +376,8 @@ vgotoCL(x) /* * Invisible goto column x of current line. */ -vigotoCL(x) - register int x; +static void +vigotoCL(register int x) { if (splitw) @@ -375,6 +389,7 @@ vigotoCL(x) /* * Move cursor to line y, column x, handling wraparound and scrolling. */ +void vgoto(y, x) register int y, x; { @@ -523,7 +538,8 @@ vgoto(y, x) * with a QUOTE. We use QUOTE internally to represent a position * which is part of the expansion of a tab. */ -vgotab() +static void +vgotab(void) { register int i = tabcol(destcol, value(TABSTOP)) - destcol; @@ -555,6 +571,7 @@ int slakused; /* This much of tabslack * of the screen image buffer so it is easier for us to * maniuplate them. */ +void vprepins() { register int i; @@ -566,6 +583,7 @@ vprepins() } } +static void vmaktop(p, cp) register int p; cell *cp; @@ -594,6 +612,7 @@ vmaktop(p, cp) * for tabs) and code assumes this in several place * to make life simpler. */ +int vinschar(c) int c; /* mjm: char --> int */ { @@ -609,12 +628,12 @@ vinschar(c) */ if (c == '\t') { vgotab(); - return; + return c; } vputchar(c); if (DEPTH(vcline) * WCOLS + !value(REDRAW) > (destline - LINE(vcline)) * WCOLS + destcol) - return; + return c; /* * The next line is about to be clobbered * make space for another segment of this line @@ -627,14 +646,14 @@ vinschar(c) } else { c = LINE(vcline) + DEPTH(vcline); if (c < LINE(vcline + 1) || c > WBOT) - return; + return c; i = destcol; vinslin(c, 1, vcline); DEPTH(vcline)++; vigoto(c, i); vprepins(); } - return; + return c; } /* * Compute the number of positions in the line image of the @@ -693,7 +712,7 @@ vinschar(c) do vputchar(c); while (--inssiz); - return; + return c; } /* @@ -787,12 +806,14 @@ vinschar(c) destline = LINE(vcline); destcol = inscol + inssiz; vcsync(); + return c; } /* * Rigidify the rest of the line after the first * group of following tabs, typing blanks over ``spaces''. */ +void vrigid() { register int col; @@ -827,6 +848,7 @@ vrigid() * On a dumb terminal we may infact redisplay the rest of the * screen here brute force to keep it pretty. */ +void vneedpos(npcnt) int npcnt; { @@ -866,6 +888,7 @@ vneedpos(npcnt) vnpins(1); } +void vnpins(dosync) int dosync; { @@ -900,6 +923,7 @@ vnpins(dosync) * Do the shift of the next tabstop implied by * insertion so it expands. */ +void vishft() { int tshft = 0; @@ -1004,6 +1028,7 @@ vishft() /* * Now do the insert of the characters (finally). */ +static void viin(c) int c; /* mjm: char --> int */ { @@ -1014,7 +1039,7 @@ viin(c) short oldhold = hold; hold |= HOLDPUPD; - if (tabsize && (IM && EI) && inssiz - doomed > tabslack) + if (tabsize && (IM && EI) && inssiz - doomed > tabslack) { /* * There is a tab out there which will be affected * by the insertion since there aren't enough doomed @@ -1053,6 +1078,7 @@ viin(c) enddm(); } } + } /* * Now put out the characters of the actual insertion. @@ -1175,6 +1201,7 @@ viin(c) * is the same as that which goes into insert * mode, then we are in delete mode already. */ +void godm() { @@ -1194,6 +1221,7 @@ godm() * if we just moved over to delete space from part of * a tab (above). */ +static void enddm() { @@ -1211,6 +1239,7 @@ enddm() * if the terminal does all insertions a single character * at a time, since it branches based on whether IM is null. */ +void goim() { @@ -1219,6 +1248,7 @@ goim() insmode = 1; } +void endim() { @@ -1238,6 +1268,7 @@ endim() * you can erase overstrikes with some work. CRT's which do underlining * implicitly which has to be erased (like CONCEPTS) are also handled. */ +int vputchar(c) register int c; { @@ -1292,7 +1323,7 @@ vputchar(c) *tp = overbuf; #endif destcol++; - return; + return c; } /* * A ``space'' ontop of a part of a tab. @@ -1303,7 +1334,7 @@ vputchar(c) if (vquot(*tp)) { #endif destcol++; - return; + return c; } #ifndef BIT8 c = ' ' | QUOTE; @@ -1328,7 +1359,7 @@ vputchar(c) case '\t': vgotab(); - return; + return c; case ' ': /* @@ -1349,7 +1380,7 @@ vputchar(c) ) { *tp = ' '; destcol++; - return; + return c; } goto def; @@ -1374,7 +1405,7 @@ def: if ((hold & HOLDPUPD) == 0) *tp = c; destcol++; - return; + return c; } /* * Backwards looking optimization. @@ -1413,7 +1444,7 @@ def: e = trim(c); if (!insmode && d && d != ' ' && d != e) { #endif - if (EO && (OS || UL && (c == '_' || d == '_'))) { + if (EO && (OS || (UL && (c == '_' || d == '_')))) { vputc(' '); outcol++, destcol++; back1(); @@ -1478,12 +1509,14 @@ def: vputc('\n'); } } + return c; } /* * Delete display positions stcol through endcol. * Amount of use of special terminal features here is limited. */ +void physdc(stcol, endcol) int stcol, endcol; { @@ -1578,7 +1611,7 @@ physdc(stcol, endcol) if (IN) { up = vtube0 + stcol; tp = vtube0 + endcol; - while (i = *tp++) { + while ((i = *tp++) != 0) { #ifndef BIT8 if ((i & (QUOTE|TRIM)) == QUOTE) #else @@ -1602,6 +1635,7 @@ physdc(stcol, endcol) } #ifdef TRACE +void tfixnl() { @@ -1610,6 +1644,7 @@ tfixnl() trubble = 0, techoin = 0; } +void tvliny() { register int i; @@ -1630,6 +1665,7 @@ tvliny() fprintf(trace, "\n"); } +void tracec(c) int c; /* mjm: char --> int */ { @@ -1652,6 +1688,7 @@ tracec(c) /* * Put a character with possible tracing. */ +int vputch(c) int c; { @@ -1660,5 +1697,5 @@ vputch(c) if (trace) tracec(c); #endif - vputc(c); + return vputc(c); }