FreeBSD Bugzilla – Attachment 150506 Details for
Bug 195922
split(1) : wrong output with option -l and line length > MAXBSIZE
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
split.c.patch (text/plain), 1.25 KB, created by
franz
on 2014-12-12 14:29:40 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
franz
Created:
2014-12-12 14:29:40 UTC
Size:
1.25 KB
patch
obsolete
>--- split.c.orig 2014-12-04 14:29:00.000000000 +0100 >+++ split.c 2014-12-04 14:29:47.000000000 +0100 >@@ -279,6 +279,8 @@ > split2(void) > { > long lcnt = 0; >+ long lpcnt = 0; >+ int wsw = 0; > FILE *infp; > > /* Stick a stream on top of input file descriptor */ >@@ -289,24 +291,39 @@ > while (fgets(bfr, sizeof(bfr), infp) != NULL) { > const int len = strlen(bfr); > >- /* If line is too long to deal with, just write it out */ >+ /* If line is longer than buffer, set switch/counter */ > if (bfr[len - 1] != '\n') >- goto writeit; >+ lpcnt++; >+ else lpcnt = 0; > > /* Check if we need to start a new file */ > if (pflag) { >+ if ( lpcnt == 1 ) >+ errx(EX_USAGE, "Error: The maximum line length for matching patterns is %d",MAXBSIZE); >+ > regmatch_t pmatch; > > pmatch.rm_so = 0; > pmatch.rm_eo = len - 1; > if (regexec(&rgx, bfr, 0, &pmatch, REG_STARTEND) == 0) > newfile(); >- } else if (lcnt++ == numlines) { >- newfile(); >- lcnt = 1; > } >+ else { >+ if ( lpcnt == 1 ){ >+ if ( lcnt == numlines) { >+ newfile(); >+ wsw = 1; >+ } >+ } >+ else if ( !lpcnt && lcnt++ == numlines) { >+ if (!wsw) >+ newfile(); >+ lcnt = 1; >+ wsw = 0; >+ } >+ } >+ > >-writeit: > /* Open output file if needed */ > if (!file_open) > newfile();
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 195922
: 150506