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 - use volatile for compiler warnings about setjmp/vfork clobbering - fix up function pointer casting mess - silence warnings about assignments in conditionals - use functions correctly - silence warnings about && and || precedence --- ex_vmain.c~ 2012-12-27 21:58:42.000000000 +0000 +++ ex_vmain.c @@@@ -83,8 +83,8 @@@@ static char sccsid[] = "@@(#)ex_vmain.c 1 #include "ex_tty.h" #include "ex_vis.h" -int vzop __P((int, int, register int)); -int grabtag __P((void)); +static void vzop __P((int, int, register int)); +static void grabtag __P((void)); /* * This is the main routine for visual. @@@@ -96,17 +96,26 @@@@ int grabtag __P((void)); #define forbid(a) { if (a) goto fonfon; } +static void +doput(int ignore) +{ + (void)ignore; + put(); +} + +void vmain() { int c, cnt, i; cell esave[TUBECOLS]; - char *oglobp; - short d; - line *addr; + const char *volatile oglobp; + volatile short d; + line *volatile addr; int ind, nlput; - int shouldpo = 0; - int onumber = 0, olist = 0, - (*OPline)() = NULL, (*OPutchar)() = NULL; + volatile int shouldpo = 0; + volatile int onumber = 0, olist = 0; + int (*volatile OPline)(int) = NULL; + int (*volatile OPutchar)(int) = NULL; CLOBBGRD(c); CLOBBGRD(cnt); @@@@ -160,7 +169,7 @@@@ vmain() Xhadcnt = hadcnt = 0; Xcnt = cnt = 1; splitw = 0; - if (i = holdupd) { + if ((i = holdupd) != 0) { if (state == VISUAL) ignore(peekkey()); holdupd = 0; @@@@ -205,7 +214,7 @@@@ looptop: * an 'empty' named buffer spec in the routine * kshift (see ex_temp.c). */ - forbid (c == '0' || !isalpha(c) && !isdigit(c)); + forbid (c == '0' || (!isalpha((unsigned char)c) && !isdigit((unsigned char)c))); vreg = c; } reread: @@@@ -635,8 +644,8 @@@@ reread: if (isalpha(cuc(mbuf[1]))) { char x = cuc(mbuf[1]); - mbuf[1] = isupper(x) ? - tolower(x) : toupper(x); + mbuf[1] = isupper((unsigned char)x) ? + tolower((unsigned char)x) : toupper((unsigned char)x); } macpush(mbuf, 1); } @@@@ -865,7 +874,7 @@@@ case_ATTN: vmacchng(1); setLAST(); i = 0; - if (vreg && partreg(vreg) || !vreg && pkill[0]) { + if ((vreg && partreg(vreg)) || (!vreg && pkill[0])) { /* * Restoring multiple lines which were partial * lines; will leave cursor in middle @@@@ -898,8 +907,7 @@@@ case_ATTN: */ addr = dol; /* old dol */ CATCH - vremote(1, vreg ? (int(*)())putreg - : (int(*)())put, vreg); + vremote(1, vreg ? putreg : doput, vreg); ONERR if (vreg == -1) { splitw = 0; @@@@ -1160,7 +1168,7 @@@@ fixup: * in open mode and . moved, then redraw. */ i = vcline + (dot - addr); - if (i < 0 || i >= vcnt && i >= -vcnt || state != VISUAL && dot != addr) { + if (i < 0 || (i >= vcnt && i >= -vcnt) || (state != VISUAL && dot != addr)) { if (state == CRTOPEN) vup1(); if (vcnt > 0) @@@@ -1247,6 +1255,7 @@@@ fonfon: /* * Grab the word after the cursor so we can look for it as a tag. */ +static void grabtag() { register char *cp, *dp; @@@@ -1271,6 +1280,7 @@@@ grabtag() * Before appending lines, set up addr1 and * the command mode undo information. */ +void prepapp() { @@@@ -1284,8 +1294,8 @@@@ prepapp() * Execute function f with the address bounds addr1 * and addr2 surrounding cnt lines starting at dot. */ -vremote(cnt, f, arg) - int cnt, (*f)(), arg; +void +vremote(int cnt, void (*f)(int), int arg) { register int oing = inglobal; @@@@ -1301,15 +1311,23 @@@@ vremote(cnt, f, arg) vmcurs = 0; } +static void +doyank(int ignore) +{ + (void)ignore; + yank(); +} + /* * Save the current contents of linebuf, if it has changed. */ +void vsave() { char temp[LBSIZE]; CP(temp, linebuf); - if (FIXUNDO && vundkind == VCHNG || vundkind == VCAPU) { + if ((FIXUNDO && vundkind == VCHNG) || vundkind == VCAPU) { /* * If the undo state is saved in the temporary buffer * vutmp, then we sync this into the temp file so that @@@@ -1321,7 +1339,7 @@@@ vsave() prepapp(); CP(linebuf, vutmp); putmark(dot); - vremote(1, yank, 0); + vremote(1, doyank, 0); vundkind = VMCHNG; notecnt = 0; undkind = UNDCHANGE; @@@@ -1345,6 +1363,7 @@@@ vsave() * Do a z operation. * Code here is rather long, and very uninteresting. */ +static void vzop(hadcnt, cnt, c) bool hadcnt; int cnt; @@@@ -1434,7 +1453,7 @@@@ register char *src; { register cell *cp = dst; - while (*cp++ = *src++ & 0377); + while ((*cp++ = *src++ & 0377) != 0); return dst; } @@@@ -1445,7 +1464,7 @@@@ register cell *src; { register char *cp = dst; - while (*cp++ = *src++); + while ((*cp++ = *src++) != 0); return dst; } @@@@ -1456,7 +1475,7 @@@@ register cell *src; { register cell *cp = dst; - while (*cp++ = *src++); + while ((*cp++ = *src++) != 0); return dst; } @