head 1.1; access; symbols pkgsrc-2026Q1:1.1.0.108 pkgsrc-2026Q1-base:1.1 pkgsrc-2025Q4:1.1.0.106 pkgsrc-2025Q4-base:1.1 pkgsrc-2025Q3:1.1.0.104 pkgsrc-2025Q3-base:1.1 pkgsrc-2025Q2:1.1.0.102 pkgsrc-2025Q2-base:1.1 pkgsrc-2025Q1:1.1.0.100 pkgsrc-2025Q1-base:1.1 pkgsrc-2024Q4:1.1.0.98 pkgsrc-2024Q4-base:1.1 pkgsrc-2024Q3:1.1.0.96 pkgsrc-2024Q3-base:1.1 pkgsrc-2024Q2:1.1.0.94 pkgsrc-2024Q2-base:1.1 pkgsrc-2024Q1:1.1.0.92 pkgsrc-2024Q1-base:1.1 pkgsrc-2023Q4:1.1.0.90 pkgsrc-2023Q4-base:1.1 pkgsrc-2023Q3:1.1.0.88 pkgsrc-2023Q3-base:1.1 pkgsrc-2023Q2:1.1.0.86 pkgsrc-2023Q2-base:1.1 pkgsrc-2023Q1:1.1.0.84 pkgsrc-2023Q1-base:1.1 pkgsrc-2022Q4:1.1.0.82 pkgsrc-2022Q4-base:1.1 pkgsrc-2022Q3:1.1.0.80 pkgsrc-2022Q3-base:1.1 pkgsrc-2022Q2:1.1.0.78 pkgsrc-2022Q2-base:1.1 pkgsrc-2022Q1:1.1.0.76 pkgsrc-2022Q1-base:1.1 pkgsrc-2021Q4:1.1.0.74 pkgsrc-2021Q4-base:1.1 pkgsrc-2021Q3:1.1.0.72 pkgsrc-2021Q3-base:1.1 pkgsrc-2021Q2:1.1.0.70 pkgsrc-2021Q2-base:1.1 pkgsrc-2021Q1:1.1.0.68 pkgsrc-2021Q1-base:1.1 pkgsrc-2020Q4:1.1.0.66 pkgsrc-2020Q4-base:1.1 pkgsrc-2020Q3:1.1.0.64 pkgsrc-2020Q3-base:1.1 pkgsrc-2020Q2:1.1.0.60 pkgsrc-2020Q2-base:1.1 pkgsrc-2020Q1:1.1.0.40 pkgsrc-2020Q1-base:1.1 pkgsrc-2019Q4:1.1.0.62 pkgsrc-2019Q4-base:1.1 pkgsrc-2019Q3:1.1.0.58 pkgsrc-2019Q3-base:1.1 pkgsrc-2019Q2:1.1.0.56 pkgsrc-2019Q2-base:1.1 pkgsrc-2019Q1:1.1.0.54 pkgsrc-2019Q1-base:1.1 pkgsrc-2018Q4:1.1.0.52 pkgsrc-2018Q4-base:1.1 pkgsrc-2018Q3:1.1.0.50 pkgsrc-2018Q3-base:1.1 pkgsrc-2018Q2:1.1.0.48 pkgsrc-2018Q2-base:1.1 pkgsrc-2018Q1:1.1.0.46 pkgsrc-2018Q1-base:1.1 pkgsrc-2017Q4:1.1.0.44 pkgsrc-2017Q4-base:1.1 pkgsrc-2017Q3:1.1.0.42 pkgsrc-2017Q3-base:1.1 pkgsrc-2017Q2:1.1.0.38 pkgsrc-2017Q2-base:1.1 pkgsrc-2017Q1:1.1.0.36 pkgsrc-2017Q1-base:1.1 pkgsrc-2016Q4:1.1.0.34 pkgsrc-2016Q4-base:1.1 pkgsrc-2016Q3:1.1.0.32 pkgsrc-2016Q3-base:1.1 pkgsrc-2016Q2:1.1.0.30 pkgsrc-2016Q2-base:1.1 pkgsrc-2016Q1:1.1.0.28 pkgsrc-2016Q1-base:1.1 pkgsrc-2015Q4:1.1.0.26 pkgsrc-2015Q4-base:1.1 pkgsrc-2015Q3:1.1.0.24 pkgsrc-2015Q3-base:1.1 pkgsrc-2015Q2:1.1.0.22 pkgsrc-2015Q2-base:1.1 pkgsrc-2015Q1:1.1.0.20 pkgsrc-2015Q1-base:1.1 pkgsrc-2014Q4:1.1.0.18 pkgsrc-2014Q4-base:1.1 pkgsrc-2014Q3:1.1.0.16 pkgsrc-2014Q3-base:1.1 pkgsrc-2014Q2:1.1.0.14 pkgsrc-2014Q2-base:1.1 pkgsrc-2014Q1:1.1.0.12 pkgsrc-2014Q1-base:1.1 pkgsrc-2013Q4:1.1.0.10 pkgsrc-2013Q4-base:1.1 pkgsrc-2013Q3:1.1.0.8 pkgsrc-2013Q3-base:1.1 pkgsrc-2013Q2:1.1.0.6 pkgsrc-2013Q2-base:1.1 pkgsrc-2013Q1:1.1.0.4 pkgsrc-2013Q1-base:1.1 pkgsrc-2012Q4:1.1.0.2 pkgsrc-2012Q4-base:1.1; locks; strict; comment @# @; 1.1 date 2012.12.28.03.03.09; author dholland; state Exp; branches; next ; desc @@ 1.1 log @Fix legacy C. Pass -Wall -W -Wmissing-declarations -Wwrite-strings on gcc45. - avoid implicit int, declare void functions void - return values from non-void functions - put most external declarations properly in header files - use some static and const - fix up a big mess with function pointer casting - use standard includes, don't provide own decls of standard functions - use types matching libc when providing own malloc, printf, and putchar - use functions correctly - silence assorted compiler warnings - fix some bugs exposed by compiler warnings - don't intentionally exercise signed overflow - remove some unused items - add patch comments to other patch (patch-aa) As this includes several fixes and removes some undefined behavior on a commonly reachable code path, bump PKGREVISION. @ text @$NetBSD$ - 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); } @