Skip to content

Commit 555cc40

Browse files
committed
Important fix for back-end database file locking; also, switch back to using the system libc-provided mkstemp functions to elide some issues that would otherwise occur on networked filesystems.
1 parent 1dd0e76 commit 555cc40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+109
-335
lines changed

ChangeLog

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
OpenVi 7.0.5 -> OpenVi 7.0.6-dev (Unreleased): Thu Jan 27 14:25:39 2022
2-
+ Add attribution for DragonflyBSD Project to `LICENSE` text
3-
+ Correct `GNUmakefile` terse messages for `install` target
1+
OpenVi 7.0.5 -> OpenVi 7.0.6: Thu Jan 27 16:45:12 2022
2+
+ Important fix for back-end database file locking; also, switch
3+
back to using the system libc-provided mkstemp functions to elide
4+
some issues that would otherwise occur on networked filesystems.
5+
+ Add proper attribution for DragonflyBSD Project to `LICENSE` text
6+
+ Correct `GNUmakefile` non-verbose messages for the `install` target
47
+ Clean-up excess and trailing whitespace from source files
58

69
OpenVi 7.0.4 -> OpenVi 7.0.5: Thu Jan 27 11:00:46 2022

GNUmakefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
CC ?= cc
77
OPTLEVEL ?= -O2
88
DEPFLAGS ?= -MMD -MP
9-
CFLAGS += -std=gnu99 -I"./include"
9+
CFLAGS += -std=gnu99 -Iinclude -Idb -Icl -Iex -Ivi -Icommon
1010

1111
###############################################################################
1212

1313
# Set DEBUG to enable debugging build
1414
#DEBUG = 1
15-
DBGFLAGS ?= -ggdb
15+
DBGFLAGS ?= -ggdb -g3 -Og
1616

1717
###############################################################################
1818

@@ -52,7 +52,7 @@ IUSGR = root:bin
5252
###############################################################################
5353

5454
ifdef DEBUG
55-
CFLAGS += $(DBGFLAGS) -Wall -Wextra -DDEBUG -g3 -Og
55+
CFLAGS += $(DBGFLAGS) -Wall -Wextra -DDEBUG -DSTATISTICS -DHASH_STATISTICS
5656
else
5757
CFLAGS += $(OPTLEVEL) -pipe -fomit-frame-pointer
5858
endif # DEBUG
@@ -130,7 +130,6 @@ SRCS = cl/basename.c \
130130
common/log.c \
131131
common/main.c \
132132
common/mark.c \
133-
common/mkstemp.c \
134133
common/msg.c \
135134
common/options.c \
136135
common/options_f.c \

cl/cl_funcs.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -619,51 +619,27 @@ cl_usage()
619619
switch (pmode) {
620620
case MODE_EX:
621621
(void)fprintf(stderr, "Usage: "
622-
#ifndef DB185EMU
623622
#ifdef DEBUG
624623
"ex [ -FRrSsv ] [ -c cmd ] [ -t tag ] [ -w size ] [ -T tracefile ] [ file ... ]\n");
625624
#else
626625
"ex [ -FRrSsv ] [ -c cmd ] [ -t tag ] [ -w size ] [ file ... ]\n");
627626
#endif /* ifdef DEBUG */
628-
#else
629-
#ifdef DEBUG
630-
"ex [ -FRSsv ] [ -c cmd ] [ -t tag ] [ -w size ] [ -T tracefile ] [ file ... ]\n");
631-
#else
632-
"ex [ -FRSsv ] [ -c cmd ] [ -t tag ] [ -w size ] [ file ... ]\n");
633-
#endif /* ifdef DEBUG */
634-
#endif /* ifndef DB185EMU */
635627
break;
636628
case MODE_VI:
637629
(void)fprintf(stderr, "Usage: "
638-
#ifndef DB185EMU
639630
#ifdef DEBUG
640631
"vi [ -eFRrS ] [ -c cmd ] [ -t tag ] [ -w size ] [ -T tracefile ] [ file ... ]\n");
641632
#else
642633
"vi [ -eFRrS ] [ -c cmd ] [ -t tag ] [ -w size ] [ file ... ]\n");
643634
#endif /* ifdef DEBUG */
644-
#else
645-
#ifdef DEBUG
646-
"vi [ -eFRS ] [ -c cmd ] [ -t tag ] [ -w size ] [ -T tracefile ] [ file ... ]\n");
647-
#else
648-
"vi [ -eFRS ] [ -c cmd ] [ -t tag ] [ -w size ] [ file ... ]\n");
649-
#endif /* ifdef DEBUG */
650-
#endif /* ifndef DB185EMU */
651635
break;
652636
case MODE_VIEW:
653637
(void)fprintf(stderr, "Usage: "
654-
#ifndef DB185EMU
655638
#ifdef DEBUG
656639
"view [ -eFrS ] [ -c cmd ] [ -t tag ] [ -w size ] [ -T tracefile ] [ file ... ]\n");
657640
#else
658641
"view [ -eFrS ] [ -c cmd ] [ -t tag ] [ -w size ] [ file ... ]\n");
659642
#endif /* ifdef DEBUG */
660-
#else
661-
#ifdef DEBUG
662-
"view [ -eFS ] [ -c cmd ] [ -t tag ] [ -w size ] [ -T tracefile ] [ file ... ]\n");
663-
#else
664-
"view [ -eFS ] [ -c cmd ] [ -t tag ] [ -w size ] [ file ... ]\n");
665-
#endif /* ifdef DEBUG */
666-
#endif /* ifndef DB185EMU */
667643
break;
668644
}
669645
}

cl/cl_main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* See the LICENSE file for redistribution information.
1010
*/
1111

12+
#include "../include/compat.h"
13+
1214
#include <sys/types.h>
1315
#include <sys/queue.h>
1416

@@ -30,6 +32,8 @@
3032
#include "../common/common.h"
3133
#include "cl.h"
3234

35+
#undef open
36+
3337
GS *__global_list; /* GLOBAL: List of screens. */
3438

3539
volatile sig_atomic_t cl_sigint;

cl/engine.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ slow(struct match *m, char *start, char *stop, sopno startst, sopno stopst)
825825
return(matchp);
826826
}
827827

828-
829828
/*
830829
- step - map set of states reachable before char to set reachable after
831830
*/

common/common.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111
* @(#)common.h 10.13 (Berkeley) 9/25/96
1212
*/
1313

14-
#include <sys/time.h>
15-
16-
#ifdef DB185EMU
17-
# include <db_185.h>
18-
#else
19-
# include <bsd_db.h>
20-
#endif /* ifdef DB185EMU */
14+
#include "../include/compat.h"
2115

16+
#include <sys/time.h>
17+
#include <bsd_db.h>
2218
#include <regex.h>
2319

2420
/*

common/cut.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ namecb: CBNAME(sp, cbp, name);
127127
cbp->flags = 0;
128128
}
129129

130-
131130
/* In line mode, it's pretty easy, just cut the lines. */
132131
if (LF_ISSET(CUT_LINEMODE)) {
133132
cbp->flags |= CB_LMODE;

common/exf.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
* See the LICENSE file for redistribution information.
1010
*/
1111

12+
#include "../include/compat.h"
13+
1214
#include <sys/queue.h>
1315
#include <sys/stat.h>
1416
#include <sys/time.h>
1517

18+
#undef open
19+
1620
/*
1721
* We include <sys/file.h>, because the flock(2) and open(2) #defines
1822
* were found there on historical systems. We also include <bsd_fcntl.h>
@@ -33,14 +37,9 @@
3337
#include <bsd_unistd.h>
3438

3539
#include <sys/types.h>
36-
#ifdef DB185EMU
37-
# include <db_185.h>
38-
#else
3940
# include <bsd_db.h>
40-
#endif /* ifdef DB185EMU */
4141

4242
#include "common.h"
43-
#include "mkstemp.h"
4443

4544
static int file_backup(SCR *, char *, char *);
4645
static void file_cinit(SCR *);
@@ -129,7 +128,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
129128
struct stat sb;
130129
size_t psize;
131130
int fd, exists, open_err, readonly;
132-
char *oname, tname[] = "/tmp/vi.XXXXXXXXXXXXXXXXXXXXXXXX";
131+
char *oname, tname[] = "/tmp/vi.XXXXXX";
133132

134133
open_err = readonly = 0;
135134

@@ -195,7 +194,7 @@ file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
195194
*/
196195
if (frp->tname != NULL)
197196
goto err;
198-
fd = obsd_mkstemp(tname);
197+
fd = mkstemp(tname);
199198
if (fd == -1 || fstat(fd, &sb) == -1 ||
200199
fchmod(fd, S_IRUSR | S_IWUSR) == -1) {
201200
msgq(sp, M_SYSERR,

common/line.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ db_get(SCR *sp, recno_t lno, u_int32_t flags, char **pp, size_t *lenp)
102102
l1 = TAILQ_FIRST(&sp->tiq)->lno;
103103
l2 = TAILQ_LAST(&sp->tiq, _texth)->lno;
104104
if (l1 <= lno && l2 >= lno) {
105-
#if defined(DEBUG) && 0
106-
TRACE(sp, "retrieve TEXT buffer line %lu\n", (u_long)lno);
107-
#endif /* if defined(DEBUG) && 0 */
108105
TAILQ_FOREACH(tp, &sp->tiq, q) {
109106
if (tp->lno == lno)
110107
break;
@@ -125,9 +122,6 @@ db_get(SCR *sp, recno_t lno, u_int32_t flags, char **pp, size_t *lenp)
125122

126123
/* Look-aside into the cache, and see if the line we want is there. */
127124
if (lno == ep->c_lno) {
128-
#if defined(DEBUG) && 0
129-
TRACE(sp, "retrieve cached line %lu\n", (u_long)lno);
130-
#endif /* if defined(DEBUG) && 0 */
131125
if (lenp != NULL)
132126
*lenp = ep->c_len;
133127
if (pp != NULL)
@@ -158,9 +152,6 @@ err3: if (lenp != NULL)
158152
ep->c_len = data.size;
159153
ep->c_lp = data.data;
160154

161-
#if defined(DEBUG) && 0
162-
TRACE(sp, "retrieve DB line %lu\n", (u_long)lno);
163-
#endif /* if defined(DEBUG) && 0 */
164155
if (lenp != NULL)
165156
*lenp = data.size;
166157
if (pp != NULL)
@@ -180,9 +171,6 @@ db_delete(SCR *sp, recno_t lno)
180171
DBT key;
181172
EXF *ep;
182173

183-
#if defined(DEBUG) && 0
184-
TRACE(sp, "delete line %lu\n", (u_long)lno);
185-
#endif /* if defined(DEBUG) && 0 */
186174
/* Check for no underlying file. */
187175
if ((ep = sp->ep) == NULL) {
188176
ex_emsg(sp, NULL, EXM_NOFILEYET);
@@ -235,9 +223,6 @@ db_append(SCR *sp, int update, recno_t lno, char *p, size_t len)
235223
EXF *ep;
236224
int rval;
237225

238-
#if defined(DEBUG) && 0
239-
TRACE(sp, "append to %lu: len %u {%.*s}\n", lno, len, MIN(len, 20), p);
240-
#endif /* if defined(DEBUG) && 0 */
241226
/* Check for no underlying file. */
242227
if ((ep = sp->ep) == NULL) {
243228
ex_emsg(sp, NULL, EXM_NOFILEYET);
@@ -302,10 +287,6 @@ db_insert(SCR *sp, recno_t lno, char *p, size_t len)
302287
EXF *ep;
303288
int rval;
304289

305-
#if defined(DEBUG) && 0
306-
TRACE(sp, "insert before %lu: len %lu {%.*s}\n",
307-
(u_long)lno, (u_long)len, MIN(len, 20), p);
308-
#endif /* if defined(DEBUG) && 0 */
309290
/* Check for no underlying file. */
310291
if ((ep = sp->ep) == NULL) {
311292
ex_emsg(sp, NULL, EXM_NOFILEYET);
@@ -360,11 +341,6 @@ db_set(SCR *sp, recno_t lno, char *p, size_t len)
360341
DBT data, key;
361342
EXF *ep;
362343

363-
#if defined(DEBUG) && 0
364-
TRACE(sp, "replace line %lu: len %lu {%.*s}\n",
365-
(u_long)lno, (u_long)len, MIN(len, 20), p);
366-
#endif /* if defined(DEBUG) && 0 */
367-
368344
/* Check for no underlying file. */
369345
if ((ep = sp->ep) == NULL) {
370346
ex_emsg(sp, NULL, EXM_NOFILEYET);

0 commit comments

Comments
 (0)