commit: 4418d329ddcd8655e63b2b4cc5cb12b173d05c92
parent: 5ce539cb503ec38cd7f198c00a27744d12da75b4
author: Chris Noxz <chris@noxz.tech>
date: Tue, 9 Mar 2021 19:06:01 +0100
Match upstream 6.6
21 files changed, 98 insertions(+), 88 deletions(-)
diff --git a/Makefile b/Makefile
@@ -12,6 +12,7 @@ DOC_DIR ?= $(PREFIX)/share/doc/loksh
NCURSES_CFLAGS = $(shell pkg-config --cflags ncursesw)
NCURSES_LDFLAGS = $(shell pkg-config --libs ncursesw)
+
OBJECTS = alloc.o c_ksh.o c_sh.o c_test.o c_ulimit.o edit.o emacs.o eval.o \
exec.o expr.o history.o io.o jobs.o lex.o mail.o main.o misc.o \
path.o shf.o syn.o table.o trap.o tree.o tty.o var.o version.o vi.o \
diff --git a/c_ksh.c b/c_ksh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ksh.c,v 1.61 2018/05/18 13:25:20 benno Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.62 2019/06/28 13:34:59 deraadt Exp $ */
/*
* built-in Korn commands: c_*
@@ -114,9 +114,9 @@ c_cd(char **wp)
simplify_path(Xstring(xs, xp));
rval = chdir(try = Xstring(xs, xp));
}
- } while (rval < 0 && cdpath != NULL);
+ } while (rval == -1 && cdpath != NULL);
- if (rval < 0) {
+ if (rval == -1) {
if (cdnode)
bi_errorf("%s: bad directory", dir);
else
@@ -186,7 +186,7 @@ c_pwd(char **wp)
}
p = current_wd[0] ? (physical ? get_phys_path(current_wd) : current_wd) :
NULL;
- if (p && access(p, R_OK) < 0)
+ if (p && access(p, R_OK) == -1)
p = NULL;
if (!p) {
freep = p = ksh_get_wd(NULL, 0);
@@ -374,7 +374,7 @@ c_print(char **wp)
}
for (s = Xstring(xs, xp); len > 0; ) {
n = write(fd, s, len);
- if (n < 0) {
+ if (n == -1) {
if (flags & PO_COPROC)
restore_pipe(opipe);
if (errno == EINTR) {
@@ -1245,7 +1245,7 @@ c_kill(char **wp)
/* use killpg if < -1 since -1 does special things for
* some non-killpg-endowed kills
*/
- if ((n < -1 ? killpg(-n, sig) : kill(n, sig)) < 0) {
+ if ((n < -1 ? killpg(-n, sig) : kill(n, sig)) == -1) {
bi_errorf("%s: %s", p, strerror(errno));
rv = 1;
}
diff --git a/c_test.c b/c_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_test.c,v 1.25 2018/04/09 17:53:36 tobias Exp $ */
+/* $OpenBSD: c_test.c,v 1.27 2019/06/28 13:34:59 deraadt Exp $ */
/*
* test(1); version 7-like -- author Erik Baalbergen
@@ -32,8 +32,7 @@
"-L"|"-h"|"-S"|"-H";
binary-operator ::= "="|"=="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
- "-nt"|"-ot"|"-ef"|
- "<"|">" # rules used for [[ .. ]] expressions
+ "-nt"|"-ot"|"-ef"|"<"|">"
;
operand ::= <any thing>
*/
@@ -195,9 +194,7 @@ test_isop(Test_env *te, Test_meta meta, const char *s)
sc1 = s[1];
for (; otab->op_text[0]; otab++)
if (sc1 == otab->op_text[1] &&
- strcmp(s, otab->op_text) == 0 &&
- ((te->flags & TEF_DBRACKET) ||
- (otab->op_num != TO_STLT && otab->op_num != TO_STGT)))
+ strcmp(s, otab->op_text) == 0)
return otab->op_num;
}
return TO_NONOP;
@@ -374,7 +371,7 @@ test_eaccess(const char *path, int amode)
if (res == 0 && ksheuid == 0 && (amode & X_OK)) {
struct stat statb;
- if (stat(path, &statb) < 0)
+ if (stat(path, &statb) == -1)
res = -1;
else if (S_ISDIR(statb.st_mode))
res = 0;
diff --git a/c_ulimit.c b/c_ulimit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ulimit.c,v 1.28 2018/04/09 17:53:36 tobias Exp $ */
+/* $OpenBSD: c_ulimit.c,v 1.29 2019/06/28 13:34:59 deraadt Exp $ */
/*
ulimit -- handle "ulimit" builtin
@@ -163,7 +163,7 @@ set_ulimit(const struct limits *l, const char *v, int how)
limit.rlim_cur = val;
if (how & HARD)
limit.rlim_max = val;
- if (setrlimit(l->resource, &limit) < 0) {
+ if (setrlimit(l->resource, &limit) == -1) {
if (errno == EPERM)
bi_errorf("-%c exceeds allowable limit", l->option);
else
diff --git a/ci.sh b/ci.sh
@@ -1,12 +1,12 @@
#!/bin/sh -xe
jobs=`nproc`
-CC=gcc-8 make -j$jobs
+make -j$jobs
make DESTDIR=dst install
[ "`./dst/usr/bin/ksh -c 'echo $((1337 * 2))'`" -ne 2674 ] && exit 1
[ "`./dst/usr/bin/ksh -c 'seq 1337 | sort -rn | head -n 1'`" -ne 1337 ] && exit 1
make clean
-CC=clang-8 make -j$jobs
+CC=clang make -j$jobs
if [ "`readlink /proc/$$/exe`" != /tmp/ksh ]
then
diff --git a/edit.c b/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.67 2018/12/30 23:09:58 guenther Exp $ */
+/* $OpenBSD: edit.c,v 1.69 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Command line editing - common code
@@ -66,7 +66,7 @@ check_sigwinch(void)
struct winsize ws;
got_sigwinch = 0;
- if (procpid == kshpid && ioctl(tty_fd, TIOCGWINSZ, &ws) >= 0) {
+ if (procpid == kshpid && ioctl(tty_fd, TIOCGWINSZ, &ws) == 0) {
struct tbl *vp;
/* Do NOT export COLUMNS/LINES. Many applications
@@ -391,7 +391,7 @@ x_file_glob(int flags, const char *str, int slen, char ***wordsp)
* which evaluated to an empty string (e.g.,
* "$FOO" when there is no FOO, etc).
*/
- if ((lstat(words[0], &statb) < 0) ||
+ if ((lstat(words[0], &statb) == -1) ||
words[0][0] == '\0') {
x_free_words(nwords, words);
words = NULL;
@@ -615,12 +615,12 @@ x_try_array(const char *buf, int buflen, const char *want, int wantlen,
}
/* Try to find the array. */
- if (asprintf(&name, "complete_%.*s_%d", cmdlen, cmd, n) < 0)
+ if (asprintf(&name, "complete_%.*s_%d", cmdlen, cmd, n) == -1)
internal_errorf("unable to allocate memory");
v = global(name);
free(name);
if (~v->flag & (ISSET|ARRAY)) {
- if (asprintf(&name, "complete_%.*s", cmdlen, cmd) < 0)
+ if (asprintf(&name, "complete_%.*s", cmdlen, cmd) == -1)
internal_errorf("unable to allocate memory");
v = global(name);
free(name);
diff --git a/eval.c b/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.64 2019/02/20 23:59:17 schwarze Exp $ */
+/* $OpenBSD: eval.c,v 1.65 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -1012,12 +1012,12 @@ globit(XString *xs, /* dest string */
if ((check & GF_EXCHECK) ||
((check & GF_MARKDIR) && (check & GF_GLOBBED))) {
#define stat_check() (stat_done ? stat_done : \
- (stat_done = stat(Xstring(*xs, xp), &statb) < 0 \
+ (stat_done = stat(Xstring(*xs, xp), &statb) == -1 \
? -1 : 1))
struct stat lstatb, statb;
int stat_done = 0; /* -1: failed, 1 ok */
- if (lstat(Xstring(*xs, xp), &lstatb) < 0)
+ if (lstat(Xstring(*xs, xp), &lstatb) == -1)
return;
/* special case for systems which strip trailing
* slashes from regular files (eg, /etc/passwd/).
diff --git a/exec.c b/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.73 2018/03/15 16:51:29 anton Exp $ */
+/* $OpenBSD: exec.c,v 1.74 2019/06/28 13:34:59 deraadt Exp $ */
/*
* execute command tree
@@ -956,10 +956,10 @@ search_access(const char *path, int mode,
int ret, err = 0;
struct stat statb;
- if (stat(path, &statb) < 0)
+ if (stat(path, &statb) == -1)
return -1;
ret = access(path, mode);
- if (ret < 0)
+ if (ret == -1)
err = errno; /* File exists, but we can't access it */
else if (mode == X_OK && (!S_ISREG(statb.st_mode) ||
!(statb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))) {
@@ -1078,7 +1078,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
* things like /dev/null without error.
*/
if (Flag(FNOCLOBBER) && !(iop->flag & IOCLOB) &&
- (stat(cp, &statb) < 0 || S_ISREG(statb.st_mode)))
+ (stat(cp, &statb) == -1 || S_ISREG(statb.st_mode)))
flags |= O_EXCL;
break;
@@ -1197,7 +1197,7 @@ herein(const char *content, int sub)
* doesn't get removed too soon).
*/
h = maketemp(ATEMP, TT_HEREDOC_EXP, &genv->temps);
- if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) < 0) {
+ if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) == -1) {
warningf(true, "can't %s temporary file %s: %s",
!shf ? "create" : "open",
h->name, strerror(errno));
diff --git a/history.c b/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.81 2018/11/20 07:02:23 martijn Exp $ */
+/* $OpenBSD: history.c,v 1.82 2019/06/28 13:34:59 deraadt Exp $ */
/*
* command history
@@ -256,7 +256,7 @@ c_fc(char **wp)
return 1;
}
- n = fstat(shf->fd, &statb) < 0 ? 128 :
+ n = fstat(shf->fd, &statb) == -1 ? 128 :
statb.st_size + 1;
Xinit(xs, xp, n, hist_source->areap);
while ((n = shf_read(xp, Xnleft(xs, xp), shf)) > 0) {
diff --git a/io.c b/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.36 2018/01/16 22:52:32 jca Exp $ */
+/* $OpenBSD: io.c,v 1.38 2019/07/24 14:33:16 bcallah Exp $ */
/*
* shell buffered IO and formatted output
@@ -244,7 +244,7 @@ ksh_dup2(int ofd, int nfd, int errok)
{
int ret = dup2(ofd, nfd);
- if (ret < 0 && errno != EBADF && !errok)
+ if (ret == -1 && errno != EBADF && !errok)
errorf("too many files open in shell");
return ret;
@@ -261,7 +261,7 @@ savefd(int fd)
if (fd < FDBASE) {
nfd = fcntl(fd, F_DUPFD_CLOEXEC, FDBASE);
- if (nfd < 0) {
+ if (nfd == -1) {
if (errno == EBADF)
return -1;
else
@@ -292,7 +292,7 @@ openpipe(int *pv)
{
int lpv[2];
- if (pipe(lpv) < 0)
+ if (pipe(lpv) == -1)
errorf("can't create pipe - try again");
pv[0] = savefd(lpv[0]);
if (pv[0] != lpv[0])
@@ -319,7 +319,7 @@ check_fd(char *name, int mode, const char **emsgp)
if (isdigit((unsigned char)name[0]) && !name[1]) {
fd = name[0] - '0';
- if ((fl = fcntl(fd, F_GETFL)) < 0) {
+ if ((fl = fcntl(fd, F_GETFL)) == -1) {
if (emsgp)
*emsgp = "bad file descriptor";
return -1;
diff --git a/jobs.c b/jobs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jobs.c,v 1.60 2018/03/15 16:51:29 anton Exp $ */
+/* $OpenBSD: jobs.c,v 1.61 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Process and job control
@@ -272,7 +272,7 @@ j_change(void)
while (1) {
pid_t ttypgrp;
- if ((ttypgrp = tcgetpgrp(tty_fd)) < 0) {
+ if ((ttypgrp = tcgetpgrp(tty_fd)) == -1) {
warningf(false,
"%s: tcgetpgrp() failed: %s",
__func__, strerror(errno));
@@ -288,12 +288,12 @@ j_change(void)
setsig(&sigtraps[tt_sigs[i]], SIG_IGN,
SS_RESTORE_DFL|SS_FORCE);
if (ttypgrp_ok && our_pgrp != kshpid) {
- if (setpgid(0, kshpid) < 0) {
+ if (setpgid(0, kshpid) == -1) {
warningf(false, "%s: setpgid() failed: %s",
__func__, strerror(errno));
ttypgrp_ok = 0;
} else {
- if (tcsetpgrp(tty_fd, kshpid) < 0) {
+ if (tcsetpgrp(tty_fd, kshpid) == -1) {
warningf(false,
"%s: tcsetpgrp() failed: %s",
__func__, strerror(errno));
@@ -392,13 +392,13 @@ exchild(struct op *t, int flags, volatile int *xerrok,
/* create child process */
forksleep = 1;
- while ((i = fork()) < 0 && errno == EAGAIN && forksleep < 32) {
+ while ((i = fork()) == -1 && errno == EAGAIN && forksleep < 32) {
if (intrsig) /* allow user to ^C out... */
break;
sleep(forksleep);
forksleep <<= 1;
}
- if (i < 0) {
+ if (i == -1) {
kill_job(j, SIGKILL);
remove_job(j, "fork failed");
sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -629,7 +629,7 @@ j_kill(const char *cp, int sig)
} else {
if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP))
(void) killpg(j->pgrp, SIGCONT);
- if (killpg(j->pgrp, sig) < 0) {
+ if (killpg(j->pgrp, sig) == -1) {
bi_errorf("%s: %s", cp, strerror(errno));
rv = 1;
}
@@ -693,7 +693,7 @@ j_resume(const char *cp, int bg)
/* See comment in j_waitj regarding saved_ttypgrp. */
if (ttypgrp_ok &&
tcsetpgrp(tty_fd, (j->flags & JF_SAVEDTTYPGRP) ?
- j->saved_ttypgrp : j->pgrp) < 0) {
+ j->saved_ttypgrp : j->pgrp) == -1) {
if (j->flags & JF_SAVEDTTY)
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
sigprocmask(SIG_SETMASK, &omask, NULL);
@@ -711,14 +711,14 @@ j_resume(const char *cp, int bg)
async_job = NULL;
}
- if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) < 0) {
+ if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) == -1) {
int err = errno;
if (!bg) {
j->flags &= ~JF_FG;
if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
- if (ttypgrp_ok && tcsetpgrp(tty_fd, our_pgrp) < 0) {
+ if (ttypgrp_ok && tcsetpgrp(tty_fd, our_pgrp) == -1) {
warningf(true,
"fg: 2nd tcsetpgrp(%d, %d) failed: %s",
tty_fd, (int) our_pgrp,
@@ -984,7 +984,7 @@ j_waitj(Job *j,
if (j->state == PSTOPPED &&
(j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0)
j->flags |= JF_SAVEDTTYPGRP;
- if (tcsetpgrp(tty_fd, our_pgrp) < 0) {
+ if (tcsetpgrp(tty_fd, our_pgrp) == -1) {
warningf(true,
"%s: tcsetpgrp(%d, %d) failed: %s",
__func__, tty_fd, (int)our_pgrp,
@@ -1569,7 +1569,7 @@ kill_job(Job *j, int sig)
for (p = j->proc_list; p != NULL; p = p->next)
if (p->pid != 0)
- if (kill(p->pid, sig) < 0)
+ if (kill(p->pid, sig) == -1)
rval = -1;
return rval;
}
diff --git a/ksh.1 b/ksh.1
@@ -1,8 +1,8 @@
-.\" $OpenBSD: ksh.1,v 1.203 2019/04/03 14:55:12 jca Exp $
+.\" $OpenBSD: ksh.1,v 1.207 2019/06/24 15:05:17 jca Exp $
.\"
.\" Public Domain
.\"
-.Dd $Mdocdate: April 3 2019 $
+.Dd $Mdocdate: June 24 2019 $
.Dt KSH 1
.Os
.Sh NAME
@@ -750,12 +750,13 @@ expressions are patterns (e.g. the comparison
.Ic [[ foobar = f*r ]]
succeeds).
.It
-There are two additional binary operators,
+The
.Ql <
and
-.Ql > ,
-which return true if their first string operand is less than, or greater than,
-their second string operand, respectively.
+.Ql >
+binary operators do not need to be quoted with the
+.Ql \e
+character.
.It
The single argument form of
.Ic test ,
@@ -3890,6 +3891,10 @@ Strings are equal.
Strings are equal.
.It Ar string No != Ar string
Strings are not equal.
+.It Ar string No > Ar string
+Strings compare greater than based on the ASCII value of their characters.
+.It Ar string No < Ar string
+Strings compare less than based on the ASCII value of their characters.
.It Ar number Fl eq Ar number
Numbers compare equal.
.It Ar number Fl ne Ar number
@@ -5540,10 +5545,12 @@ Privileged shell profile.
.Rs
.%A Morris Bolsky
.%A David Korn
-.%B The KornShell Command and Programming Language, 2nd Edition
-.%D 1995
+.%B The KornShell Command and Programming Language
+.%D First Edition 1989
.%I Prentice Hall
-.%O ISBN 0131827006
+.%O ISBN 0135169720
+.\" The second edition of the above book (1995) is about ksh93,
+.\" but the OpenBSD ksh is a descendant from ksh88 via pdksh.
.Re
.Rs
.%A Stephen G. Kochan
diff --git a/main.c b/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.97 2019/02/20 23:59:17 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.98 2019/06/28 13:34:59 deraadt Exp $ */
/*
* startup, main loop, environments and error handling
@@ -270,7 +270,7 @@ main(int argc, char *argv[])
/* Try to use existing $PWD if it is valid */
if (pwd[0] != '/' ||
- stat(pwd, &s_pwd) < 0 || stat(".", &s_dot) < 0 ||
+ stat(pwd, &s_pwd) == -1 || stat(".", &s_dot) == -1 ||
s_pwd.st_dev != s_dot.st_dev ||
s_pwd.st_ino != s_dot.st_ino)
pwdx = NULL;
diff --git a/misc.c b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.72 2018/11/20 08:12:26 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.73 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Miscellaneous functions
@@ -1084,7 +1084,7 @@ blocking_read(int fd, char *buf, int nbytes)
int ret;
int tried_reset = 0;
- while ((ret = read(fd, buf, nbytes)) < 0) {
+ while ((ret = read(fd, buf, nbytes)) == -1) {
if (!tried_reset && errno == EAGAIN) {
int oerrno = errno;
if (reset_nonblock(fd) > 0) {
@@ -1107,12 +1107,12 @@ reset_nonblock(int fd)
{
int flags;
- if ((flags = fcntl(fd, F_GETFL)) < 0)
+ if ((flags = fcntl(fd, F_GETFL)) == -1)
return -1;
if (!(flags & O_NONBLOCK))
return 0;
flags &= ~O_NONBLOCK;
- if (fcntl(fd, F_SETFL, flags) < 0)
+ if (fcntl(fd, F_SETFL, flags) == -1)
return -1;
return 1;
}
diff --git a/path.c b/path.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: path.c,v 1.22 2018/01/06 16:28:58 millert Exp $ */
+/* $OpenBSD: path.c,v 1.23 2019/06/28 13:34:59 deraadt Exp $ */
#include <sys/stat.h>
@@ -248,7 +248,7 @@ do_phys_path(XString *xsp, char *xp, const char *path)
*xp = '\0';
llen = readlink(Xstring(*xsp, xp), lbuf, sizeof(lbuf) - 1);
- if (llen < 0) {
+ if (llen == -1) {
/* EINVAL means it wasn't a symlink... */
if (errno != EINVAL)
return NULL;
diff --git a/sh.1 b/sh.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sh.1,v 1.151 2018/12/16 13:08:35 schwarze Exp $
+.\" $OpenBSD: sh.1,v 1.152 2019/05/22 15:23:23 schwarze Exp $
.\"
.\" Copyright (c) 2015 Jason McIntyre <jmc@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 16 2018 $
+.Dd $Mdocdate: May 22 2019 $
.Dt SH 1
.Os
.Sh NAME
@@ -866,7 +866,11 @@ it keeps a record of commands run in a
either internally in memory or in a file,
as determined by
.Dv HISTFILE .
-The command line and all the commands in command history
+When
+.Cm vi
+command line editing mode is enabled
+.Pq set -o vi ,
+the command line and all the commands in command history
can be edited using commands similar to those of
.Xr vi 1 .
.Pp
diff --git a/shf.c b/shf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shf.c,v 1.33 2018/03/15 16:51:29 anton Exp $ */
+/* $OpenBSD: shf.c,v 1.34 2019/06/28 13:34:59 deraadt Exp $ */
/*
* Shell file I/O routines
@@ -49,7 +49,7 @@ shf_open(const char *name, int oflags, int mode, int sflags)
/* Rest filled in by reopen. */
fd = open(name, oflags, mode);
- if (fd < 0) {
+ if (fd == -1) {
afree(shf, shf->areap);
return NULL;
}
@@ -58,7 +58,7 @@ shf_open(const char *name, int oflags, int mode, int sflags)
nfd = fcntl(fd, F_DUPFD, FDBASE);
close(fd);
- if (nfd < 0) {
+ if (nfd == -1) {
afree(shf, shf->areap);
return NULL;
}
@@ -81,7 +81,7 @@ shf_fdopen(int fd, int sflags, struct shf *shf)
if (sflags & SHF_GETFL) {
int flags = fcntl(fd, F_GETFL);
- if (flags < 0)
+ if (flags == -1)
/* will get an error on first read/write */
sflags |= SHF_RDWR;
else {
@@ -138,7 +138,7 @@ shf_reopen(int fd, int sflags, struct shf *shf)
if (sflags & SHF_GETFL) {
int flags = fcntl(fd, F_GETFL);
- if (flags < 0)
+ if (flags == -1)
/* will get an error on first read/write */
sflags |= SHF_RDWR;
else {
@@ -223,7 +223,7 @@ shf_close(struct shf *shf)
if (shf->fd >= 0) {
ret = shf_flush(shf);
- if (close(shf->fd) < 0)
+ if (close(shf->fd) == -1)
ret = EOF;
}
if (shf->flags & SHF_ALLOCS)
@@ -242,7 +242,7 @@ shf_fdclose(struct shf *shf)
if (shf->fd >= 0) {
ret = shf_flush(shf);
- if (close(shf->fd) < 0)
+ if (close(shf->fd) == -1)
ret = EOF;
shf->rnleft = 0;
shf->rp = shf->buf;
@@ -350,7 +350,7 @@ shf_emptybuf(struct shf *shf, int flags)
while (ntowrite > 0) {
n = write(shf->fd, buf, ntowrite);
- if (n < 0) {
+ if (n == -1) {
if (errno == EINTR &&
!(shf->flags & SHF_INTERRUPT))
continue;
@@ -574,7 +574,7 @@ shf_putchar(int c, struct shf *shf)
return EOF;
}
while ((n = write(shf->fd, &cc, 1)) != 1)
- if (n < 0) {
+ if (n == -1) {
if (errno == EINTR &&
!(shf->flags & SHF_INTERRUPT))
continue;
@@ -641,7 +641,7 @@ shf_write(const char *buf, int nbytes, struct shf *shf)
nbytes -= ncopy;
while (ncopy > 0) {
n = write(shf->fd, buf, ncopy);
- if (n < 0) {
+ if (n == -1) {
if (errno == EINTR &&
!(shf->flags & SHF_INTERRUPT))
continue;
diff --git a/stdlib.h b/stdlib.h
@@ -3,7 +3,7 @@
#include_next <stdlib.h>
-/* $OpenBSD: stdlib.h,v 1.75 2018/11/21 06:57:04 otto Exp $ */
+/* $OpenBSD: stdlib.h,v 1.76 2019/05/10 15:03:24 otto Exp $ */
/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
/*-
diff --git a/sys/time.h b/sys/time.h
@@ -1,7 +1,4 @@
-#ifndef _COMPAT_SYS_TIME_H_
-#define _COMPAT_SYS_TIME_H_
-
-/* $OpenBSD: time.h,v 1.40 2019/01/19 01:53:44 cheloha Exp $ */
+/* $OpenBSD: time.h,v 1.46 2019/08/03 22:53:45 cheloha Exp $ */
/* $NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $ */
/*
@@ -35,6 +32,9 @@
* @(#)time.h 8.2 (Berkeley) 7/10/94
*/
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
/* Operations on timevals. */
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
@@ -76,4 +76,4 @@
} \
} while (0)
-#endif
+#endif /* !_SYS_TIME_H_ */
diff --git a/tty.c b/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.17 2018/03/15 16:51:29 anton Exp $ */
+/* $OpenBSD: tty.c,v 1.18 2019/06/28 13:34:59 deraadt Exp $ */
#include <errno.h>
#include <fcntl.h>
@@ -34,7 +34,7 @@ tty_init(int init_ttystate)
tty_devtty = 1;
tfd = open("/dev/tty", O_RDWR, 0);
- if (tfd < 0) {
+ if (tfd == -1) {
tty_devtty = 0;
warningf(false, "No controlling tty (open /dev/tty: %s)",
strerror(errno));
@@ -49,7 +49,7 @@ tty_init(int init_ttystate)
return;
}
}
- if ((tty_fd = fcntl(tfd, F_DUPFD_CLOEXEC, FDBASE)) < 0) {
+ if ((tty_fd = fcntl(tfd, F_DUPFD_CLOEXEC, FDBASE)) == -1) {
warningf(false, "%s: dup of tty fd failed: %s",
__func__, strerror(errno));
} else if (init_ttystate)
diff --git a/unvis.c b/unvis.c
@@ -282,3 +282,4 @@ strnunvis(char *dst, const char *src, size_t sz)
*dst = '\0';
return (dst - start);
}
+