Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Feb 1998 18:52:59 -0600
From:      "Jason" <jason_smethers@bigfoot.com>
To:        <bugs@FreeBSD.ORG>
Subject:   Re: bin/5711
Message-ID:  <007501bd39ac$10e4a520$016f6f6f@jason>

next in thread | raw e-mail | index | archive | help
>From: "Jason" <jason_smethers@bigfoot.com>
>To: <bug-followup@FreeBSD.ORG>
>Cc:  Subject: Re: bin/5711
>Date: Fri, 13 Feb 1998 20:12:30 -0600
>
> new diffs:

left out a s on line 246, should be:
ssize_t nr, nw, off;

even newer diffs:


diff -c -r /usr/src/bin/cat/cat.1 /usr/local/src/bin/cat/cat.1
*** /usr/src/bin/cat/cat.1 Sat Feb 22 08:01:26 1997
--- /usr/local/src/bin/cat/cat.1 Fri Feb 13 19:48:29 1998
***************
*** 118,125 ****
   .Sh HISTORY
   A
   .Nm
! command appeared in Version 1 AT&T UNIX. 
   Dennis Ritchie designed and wrote the first man page. 
   It appears to have been
   .Xr cat 1 .
! 
--- 118,134 ----
   .Sh HISTORY
   A
   .Nm
! utility appeared in Version 1 AT&T UNIX. 
   Dennis Ritchie designed and wrote the first man page. 
   It appears to have been
   .Xr cat 1 .
! .Sh STANDARDS
! The
! .Nm cat
! utility is expected to conform to the
! .St -p1003.2-92
! specification.
! .Pp
! The flags
! .Op Fl benstv
! are extensions to the specification.
diff -c -r /usr/src/bin/cat/cat.c /usr/local/src/bin/cat/cat.c
*** /usr/src/bin/cat/cat.c Fri Mar 28 09:24:04 1997
--- /usr/local/src/bin/cat/cat.c Fri Feb 13 19:52:55 1998
***************
*** 49,54 ****
--- 49,55 ----
   #include <sys/param.h>
   #include <sys/stat.h>
   
+ #include <assert.h>
   #include <ctype.h>
   #include <err.h>
   #include <errno.h>
***************
*** 63,72 ****
   int rval;
   char *filename;
   
! void cook_args __P((char *argv[]));
! void cook_buf __P((FILE *));
! void raw_args __P((char *argv[]));
! void raw_cat __P((int));
   
   int
   main(argc, argv)
--- 64,74 ----
   int rval;
   char *filename;
   
! void cook_args __P((char *argv[]));
! void cook_buf __P((FILE *));
! void raw_args __P((char *argv[]));
! void raw_cat __P((int));
! int main __P((int, char *[]));
   
   int
   main(argc, argv)
***************
*** 76,82 ****
    extern int optind;
    int ch;
   
!  setlocale(LC_CTYPE, "");
   
    while ((ch = getopt(argc, argv, "benstuv")) != -1)
     switch (ch) {
--- 78,84 ----
    extern int optind;
    int ch;
   
!  setlocale(LC_ALL, "");
   
    while ((ch = getopt(argc, argv, "benstuv")) != -1)
     switch (ch) {
***************
*** 237,258 ****
   raw_cat(rfd)
    register int rfd;
   {
!  register int nr, nw, off, wfd;
!  static int bsize;
    static char *buf;
    struct stat sbuf;
   
    wfd = fileno(stdout);
!  if (buf == NULL) {
!   if (fstat(wfd, &sbuf))
!    err(1, "%s", filename);
!   bsize = MAX(sbuf.st_blksize, 1024);
!   if ((buf = malloc((u_int)bsize)) == NULL)
!    err(1, NULL);
    }
    while ((nr = read(rfd, buf, bsize)) > 0)
     for (off = 0; nr; nr -= nw, off += nw)
!    if ((nw = write(wfd, buf + off, nr)) < 0)
       err(1, "stdout");
    if (nr < 0) {
     warn("%s", filename);
--- 239,269 ----
   raw_cat(rfd)
    register int rfd;
   {
!  register int wfd = 0;
    static char *buf;
    struct stat sbuf;
+  static size_t bsize;
+  ssize_t nr, nw, off;
   
    wfd = fileno(stdout);
!  if (fstat(wfd, &sbuf))
!   err(1, "%s", filename);
!  if (bsize < sbuf.st_blksize) {
!   bsize = MIN(sbuf.st_blksize, SSIZE_MAX);
!   if (bsize != sbuf.st_blksize) {
!    assert(SSIZE_MAX >= 32767);
!    bsize = 16384;
!   }
!   if (buf != NULL)
!    free(buf);
!   if ((buf = malloc(bsize)) == NULL) {
!    bsize = 0;
!    err(1, "malloc failed: cannot allocate buffer");
!   }
    }
    while ((nr = read(rfd, buf, bsize)) > 0)
     for (off = 0; nr; nr -= nw, off += nw)
!    if ((nw = write(wfd, buf + off, (size_t)nr)) < 0)
       err(1, "stdout");
    if (nr < 0) {
     warn("%s", filename);



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?007501bd39ac$10e4a520$016f6f6f>