- use STD*_FILENO some more. No object-code changes
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Mon, 19 May 2008 09:48:17 +0000 (09:48 -0000)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Mon, 19 May 2008 09:48:17 +0000 (09:48 -0000)
21 files changed:
applets/usage.c
archival/libunarchive/decompress_bunzip2.c
coreutils/split.c
editors/ed.c
editors/vi.c
init/init.c
libbb/appletlib.c
libbb/verror_msg.c
loginutils/getty.c
miscutils/hdparm.c
miscutils/less.c
networking/httpd.c
networking/httpd_indexcgi.c
networking/nc_bloaty.c
networking/telnet.c
procps/nmeter.c
procps/top.c
runit/svlogd.c
shell/ash.c
shell/msh.c
util-linux/script.c

index 4955839fc03951d7a02309b94f7cba52d876bcaf..4f6a569d4c82f8378ac9603a05fbfecfd6f3018a 100644 (file)
@@ -13,6 +13,6 @@ static const char usage_messages[] = ""
 
 int main(void)
 {
-       write(1, usage_messages, sizeof(usage_messages));
+       write(STDOUT_FILENO, usage_messages, sizeof(usage_messages));
        return 0;
 }
index f74fdf1ad75d516e2966ffbdc1bcf365d382c2d0..8f35bc5f9a4839a01b814564debe1e7adaf7c959 100644 (file)
@@ -762,7 +762,7 @@ int main(int argc, char **argv)
 
        if (i < 0)
                fprintf(stderr,"%s\n", bunzip_errors[-i]);
-       else if (read(0, &c, 1))
+       else if (read(STDIN_FILENO, &c, 1))
                fprintf(stderr,"Trailing garbage ignored\n");
        return -i;
 }
index 2306789f0824d70060d43fdd1e763d7f0edd3d97..39f62e6ddb2e6b461f6707bd6c7711bc5d282848 100644 (file)
@@ -98,7 +98,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
        }
 
        while (1) {
-               bytes_read = safe_read(0, read_buffer, READ_BUFFER_SIZE);
+               bytes_read = safe_read(STDIN_FILENO, read_buffer, READ_BUFFER_SIZE);
                if (!bytes_read)
                        break;
                if (bytes_read < 0)
@@ -130,7 +130,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
                                }
                        }
 
-                       xwrite(1, src, to_write);
+                       xwrite(STDOUT_FILENO, src, to_write);
                        bytes_read -= to_write;
                        src += to_write;
                } while (bytes_read);
index 2f3bf03bf009cb7d1b4a9172ef38b92c3ac60bea..0961cc38eaf18aa6035acb73b82f7cb07ac12225 100644 (file)
@@ -825,7 +825,7 @@ static int printLines(int num1, int num2, int expandFlag)
 
        while (num1 <= num2) {
                if (!expandFlag) {
-                       write(1, lp->data, lp->len);
+                       write(STDOUT_FILENO, lp->data, lp->len);
                        setCurNum(num1++);
                        lp = lp->next;
                        continue;
index dded6edb37b7cd66dadea0f64248127f6d6ea9d0..1770d98c594aa47a373d24b90faa04c6b638a949 100644 (file)
@@ -2220,7 +2220,7 @@ static char readit(void)  // read (maybe cursor) key from stdin
        // get input from User- are there already input chars in Q?
        if (n <= 0) {
                // the Q is empty, wait for a typed char
-               n = safe_read(0, readbuffer, sizeof(readbuffer));
+               n = safe_read(STDIN_FILENO, readbuffer, sizeof(readbuffer));
                if (n < 0) {
                        if (errno == EBADF || errno == EFAULT || errno == EINVAL
                         || errno == EIO)
@@ -2243,7 +2243,7 @@ static char readit(void)  // read (maybe cursor) key from stdin
                         && ((size_t)n <= (sizeof(readbuffer) - 8))
                        ) {
                                // read the rest of the ESC string
-                               int r = safe_read(0, readbuffer + n, sizeof(readbuffer) - n);
+                               int r = safe_read(STDIN_FILENO, readbuffer + n, sizeof(readbuffer) - n);
                                if (r > 0)
                                        n += r;
                        }
@@ -4035,7 +4035,7 @@ static void crash_test()
                printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
                        totalcmds, last_input_char, msg, SOs, SOn);
                fflush(stdout);
-               while (safe_read(0, d, 1) > 0) {
+               while (safe_read(STDIN_FILENO, d, 1) > 0) {
                        if (d[0] == '\n' || d[0] == '\r')
                                break;
                }
index 63154ce8977a25a43a85fe712bba474d8e43430f..e3993896dccee91092d233d86fdabe4dffd7395c 100644 (file)
@@ -175,7 +175,7 @@ static void message(int where, const char *fmt, ...)
 
        if (where & L_CONSOLE) {
                /* Send console messages to console so people will see them. */
-               full_write(2, msg, l);
+               full_write(STDERR_FILENO, msg, l);
        }
 }
 
@@ -471,8 +471,8 @@ static pid_t run(const struct init_action *a)
                messageD(L_LOG, "waiting for enter to start '%s'"
                                        "(pid %d, tty '%s')\n",
                                a->command, getpid(), a->terminal);
-               full_write(1, press_enter, sizeof(press_enter) - 1);
-               while (safe_read(0, &c, 1) == 1 && c != '\n')
+               full_write(STDOUT_FILENO, press_enter, sizeof(press_enter) - 1);
+               while (safe_read(STDIN_FILENO, &c, 1) == 1 && c != '\n')
                        continue;
        }
 
index 464280b17d7f797acca61d874832af4ea1ad2ea1..86f85081c8f125e9279909416e5b707fb4eefcd5 100644 (file)
@@ -98,7 +98,7 @@ static const char *unpack_usage_messages(void)
 
 static void full_write2_str(const char *str)
 {
-       full_write(2, str, strlen(str));
+       full_write(STDERR_FILENO, str, strlen(str));
 }
 
 void bb_show_usage(void)
index ca44030b20bc7d964138e2eafc290ae4c7a7d709..5c6df48d4218ceea57ac67dcb3d1e94cbc1518a9 100644 (file)
@@ -56,7 +56,7 @@ void bb_verror_msg(const char *s, va_list p, const char* strerr)
 
        if (logmode & LOGMODE_STDIO) {
                fflush(stdout);
-               full_write(2, msg, used + msgeol_len);
+               full_write(STDERR_FILENO, msg, used + msgeol_len);
        }
        if (logmode & LOGMODE_SYSLOG) {
                syslog(LOG_ERR, "%s", msg + applet_len);
index f022aec59bd72d0d0c536b488a3d08369141191f..ae183a62b486833bea32718188dcdc9a89b74dc8 100644 (file)
@@ -344,7 +344,7 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp)
         * try to extract the speed of the dial-in call.
         */
        sleep(1);
-       nread = safe_read(0, buf, size_buf - 1);
+       nread = safe_read(STDIN_FILENO, buf, size_buf - 1);
        if (nread > 0) {
                buf[nread] = '\0';
                for (bp = buf; bp < buf + nread; bp++) {
@@ -421,7 +421,7 @@ static char *get_logname(char *logname, unsigned size_logname,
                while (cp->eol == '\0') {
 
                        /* Do not report trivial EINTR/EIO errors. */
-                       if (read(0, &c, 1) < 1) {
+                       if (read(STDIN_FILENO, &c, 1) < 1) {
                                if (errno == EINTR || errno == EIO)
                                        exit(EXIT_SUCCESS);
                                bb_perror_msg_and_die("%s: read", op->tty);
@@ -460,7 +460,7 @@ static char *get_logname(char *logname, unsigned size_logname,
 #endif
                                cp->erase = ascval;     /* set erase character */
                                if (bp > logname) {
-                                       full_write(1, erase[cp->parity], 3);
+                                       full_write(STDOUT_FILENO, erase[cp->parity], 3);
                                        bp--;
                                }
                                break;
@@ -470,7 +470,7 @@ static char *get_logname(char *logname, unsigned size_logname,
 #endif
                                cp->kill = ascval;      /* set kill character */
                                while (bp > logname) {
-                                       full_write(1, erase[cp->parity], 3);
+                                       full_write(STDOUT_FILENO, erase[cp->parity], 3);
                                        bp--;
                                }
                                break;
@@ -482,7 +482,7 @@ static char *get_logname(char *logname, unsigned size_logname,
                                } else if ((int)(bp - logname) >= size_logname - 1) {
                                        bb_error_msg_and_die("%s: input overrun", op->tty);
                                } else {
-                                       full_write(1, &c, 1); /* echo the character */
+                                       full_write(STDOUT_FILENO, &c, 1); /* echo the character */
                                        *bp++ = ascval; /* and store it */
                                }
                                break;
@@ -715,7 +715,7 @@ int getty_main(int argc ATTRIBUTE_UNUSED, char **argv)
        /* Write the modem init string and DON'T flush the buffers */
        if (options.flags & F_INITSTRING) {
                debug("writing init string\n");
-               full_write(1, options.initstring, strlen(options.initstring));
+               full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring));
        }
 
        /* Optionally detect the baud rate from the modem status message */
@@ -731,7 +731,7 @@ int getty_main(int argc ATTRIBUTE_UNUSED, char **argv)
                char ch;
 
                debug("waiting for cr-lf\n");
-               while (safe_read(0, &ch, 1) == 1) {
+               while (safe_read(STDIN_FILENO, &ch, 1) == 1) {
                        debug("read %x\n", (unsigned char)ch);
                        ch &= 0x7f;                     /* strip "parity bit" */
                        if (ch == '\n' || ch == '\r')
@@ -767,7 +767,7 @@ int getty_main(int argc ATTRIBUTE_UNUSED, char **argv)
        termios_final(&options, &termios, &chardata);
 
        /* Now the newline character should be properly written. */
-       full_write(1, "\n", 1);
+       full_write(STDOUT_FILENO, "\n", 1);
 
        /* Let the login program take care of password validation. */
        /* We use PATH because we trust that root doesn't set "bad" PATH,
index 7afa9ff862bd4f6feef7946785e9d069ecb8e993..8c0e47334027d50698cfc3fc52643226311ed6ea 100644 (file)
@@ -1924,7 +1924,7 @@ static void identify_from_stdin(void)
        unsigned char *b = (unsigned char *)buf;
        int i;
 
-       xread(0, buf, 1280);
+       xread(STDIN_FILENO, buf, 1280);
 
        // Convert the newline-separated hex data into an identify block.
 
index f69bce97e14bb64f4ee2691d9a79635dca818bde..0529b20479e4408db6c7f82a62fb326277b96406 100644 (file)
@@ -273,7 +273,7 @@ static void read_lines(void)
                        /* if no unprocessed chars left, eat more */
                        if (readpos >= readeof) {
                                ndelay_on(0);
-                               eof_error = safe_read(0, readbuf, sizeof(readbuf));
+                               eof_error = safe_read(STDIN_FILENO, readbuf, sizeof(readbuf));
                                ndelay_off(0);
                                readpos = 0;
                                readeof = eof_error;
index 4094061a8829c9ab19befea0714001ca4036c290..4da7e5c65ad06084bd63cecaaefb26c55d94dc3d 100644 (file)
@@ -947,7 +947,7 @@ static void log_and_exit(void)
        /* Why??
        (this also messes up stdin when user runs httpd -i from terminal)
        ndelay_on(0);
-       while (read(0, iobuf, IOBUF_SIZE) > 0)
+       while (read(STDIN_FILENO, iobuf, IOBUF_SIZE) > 0)
                continue;
        */
 
@@ -1023,7 +1023,7 @@ static void send_headers(int responseNum)
 
                if (DEBUG)
                        fprintf(stderr, "headers: '%s'\n", iobuf);
-               full_write(1, iobuf, len);
+               full_write(STDOUT_FILENO, iobuf, len);
                if (DEBUG)
                        fprintf(stderr, "writing error page: '%s'\n", error_page);
                return send_file_and_exit(error_page, SEND_BODY);
@@ -1062,7 +1062,7 @@ static void send_headers(int responseNum)
        }
        if (DEBUG)
                fprintf(stderr, "headers: '%s'\n", iobuf);
-       if (full_write(1, iobuf, len) != len) {
+       if (full_write(STDOUT_FILENO, iobuf, len) != len) {
                if (verbose > 1)
                        bb_perror_msg("error");
                log_and_exit();
@@ -1090,7 +1090,7 @@ static int get_line(void)
 
        while (1) {
                if (hdr_cnt <= 0) {
-                       hdr_cnt = safe_read(0, hdr_buf, sizeof(hdr_buf));
+                       hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf));
                        if (hdr_cnt <= 0)
                                break;
                        hdr_ptr = hdr_buf;
@@ -1202,8 +1202,8 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
                         * and there *is* data to read from the peer
                         * (POSTDATA) */
                        //count = post_len > (int)sizeof(hdr_buf) ? (int)sizeof(hdr_buf) : post_len;
-                       //count = safe_read(0, hdr_buf, count);
-                       count = safe_read(0, hdr_buf, sizeof(hdr_buf));
+                       //count = safe_read(STDIN_FILENO, hdr_buf, count);
+                       count = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf));
                        if (count > 0) {
                                hdr_cnt = count;
                                hdr_ptr = hdr_buf;
@@ -1237,8 +1237,8 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
                                        /* eof (or error) and there was no "HTTP",
                                         * so write it, then write received data */
                                        if (out_cnt) {
-                                               full_write(1, HTTP_200, sizeof(HTTP_200)-1);
-                                               full_write(1, rbuf, out_cnt);
+                                               full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1);
+                                               full_write(STDOUT_FILENO, rbuf, out_cnt);
                                        }
                                        break; /* CGI stdout is closed, exiting */
                                }
@@ -1247,7 +1247,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
                                /* "Status" header format is: "Status: 302 Redirected\r\n" */
                                if (out_cnt >= 8 && memcmp(rbuf, "Status: ", 8) == 0) {
                                        /* send "HTTP/1.0 " */
-                                       if (full_write(1, HTTP_200, 9) != 9)
+                                       if (full_write(STDOUT_FILENO, HTTP_200, 9) != 9)
                                                break;
                                        rbuf += 8; /* skip "Status: " */
                                        count = out_cnt - 8;
@@ -1256,7 +1256,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
                                        /* Did CGI add "HTTP"? */
                                        if (memcmp(rbuf, HTTP_200, 4) != 0) {
                                                /* there is no "HTTP", do it ourself */
-                                               if (full_write(1, HTTP_200, sizeof(HTTP_200)-1) != sizeof(HTTP_200)-1)
+                                               if (full_write(STDOUT_FILENO, HTTP_200, sizeof(HTTP_200)-1) != sizeof(HTTP_200)-1)
                                                        break;
                                        }
                                        /* Commented out:
@@ -1276,7 +1276,7 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
                                if (count <= 0)
                                        break;  /* eof (or error) */
                        }
-                       if (full_write(1, rbuf, count) != count)
+                       if (full_write(STDOUT_FILENO, rbuf, count) != count)
                                break;
                        if (DEBUG)
                                fprintf(stderr, "cgi read %d bytes: '%.*s'\n", count, count, rbuf);
@@ -1632,7 +1632,7 @@ static void send_file_and_exit(const char *url, int what)
        while ((count = safe_read(f, iobuf, IOBUF_SIZE)) > 0) {
                ssize_t n;
                USE_FEATURE_HTTPD_RANGES(if (count > range_len) count = range_len;)
-               n = full_write(1, iobuf, count);
+               n = full_write(STDOUT_FILENO, iobuf, count);
                if (count != n)
                        break;
                USE_FEATURE_HTTPD_RANGES(range_len -= count;)
index fd64af38f70687e183fcbda431f8a4fccdeca756..94c6a692a63bc1562df2e10ca507e7d979c5a361 100644 (file)
@@ -125,7 +125,7 @@ static void guarantee(int size)
 {
        if (buffer + (BUFFER_SIZE-HEADROOM) - dst >= size)
                return;
-       write(1, buffer, dst - buffer);
+       write(STDOUT_FILENO, buffer, dst - buffer);
        dst = buffer;
 }
 
index 4ba726eb5145c9b49ffc75b46a5e64c61d7299b1..5f7bd03720e036bfe2467454b18abbf7d12792d0 100644 (file)
@@ -562,7 +562,7 @@ static int readwrite(void)
        /* if we have a timeout AND stdin is closed AND we haven't heard anything
         from the net during that time, assume it's dead and close it too. */
                if (rr == 0) {
-                       if (!FD_ISSET(0, &ding1))
+                       if (!FD_ISSET(STDIN_FILENO, &ding1))
                                netretry--;                        /* we actually try a coupla times. */
                        if (!netretry) {
                                if (o_verbose > 1)                /* normally we don't care */
@@ -597,12 +597,12 @@ Debug("got %d from the net, errno %d", rr, errno);
                        goto shovel;
 
        /* okay, suck more stdin */
-               if (FD_ISSET(0, &ding2)) {                /* stdin: ding! */
-                       rr = read(0, bigbuf_in, BIGSIZ);
+               if (FD_ISSET(STDIN_FILENO, &ding2)) {                /* stdin: ding! */
+                       rr = read(STDIN_FILENO, bigbuf_in, BIGSIZ);
        /* Considered making reads here smaller for UDP mode, but 8192-byte
         mobygrams are kinda fun and exercise the reassembler. */
                        if (rr <= 0) {                        /* at end, or fukt, or ... */
-                               FD_CLR(0, &ding1);                /* disable and close stdin */
+                               FD_CLR(STDIN_FILENO, &ding1);                /* disable and close stdin */
                                close(0);
                        } else {
                                rzleft = rr;
@@ -625,7 +625,7 @@ Debug("got %d from the net, errno %d", rr, errno);
                        return 1;
                }
                if (rnleft) {
-                       rr = write(1, np, rnleft);
+                       rr = write(STDOUT_FILENO, np, rnleft);
                        if (rr > 0) {
                                if (o_ofile) /* log the stdout */
                                        oprint('<', (unsigned char *)np, rr);
@@ -783,7 +783,7 @@ int nc_main(int argc, char **argv)
        }
 #endif
 
-       FD_SET(0, &ding1);                        /* stdin *is* initially open */
+       FD_SET(STDIN_FILENO, &ding1);                        /* stdin *is* initially open */
        if (proggie) {
                close(0); /* won't need stdin */
                option_mask32 &= ~OPT_o; /* -o with -e is meaningless! */
index b357e690ce4f5ad62f146fce8b978cf3d6faa1b2..3a06c167c94037d6ffcb0731231c49fdee7bcbc8 100644 (file)
@@ -121,7 +121,7 @@ static void conescape(void)
                        " z     suspend telnet\r\n"
                        " e     exit telnet\r\n");
 
-       if (read(0, &b, 1) <= 0)
+       if (read(STDIN_FILENO, &b, 1) <= 0)
                doexit(EXIT_FAILURE);
 
        switch (b) {
@@ -256,7 +256,7 @@ static void handlenetinput(int len)
        }
 
        if (len)
-               write(1, G.buf, len);
+               write(STDOUT_FILENO, G.buf, len);
 }
 
 static void putiac(int c)
@@ -601,7 +601,7 @@ int telnet_main(int argc, char **argv)
        ufds[0].events = ufds[1].events = POLLIN;
 #else
        FD_ZERO(&readfds);
-       FD_SET(0, &readfds);
+       FD_SET(STDIN_FILENO, &readfds);
        FD_SET(G.netfd, &readfds);
        maxfd = G.netfd + 1;
 #endif
@@ -629,10 +629,10 @@ int telnet_main(int argc, char **argv)
 #ifdef USE_POLL
                        if (ufds[0].revents) /* well, should check POLLIN, but ... */
 #else
-                       if (FD_ISSET(0, &rfds))
+                       if (FD_ISSET(STDIN_FILENO, &rfds))
 #endif
                        {
-                               len = read(0, G.buf, DATABUFSIZE);
+                               len = read(STDIN_FILENO, G.buf, DATABUFSIZE);
                                if (len <= 0)
                                        doexit(EXIT_SUCCESS);
                                TRACE(0, ("Read con: %d\n", len));
index b6e754b7ae2f1db49dbc429cd821910e62d810be..798afcf16ec0e1673ff673c31623cd14eae74585 100644 (file)
@@ -98,7 +98,7 @@ static void print_outbuf(void)
 {
        int sz = cur_outbuf - outbuf;
        if (sz > 0) {
-               xwrite(1, outbuf, sz);
+               xwrite(STDOUT_FILENO, outbuf, sz);
                cur_outbuf = outbuf;
        }
 }
index de30ffb28e21164350900ec56bc1d04a402a19ce..b861deb66fe9465895eaa25c46ad7fbcb8117f95 100644 (file)
@@ -888,7 +888,7 @@ int top_main(int argc ATTRIBUTE_UNUSED, char **argv)
                         /* batch mode, or EOF on stdin ("top </dev/null") */
                        sleep(interval);
                else if (safe_poll(pfd, 1, interval * 1000) > 0) {
-                       if (safe_read(0, &c, 1) != 1) { /* error/EOF? */
+                       if (safe_read(STDIN_FILENO, &c, 1) != 1) { /* error/EOF? */
                                option_mask32 |= OPT_EOF;
                                continue;
                        }
index db3d4c5406bca394c79b05fe0baea0048c222ba6..bfb97166f17429e92f73babf4ca53aa6ce3f2fe7 100644 (file)
@@ -748,7 +748,7 @@ static int buffer_pread(/*int fd, */char *s, unsigned len)
                poll(&input, 1, i * 1000);
                sigprocmask(SIG_BLOCK, &blocked_sigset, NULL);
 
-               i = ndelay_read(0, s, len);
+               i = ndelay_read(STDIN_FILENO, s, len);
                if (i >= 0)
                        break;
                if (errno == EINTR)
@@ -994,7 +994,7 @@ int svlogd_main(int argc, char **argv)
                                logmatch(ld);
                        if (ld->matcherr == 'e') {
                                /* runit-1.8.0 compat: if timestamping, do it on stderr too */
-                               ////full_write(2, printptr, printlen);
+                               ////full_write(STDERR_FILENO, printptr, printlen);
                                fwrite(printptr, 1, printlen, stderr);
                        }
                        if (ld->match != '+') continue;
@@ -1022,7 +1022,7 @@ int svlogd_main(int argc, char **argv)
                        for (i = 0; i < dirn; ++i) {
                                if (dir[i].fddir == -1) continue;
                                if (dir[i].matcherr == 'e') {
-                                       ////full_write(2, lineptr, linelen);
+                                       ////full_write(STDERR_FILENO, lineptr, linelen);
                                        fwrite(lineptr, 1, linelen, stderr);
                                }
                                if (dir[i].match != '+') continue;
index fa063bf2016c080918cfd33c412a47d8db295a9f..20b93f326fa804970dbf582a18cf9ff05a5e0efc 100644 (file)
@@ -1258,7 +1258,7 @@ stunalloc(void *p)
 {
 #if DEBUG
        if (!p || (g_stacknxt < (char *)p) || ((char *)p < g_stackp->space)) {
-               write(2, "stunalloc\n", 10);
+               write(STDERR_FILENO, "stunalloc\n", 10);
                abort();
        }
 #endif
index 48fa56eb7fb10f7295407b6f1e94530eec88d336..9e06a3bff2181481d3e416bc49f4d9fcdfa82648 100644 (file)
@@ -743,7 +743,7 @@ static void print_tree(struct op *head)
 static void prs(const char *s)
 {
        if (*s)
-               write(2, s, strlen(s));
+               write(STDERR_FILENO, s, strlen(s));
 }
 
 static void prn(unsigned u)
@@ -3384,7 +3384,7 @@ static int doread(struct op *t ATTRIBUTE_UNUSED, char **args)
        }
        for (wp = args + 1; *wp; wp++) {
                for (cp = global_env.linep; !nl && cp < elinep - 1; cp++) {
-                       nb = nonblock_safe_read(0, cp, sizeof(*cp));
+                       nb = nonblock_safe_read(STDIN_FILENO, cp, sizeof(*cp));
                        if (nb != sizeof(*cp))
                                break;
                        nl = (*cp == '\n');
@@ -4522,7 +4522,7 @@ static int readc(void)
 static void ioecho(char c)
 {
        if (FLAG['v'])
-               write(2, &c, sizeof c);
+               write(STDERR_FILENO, &c, sizeof c);
 }
 
 static void pushio(struct ioarg *argp, int (*fn) (struct ioarg *))
index c1883328f234041dfe4e716d661b82b3bc1c5786..e70294e6cbd229e17952219f5ad92564c9882cae 100644 (file)
@@ -124,7 +124,7 @@ int script_main(int argc ATTRIBUTE_UNUSED, char **argv)
                                        goto restore;
                                }
                                if (count > 0) {
-                                       full_write(1, buf, count);
+                                       full_write(STDOUT_FILENO, buf, count);
                                        full_write(outfd, buf, count);
                                        if (opt & 4) { /* -f */
                                                fsync(outfd);
@@ -132,7 +132,7 @@ int script_main(int argc ATTRIBUTE_UNUSED, char **argv)
                                }
                        }
                        if (pfd[1].revents) {
-                               count = safe_read(0, buf, sizeof(buf));
+                               count = safe_read(STDIN_FILENO, buf, sizeof(buf));
                                if (count <= 0) {
                                        /* err/eof from stdin: don't read stdin anymore */
                                        pfd[1].revents = 0;
@@ -152,7 +152,7 @@ int script_main(int argc ATTRIBUTE_UNUSED, char **argv)
                loop = 999;
                /* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */
                while (--loop && (count = safe_read(pty, buf, sizeof(buf))) > 0) {
-                       full_write(1, buf, count);
+                       full_write(STDOUT_FILENO, buf, count);
                        full_write(outfd, buf, count);
                }
  restore: