summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorKevin Lo <kevlo@cvs.openbsd.org>2010-08-12 02:00:29 +0000
committerKevin Lo <kevlo@cvs.openbsd.org>2010-08-12 02:00:29 +0000
commit9628420868d694a31d68092cb5ef07b851f22f74 (patch)
tree6451f1e7a1ae68577d25fa714b2f225f316e95d9 /bin
parent3dbd24ec174919c1882f89080e45778a13605c23 (diff)
Use symbolic names for the file descriptors rather than numeric values.
Some from damien@, millert@ ok phessler@, millert@
Diffstat (limited to 'bin')
-rw-r--r--bin/csh/dol.c13
-rw-r--r--bin/csh/sem.c10
-rw-r--r--bin/ed/main.c8
3 files changed, 16 insertions, 15 deletions
diff --git a/bin/csh/dol.c b/bin/csh/dol.c
index fcb4819c997..864a7906657 100644
--- a/bin/csh/dol.c
+++ b/bin/csh/dol.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dol.c,v 1.16 2009/10/27 23:59:21 deraadt Exp $ */
+/* $OpenBSD: dol.c,v 1.17 2010/08/12 02:00:27 kevlo Exp $ */
/* $NetBSD: dol.c,v 1.8 1995/09/27 00:38:38 jtc Exp $ */
/*-
@@ -862,8 +862,9 @@ heredoc(Char *term)
* Check for EOF or compare to terminator -- before expansion
*/
if (c < 0 || eq(lbuf, term)) {
- (void) write(0, short2str(obuf), (size_t) (BUFSIZ - ocnt));
- (void) lseek(0, (off_t) 0, SEEK_SET);
+ (void) write(STDIN_FILENO, short2str(obuf),
+ (size_t) (BUFSIZ - ocnt));
+ (void) lseek(STDIN_FILENO, (off_t) 0, SEEK_SET);
return;
}
@@ -876,7 +877,7 @@ heredoc(Char *term)
for (lbp = lbuf; (c = *lbp++) != '\0';) {
*obp++ = c;
if (--ocnt == 0) {
- (void) write(0, short2str(obuf), BUFSIZ);
+ (void) write(STDIN_FILENO, short2str(obuf), BUFSIZ);
obp = obuf;
ocnt = BUFSIZ;
}
@@ -940,14 +941,14 @@ heredoc(Char *term)
for (mbp = *vp; *mbp; mbp++) {
*obp++ = *mbp & TRIM;
if (--ocnt == 0) {
- (void) write(0, short2str(obuf), BUFSIZ);
+ (void) write(STDIN_FILENO, short2str(obuf), BUFSIZ);
obp = obuf;
ocnt = BUFSIZ;
}
}
*obp++ = '\n';
if (--ocnt == 0) {
- (void) write(0, short2str(obuf), BUFSIZ);
+ (void) write(STDIN_FILENO, short2str(obuf), BUFSIZ);
obp = obuf;
ocnt = BUFSIZ;
}
diff --git a/bin/csh/sem.c b/bin/csh/sem.c
index c4d0255dadc..3d4d0428ffe 100644
--- a/bin/csh/sem.c
+++ b/bin/csh/sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sem.c,v 1.16 2009/10/27 23:59:21 deraadt Exp $ */
+/* $OpenBSD: sem.c,v 1.17 2010/08/12 02:00:27 kevlo Exp $ */
/* $NetBSD: sem.c,v 1.9 1995/09/27 00:38:50 jtc Exp $ */
/*-
@@ -546,7 +546,7 @@ doio(struct command *t, int *pipein, int *pipeout)
else {
(void) close(0);
(void) dup(OLDSTD);
- (void) ioctl(0, FIONCLEX, NULL);
+ (void) ioctl(STDIN_FILENO, FIONCLEX, NULL);
}
}
if (t->t_drit) {
@@ -565,7 +565,7 @@ doio(struct command *t, int *pipein, int *pipeout)
(fd = open(tmp, O_WRONLY | O_APPEND)) >= 0);
#else
(fd = open(tmp, O_WRONLY)) >= 0)
- (void) lseek(1, (off_t) 0, SEEK_END);
+ (void) lseek(STDOUT_FILENO, (off_t) 0, SEEK_END);
#endif
else {
if (!(flags & F_OVERWRITE) && adrof(STRnoclobber)) {
@@ -585,7 +585,7 @@ doio(struct command *t, int *pipein, int *pipeout)
else {
(void) close(1);
(void) dup(SHOUT);
- (void) ioctl(1, FIONCLEX, NULL);
+ (void) ioctl(STDOUT_FILENO, FIONCLEX, NULL);
}
(void) close(2);
@@ -594,7 +594,7 @@ doio(struct command *t, int *pipein, int *pipeout)
}
else {
(void) dup(SHERR);
- (void) ioctl(2, FIONCLEX, NULL);
+ (void) ioctl(STDERR_FILENO, FIONCLEX, NULL);
}
didfds = 1;
}
diff --git a/bin/ed/main.c b/bin/ed/main.c
index a12f83aeaca..92943b53cae 100644
--- a/bin/ed/main.c
+++ b/bin/ed/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.33 2009/10/27 23:59:21 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.34 2010/08/12 02:00:28 kevlo Exp $ */
/* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */
/* main.c: This file contains the main control and user-interface routines
@@ -150,8 +150,8 @@ top:
struct stat sb;
/* assert: pipes show up as fifo's when fstat'd */
- if (fstat(0, &sb) || !S_ISFIFO(sb.st_mode)) {
- if (lseek(0, 0, SEEK_CUR)) {
+ if (fstat(STDIN_FILENO, &sb) || !S_ISFIFO(sb.st_mode)) {
+ if (lseek(STDIN_FILENO, 0, SEEK_CUR)) {
interactive = 1;
setlinebuf(stdout);
}
@@ -1436,7 +1436,7 @@ handle_winch(int signo)
struct winsize ws; /* window size structure */
sigflags &= ~(1 << (signo - 1));
- if (ioctl(0, TIOCGWINSZ, &ws) >= 0) {
+ if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) >= 0) {
if (ws.ws_row > 2)
rows = ws.ws_row - 2;
if (ws.ws_col > 8)