aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2020-09-09 07:57:59 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2020-09-09 07:57:59 +0000
commit2a1ac9cdf3c720b70043224e0e4320f5ae5226ca (patch)
treea9eb403eff4055e4c30b916670ebd8d153f9a3d4 /common
parent5a709d61a37133c04bc540b7c531c49239e71145 (diff)
downloadsrc-2a1ac9cdf3c720b70043224e0e4320f5ae5226ca.tar.gz
src-2a1ac9cdf3c720b70043224e0e4320f5ae5226ca.zip
Import nvi 2.2.0
Notes
Notes: svn path=/vendor/nvi/dist/; revision=365495
Diffstat (limited to 'common')
-rw-r--r--common/args.h2
-rw-r--r--common/common.h11
-rw-r--r--common/conv.c13
-rw-r--r--common/conv.h2
-rw-r--r--common/cut.c34
-rw-r--r--common/cut.h2
-rw-r--r--common/delete.c28
-rw-r--r--common/encoding.c6
-rw-r--r--common/exf.c106
-rw-r--r--common/exf.h2
-rw-r--r--common/extern.h132
-rw-r--r--common/gs.h4
-rw-r--r--common/key.c61
-rw-r--r--common/key.h12
-rw-r--r--common/line.c60
-rw-r--r--common/log.c61
-rw-r--r--common/log.h2
-rw-r--r--common/main.c76
-rw-r--r--common/mark.c35
-rw-r--r--common/mark.h2
-rw-r--r--common/mem.h51
-rw-r--r--common/msg.c55
-rw-r--r--common/msg.h2
-rw-r--r--common/multibyte.h36
-rw-r--r--common/options.c66
-rw-r--r--common/options.h2
-rw-r--r--common/options_def.h83
-rw-r--r--common/options_f.c94
-rw-r--r--common/put.c12
-rw-r--r--common/recover.c68
-rw-r--r--common/screen.c28
-rw-r--r--common/screen.h2
-rw-r--r--common/search.c41
-rw-r--r--common/seq.c65
-rw-r--r--common/seq.h2
-rw-r--r--common/util.c76
-rw-r--r--common/util.h2
37 files changed, 290 insertions, 1046 deletions
diff --git a/common/args.h b/common/args.h
index b23699c250e3..3f9b43a272ac 100644
--- a/common/args.h
+++ b/common/args.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: args.h,v 10.2 1996/03/06 19:50:07 bostic Exp $
*/
/*
diff --git a/common/common.h b/common/common.h
index c64adb51d6b4..ad559a5a2267 100644
--- a/common/common.h
+++ b/common/common.h
@@ -5,17 +5,10 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: common.h,v 10.22 2012/04/13 05:21:50 zy Exp $
*/
-/*
- * Pseudo-local includes. These are files that are unlikely to exist
- * on most machines to which we're porting vi, and we want to include
- * them in a very specific order, regardless.
- */
-#include <db.h>
-#include <regex.h>
+#include "/usr/include/db.h" /* Only include db1. */
+#include <regex.h> /* May refer to the bundled regex. */
/*
* Forward structure declarations. Not pretty, but the include files
diff --git a/common/conv.c b/common/conv.c
index aaa7af37e548..2e675a6d3f77 100644
--- a/common/conv.c
+++ b/common/conv.c
@@ -11,10 +11,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: conv.c,v 2.40 2014/02/27 16:25:29 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -118,7 +114,7 @@ default_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw,
size_t left = len;
int error = 1;
- BZERO(&mbs, 1);
+ memset(&mbs, 0, sizeof(mbs));
BINC_RETW(NULL, *tostr, *blen, nlen);
#ifdef USE_ICONV
@@ -245,7 +241,7 @@ default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw,
#endif
- BZERO(&mbs, 1);
+ memset(&mbs, 0, sizeof(mbs));
BINC_RETC(NULL, *tostr, *blen, nlen);
dst = *tostr; buflen = *blen;
@@ -323,7 +319,7 @@ conv_init(SCR *orig, SCR *sp)
if (orig == NULL)
setlocale(LC_ALL, "");
if (orig != NULL)
- BCOPY(&orig->conv, &sp->conv, 1);
+ memmove(&sp->conv, &orig->conv, sizeof(CONV));
#ifdef USE_WIDECHAR
else {
char *ctype = setlocale(LC_CTYPE, NULL);
@@ -464,7 +460,6 @@ conv_end(SCR *sp)
for (i = 0; i <= IC_IE_TO_UTF16; ++i)
if (sp->conv.id[i] != (iconv_t)-1)
iconv_close(sp->conv.id[i]);
- if (sp->cw.bp1.c != NULL)
- free(sp->cw.bp1.c);
+ free(sp->cw.bp1.c);
#endif
}
diff --git a/common/conv.h b/common/conv.h
index b17c3bb24ace..ee3efb5a8308 100644
--- a/common/conv.h
+++ b/common/conv.h
@@ -7,8 +7,6 @@
* Zhihao Yuan. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: conv.h,v 2.32 2013/03/11 01:20:53 zy Exp $
*/
#ifdef USE_ICONV
diff --git a/common/cut.c b/common/cut.c
index 810aef6ac89c..7d74f764a6d9 100644
--- a/common/cut.c
+++ b/common/cut.c
@@ -9,12 +9,9 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: cut.c,v 10.12 2012/02/11 15:52:33 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/time.h>
#include <bitstring.h>
#include <ctype.h>
@@ -64,12 +61,7 @@ static void cb_rotate(SCR *);
* PUBLIC: int cut(SCR *, CHAR_T *, MARK *, MARK *, int);
*/
int
-cut(
- SCR *sp,
- CHAR_T *namep,
- MARK *fm,
- MARK *tm,
- int flags)
+cut(SCR *sp, CHAR_T *namep, MARK *fm, MARK *tm, int flags)
{
CB *cbp;
CHAR_T name = '\0';
@@ -126,7 +118,7 @@ copyloop:
* Otherwise, if it's not an append, free its current contents.
*/
if (cbp == NULL) {
- CALLOC_RET(sp, cbp, CB *, 1, sizeof(CB));
+ CALLOC_RET(sp, cbp, 1, sizeof(CB));
cbp->name = name;
TAILQ_INIT(cbp->textq);
SLIST_INSERT_HEAD(sp->gp->cutq, cbp, q);
@@ -225,12 +217,7 @@ cb_rotate(SCR *sp)
* PUBLIC: int cut_line(SCR *, recno_t, size_t, size_t, CB *);
*/
int
-cut_line(
- SCR *sp,
- recno_t lno,
- size_t fcno,
- size_t clen,
- CB *cbp)
+cut_line(SCR *sp, recno_t lno, size_t fcno, size_t clen, CB *cbp)
{
TEXT *tp;
size_t len;
@@ -294,20 +281,16 @@ cut_close(GS *gp)
* PUBLIC: TEXT *text_init(SCR *, const CHAR_T *, size_t, size_t);
*/
TEXT *
-text_init(
- SCR *sp,
- const CHAR_T *p,
- size_t len,
- size_t total_len)
+text_init(SCR *sp, const CHAR_T *p, size_t len, size_t total_len)
{
TEXT *tp;
- CALLOC(sp, tp, TEXT *, 1, sizeof(TEXT));
+ CALLOC(sp, tp, 1, sizeof(TEXT));
if (tp == NULL)
return (NULL);
/* ANSI C doesn't define a call to malloc(3) for 0 bytes. */
if ((tp->lb_len = total_len * sizeof(CHAR_T)) != 0) {
- MALLOC(sp, tp->lb, CHAR_T *, tp->lb_len);
+ MALLOC(sp, tp->lb, tp->lb_len);
if (tp->lb == NULL) {
free(tp);
return (NULL);
@@ -345,7 +328,6 @@ text_lfree(TEXTH *headp)
void
text_free(TEXT *tp)
{
- if (tp->lb != NULL)
- free(tp->lb);
+ free(tp->lb);
free(tp);
}
diff --git a/common/cut.h b/common/cut.h
index 30e9350dbb75..d220cd8cc69c 100644
--- a/common/cut.h
+++ b/common/cut.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: cut.h,v 10.10 2012/02/11 15:52:33 zy Exp $
*/
typedef struct _texth TEXTH; /* TEXT list head structure. */
diff --git a/common/delete.c b/common/delete.c
index b9bd0388946f..f52132340f06 100644
--- a/common/delete.c
+++ b/common/delete.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: delete.c,v 10.18 2012/02/11 15:52:33 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -33,11 +29,7 @@ static const char sccsid[] = "$Id: delete.c,v 10.18 2012/02/11 15:52:33 zy Exp $
* PUBLIC: int del(SCR *, MARK *, MARK *, int);
*/
int
-del(
- SCR *sp,
- MARK *fm,
- MARK *tm,
- int lmode)
+del(SCR *sp, MARK *fm, MARK *tm, int lmode)
{
recno_t lno;
size_t blen, len, nlen, tlen;
@@ -94,14 +86,16 @@ del(
if (tm->lno == fm->lno) {
if (db_get(sp, fm->lno, DBG_FATAL, &p, &len))
return (1);
- GET_SPACE_RETW(sp, bp, blen, len);
- if (fm->cno != 0)
- MEMCPY(bp, p, fm->cno);
- MEMCPY(bp + fm->cno, p + (tm->cno + 1),
- len - (tm->cno + 1));
- if (db_set(sp, fm->lno,
- bp, len - ((tm->cno - fm->cno) + 1)))
- goto err;
+ if (len != 0) {
+ GET_SPACE_RETW(sp, bp, blen, len);
+ if (fm->cno != 0)
+ MEMCPY(bp, p, fm->cno);
+ MEMCPY(bp + fm->cno, p + (tm->cno + 1),
+ len - (tm->cno + 1));
+ if (db_set(sp, fm->lno,
+ bp, len - ((tm->cno - fm->cno) + 1)))
+ goto err;
+ }
goto done;
}
diff --git a/common/encoding.c b/common/encoding.c
index 7bdcf7069238..a1ff1c102135 100644
--- a/common/encoding.c
+++ b/common/encoding.c
@@ -5,10 +5,6 @@
* See the LICENSE file for redistribution information.
*/
-#ifndef lint
-static const char sccsid[] = "$Id: encoding.c,v 1.4 2011/12/13 19:40:52 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
int looks_utf8(const char *, size_t);
@@ -96,7 +92,7 @@ looks_utf8(const char *ibuf, size_t nbytes)
if (i >= nbytes)
goto done;
- if (buf[i] & 0x40) /* 10xxxxxx */
+ if ((buf[i] & 0xc0) != 0x80) /* 10xxxxxx */
return -1;
}
diff --git a/common/exf.c b/common/exf.c
index 1fcf7f6da498..ccfa66ef4089 100644
--- a/common/exf.c
+++ b/common/exf.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: exf.c,v 10.64 2015/04/05 15:21:55 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -59,9 +55,7 @@ static int file_spath(SCR *, FREF *, struct stat *, int *);
* PUBLIC: FREF *file_add(SCR *, char *);
*/
FREF *
-file_add(
- SCR *sp,
- char *name)
+file_add(SCR *sp, char *name)
{
GS *gp;
FREF *frp, *tfrp;
@@ -80,8 +74,7 @@ file_add(
TAILQ_FOREACH_SAFE(frp, gp->frefq, q, tfrp) {
if (frp->name == NULL) {
TAILQ_REMOVE(gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
+ free(frp->name);
free(frp);
continue;
}
@@ -90,7 +83,7 @@ file_add(
}
/* Allocate and initialize the FREF structure. */
- CALLOC(sp, frp, FREF *, 1, sizeof(FREF));
+ CALLOC(sp, frp, 1, sizeof(FREF));
if (frp == NULL)
return (NULL);
@@ -121,11 +114,7 @@ file_add(
* PUBLIC: int file_init(SCR *, FREF *, char *, int);
*/
int
-file_init(
- SCR *sp,
- FREF *frp,
- char *rcv_name,
- int flags)
+file_init(SCR *sp, FREF *frp, char *rcv_name, int flags)
{
EXF *ep;
RECNOINFO oinfo = { 0 };
@@ -160,7 +149,7 @@ file_init(
* Default recover mail file fd to -1.
* Set initial EXF flag bits.
*/
- CALLOC_RET(sp, ep, EXF *, 1, sizeof(EXF));
+ CALLOC_RET(sp, ep, 1, sizeof(EXF));
ep->c_lno = ep->c_nlines = OOBLNO;
ep->rcv_fd = -1;
F_SET(ep, F_FIRSTMODIFY);
@@ -356,9 +345,9 @@ file_init(
* vi, unless the -R command-line option was specified or the program
* was executed as "view". (Well, to be truthful, if the letter 'w'
* occurred anywhere in the program name, but let's not get into that.)
- * So, the persistant readonly state has to be stored in the screen
+ * So, the persistent readonly state has to be stored in the screen
* structure, and the edit option value toggles with the contents of
- * the edit buffer. If the persistant readonly flag is set, set the
+ * the edit buffer. If the persistent readonly flag is set, set the
* readonly edit option.
*
* Otherwise, try and figure out if a file is readonly. This is a
@@ -418,10 +407,8 @@ file_init(
return (0);
-err: if (frp->name != NULL) {
- free(frp->name);
- frp->name = NULL;
- }
+err: free(frp->name);
+ frp->name = NULL;
if (frp->tname != NULL) {
(void)unlink(frp->tname);
free(frp->tname);
@@ -430,10 +417,9 @@ err: if (frp->name != NULL) {
oerr: if (F_ISSET(ep, F_RCV_ON))
(void)unlink(ep->rcv_path);
- if (ep->rcv_path != NULL) {
- free(ep->rcv_path);
- ep->rcv_path = NULL;
- }
+ free(ep->rcv_path);
+ ep->rcv_path = NULL;
+
if (ep->db != NULL)
(void)ep->db->close(ep->db);
free(ep);
@@ -448,11 +434,7 @@ oerr: if (F_ISSET(ep, F_RCV_ON))
* try and open.
*/
static int
-file_spath(
- SCR *sp,
- FREF *frp,
- struct stat *sbp,
- int *existsp)
+file_spath(SCR *sp, FREF *frp, struct stat *sbp, int *existsp)
{
int savech;
size_t len;
@@ -564,7 +546,7 @@ file_cinit(SCR *sp)
}
CHAR2INT(sp, gp->c_option, strlen(gp->c_option) + 1,
wp, wlen);
- if (ex_run_str(sp, "-c option", wp, wlen - 1, 1, 1))
+ if (ex_run_str(sp, "-c option", wp, wlen - 1, 1, 0))
return;
gp->c_option = NULL;
} else if (F_ISSET(sp, SC_EX)) {
@@ -632,10 +614,7 @@ file_cinit(SCR *sp)
* PUBLIC: int file_end(SCR *, EXF *, int);
*/
int
-file_end(
- SCR *sp,
- EXF *ep,
- int force)
+file_end(SCR *sp, EXF *ep, int force)
{
FREF *frp;
@@ -681,8 +660,7 @@ file_end(
frp->tname = NULL;
if (F_ISSET(frp, FR_TMPFILE)) {
TAILQ_REMOVE(sp->gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
+ free(frp->name);
free(frp);
}
sp->frp = NULL;
@@ -724,10 +702,8 @@ file_end(
}
if (ep->rcv_fd != -1)
(void)close(ep->rcv_fd);
- if (ep->rcv_path != NULL)
- free(ep->rcv_path);
- if (ep->rcv_mpath != NULL)
- free(ep->rcv_mpath);
+ free(ep->rcv_path);
+ free(ep->rcv_mpath);
if (ep->c_blen > 0)
free(ep->c_lp);
@@ -744,12 +720,7 @@ file_end(
* PUBLIC: int file_write(SCR *, MARK *, MARK *, char *, int);
*/
int
-file_write(
- SCR *sp,
- MARK *fm,
- MARK *tm,
- char *name,
- int flags)
+file_write(SCR *sp, MARK *fm, MARK *tm, char *name, int flags)
{
enum { NEWFILE, OLDFILE } mtype;
struct stat sb;
@@ -1016,10 +987,7 @@ success_open:
* recreate the file. So, let's not risk it.
*/
static int
-file_backup(
- SCR *sp,
- char *name,
- char *bname)
+file_backup(SCR *sp, char *name, char *bname)
{
struct dirent *dp;
struct stat sb;
@@ -1188,6 +1156,7 @@ file_backup(
estr = wfname;
goto err;
}
+ free(d);
if (bp != NULL)
FREE_SPACE(sp, bp, blen);
return (0);
@@ -1201,8 +1170,7 @@ err: if (rfd != -1)
}
if (estr)
msgq_str(sp, M_SYSERR, estr, "%s");
- if (d != NULL)
- free(d);
+ free(d);
if (bp != NULL)
FREE_SPACE(sp, bp, blen);
return (1);
@@ -1306,10 +1274,7 @@ file_comment(SCR *sp)
* PUBLIC: int file_m1(SCR *, int, int);
*/
int
-file_m1(
- SCR *sp,
- int force,
- int flags)
+file_m1(SCR *sp, int force, int flags)
{
EXF *ep;
@@ -1347,9 +1312,7 @@ file_m1(
* PUBLIC: int file_m2(SCR *, int);
*/
int
-file_m2(
- SCR *sp,
- int force)
+file_m2(SCR *sp, int force)
{
EXF *ep;
@@ -1379,9 +1342,7 @@ file_m2(
* PUBLIC: int file_m3(SCR *, int);
*/
int
-file_m3(
- SCR *sp,
- int force)
+file_m3(SCR *sp, int force)
{
EXF *ep;
@@ -1415,9 +1376,7 @@ file_m3(
* PUBLIC: int file_aw(SCR *, int);
*/
int
-file_aw(
- SCR *sp,
- int flags)
+file_aw(SCR *sp, int flags)
{
if (!F_ISSET(sp->ep, F_MODIFIED))
return (0);
@@ -1476,12 +1435,9 @@ file_aw(
* PUBLIC: void set_alt_name(SCR *, char *);
*/
void
-set_alt_name(
- SCR *sp,
- char *name)
+set_alt_name(SCR *sp, char *name)
{
- if (sp->alt_name != NULL)
- free(sp->alt_name);
+ free(sp->alt_name);
if (name == NULL)
sp->alt_name = NULL;
else if ((sp->alt_name = strdup(name)) == NULL)
@@ -1495,11 +1451,7 @@ set_alt_name(
* PUBLIC: lockr_t file_lock(SCR *, char *, int, int);
*/
lockr_t
-file_lock(
- SCR *sp,
- char *name,
- int fd,
- int iswrite)
+file_lock(SCR *sp, char *name, int fd, int iswrite)
{
if (!O_ISSET(sp, O_LOCKFILES))
return (LOCK_SUCCESS);
diff --git a/common/exf.h b/common/exf.h
index 8f70d51dbb61..e6f8e31f0f7a 100644
--- a/common/exf.h
+++ b/common/exf.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: exf.h,v 10.10 2012/07/06 16:03:37 zy Exp $
*/
/* Undo direction. */
/*
diff --git a/common/extern.h b/common/extern.h
deleted file mode 100644
index f8acf8eacd83..000000000000
--- a/common/extern.h
+++ /dev/null
@@ -1,132 +0,0 @@
-char * codeset(void);
-void conv_init(SCR *, SCR *);
-int conv_enc(SCR *, int, char *);
-void conv_end(SCR *);
-int cut(SCR *, CHAR_T *, MARK *, MARK *, int);
-int cut_line(SCR *, recno_t, size_t, size_t, CB *);
-void cut_close(GS *);
-TEXT *text_init(SCR *, const CHAR_T *, size_t, size_t);
-void text_lfree(TEXTH *);
-void text_free(TEXT *);
-int del(SCR *, MARK *, MARK *, int);
-int looks_utf8(const char *, size_t);
-int looks_utf16(const char *, size_t);
-int decode_utf8(const char *);
-int decode_utf16(const char *, int);
-FREF *file_add(SCR *, char *);
-int file_init(SCR *, FREF *, char *, int);
-int file_end(SCR *, EXF *, int);
-int file_write(SCR *, MARK *, MARK *, char *, int);
-int file_m1(SCR *, int, int);
-int file_m2(SCR *, int);
-int file_m3(SCR *, int);
-int file_aw(SCR *, int);
-void set_alt_name(SCR *, char *);
-lockr_t file_lock(SCR *, char *, int, int);
-int v_key_init(SCR *);
-void v_key_ilookup(SCR *);
-size_t v_key_len(SCR *, ARG_CHAR_T);
-char *v_key_name(SCR *, ARG_CHAR_T);
-e_key_t v_key_val(SCR *, ARG_CHAR_T);
-int v_event_push(SCR *, EVENT *, CHAR_T *, size_t, u_int);
-int v_event_get(SCR *, EVENT *, int, u_int32_t);
-void v_event_err(SCR *, EVENT *);
-int v_event_flush(SCR *, u_int);
-int db_eget(SCR *, recno_t, CHAR_T **, size_t *, int *);
-int db_get(SCR *, recno_t, u_int32_t, CHAR_T **, size_t *);
-int db_delete(SCR *, recno_t);
-int db_append(SCR *, int, recno_t, CHAR_T *, size_t);
-int db_insert(SCR *, recno_t, CHAR_T *, size_t);
-int db_set(SCR *, recno_t, CHAR_T *, size_t);
-int db_exist(SCR *, recno_t);
-int db_last(SCR *, recno_t *);
-int db_rget(SCR *, recno_t, char **, size_t *);
-int db_rset(SCR *, recno_t, char *, size_t);
-void db_err(SCR *, recno_t);
-int log_init(SCR *, EXF *);
-int log_end(SCR *, EXF *);
-int log_cursor(SCR *);
-int log_line(SCR *, recno_t, u_int);
-int log_mark(SCR *, LMARK *);
-int log_backward(SCR *, MARK *);
-int log_setline(SCR *);
-int log_forward(SCR *, MARK *);
-int editor(GS *, int, char *[]);
-void v_end(GS *);
-int mark_init(SCR *, EXF *);
-int mark_end(SCR *, EXF *);
-int mark_get(SCR *, ARG_CHAR_T, MARK *, mtype_t);
-int mark_set(SCR *, ARG_CHAR_T, MARK *, int);
-int mark_insdel(SCR *, lnop_t, recno_t);
-void msgq(SCR *, mtype_t, const char *, ...);
-void msgq_wstr(SCR *, mtype_t, const CHAR_T *, const char *);
-void msgq_str(SCR *, mtype_t, const char *, const char *);
-void mod_rpt(SCR *);
-void msgq_status(SCR *, recno_t, u_int);
-int msg_open(SCR *, char *);
-void msg_close(GS *);
-const char *msg_cmsg(SCR *, cmsg_t, size_t *);
-const char *msg_cat(SCR *, const char *, size_t *);
-char *msg_print(SCR *, const char *, int *);
-int opts_init(SCR *, int *);
-int opts_set(SCR *, ARGS *[], char *);
-int o_set(SCR *, int, u_int, char *, u_long);
-int opts_empty(SCR *, int, int);
-void opts_dump(SCR *, enum optdisp);
-int opts_save(SCR *, FILE *);
-OPTLIST const *opts_search(CHAR_T *);
-void opts_nomatch(SCR *, CHAR_T *);
-int opts_copy(SCR *, SCR *);
-void opts_free(SCR *);
-int f_altwerase(SCR *, OPTION *, char *, u_long *);
-int f_columns(SCR *, OPTION *, char *, u_long *);
-int f_lines(SCR *, OPTION *, char *, u_long *);
-int f_lisp(SCR *, OPTION *, char *, u_long *);
-int f_msgcat(SCR *, OPTION *, char *, u_long *);
-int f_print(SCR *, OPTION *, char *, u_long *);
-int f_readonly(SCR *, OPTION *, char *, u_long *);
-int f_recompile(SCR *, OPTION *, char *, u_long *);
-int f_reformat(SCR *, OPTION *, char *, u_long *);
-int f_ttywerase(SCR *, OPTION *, char *, u_long *);
-int f_w300(SCR *, OPTION *, char *, u_long *);
-int f_w1200(SCR *, OPTION *, char *, u_long *);
-int f_w9600(SCR *, OPTION *, char *, u_long *);
-int f_window(SCR *, OPTION *, char *, u_long *);
-int f_encoding(SCR *, OPTION *, char *, u_long *);
-int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int);
-int rcv_tmp(SCR *, EXF *, char *);
-int rcv_init(SCR *);
-int rcv_sync(SCR *, u_int);
-int rcv_list(SCR *);
-int rcv_read(SCR *, FREF *);
-int screen_init(GS *, SCR *, SCR **);
-int screen_end(SCR *);
-SCR *screen_next(SCR *);
-int f_search(SCR *,
- MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int);
-int b_search(SCR *,
- MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int);
-void search_busy(SCR *, busy_t);
-int seq_set(SCR *, CHAR_T *,
- size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int);
-int seq_delete(SCR *, CHAR_T *, size_t, seq_t);
-int seq_free(SEQ *);
-SEQ *seq_find
- (SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *);
-void seq_close(GS *);
-int seq_dump(SCR *, seq_t, int);
-int seq_save(SCR *, FILE *, char *, seq_t);
-int e_memcmp(CHAR_T *, EVENT *, size_t);
-void *binc(SCR *, void *, size_t *, size_t);
-int nonblank(SCR *, recno_t, size_t *);
-char *tail(char *);
-char *join(char *, char *);
-char *expanduser(char *);
-char *quote(char *);
-char *v_strdup(SCR *, const char *, size_t);
-CHAR_T *v_wstrdup(SCR *, const CHAR_T *, size_t);
-enum nresult nget_uslong(u_long *, const CHAR_T *, CHAR_T **, int);
-enum nresult nget_slong(long *, const CHAR_T *, CHAR_T **, int);
-void timepoint_steady(struct timespec *);
-void timepoint_system(struct timespec *);
-void TRACE(SCR *, const char *, ...);
diff --git a/common/gs.h b/common/gs.h
index 4d0dc6fe5bf8..c3d10e70048e 100644
--- a/common/gs.h
+++ b/common/gs.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: gs.h,v 11.0 2012/10/17 06:34:37 zy Exp $
*/
#define TEMPORARY_FILE_STRING "/tmp" /* Default temporary file name. */
@@ -55,8 +53,6 @@ typedef enum { KEY_VEOF, KEY_VERASE, KEY_VKILL, KEY_VWERASE } scr_keyval_t;
* Structure that describes global state of the running program.
*/
struct _gs {
- char *progname; /* Programe name. */
-
int id; /* Last allocated screen id. */
TAILQ_HEAD(_dqh, _scr) dq[1]; /* Displayed screens. */
TAILQ_HEAD(_hqh, _scr) hq[1]; /* Hidden screens. */
diff --git a/common/key.c b/common/key.c
index 790c3719e9b6..23da0498a757 100644
--- a/common/key.c
+++ b/common/key.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: key.c,v 10.54 2013/11/13 12:15:27 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -145,10 +141,7 @@ v_key_init(SCR *sp)
* in the table, so we check for that first.
*/
static void
-v_keyval(
- SCR *sp,
- int val,
- scr_keyval_t name)
+v_keyval(SCR *sp, int val, scr_keyval_t name)
{
KEYLIST *kp;
CHAR_T ch;
@@ -206,9 +199,7 @@ v_key_ilookup(SCR *sp)
* PUBLIC: size_t v_key_len(SCR *, ARG_CHAR_T);
*/
size_t
-v_key_len(
- SCR *sp,
- ARG_CHAR_T ch)
+v_key_len(SCR *sp, ARG_CHAR_T ch)
{
(void)v_key_name(sp, ch);
return (sp->clen);
@@ -222,9 +213,7 @@ v_key_len(
* PUBLIC: char *v_key_name(SCR *, ARG_CHAR_T);
*/
char *
-v_key_name(
- SCR *sp,
- ARG_CHAR_T ach)
+v_key_name(SCR *sp, ARG_CHAR_T ach)
{
static const char hexdigit[] = "0123456789abcdef";
static const char octdigit[] = "01234567";
@@ -330,9 +319,7 @@ done: sp->cname[sp->clen = len] = '\0';
* PUBLIC: e_key_t v_key_val(SCR *, ARG_CHAR_T);
*/
e_key_t
-v_key_val(
- SCR *sp,
- ARG_CHAR_T ch)
+v_key_val(SCR *sp, ARG_CHAR_T ch)
{
KEYLIST k, *kp;
@@ -354,8 +341,7 @@ v_key_val(
* PUBLIC: int v_event_push(SCR *, EVENT *, CHAR_T *, size_t, u_int);
*/
int
-v_event_push(
- SCR *sp,
+v_event_push(SCR *sp,
EVENT *p_evp, /* Push event. */
CHAR_T *p_s, /* Push characters. */
size_t nitems, /* Number of items to push. */
@@ -384,8 +370,8 @@ v_event_push(
if (total >= gp->i_nelem && v_event_grow(sp, MAX(total, 64)))
return (1);
if (gp->i_cnt)
- BCOPY(gp->i_event + gp->i_next,
- gp->i_event + TERM_PUSH_SHIFT + nitems, gp->i_cnt);
+ memmove(gp->i_event + TERM_PUSH_SHIFT + nitems,
+ gp->i_event + gp->i_next, gp->i_cnt * sizeof(EVENT));
gp->i_next = TERM_PUSH_SHIFT;
/* Put the new items into the queue. */
@@ -408,9 +394,7 @@ copy: gp->i_cnt += nitems;
* Append events onto the tail of the buffer.
*/
static int
-v_event_append(
- SCR *sp,
- EVENT *argp)
+v_event_append(SCR *sp, EVENT *argp)
{
CHAR_T *s; /* Characters. */
EVENT *evp;
@@ -535,11 +519,7 @@ v_event_append(
* PUBLIC: int v_event_get(SCR *, EVENT *, int, u_int32_t);
*/
int
-v_event_get(
- SCR *sp,
- EVENT *argp,
- int timeout,
- u_int32_t flags)
+v_event_get(SCR *sp, EVENT *argp, int timeout, u_int32_t flags)
{
EVENT *evp, ev;
GS *gp;
@@ -754,9 +734,7 @@ not_digit: argp->e_c = CH_NOT_DIGIT;
* Walk the screen lists, sync'ing files to their backup copies.
*/
static void
-v_sync(
- SCR *sp,
- int flags)
+v_sync(SCR *sp, int flags)
{
GS *gp;
@@ -774,9 +752,7 @@ v_sync(
* PUBLIC: void v_event_err(SCR *, EVENT *);
*/
void
-v_event_err(
- SCR *sp,
- EVENT *evp)
+v_event_err(SCR *sp, EVENT *evp)
{
switch (evp->e_event) {
case E_CHARACTER:
@@ -813,8 +789,7 @@ v_event_err(
}
/* Free any allocated memory. */
- if (evp->e_asp != NULL)
- free(evp->e_asp);
+ free(evp->e_asp);
}
/*
@@ -824,9 +799,7 @@ v_event_err(
* PUBLIC: int v_event_flush(SCR *, u_int);
*/
int
-v_event_flush(
- SCR *sp,
- u_int flags)
+v_event_flush(SCR *sp, u_int flags)
{
GS *gp;
int rval;
@@ -842,9 +815,7 @@ v_event_flush(
* Grow the terminal queue.
*/
static int
-v_event_grow(
- SCR *sp,
- int add)
+v_event_grow(SCR *sp, int add)
{
GS *gp;
size_t new_nelem, olen;
@@ -862,9 +833,7 @@ v_event_grow(
* Compare two keys for sorting.
*/
static int
-v_key_cmp(
- const void *ap,
- const void *bp)
+v_key_cmp(const void *ap, const void *bp)
{
return (((KEYLIST *)ap)->ch - ((KEYLIST *)bp)->ch);
}
diff --git a/common/key.h b/common/key.h
index 43cef77a4af5..3e55d3044129 100644
--- a/common/key.h
+++ b/common/key.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: key.h,v 10.56 2013/11/13 12:15:27 zy Exp $
*/
#include "multibyte.h"
@@ -159,11 +157,13 @@ extern KEYLIST keylist[];
* can't use the standard isspace(3) macro because it returns true for
* characters like ^K in the ASCII character set. The POSIX isblank(3)
* has the same problem for non-ASCII locale, so we need a standalone one.
- *
- * XXX
- * Note side effect, ch is evaluated multiple times.
*/
-#define cmdskip(ch) ((ch) == ' ' || (ch) == '\t')
+
+static __inline int
+cmdskip(CHAR_T ch)
+{
+ return ch == ' ' || ch == '\t';
+}
/* The "standard" tab width, for displaying things to users. */
#define STANDARD_TAB 6
diff --git a/common/line.c b/common/line.c
index 5549ad93cb66..06d9a3e692d1 100644
--- a/common/line.c
+++ b/common/line.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: line.c,v 10.27 2015/04/03 14:17:21 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -35,8 +31,7 @@ static int scr_update(SCR *, recno_t, lnop_t, int);
* PUBLIC: int db_eget(SCR *, recno_t, CHAR_T **, size_t *, int *);
*/
int
-db_eget(
- SCR *sp,
+db_eget(SCR *sp,
recno_t lno, /* Line number. */
CHAR_T **pp, /* Pointer store. */
size_t *lenp, /* Length store. */
@@ -79,8 +74,7 @@ db_eget(
* PUBLIC: int db_get(SCR *, recno_t, u_int32_t, CHAR_T **, size_t *);
*/
int
-db_get(
- SCR *sp,
+db_get(SCR *sp,
recno_t lno, /* Line number. */
u_int32_t flags,
CHAR_T **pp, /* Pointer store. */
@@ -202,9 +196,7 @@ err3: if (lenp != NULL)
* PUBLIC: int db_delete(SCR *, recno_t);
*/
int
-db_delete(
- SCR *sp,
- recno_t lno)
+db_delete(SCR *sp, recno_t lno)
{
DBT key;
EXF *ep;
@@ -258,12 +250,7 @@ db_delete(
* PUBLIC: int db_append(SCR *, int, recno_t, CHAR_T *, size_t);
*/
int
-db_append(
- SCR *sp,
- int update,
- recno_t lno,
- CHAR_T *p,
- size_t len)
+db_append(SCR *sp, int update, recno_t lno, CHAR_T *p, size_t len)
{
DBT data, key;
EXF *ep;
@@ -334,11 +321,7 @@ db_append(
* PUBLIC: int db_insert(SCR *, recno_t, CHAR_T *, size_t);
*/
int
-db_insert(
- SCR *sp,
- recno_t lno,
- CHAR_T *p,
- size_t len)
+db_insert(SCR *sp, recno_t lno, CHAR_T *p, size_t len)
{
DBT data, key;
EXF *ep;
@@ -401,11 +384,7 @@ db_insert(
* PUBLIC: int db_set(SCR *, recno_t, CHAR_T *, size_t);
*/
int
-db_set(
- SCR *sp,
- recno_t lno,
- CHAR_T *p,
- size_t len)
+db_set(SCR *sp, recno_t lno, CHAR_T *p, size_t len)
{
DBT data, key;
EXF *ep;
@@ -461,9 +440,7 @@ db_set(
* PUBLIC: int db_exist(SCR *, recno_t);
*/
int
-db_exist(
- SCR *sp,
- recno_t lno)
+db_exist(SCR *sp, recno_t lno)
{
EXF *ep;
@@ -496,9 +473,7 @@ db_exist(
* PUBLIC: int db_last(SCR *, recno_t *);
*/
int
-db_last(
- SCR *sp,
- recno_t *lnop)
+db_last(SCR *sp, recno_t *lnop)
{
DBT data, key;
EXF *ep;
@@ -568,8 +543,7 @@ alloc_err:
* PUBLIC: int db_rget(SCR *, recno_t, char **, size_t *);
*/
int
-db_rget(
- SCR *sp,
+db_rget(SCR *sp,
recno_t lno, /* Line number. */
char **pp, /* Pointer store. */
size_t *lenp) /* Length store. */
@@ -597,11 +571,7 @@ db_rget(
* PUBLIC: int db_rset(SCR *, recno_t, char *, size_t);
*/
int
-db_rset(
- SCR *sp,
- recno_t lno,
- char *p,
- size_t len)
+db_rset(SCR *sp, recno_t lno, char *p, size_t len)
{
DBT data, key;
EXF *ep = sp->ep;
@@ -621,9 +591,7 @@ db_rset(
* PUBLIC: void db_err(SCR *, recno_t);
*/
void
-db_err(
- SCR *sp,
- recno_t lno)
+db_err(SCR *sp, recno_t lno)
{
msgq(sp, M_ERR,
"008|Error: unable to retrieve line %lu", (u_long)lno);
@@ -635,11 +603,7 @@ db_err(
* just changed.
*/
static int
-scr_update(
- SCR *sp,
- recno_t lno,
- lnop_t op,
- int current)
+scr_update(SCR *sp, recno_t lno, lnop_t op, int current)
{
EXF *ep;
SCR *tsp;
diff --git a/common/log.c b/common/log.c
index 5adfeaf0fc58..5dcd9a2945fc 100644
--- a/common/log.c
+++ b/common/log.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: log.c,v 10.27 2011/07/13 06:25:50 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -20,6 +16,7 @@ static const char sccsid[] = "$Id: log.c,v 10.27 2011/07/13 06:25:50 zy Exp $";
#include <bitstring.h>
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
@@ -93,9 +90,7 @@ typedef struct {
* PUBLIC: int log_init(SCR *, EXF *);
*/
int
-log_init(
- SCR *sp,
- EXF *ep)
+log_init(SCR *sp, EXF *ep)
{
/*
* !!!
@@ -129,9 +124,7 @@ log_init(
* PUBLIC: int log_end(SCR *, EXF *);
*/
int
-log_end(
- SCR *sp,
- EXF *ep)
+log_end(SCR *sp, EXF *ep)
{
/*
* !!!
@@ -141,10 +134,8 @@ log_end(
(void)(ep->log->close)(ep->log);
ep->log = NULL;
}
- if (ep->l_lp != NULL) {
- free(ep->l_lp);
- ep->l_lp = NULL;
- }
+ free(ep->l_lp);
+ ep->l_lp = NULL;
ep->l_len = 0;
ep->l_cursor.lno = 1; /* XXX Any valid recno. */
ep->l_cursor.cno = 0;
@@ -186,9 +177,7 @@ log_cursor(SCR *sp)
* Actually push a cursor record out.
*/
static int
-log_cursor1(
- SCR *sp,
- int type)
+log_cursor1(SCR *sp, int type)
{
DBT data, key;
EXF *ep;
@@ -224,10 +213,7 @@ log_cursor1(
* PUBLIC: int log_line(SCR *, recno_t, u_int);
*/
int
-log_line(
- SCR *sp,
- recno_t lno,
- u_int action)
+log_line(SCR *sp, recno_t lno, u_int action)
{
DBT data, key;
EXF *ep;
@@ -327,9 +313,7 @@ log_line(
* PUBLIC: int log_mark(SCR *, LMARK *);
*/
int
-log_mark(
- SCR *sp,
- LMARK *lmp)
+log_mark(SCR *sp, LMARK *lmp)
{
DBT data, key;
EXF *ep;
@@ -373,9 +357,7 @@ log_mark(
* PUBLIC: int log_backward(SCR *, MARK *);
*/
int
-log_backward(
- SCR *sp,
- MARK *rp)
+log_backward(SCR *sp, MARK *rp)
{
DBT key, data;
EXF *ep;
@@ -561,9 +543,7 @@ err: F_CLR(ep, F_NOLOG);
* PUBLIC: int log_forward(SCR *, MARK *);
*/
int
-log_forward(
- SCR *sp,
- MARK *rp)
+log_forward(SCR *sp, MARK *rp)
{
DBT key, data;
EXF *ep;
@@ -658,14 +638,11 @@ err: F_CLR(ep, F_NOLOG);
* Try and restart the log on failure, i.e. if we run out of memory.
*/
static void
-log_err(
- SCR *sp,
- char *file,
- int line)
+log_err(SCR *sp, char *file, int line)
{
EXF *ep;
- msgq(sp, M_SYSERR, "015|%s/%d: log put error", tail(file), line);
+ msgq(sp, M_SYSERR, "015|%s/%d: log put error", basename(file), line);
ep = sp->ep;
(void)ep->log->close(ep->log);
if (!log_init(sp, ep))
@@ -674,11 +651,7 @@ log_err(
#if defined(DEBUG) && 0
static void
-log_trace(
- SCR *sp,
- char *msg,
- recno_t rno,
- u_char *p)
+log_trace(SCR *sp, char *msg, recno_t rno, u_char *p)
{
LMARK lm;
MARK m;
@@ -729,12 +702,8 @@ log_trace(
* Apply a realigned line from the log db to the file db.
*/
static int
-apply_with(
- int (*db_func)(SCR *, recno_t, CHAR_T *, size_t),
- SCR *sp,
- recno_t lno,
- u_char *p,
- size_t len)
+apply_with(int (*db_func)(SCR *, recno_t, CHAR_T *, size_t), SCR *sp,
+ recno_t lno, u_char *p, size_t len)
{
#ifdef USE_WIDECHAR
typedef unsigned long nword;
diff --git a/common/log.h b/common/log.h
index df307319b1d3..39af1f5dbfdc 100644
--- a/common/log.h
+++ b/common/log.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * @(#)log.h 10.2 (Berkeley) 3/6/96
*/
#define LOG_NOTYPE 0
diff --git a/common/main.c b/common/main.c
index d9ae96f9e7dd..c0b81960bd55 100644
--- a/common/main.c
+++ b/common/main.c
@@ -9,15 +9,12 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: main.c,v 11.0 2012/10/17 06:34:37 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <bitstring.h>
+#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -31,8 +28,7 @@ static const char sccsid[] = "$Id: main.c,v 11.0 2012/10/17 06:34:37 zy Exp $";
#include "pathnames.h"
static void attach(GS *);
-static void v_estr(char *, int, char *);
-static int v_obsolete(char *, char *[]);
+static int v_obsolete(char *[]);
/*
* editor --
@@ -41,10 +37,7 @@ static int v_obsolete(char *, char *[]);
* PUBLIC: int editor(GS *, int, char *[]);
*/
int
-editor(
- GS *gp,
- int argc,
- char *argv[])
+editor(GS *gp, int argc, char *argv[])
{
extern int optind;
extern char *optarg;
@@ -82,12 +75,12 @@ editor(
/* Set initial screen type and mode based on the program name. */
readonly = 0;
- if (!strcmp(gp->progname, "ex") || !strcmp(gp->progname, "nex"))
+ if (!strcmp(getprogname(), "ex") || !strcmp(getprogname(), "nex"))
LF_INIT(SC_EX);
else {
/* Nview, view are readonly. */
- if (!strcmp(gp->progname, "nview") ||
- !strcmp(gp->progname, "view"))
+ if (!strcmp(getprogname(), "nview") ||
+ !strcmp(getprogname(), "view"))
readonly = 1;
/* Vi is the default. */
@@ -95,7 +88,7 @@ editor(
}
/* Convert old-style arguments into new-style ones. */
- if (v_obsolete(gp->progname, argv))
+ if (v_obsolete(argv))
return (1);
/* Parse the arguments. */
@@ -119,8 +112,7 @@ editor(
* We should support multiple -c options.
*/
if (gp->c_option != NULL) {
- v_estr(gp->progname, 0,
- "only one -c command may be specified.");
+ warnx("only one -c command may be specified.");
return (1);
}
gp->c_option = optarg;
@@ -135,8 +127,7 @@ editor(
attach(gp);
break;
default:
- v_estr(gp->progname, 0,
- "usage: -D requires s or w argument.");
+ warnx("usage: -D requires s or w argument.");
return (1);
}
break;
@@ -156,8 +147,7 @@ editor(
break;
case 'r': /* Recover. */
if (flagchk == 't') {
- v_estr(gp->progname, 0,
- "only one of -r and -t may be specified.");
+ warnx("only one of -r and -t may be specified.");
return (1);
}
flagchk = 'r';
@@ -171,7 +161,7 @@ editor(
#ifdef DEBUG
case 'T': /* Trace. */
if ((gp->tracefp = fopen(optarg, "w")) == NULL) {
- v_estr(gp->progname, errno, optarg);
+ warn("%s", optarg);
goto err;
}
(void)fprintf(gp->tracefp,
@@ -180,13 +170,11 @@ editor(
#endif
case 't': /* Tag. */
if (flagchk == 'r') {
- v_estr(gp->progname, 0,
- "only one of -r and -t may be specified.");
+ warnx("only one of -r and -t may be specified.");
return (1);
}
if (flagchk == 't') {
- v_estr(gp->progname, 0,
- "only one tag file may be specified.");
+ warnx("only one tag file may be specified.");
return (1);
}
flagchk = 't';
@@ -213,7 +201,7 @@ editor(
* If not reading from a terminal, it's like -s was specified.
*/
if (silent && !LF_ISSET(SC_EX)) {
- v_estr(gp->progname, 0, "-s option is only applicable to ex.");
+ warnx("-s option is only applicable to ex.");
goto err;
}
if (LF_ISSET(SC_EX) && F_ISSET(gp, G_SCRIPTED))
@@ -341,7 +329,7 @@ editor(
/* Cheat -- we know we have an extra argv slot. */
*--argv = strdup(sp->frp->name);
if (*argv == NULL) {
- v_estr(gp->progname, errno, NULL);
+ warn(NULL);
goto err;
}
}
@@ -452,17 +440,14 @@ v_end(gp)
/* Free FREF's. */
while ((frp = TAILQ_FIRST(gp->frefq)) != NULL) {
TAILQ_REMOVE(gp->frefq, frp, q);
- if (frp->name != NULL)
- free(frp->name);
- if (frp->tname != NULL)
- free(frp->tname);
+ free(frp->name);
+ free(frp->tname);
free(frp);
}
}
/* Free key input queue. */
- if (gp->i_event != NULL)
- free(gp->i_event);
+ free(gp->i_event);
/* Free cut buffers. */
cut_close(gp);
@@ -499,8 +484,7 @@ v_end(gp)
#if defined(DEBUG) || defined(PURIFY)
/* Free any temporary space. */
- if (gp->tmp_bp != NULL)
- free(gp->tmp_bp);
+ free(gp->tmp_bp);
#if defined(DEBUG)
/* Close debugging file descriptor. */
@@ -515,9 +499,7 @@ v_end(gp)
* Convert historic arguments into something getopt(3) will like.
*/
static int
-v_obsolete(
- char *name,
- char *argv[])
+v_obsolete(char *argv[])
{
size_t len;
char *p;
@@ -555,7 +537,7 @@ v_obsolete(
if (argv[0][1] == '\0') {
argv[0] = strdup("-s");
if (argv[0] == NULL) {
-nomem: v_estr(name, errno, NULL);
+nomem: warn(NULL);
return (1);
}
} else
@@ -574,7 +556,7 @@ attach(GS *gp)
char ch;
if ((fd = open(_PATH_TTY, O_RDONLY, 0)) < 0) {
- v_estr(gp->progname, errno, _PATH_TTY);
+ warn("%s", _PATH_TTY);
return;
}
@@ -591,17 +573,3 @@ attach(GS *gp)
(void)close(fd);
}
#endif
-
-static void
-v_estr(
- char *name,
- int eno,
- char *msg)
-{
- (void)fprintf(stderr, "%s", name);
- if (msg != NULL)
- (void)fprintf(stderr, ": %s", msg);
- if (eno)
- (void)fprintf(stderr, ": %s", strerror(errno));
- (void)fprintf(stderr, "\n");
-}
diff --git a/common/mark.c b/common/mark.c
index a3158e4560b6..9af4612cb22a 100644
--- a/common/mark.c
+++ b/common/mark.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: mark.c,v 10.14 2011/07/04 14:42:58 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -66,9 +62,7 @@ static LMARK *mark_find(SCR *, ARG_CHAR_T);
* PUBLIC: int mark_init(SCR *, EXF *);
*/
int
-mark_init(
- SCR *sp,
- EXF *ep)
+mark_init(SCR *sp, EXF *ep)
{
/*
* !!!
@@ -87,9 +81,7 @@ mark_init(
* PUBLIC: int mark_end(SCR *, EXF *);
*/
int
-mark_end(
- SCR *sp,
- EXF *ep)
+mark_end(SCR *sp, EXF *ep)
{
LMARK *lmp;
@@ -111,11 +103,7 @@ mark_end(
* PUBLIC: int mark_get(SCR *, ARG_CHAR_T, MARK *, mtype_t);
*/
int
-mark_get(
- SCR *sp,
- ARG_CHAR_T key,
- MARK *mp,
- mtype_t mtype)
+mark_get(SCR *sp, ARG_CHAR_T key, MARK *mp, mtype_t mtype)
{
LMARK *lmp;
@@ -156,11 +144,7 @@ mark_get(
* PUBLIC: int mark_set(SCR *, ARG_CHAR_T, MARK *, int);
*/
int
-mark_set(
- SCR *sp,
- ARG_CHAR_T key,
- MARK *value,
- int userset)
+mark_set(SCR *sp, ARG_CHAR_T key, MARK *value, int userset)
{
LMARK *lmp, *lmt;
@@ -175,7 +159,7 @@ mark_set(
*/
lmp = mark_find(sp, key);
if (lmp == NULL || lmp->name != key) {
- MALLOC_RET(sp, lmt, LMARK *, sizeof(LMARK));
+ MALLOC_RET(sp, lmt, sizeof(LMARK));
if (lmp == NULL) {
SLIST_INSERT_HEAD(sp->ep->marks, lmt, q);
} else
@@ -198,9 +182,7 @@ mark_set(
* where it would go.
*/
static LMARK *
-mark_find(
- SCR *sp,
- ARG_CHAR_T key)
+mark_find(SCR *sp, ARG_CHAR_T key)
{
LMARK *lmp, *lastlmp = NULL;
@@ -223,10 +205,7 @@ mark_find(
* PUBLIC: int mark_insdel(SCR *, lnop_t, recno_t);
*/
int
-mark_insdel(
- SCR *sp,
- lnop_t op,
- recno_t lno)
+mark_insdel(SCR *sp, lnop_t op, recno_t lno)
{
LMARK *lmp;
recno_t lline;
diff --git a/common/mark.h b/common/mark.h
index 44b8a19938ca..53a07836c625 100644
--- a/common/mark.h
+++ b/common/mark.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: mark.h,v 10.6 2011/07/04 14:41:51 zy Exp $
*/
/*
diff --git a/common/mem.h b/common/mem.h
index b2b44b62ec8e..1e26a6ea6549 100644
--- a/common/mem.h
+++ b/common/mem.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: mem.h,v 10.17 2012/10/07 00:40:29 zy Exp $
*/
#ifdef DEBUG
@@ -148,45 +146,32 @@
/*
* Malloc a buffer, casting the return pointer. Various versions.
- *
- * !!!
- * The cast should be unnecessary, malloc(3) and friends return void *'s,
- * which is all we need. However, some systems that nvi needs to run on
- * don't do it right yet, resulting in the compiler printing out roughly
- * a million warnings. After awhile, it seemed easier to put the casts
- * in instead of explaining it all the time.
*/
-#define CALLOC(sp, p, cast, nmemb, size) { \
- if ((p = (cast)calloc(nmemb, size)) == NULL) \
+#define CALLOC(sp, p, nmemb, size) { \
+ if ((p = calloc(nmemb, size)) == NULL) \
msgq(sp, M_SYSERR, NULL); \
}
-#define CALLOC_GOTO(sp, p, cast, nmemb, size) { \
- if ((p = (cast)calloc(nmemb, size)) == NULL) \
+#define CALLOC_GOTO(sp, p, nmemb, size) { \
+ if ((p = calloc(nmemb, size)) == NULL) \
goto alloc_err; \
}
-#define CALLOC_NOMSG(sp, p, cast, nmemb, size) { \
- p = (cast)calloc(nmemb, size); \
-}
-#define CALLOC_RET(sp, p, cast, nmemb, size) { \
- if ((p = (cast)calloc(nmemb, size)) == NULL) { \
+#define CALLOC_RET(sp, p, nmemb, size) { \
+ if ((p = calloc(nmemb, size)) == NULL) { \
msgq(sp, M_SYSERR, NULL); \
return (1); \
} \
}
-#define MALLOC(sp, p, cast, size) { \
- if ((p = (cast)malloc(size)) == NULL) \
+#define MALLOC(sp, p, size) { \
+ if ((p = malloc(size)) == NULL) \
msgq(sp, M_SYSERR, NULL); \
}
-#define MALLOC_GOTO(sp, p, cast, size) { \
- if ((p = (cast)malloc(size)) == NULL) \
+#define MALLOC_GOTO(sp, p, size) { \
+ if ((p = malloc(size)) == NULL) \
goto alloc_err; \
}
-#define MALLOC_NOMSG(sp, p, cast, size) { \
- p = (cast)malloc(size); \
-}
-#define MALLOC_RET(sp, p, cast, size) { \
- if ((p = (cast)malloc(size)) == NULL) { \
+#define MALLOC_RET(sp, p, size) { \
+ if ((p = malloc(size)) == NULL) { \
msgq(sp, M_SYSERR, NULL); \
return (1); \
} \
@@ -198,21 +183,13 @@
*/
#define REALLOC(sp, p, cast, size) { \
cast newp; \
- if ((newp = (cast)realloc(p, size)) == NULL) { \
- if (p != NULL) \
- free(p); \
+ if ((newp = realloc(p, size)) == NULL) { \
+ free(p); \
msgq(sp, M_SYSERR, NULL); \
} \
p = newp; \
}
-/*
- * Versions of bcopy(3) and bzero(3) that use the size of the
- * initial pointer to figure out how much memory to manipulate.
- */
-#define BCOPY(p, t, len) bcopy(p, t, (len) * sizeof(*(p)))
-#define BZERO(p, len) bzero(p, (len) * sizeof(*(p)))
-
/*
* p2roundup --
* Get next power of 2; convenient for realloc.
diff --git a/common/msg.c b/common/msg.c
index 3099b1e98b3c..d2463a3ecccd 100644
--- a/common/msg.c
+++ b/common/msg.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: msg.c,v 11.1 2015/02/09 11:12:44 marc Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -39,11 +35,7 @@ static const char sccsid[] = "$Id: msg.c,v 11.1 2015/02/09 11:12:44 marc Exp $";
* PUBLIC: void msgq(SCR *, mtype_t, const char *, ...);
*/
void
-msgq(
- SCR *sp,
- mtype_t mt,
- const char *fmt,
- ...)
+msgq(SCR *sp, mtype_t mt, const char *fmt, ...)
{
#ifndef NL_ARGMAX
#define __NL_ARGMAX 20 /* Set to 9 by System V. */
@@ -202,12 +194,12 @@ retry: FREE_SPACE(sp, bp, blen);
if (*p == '\0')
break;
++p;
- if (!isdigit(*p)) {
+ if (!isdigit((u_char)*p)) {
if (*p == '%')
++p;
continue;
}
- for (u = p; *++p != '\0' && isdigit(*p););
+ for (u = p; *++p != '\0' && isdigit((u_char)*p););
if (*p != '$')
continue;
@@ -359,11 +351,7 @@ alloc_err:
* PUBLIC: void msgq_wstr(SCR *, mtype_t, const CHAR_T *, const char *);
*/
void
-msgq_wstr(
- SCR *sp,
- mtype_t mtype,
- const CHAR_T *str,
- const char *fmt)
+msgq_wstr(SCR *sp, mtype_t mtype, const CHAR_T *str, const char *fmt)
{
size_t nlen;
CONST char *nstr;
@@ -383,11 +371,7 @@ msgq_wstr(
* PUBLIC: void msgq_str(SCR *, mtype_t, const char *, const char *);
*/
void
-msgq_str(
- SCR *sp,
- mtype_t mtype,
- const char *str,
- const char *fmt)
+msgq_str(SCR *sp, mtype_t mtype, const char *str, const char *fmt)
{
int nf, sv_errno;
char *p;
@@ -536,10 +520,7 @@ alloc_err:
* PUBLIC: void msgq_status(SCR *, recno_t, u_int);
*/
void
-msgq_status(
- SCR *sp,
- recno_t lno,
- u_int flags)
+msgq_status(SCR *sp, recno_t lno, u_int flags)
{
recno_t last;
size_t blen, len;
@@ -708,9 +689,7 @@ alloc_err:
* PUBLIC: int msg_open(SCR *, char *);
*/
int
-msg_open(
- SCR *sp,
- char *file)
+msg_open(SCR *sp, char *file)
{
/*
* !!!
@@ -788,10 +767,7 @@ msg_close(GS *gp)
* PUBLIC: const char *msg_cmsg(SCR *, cmsg_t, size_t *);
*/
const char *
-msg_cmsg(
- SCR *sp,
- cmsg_t which,
- size_t *lenp)
+msg_cmsg(SCR *sp, cmsg_t which, size_t *lenp)
{
switch (which) {
case CMSG_CONF:
@@ -826,10 +802,7 @@ msg_cmsg(
* PUBLIC: const char *msg_cat(SCR *, const char *, size_t *);
*/
const char *
-msg_cat(
- SCR *sp,
- const char *str,
- size_t *lenp)
+msg_cat(SCR *sp, const char *str, size_t *lenp)
{
GS *gp;
char *p;
@@ -839,8 +812,9 @@ msg_cat(
* If it's not a catalog message, i.e. has doesn't have a leading
* number and '|' symbol, we're done.
*/
- if (isdigit(str[0]) &&
- isdigit(str[1]) && isdigit(str[2]) && str[3] == '|') {
+ if (isdigit((u_char)str[0]) &&
+ isdigit((u_char)str[1]) &&
+ isdigit((u_char)str[2]) && str[3] == '|') {
msgno = atoi(str);
str = &str[4];
@@ -864,10 +838,7 @@ msg_cat(
* PUBLIC: char *msg_print(SCR *, const char *, int *);
*/
char *
-msg_print(
- SCR *sp,
- const char *s,
- int *needfree)
+msg_print(SCR *sp, const char *s, int *needfree)
{
size_t blen, nlen;
char *bp, *ep, *p, *t;
diff --git a/common/msg.h b/common/msg.h
index d65bb1aaf542..f0f8a308e586 100644
--- a/common/msg.h
+++ b/common/msg.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * @(#)msg.h 10.10 (Berkeley) 5/10/96
*/
/*
diff --git a/common/multibyte.h b/common/multibyte.h
index 40e352100ec3..4967818f3e6a 100644
--- a/common/multibyte.h
+++ b/common/multibyte.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: multibyte.h,v 1.32 2012/10/07 01:35:58 zy Exp $
*/
#ifndef MULTIBYTE_H
@@ -112,4 +110,38 @@ typedef char RCHAR_T;
#define SIZE(w) (sizeof(w) / sizeof(*w))
+/*
+ * Locale insensitive character category detection.
+ */
+
+static __inline int
+isatoz(CHAR_T c)
+{
+ return 'a' <= c && c <= 'z';
+}
+
+static __inline int
+isAtoZ(CHAR_T c)
+{
+ return 'A' <= c && c <= 'Z';
+}
+
+static __inline int
+is0to9(CHAR_T c)
+{
+ return '0' <= c && c <= '9';
+}
+
+static __inline int
+isazAZ(CHAR_T c)
+{
+ return isatoz(c) || isAtoZ(c);
+}
+
+static __inline int
+is09azAZ(CHAR_T c)
+{
+ return is0to9(c) || isazAZ(c);
+}
+
#endif
diff --git a/common/options.c b/common/options.c
index e619d8f08eb7..25b10fe67012 100644
--- a/common/options.c
+++ b/common/options.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: options.c,v 10.73 2012/10/09 06:14:07 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -79,6 +75,8 @@ OPTLIST const optlist[] = {
{L("errorbells"), NULL, OPT_0BOOL, 0},
/* O_ESCAPETIME 4.4BSD */
{L("escapetime"), NULL, OPT_NUM, 0},
+/* O_EXPANDTAB NetBSD 5.0 */
+ {L("expandtab"), NULL, OPT_0BOOL, 0},
/* O_EXRC System V (undocumented) */
{L("exrc"), NULL, OPT_0BOOL, 0},
/* O_EXTENDED 4.4BSD */
@@ -256,6 +254,7 @@ static OABBREV const abbrev[] = {
{L("dir"), O_TMPDIR}, /* 4BSD */
{L("eb"), O_ERRORBELLS}, /* 4BSD */
{L("ed"), O_EDCOMPATIBLE}, /* 4BSD */
+ {L("et"), O_EXPANDTAB}, /* NetBSD 5.0 */
{L("ex"), O_EXRC}, /* System V (undocumented) */
{L("fe"), O_FILEENCODING},
{L("ht"), O_HARDTABS}, /* 4BSD */
@@ -297,9 +296,7 @@ static OABBREV const abbrev[] = {
* PUBLIC: int opts_init(SCR *, int *);
*/
int
-opts_init(
- SCR *sp,
- int *oargs)
+opts_init(SCR *sp, int *oargs)
{
ARGS *argv[2], a, b;
OPTLIST const *op;
@@ -463,10 +460,7 @@ err: msgq_wstr(sp, M_ERR, optlist[optindx].name,
* PUBLIC: int opts_set(SCR *, ARGS *[], char *);
*/
int
-opts_set(
- SCR *sp,
- ARGS *argv[],
- char *usage)
+opts_set(SCR *sp, ARGS *argv[], char *usage)
{
enum optdisp disp;
enum nresult nret;
@@ -757,12 +751,7 @@ badnum: INT2CHAR(sp, name, STRLEN(name) + 1,
* PUBLIC: int o_set(SCR *, int, u_int, char *, u_long);
*/
int
-o_set(
- SCR *sp,
- int opt,
- u_int flags,
- char *str,
- u_long val)
+o_set(SCR *sp, int opt, u_int flags, char *str, u_long val)
{
OPTION *op;
@@ -779,14 +768,14 @@ o_set(
/* Free the previous string, if requested, and set the value. */
if LF_ISSET(OS_DEF)
if (LF_ISSET(OS_STR | OS_STRDUP)) {
- if (!LF_ISSET(OS_NOFREE) && op->o_def.str != NULL)
+ if (!LF_ISSET(OS_NOFREE))
free(op->o_def.str);
op->o_def.str = str;
} else
op->o_def.val = val;
else
if (LF_ISSET(OS_STR | OS_STRDUP)) {
- if (!LF_ISSET(OS_NOFREE) && op->o_cur.str != NULL)
+ if (!LF_ISSET(OS_NOFREE))
free(op->o_cur.str);
op->o_cur.str = str;
} else
@@ -801,10 +790,7 @@ o_set(
* PUBLIC: int opts_empty(SCR *, int, int);
*/
int
-opts_empty(
- SCR *sp,
- int off,
- int silent)
+opts_empty(SCR *sp, int off, int silent)
{
char *p;
@@ -824,9 +810,7 @@ opts_empty(
* PUBLIC: void opts_dump(SCR *, enum optdisp);
*/
void
-opts_dump(
- SCR *sp,
- enum optdisp type)
+opts_dump(SCR *sp, enum optdisp type)
{
OPTLIST const *op;
int base, b_num, cnt, col, colwidth, curlen, s_num;
@@ -958,9 +942,7 @@ opts_dump(
* Print out an option.
*/
static int
-opts_print(
- SCR *sp,
- OPTLIST const *op)
+opts_print(SCR *sp, OPTLIST const *op)
{
int curlen, offset;
@@ -990,9 +972,7 @@ opts_print(
* PUBLIC: int opts_save(SCR *, FILE *);
*/
int
-opts_save(
- SCR *sp,
- FILE *fp)
+opts_save(SCR *sp, FILE *fp)
{
OPTLIST const *op;
CHAR_T ch, *p;
@@ -1093,26 +1073,20 @@ opts_search(CHAR_T *name)
* PUBLIC: void opts_nomatch(SCR *, CHAR_T *);
*/
void
-opts_nomatch(
- SCR *sp,
- CHAR_T *name)
+opts_nomatch(SCR *sp, CHAR_T *name)
{
msgq_wstr(sp, M_ERR, name,
"033|set: no %s option: 'set all' gives all option values");
}
static int
-opts_abbcmp(
- const void *a,
- const void *b)
+opts_abbcmp(const void *a, const void *b)
{
return(STRCMP(((OABBREV *)a)->name, ((OABBREV *)b)->name));
}
static int
-opts_cmp(
- const void *a,
- const void *b)
+opts_cmp(const void *a, const void *b)
{
return(STRCMP(((OPTLIST *)a)->name, ((OPTLIST *)b)->name));
}
@@ -1124,9 +1098,7 @@ opts_cmp(
* PUBLIC: int opts_copy(SCR *, SCR *);
*/
int
-opts_copy(
- SCR *orig,
- SCR *sp)
+opts_copy(SCR *orig, SCR *sp)
{
int cnt, rval;
@@ -1180,9 +1152,7 @@ opts_free(SCR *sp)
if (optlist[cnt].type != OPT_STR ||
F_ISSET(&sp->opts[cnt], OPT_GLOBAL))
continue;
- if (O_STR(sp, cnt) != NULL)
- free(O_STR(sp, cnt));
- if (O_D_STR(sp, cnt) != NULL)
- free(O_D_STR(sp, cnt));
+ free(O_STR(sp, cnt));
+ free(O_D_STR(sp, cnt));
}
}
diff --git a/common/options.h b/common/options.h
index aaeece144d89..5ed12d39c342 100644
--- a/common/options.h
+++ b/common/options.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: options.h,v 10.21 2012/02/10 20:24:58 zy Exp $
*/
/*
diff --git a/common/options_def.h b/common/options_def.h
deleted file mode 100644
index 8e232786cfe6..000000000000
--- a/common/options_def.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#define O_ALTWERASE 0
-#define O_AUTOINDENT 1
-#define O_AUTOPRINT 2
-#define O_AUTOWRITE 3
-#define O_BACKUP 4
-#define O_BEAUTIFY 5
-#define O_CDPATH 6
-#define O_CEDIT 7
-#define O_COLUMNS 8
-#define O_COMBINED 9
-#define O_COMMENT 10
-#define O_TMPDIR 11
-#define O_EDCOMPATIBLE 12
-#define O_ERRORBELLS 13
-#define O_ESCAPETIME 14
-#define O_EXRC 15
-#define O_EXTENDED 16
-#define O_FILEC 17
-#define O_FILEENCODING 18
-#define O_FLASH 19
-#define O_HARDTABS 20
-#define O_ICLOWER 21
-#define O_IGNORECASE 22
-#define O_INPUTENCODING 23
-#define O_KEYTIME 24
-#define O_LEFTRIGHT 25
-#define O_LINES 26
-#define O_LISP 27
-#define O_LIST 28
-#define O_LOCKFILES 29
-#define O_MAGIC 30
-#define O_MATCHCHARS 31
-#define O_MATCHTIME 32
-#define O_MESG 33
-#define O_MODELINE 34
-#define O_MSGCAT 35
-#define O_NOPRINT 36
-#define O_NUMBER 37
-#define O_OCTAL 38
-#define O_OPEN 39
-#define O_OPTIMIZE 40
-#define O_PARAGRAPHS 41
-#define O_PATH 42
-#define O_PRINT 43
-#define O_PROMPT 44
-#define O_READONLY 45
-#define O_RECDIR 46
-#define O_REDRAW 47
-#define O_REMAP 48
-#define O_REPORT 49
-#define O_RULER 50
-#define O_SCROLL 51
-#define O_SEARCHINCR 52
-#define O_SECTIONS 53
-#define O_SECURE 54
-#define O_SHELL 55
-#define O_SHELLMETA 56
-#define O_SHIFTWIDTH 57
-#define O_SHOWMATCH 58
-#define O_SHOWMODE 59
-#define O_SIDESCROLL 60
-#define O_SLOWOPEN 61
-#define O_SOURCEANY 62
-#define O_TABSTOP 63
-#define O_TAGLENGTH 64
-#define O_TAGS 65
-#define O_TERM 66
-#define O_TERSE 67
-#define O_TILDEOP 68
-#define O_TIMEOUT 69
-#define O_TTYWERASE 70
-#define O_VERBOSE 71
-#define O_W1200 72
-#define O_W300 73
-#define O_W9600 74
-#define O_WARN 75
-#define O_WINDOW 76
-#define O_WINDOWNAME 77
-#define O_WRAPLEN 78
-#define O_WRAPMARGIN 79
-#define O_WRAPSCAN 80
-#define O_WRITEANY 81
-#define O_OPTIONCOUNT 82
diff --git a/common/options_f.c b/common/options_f.c
index 850bfc2eca5c..45ab913c55ab 100644
--- a/common/options_f.c
+++ b/common/options_f.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: options_f.c,v 10.34 04/07/11 16:06:29 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -32,11 +28,7 @@ static const char sccsid[] = "$Id: options_f.c,v 10.34 04/07/11 16:06:29 zy Exp
* PUBLIC: int f_altwerase(SCR *, OPTION *, char *, u_long *);
*/
int
-f_altwerase(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_altwerase(SCR *sp, OPTION *op, char *str, u_long *valp)
{
if (*valp)
O_CLR(sp, O_TTYWERASE);
@@ -47,11 +39,7 @@ f_altwerase(
* PUBLIC: int f_columns(SCR *, OPTION *, char *, u_long *);
*/
int
-f_columns(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_columns(SCR *sp, OPTION *op, char *str, u_long *valp)
{
/* Validate the number. */
if (*valp < MINIMUM_SCREEN_COLS) {
@@ -81,11 +69,7 @@ f_columns(
* PUBLIC: int f_lines(SCR *, OPTION *, char *, u_long *);
*/
int
-f_lines(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_lines(SCR *sp, OPTION *op, char *str, u_long *valp)
{
/* Validate the number. */
if (*valp < MINIMUM_SCREEN_ROWS) {
@@ -138,11 +122,7 @@ f_lines(
* PUBLIC: int f_lisp(SCR *, OPTION *, char *, u_long *);
*/
int
-f_lisp(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_lisp(SCR *sp, OPTION *op, char *str, u_long *valp)
{
msgq(sp, M_ERR, "044|The lisp option is not implemented");
return (0);
@@ -152,11 +132,7 @@ f_lisp(
* PUBLIC: int f_msgcat(SCR *, OPTION *, char *, u_long *);
*/
int
-f_msgcat(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_msgcat(SCR *sp, OPTION *op, char *str, u_long *valp)
{
(void)msg_open(sp, str);
return (0);
@@ -166,11 +142,7 @@ f_msgcat(
* PUBLIC: int f_print(SCR *, OPTION *, char *, u_long *);
*/
int
-f_print(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_print(SCR *sp, OPTION *op, char *str, u_long *valp)
{
int offset = op - sp->opts;
@@ -195,11 +167,7 @@ f_print(
* PUBLIC: int f_readonly(SCR *, OPTION *, char *, u_long *);
*/
int
-f_readonly(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_readonly(SCR *sp, OPTION *op, char *str, u_long *valp)
{
/*
* !!!
@@ -216,11 +184,7 @@ f_readonly(
* PUBLIC: int f_recompile(SCR *, OPTION *, char *, u_long *);
*/
int
-f_recompile(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_recompile(SCR *sp, OPTION *op, char *str, u_long *valp)
{
if (F_ISSET(sp, SC_RE_SEARCH)) {
regfree(&sp->re_c);
@@ -237,11 +201,7 @@ f_recompile(
* PUBLIC: int f_reformat(SCR *, OPTION *, char *, u_long *);
*/
int
-f_reformat(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_reformat(SCR *sp, OPTION *op, char *str, u_long *valp)
{
F_SET(sp, SC_SCR_REFORMAT);
return (0);
@@ -251,11 +211,7 @@ f_reformat(
* PUBLIC: int f_ttywerase(SCR *, OPTION *, char *, u_long *);
*/
int
-f_ttywerase(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_ttywerase(SCR *sp, OPTION *op, char *str, u_long *valp)
{
if (*valp)
O_CLR(sp, O_ALTWERASE);
@@ -266,11 +222,7 @@ f_ttywerase(
* PUBLIC: int f_w300(SCR *, OPTION *, char *, u_long *);
*/
int
-f_w300(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_w300(SCR *sp, OPTION *op, char *str, u_long *valp)
{
u_long v;
@@ -287,11 +239,7 @@ f_w300(
* PUBLIC: int f_w1200(SCR *, OPTION *, char *, u_long *);
*/
int
-f_w1200(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_w1200(SCR *sp, OPTION *op, char *str, u_long *valp)
{
u_long v;
@@ -308,11 +256,7 @@ f_w1200(
* PUBLIC: int f_w9600(SCR *, OPTION *, char *, u_long *);
*/
int
-f_w9600(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_w9600(SCR *sp, OPTION *op, char *str, u_long *valp)
{
u_long v;
@@ -329,11 +273,7 @@ f_w9600(
* PUBLIC: int f_window(SCR *, OPTION *, char *, u_long *);
*/
int
-f_window(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_window(SCR *sp, OPTION *op, char *str, u_long *valp)
{
if (*valp >= O_VAL(sp, O_LINES) - 1 &&
(*valp = O_VAL(sp, O_LINES) - 1) == 0)
@@ -345,11 +285,7 @@ f_window(
* PUBLIC: int f_encoding(SCR *, OPTION *, char *, u_long *);
*/
int
-f_encoding(
- SCR *sp,
- OPTION *op,
- char *str,
- u_long *valp)
+f_encoding(SCR *sp, OPTION *op, char *str, u_long *valp)
{
int offset = op - sp->opts;
diff --git a/common/put.c b/common/put.c
index d3adf5c08607..26a67ac8711c 100644
--- a/common/put.c
+++ b/common/put.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: put.c,v 10.19 04/07/11 17:00:24 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -33,13 +29,7 @@ static const char sccsid[] = "$Id: put.c,v 10.19 04/07/11 17:00:24 zy Exp $";
* PUBLIC: int put(SCR *, CB *, CHAR_T *, MARK *, MARK *, int);
*/
int
-put(
- SCR *sp,
- CB *cbp,
- CHAR_T *namep,
- MARK *cp,
- MARK *rp,
- int append)
+put(SCR *sp, CB *cbp, CHAR_T *namep, MARK *cp, MARK *rp, int append)
{
CHAR_T name;
TEXT *ltp, *tp;
diff --git a/common/recover.c b/common/recover.c
index d0a927bd4301..89f25a4146e9 100644
--- a/common/recover.c
+++ b/common/recover.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: recover.c,v 11.3 2015/04/04 03:50:42 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -116,10 +112,7 @@ static int rcv_dlnread(SCR *, char **, char **, FILE *);
* PUBLIC: int rcv_tmp(SCR *, EXF *, char *);
*/
int
-rcv_tmp(
- SCR *sp,
- EXF *ep,
- char *name)
+rcv_tmp(SCR *sp, EXF *ep, char *name)
{
struct stat sb;
int fd;
@@ -237,9 +230,7 @@ err: msgq(sp, M_ERR,
* PUBLIC: int rcv_sync(SCR *, u_int);
*/
int
-rcv_sync(
- SCR *sp,
- u_int flags)
+rcv_sync(SCR *sp, u_int flags)
{
EXF *ep;
int fd, rval;
@@ -318,10 +309,7 @@ err: rval = 1;
* Build the file to mail to the user.
*/
static int
-rcv_mailfile(
- SCR *sp,
- int issync,
- char *cp_path)
+rcv_mailfile(SCR *sp, int issync, char *cp_path)
{
EXF *ep;
GS *gp;
@@ -404,7 +392,7 @@ rcv_mailfile(
goto err;
}
- MALLOC(sp, host, char *, hostmax + 1);
+ MALLOC(sp, host, hostmax + 1);
if (host == NULL)
goto err;
(void)gethostname(host, hostmax + 1);
@@ -429,8 +417,8 @@ rcv_mailfile(
" was editing a file named ", t, " on the machine ",
host, ", when it was saved for recovery. ",
"You can recover most, if not all, of the changes ",
- "to this file using the -r option to ", gp->progname, ":\n\n\t",
- gp->progname, " -r ", qt);
+ "to this file using the -r option to ", getprogname(), ":\n\n\t",
+ getprogname(), " -r ", qt);
free(qt);
free(host);
if (buf == NULL) {
@@ -594,13 +582,11 @@ rcv_list(SCR *sp)
/* Close, discarding lock. */
next: (void)fclose(fp);
- if (file != NULL)
- free(file);
- if (path != NULL)
- free(path);
+ free(file);
+ free(path);
}
if (found == 0)
- (void)printf("%s: No files to recover\n", sp->gp->progname);
+ (void)printf("%s: No files to recover\n", getprogname());
(void)closedir(dirp);
return (0);
}
@@ -612,9 +598,7 @@ next: (void)fclose(fp);
* PUBLIC: int rcv_read(SCR *, FREF *);
*/
int
-rcv_read(
- SCR *sp,
- FREF *frp)
+rcv_read(SCR *sp, FREF *frp)
{
struct dirent *dp;
struct stat sb;
@@ -732,12 +716,10 @@ rcv_read(
sv_fd = dup(fileno(fp));
} else {
next: free(recpath);
- if (path != NULL)
- free(path);
+ free(path);
}
(void)fclose(fp);
- if (file != NULL)
- free(file);
+ free(file);
}
(void)closedir(dirp);
@@ -790,10 +772,7 @@ next: free(recpath);
* Copy a recovery file.
*/
static int
-rcv_copy(
- SCR *sp,
- int wfd,
- char *fname)
+rcv_copy(SCR *sp, int wfd, char *fname)
{
int nr, nw, off, rfd;
char buf[8 * 1024];
@@ -816,10 +795,7 @@ err: msgq_str(sp, M_SYSERR, fname, "%s");
* Paranoid make temporary file routine.
*/
static int
-rcv_mktemp(
- SCR *sp,
- char *path,
- char *dname)
+rcv_mktemp(SCR *sp, char *path, char *dname)
{
int fd;
@@ -833,9 +809,7 @@ rcv_mktemp(
* Send email.
*/
static void
-rcv_email(
- SCR *sp,
- char *fname)
+rcv_email(SCR *sp, char *fname)
{
char *buf;
@@ -854,11 +828,7 @@ rcv_email(
* Encode a string into an X-vi-data line and write it.
*/
static int
-rcv_dlnwrite(
- SCR *sp,
- const char *dtype,
- const char *src,
- FILE *fp)
+rcv_dlnwrite(SCR *sp, const char *dtype, const char *src, FILE *fp)
{
char *bp = NULL, *p;
size_t blen = 0;
@@ -901,9 +871,7 @@ alloc_err:
* Read an X-vi-data line and decode it.
*/
static int
-rcv_dlnread(
- SCR *sp,
- char **dtypep,
+rcv_dlnread(SCR *sp, char **dtypep,
char **datap, /* free *datap if != NULL after use. */
FILE *fp)
{
@@ -948,7 +916,7 @@ rcv_dlnread(
len -= src - bp;
/* Memory looks like: "<data>\0<dtype>\0". */
- MALLOC(sp, data, char *, dlen + len / 4 * 3 + 2);
+ MALLOC(sp, data, dlen + len / 4 * 3 + 2);
if (data == NULL)
goto err;
if ((xlen = (b64_pton(p + dlen + 1,
diff --git a/common/screen.c b/common/screen.c
index ae6fb207567f..0d0da0a56def 100644
--- a/common/screen.c
+++ b/common/screen.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: screen.c,v 10.25 2011/12/04 04:06:45 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -35,16 +31,13 @@ static const char sccsid[] = "$Id: screen.c,v 10.25 2011/12/04 04:06:45 zy Exp $
* PUBLIC: int screen_init(GS *, SCR *, SCR **);
*/
int
-screen_init(
- GS *gp,
- SCR *orig,
- SCR **spp)
+screen_init(GS *gp, SCR *orig, SCR **spp)
{
SCR *sp;
size_t len;
*spp = NULL;
- CALLOC_RET(orig, sp, SCR *, 1, sizeof(SCR));
+ CALLOC_RET(orig, sp, 1, sizeof(SCR));
*spp = sp;
/* INITIALIZED AT SCREEN CREATE. */
@@ -94,7 +87,7 @@ screen_init(
sp->repl_len = orig->repl_len;
if (orig->newl_len) {
len = orig->newl_len * sizeof(size_t);
- MALLOC(sp, sp->newl, size_t *, len);
+ MALLOC(sp, sp->newl, len);
if (sp->newl == NULL) {
mem: msgq(orig, M_SYSERR, NULL);
goto err;
@@ -172,22 +165,17 @@ screen_end(SCR *sp)
text_lfree(sp->tiq);
/* Free alternate file name. */
- if (sp->alt_name != NULL)
- free(sp->alt_name);
+ free(sp->alt_name);
/* Free up search information. */
- if (sp->re != NULL)
- free(sp->re);
+ free(sp->re);
if (F_ISSET(sp, SC_RE_SEARCH))
regfree(&sp->re_c);
- if (sp->subre != NULL)
- free(sp->subre);
+ free(sp->subre);
if (F_ISSET(sp, SC_RE_SUBST))
regfree(&sp->subre_c);
- if (sp->repl != NULL)
- free(sp->repl);
- if (sp->newl != NULL)
- free(sp->newl);
+ free(sp->repl);
+ free(sp->newl);
/* Free the iconv environment */
conv_end(sp);
diff --git a/common/screen.h b/common/screen.h
index a762706834dd..94512a7c0cfb 100644
--- a/common/screen.h
+++ b/common/screen.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: screen.h,v 10.26 2011/12/12 22:31:36 zy Exp $
*/
/*
diff --git a/common/search.c b/common/search.c
index 4831a0874aae..e8dcac431f51 100644
--- a/common/search.c
+++ b/common/search.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: search.c,v 10.27 2015/03/13 18:41:35 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -38,13 +34,8 @@ static int search_init(SCR *, dir_t, CHAR_T *, size_t, CHAR_T **, u_int);
* Set up a search.
*/
static int
-search_init(
- SCR *sp,
- dir_t dir,
- CHAR_T *ptrn,
- size_t plen,
- CHAR_T **epp,
- u_int flags)
+search_init(SCR *sp, dir_t dir, CHAR_T *ptrn, size_t plen, CHAR_T **epp,
+ u_int flags)
{
recno_t lno;
int delim;
@@ -146,14 +137,8 @@ prev: if (sp->re == NULL) {
* PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int);
*/
int
-f_search(
- SCR *sp,
- MARK *fm,
- MARK *rm,
- CHAR_T *ptrn,
- size_t plen,
- CHAR_T **eptrn,
- u_int flags)
+f_search(SCR *sp, MARK *fm, MARK *rm, CHAR_T *ptrn, size_t plen,
+ CHAR_T **eptrn, u_int flags)
{
busy_t btype;
recno_t lno;
@@ -293,14 +278,8 @@ f_search(
* PUBLIC: MARK *, MARK *, CHAR_T *, size_t, CHAR_T **, u_int);
*/
int
-b_search(
- SCR *sp,
- MARK *fm,
- MARK *rm,
- CHAR_T *ptrn,
- size_t plen,
- CHAR_T **eptrn,
- u_int flags)
+b_search(SCR *sp, MARK *fm, MARK *rm, CHAR_T *ptrn, size_t plen,
+ CHAR_T **eptrn, u_int flags)
{
busy_t btype;
recno_t lno;
@@ -454,9 +433,7 @@ err: if (LF_ISSET(SEARCH_MSG))
* Display one of the search messages.
*/
static void
-search_msg(
- SCR *sp,
- smsg_t msg)
+search_msg(SCR *sp, smsg_t msg)
{
switch (msg) {
case S_EMPTY:
@@ -491,9 +468,7 @@ search_msg(
* PUBLIC: void search_busy(SCR *, busy_t);
*/
void
-search_busy(
- SCR *sp,
- busy_t btype)
+search_busy(SCR *sp, busy_t btype)
{
sp->gp->scr_busy(sp, "078|Searching...", btype);
}
diff --git a/common/seq.c b/common/seq.c
index 61c7fcd0b285..87bc051e1af9 100644
--- a/common/seq.c
+++ b/common/seq.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: seq.c,v 10.18 2011/12/11 23:13:00 zy Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/time.h>
@@ -35,16 +31,8 @@ static const char sccsid[] = "$Id: seq.c,v 10.18 2011/12/11 23:13:00 zy Exp $";
* PUBLIC: size_t, CHAR_T *, size_t, CHAR_T *, size_t, seq_t, int);
*/
int
-seq_set(
- SCR *sp,
- CHAR_T *name,
- size_t nlen,
- CHAR_T *input,
- size_t ilen,
- CHAR_T *output,
- size_t olen,
- seq_t stype,
- int flags)
+seq_set(SCR *sp, CHAR_T *name, size_t nlen, CHAR_T *input, size_t ilen,
+ CHAR_T *output, size_t olen, seq_t stype, int flags)
{
CHAR_T *p;
SEQ *lastqp, *qp;
@@ -68,15 +56,14 @@ seq_set(
sv_errno = errno;
goto mem1;
}
- if (qp->output != NULL)
- free(qp->output);
+ free(qp->output);
qp->olen = olen;
qp->output = p;
return (0);
}
/* Allocate and initialize SEQ structure. */
- CALLOC(sp, qp, SEQ *, 1, sizeof(SEQ));
+ CALLOC(sp, qp, 1, sizeof(SEQ));
if (qp == NULL) {
sv_errno = errno;
goto mem1;
@@ -105,8 +92,7 @@ seq_set(
} else if ((qp->output = v_wstrdup(sp, output, olen)) == NULL) {
sv_errno = errno;
free(qp->input);
-mem3: if (qp->name != NULL)
- free(qp->name);
+mem3: free(qp->name);
mem2: free(qp);
mem1: errno = sv_errno;
msgq(sp, M_SYSERR, NULL);
@@ -139,11 +125,7 @@ mem1: errno = sv_errno;
* PUBLIC: int seq_delete(SCR *, CHAR_T *, size_t, seq_t);
*/
int
-seq_delete(
- SCR *sp,
- CHAR_T *input,
- size_t ilen,
- seq_t stype)
+seq_delete(SCR *sp, CHAR_T *input, size_t ilen, seq_t stype)
{
SEQ *qp, *pre_qp = NULL;
int diff;
@@ -177,12 +159,9 @@ seq_delete(
int
seq_free(SEQ *qp)
{
- if (qp->name != NULL)
- free(qp->name);
- if (qp->input != NULL)
- free(qp->input);
- if (qp->output != NULL)
- free(qp->output);
+ free(qp->name);
+ free(qp->input);
+ free(qp->output);
free(qp);
return (0);
}
@@ -196,14 +175,8 @@ seq_free(SEQ *qp)
* PUBLIC: (SCR *, SEQ **, EVENT *, CHAR_T *, size_t, seq_t, int *);
*/
SEQ *
-seq_find(
- SCR *sp,
- SEQ **lastqp,
- EVENT *e_input,
- CHAR_T *c_input,
- size_t ilen,
- seq_t stype,
- int *ispartialp)
+seq_find(SCR *sp, SEQ **lastqp, EVENT *e_input, CHAR_T *c_input, size_t ilen,
+ seq_t stype, int *ispartialp)
{
SEQ *lqp = NULL, *qp;
int diff;
@@ -298,10 +271,7 @@ seq_close(GS *gp)
* PUBLIC: int seq_dump(SCR *, seq_t, int);
*/
int
-seq_dump(
- SCR *sp,
- seq_t stype,
- int isname)
+seq_dump(SCR *sp, seq_t stype, int isname)
{
CHAR_T *p;
GS *gp;
@@ -346,11 +316,7 @@ seq_dump(
* PUBLIC: int seq_save(SCR *, FILE *, char *, seq_t);
*/
int
-seq_save(
- SCR *sp,
- FILE *fp,
- char *prefix,
- seq_t stype)
+seq_save(SCR *sp, FILE *fp, char *prefix, seq_t stype)
{
CHAR_T *p;
SEQ *qp;
@@ -392,10 +358,7 @@ seq_save(
* PUBLIC: int e_memcmp(CHAR_T *, EVENT *, size_t);
*/
int
-e_memcmp(
- CHAR_T *p1,
- EVENT *ep,
- size_t n)
+e_memcmp(CHAR_T *p1, EVENT *ep, size_t n)
{
if (n != 0) {
do {
diff --git a/common/seq.h b/common/seq.h
index 2c5ae576e3ee..514d5500b652 100644
--- a/common/seq.h
+++ b/common/seq.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: seq.h,v 10.4 2011/12/11 21:43:39 zy Exp $
*/
/*
diff --git a/common/util.c b/common/util.c
index 44c8e29482e6..1e87c6293550 100644
--- a/common/util.c
+++ b/common/util.c
@@ -9,10 +9,6 @@
#include "config.h"
-#ifndef lint
-static const char sccsid[] = "$Id: util.c,v 10.30 2013/03/19 10:00:27 yamt Exp $";
-#endif /* not lint */
-
#include <sys/types.h>
#include <sys/queue.h>
@@ -42,11 +38,8 @@ static const char sccsid[] = "$Id: util.c,v 10.30 2013/03/19 10:00:27 yamt Exp $
* PUBLIC: void *binc(SCR *, void *, size_t *, size_t);
*/
void *
-binc(
- SCR *sp, /* sp MAY BE NULL!!! */
- void *bp,
- size_t *bsizep,
- size_t min)
+binc(SCR *sp, /* sp MAY BE NULL!!! */
+ void *bp, size_t *bsizep, size_t min)
{
size_t csize;
@@ -79,10 +72,7 @@ binc(
* PUBLIC: int nonblank(SCR *, recno_t, size_t *);
*/
int
-nonblank(
- SCR *sp,
- recno_t lno,
- size_t *cnop)
+nonblank(SCR *sp, recno_t lno, size_t *cnop)
{
CHAR_T *p;
size_t cnt, len, off;
@@ -109,31 +99,13 @@ nonblank(
}
/*
- * tail --
- * Return tail of a path.
- *
- * PUBLIC: char *tail(char *);
- */
-char *
-tail(char *path)
-{
- char *p;
-
- if ((p = strrchr(path, '/')) == NULL)
- return (path);
- return (p + 1);
-}
-
-/*
* join --
* Join two paths; need free.
*
* PUBLIC: char *join(char *, char *);
*/
char *
-join(
- char *path1,
- char *path2)
+join(char *path1, char *path2)
{
char *p;
@@ -212,8 +184,8 @@ quote(char *str)
n++;
if (unsafe)
continue;
- if (isascii(*p)) {
- if (isalnum(*p))
+ if (isascii((u_char)*p)) {
+ if (isalnum((u_char)*p))
continue;
switch (*p) {
case '%': case '+': case ',': case '-': case '.':
@@ -248,14 +220,11 @@ quote(char *str)
* PUBLIC: char *v_strdup(SCR *, const char *, size_t);
*/
char *
-v_strdup(
- SCR *sp,
- const char *str,
- size_t len)
+v_strdup(SCR *sp, const char *str, size_t len)
{
char *copy;
- MALLOC(sp, copy, char *, len + 1);
+ MALLOC(sp, copy, len + 1);
if (copy == NULL)
return (NULL);
memcpy(copy, str, len);
@@ -270,13 +239,11 @@ v_strdup(
* PUBLIC: CHAR_T *v_wstrdup(SCR *, const CHAR_T *, size_t);
*/
CHAR_T *
-v_wstrdup(SCR *sp,
- const CHAR_T *str,
- size_t len)
+v_wstrdup(SCR *sp, const CHAR_T *str, size_t len)
{
CHAR_T *copy;
- MALLOC(sp, copy, CHAR_T *, (len + 1) * sizeof(CHAR_T));
+ MALLOC(sp, copy, (len + 1) * sizeof(CHAR_T));
if (copy == NULL)
return (NULL);
MEMCPY(copy, str, len);
@@ -291,11 +258,7 @@ v_wstrdup(SCR *sp,
* PUBLIC: enum nresult nget_uslong(u_long *, const CHAR_T *, CHAR_T **, int);
*/
enum nresult
-nget_uslong(
- u_long *valp,
- const CHAR_T *p,
- CHAR_T **endp,
- int base)
+nget_uslong(u_long *valp, const CHAR_T *p, CHAR_T **endp, int base)
{
errno = 0;
*valp = STRTOUL(p, endp, base);
@@ -313,11 +276,7 @@ nget_uslong(
* PUBLIC: enum nresult nget_slong(long *, const CHAR_T *, CHAR_T **, int);
*/
enum nresult
-nget_slong(
- long *valp,
- const CHAR_T *p,
- CHAR_T **endp,
- int base)
+nget_slong(long *valp, const CHAR_T *p, CHAR_T **endp, int base)
{
errno = 0;
*valp = STRTOL(p, endp, base);
@@ -339,8 +298,7 @@ nget_slong(
* PUBLIC: void timepoint_steady(struct timespec *);
*/
void
-timepoint_steady(
- struct timespec *ts)
+timepoint_steady(struct timespec *ts)
{
#ifdef __APPLE__
static mach_timebase_info_data_t base = { 0 };
@@ -370,8 +328,7 @@ timepoint_steady(
* PUBLIC: void timepoint_system(struct timespec *);
*/
void
-timepoint_system(
- struct timespec *ts)
+timepoint_system(struct timespec *ts)
{
#ifdef __APPLE__
clock_serv_t clk;
@@ -404,10 +361,7 @@ timepoint_system(
* PUBLIC: void TRACE(SCR *, const char *, ...);
*/
void
-TRACE(
- SCR *sp,
- const char *fmt,
- ...)
+TRACE(SCR *sp, const char *fmt, ...)
{
FILE *tfp;
va_list ap;
diff --git a/common/util.h b/common/util.h
index e6b2bec94e15..46fa4a17bc0f 100644
--- a/common/util.h
+++ b/common/util.h
@@ -5,8 +5,6 @@
* Keith Bostic. All rights reserved.
*
* See the LICENSE file for redistribution information.
- *
- * $Id: util.h,v 10.7 2013/02/24 21:00:10 zy Exp $
*/
/* Macros to init/set/clear/test flags. */