FreeBSD Bugzilla – Attachment 171508 Details for
Bug 210344
ul(1) truncates long lines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Accomodate long lines in ul(1) - white space changes removed
ul.c-nospace.diff.txt (text/plain), 1.43 KB, created by
Pietro Cerutti
on 2016-06-17 14:09:28 UTC
(
hide
)
Description:
Accomodate long lines in ul(1) - white space changes removed
Filename:
MIME Type:
Creator:
Pietro Cerutti
Created:
2016-06-17 14:09:28 UTC
Size:
1.43 KB
patch
obsolete
>Index: ul.c >=================================================================== >--- ul.c (revision 301965) >+++ ul.c (working copy) >@@ -78,7 +78,9 @@ > int c_width; /* width or -1 if multi-column char. filler */ > } ; > >-static struct CHAR obuf[MAXBUF]; >+static struct CHAR sobuf[MAXBUF]; // static output buffer >+static struct CHAR *obuf = sobuf; >+static int buflen = MAXBUF; > static int col, maxcol; > static int mode; > static int halfpos; >@@ -151,6 +153,9 @@ > else > filter(f); > } >+ if (obuf != sobuf) { >+ free(obuf); >+ } > exit(0); > } > >@@ -166,9 +171,26 @@ > { > wint_t c; > int i, w; >+ int copy = 0; > >- while ((c = getwc(f)) != WEOF && col < MAXBUF) switch(c) { >- >+ while ((c = getwc(f)) != WEOF) { >+ if (col == buflen) { >+ if (obuf == sobuf) { >+ obuf = NULL; >+ copy = 1; >+ } >+ obuf = realloc(obuf, sizeof(*obuf) * 2 * buflen); >+ if (obuf == NULL) { >+ obuf = sobuf; >+ break; >+ } else if (copy) { >+ memcpy(obuf, sobuf, sizeof(*obuf) * buflen); >+ copy = 0; >+ } >+ bzero((char *)(obuf + buflen), sizeof(*obuf) * buflen); >+ buflen *= 2; >+ } >+ switch(c) { > case '\b': > if (col > 0) > col--; >@@ -289,6 +311,7 @@ > maxcol = col; > continue; > } >+ } > if (ferror(f)) > err(1, NULL); > if (maxcol) >@@ -405,7 +428,7 @@ > initbuf(void) > { > >- bzero((char *)obuf, sizeof (obuf)); /* depends on NORMAL == 0 */ >+ bzero((char *)obuf, buflen * sizeof(*obuf)); /* depends on NORMAL == 0 */ > col = 0; > maxcol = 0; > mode &= ALTSET;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 210344
:
171507
| 171508