From owner-freebsd-standards Thu Jan 24 1:29:51 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (122.a.006.mel.iprimus.net.au [210.50.44.122]) by hub.freebsd.org (Postfix) with ESMTP id 9E3B537B400 for ; Thu, 24 Jan 2002 01:29:43 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g0O9QFD12800 for freebsd-standards@FreeBSD.ORG; Thu, 24 Jan 2002 20:26:15 +1100 (EST) (envelope-from tim) Date: Thu, 24 Jan 2002 20:26:15 +1100 From: "Tim J. Robbins" To: freebsd-standards@FreeBSD.ORG Subject: tabs(1) utility implementation Message-ID: <20020124202615.A12676@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Attached is an implementation of the `tabs' utility I've written. I haven't had a chance to extensively test it just yet, but it does seem to work. I think it implements everything required by IEEE Std 1003.1-200x except the margin option +n (I can't find it described anywhere). The manual page also could do with a bit of a cleanup by someone skilled with mdoc (not me!). Feel free to s/Tim J. Robbins/The FreeBSD Project/ on the copyright notice if this makes life easier for you. Tim --4Ckj6UjgE2iN1+kY Content-Type: application/x-tar-gz Content-Disposition: attachment; filename="tabs.tar.gz" Content-Transfer-Encoding: base64 H4sIAMnSTzwAA+1a+1PbxhbOr9Zfceq2wQbbWDaP9lIyY2xB1DE215LzGMKkQhagRJZ8JZmE Bv73+51dSZaBlPSW9DFXO9jIu2e/89pzdtfHsXUarT/5uo02mtubm/SESN3ebOb/p61JtL3R am9vqs32Nj5vbzW3n9DmV5ZLtHkUWyHRk9id/ibdQ+P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u+Gmd98LJBTYT N5JZBCDNk7Gndw4GQyTpLkJd+0j1KJ7IBKBp1OkbQ6XxCpOYh0o1+UFex2hT0plIu50Rcvvt 0MURYuJE7rkvv+Zih3tX2U6PyTHVZ+L3LS0liT15SGsUN7qiFa1oRSta0YpWtKIVrWhFK1rR ila0ohWtaEUrWtGKVrSiFa1oRSta0YpWtL9p+y/kc8fkAFAAAA== --4Ckj6UjgE2iN1+kY-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Jan 24 2:15: 6 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (122.a.006.mel.iprimus.net.au [210.50.44.122]) by hub.freebsd.org (Postfix) with ESMTP id F416437B400 for ; Thu, 24 Jan 2002 02:14:57 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g0OA9u813095 for freebsd-standards@FreeBSD.ORG; Thu, 24 Jan 2002 21:09:56 +1100 (EST) (envelope-from tim) Date: Thu, 24 Jan 2002 21:09:56 +1100 From: "Tim J. Robbins" To: freebsd-standards@FreeBSD.ORG Subject: split(1) -a option patch Message-ID: <20020124210956.A13091@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="5mCyUwZo2JvN/JJP" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, This patch implements -a option of split command to control the number of letters used to generate filename suffix. This hopefully closes the "Add -a option to the split utility" task at http://people.freebsd.org/~mike/c99/ Tim --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="split-sufflen.diff" diff -ru split.old/split.1 split/split.1 --- split.old/split.1 Thu Jan 24 21:07:03 2002 +++ split/split.1 Thu Jan 24 21:06:29 2002 @@ -40,6 +40,7 @@ .Nd split a file into pieces .Sh SYNOPSIS .Nm +.Op Fl a Ar suffix_length .Op Fl b Ar byte_count[k|m] .Op Fl l Ar line_count .Op Fl p Ar pattern @@ -54,6 +55,12 @@ .Pp The options are as follows: .Bl -tag -width Ds +.It Fl a +Use +.Ar suffix_length +letters to form the suffix of the file name. If +.Fl a +is not specified, two letters are used as the suffix. .It Fl b Create smaller files .Ar byte_count diff -ru split.old/split.c split/split.c --- split.old/split.c Thu Jan 24 21:07:03 2002 +++ split/split.c Thu Jan 24 21:05:07 2002 @@ -69,6 +69,7 @@ char fname[MAXPATHLEN]; /* File name prefix. */ regex_t rgx; int pflag; +int sufflen; /* File name suffix length. */ void newfile __P((void)); void split1 __P((void)); @@ -83,7 +84,7 @@ int ch; char *ep, *p; - while ((ch = getopt(argc, argv, "-0123456789b:l:p:")) != -1) + while ((ch = getopt(argc, argv, "-0123456789b:l:p:a:")) != -1) switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -130,6 +131,11 @@ errx(EX_USAGE, "%s: illegal line count", optarg); break; + case 'a': /* Suffix length */ + if ((sufflen = strtol(optarg, &ep, 10)) <= 0 || *ep) + err(EX_USAGE, + "%s: illegal suffix length", optarg); + break; default: usage(); } @@ -147,6 +153,9 @@ if (*argv != NULL) usage(); + if (strlen(fname) + sufflen >= sizeof (fname)) + err(EX_USAGE, "suffix is too long"); + if (pflag && (numlines != 0 || bytecnt != 0)) usage(); @@ -277,6 +286,7 @@ static long fnum; static int defname; static char *fpnt; + long maxfiles, i, tfnum; if (ofd == -1) { if (fname[0] == '\0') { @@ -289,19 +299,24 @@ } ofd = fileno(stdout); } + + /* maxfiles = 26^sufflen, but don't use libm */ + for (maxfiles = 1, i = 0; i < sufflen; i++) + maxfiles *= 26; + /* * Hack to increase max files; original code wandered through - * magic characters. Maximum files is 3 * 26 * 26 == 2028 + * magic characters. */ -#define MAXFILES 676 - if (fnum == MAXFILES) { + if (fnum == maxfiles) { if (!defname || fname[0] == 'z') errx(EX_DATAERR, "too many files"); ++fname[0]; fnum = 0; } - fpnt[0] = fnum / 26 + 'a'; - fpnt[1] = fnum % 26 + 'a'; + for (tfnum = fnum, i = sufflen; i != 0; i--, tfnum /= 26) + fpnt[i - 1] = tfnum % 26 + 'a'; + fpnt[sufflen] = '\0'; ++fnum; if (!freopen(fname, "w", stdout)) err(EX_IOERR, "%s", fname); @@ -312,6 +327,7 @@ usage() { (void)fprintf(stderr, -"usage: split [-b byte_count] [-l line_count] [-p pattern] [file [prefix]]\n"); +"usage: split [-a sufflen] [-b byte_count] [-l line_count] [-p pattern] \n" +"\t\t[file [prefix]]\n"); exit(EX_USAGE); } --5mCyUwZo2JvN/JJP-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Jan 24 2:28:36 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (122.a.006.mel.iprimus.net.au [210.50.44.122]) by hub.freebsd.org (Postfix) with ESMTP id BC7E237B402 for ; Thu, 24 Jan 2002 02:28:33 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g0OAMeC13171 for freebsd-standards@FreeBSD.ORG; Thu, 24 Jan 2002 21:22:40 +1100 (EST) (envelope-from tim) Date: Thu, 24 Jan 2002 21:22:39 +1100 From: "Tim J. Robbins" To: freebsd-standards@FreeBSD.ORG Subject: Re: split(1) -a option patch Message-ID: <20020124212239.A13167@descent.robbins.dropbear.id.au> References: <20020124210956.A13091@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020124210956.A13091@descent.robbins.dropbear.id.au>; from tim@robbins.dropbear.id.au on Thu, Jan 24, 2002 at 09:09:56PM +1100 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jan 24, 2002 at 09:09:56PM +1100, Tim J. Robbins wrote: > This patch implements -a option of split command to control the number > of letters used to generate filename suffix. Just wanted to point out that this patch is against RELENG_4, not -CURRENT as would be best. I don't have a system running -CURRENT just yet. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Jan 24 9:49:28 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (111.a.010.mel.iprimus.net.au [210.50.200.111]) by hub.freebsd.org (Postfix) with ESMTP id 2CBD137B402 for ; Thu, 24 Jan 2002 09:49:11 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g0OHgZ601180 for freebsd-standards@FreeBSD.ORG; Fri, 25 Jan 2002 04:42:35 +1100 (EST) (envelope-from tim) Date: Fri, 25 Jan 2002 04:42:35 +1100 From: "Tim J. Robbins" To: freebsd-standards@FreeBSD.ORG Subject: csplit(1) Message-ID: <20020125044235.A1126@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I've implemented the csplit(1) utility for FreeBSD. I've decided to stick everything on a web page rather than attach them to mail. http://www.wiretapped.net/~fyre/freebsd/ has this csplit implementation as well as tabs, and the patch to split. mdoc'ing needs more work, as usual. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Jan 24 13: 3:36 2002 Delivered-To: freebsd-standards@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id 2A9C437B400 for ; Thu, 24 Jan 2002 13:03:34 -0800 (PST) Received: from attbi.com ([12.237.33.57]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020124210328.ROTM3578.rwcrmhc52.attbi.com@attbi.com> for ; Thu, 24 Jan 2002 21:03:28 +0000 Message-ID: <3C5076A6.D817D951@attbi.com> Date: Thu, 24 Jan 2002 15:03:34 -0600 From: Joe Halpin X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en MIME-Version: 1.0 Cc: freebsd-standards@FreeBSD.ORG Subject: Re: split(1) -a option patch References: <20020124210956.A13091@descent.robbins.dropbear.id.au> <20020124212239.A13167@descent.robbins.dropbear.id.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG "Tim J. Robbins" wrote: > > On Thu, Jan 24, 2002 at 09:09:56PM +1100, Tim J. Robbins wrote: > > > This patch implements -a option of split command to control the number > > of letters used to generate filename suffix. > > Just wanted to point out that this patch is against RELENG_4, not -CURRENT > as would be best. I don't have a system running -CURRENT just yet. I don't think you need a -CURRENT system to make changes to something like this. You can checkout the latest version using cvs, make changes to that version, then have cvs do the diff. These are the instructions Mike sent me (I'm doing some work on at(1) and running -STABLE): %%% # Use the FreeBSD anonymous CVS server setenv CVSROOT :pserver:anoncvs@anoncvs.FreeBSD.org:/home/ncvs # Log into the server (password is anoncvs) cvs login # Checkout latest at(1) sources (creates a directory called `at') cvs checkout at # Go into that directory and make your modifications, or copy your # files from elsewhere cd at ; vi at.c # Get to the directory outside of `at' again cd .. # Make a diff cvs diff -uN at >at.diff %%% If you're doing something that needs current system libraries or kernel stuff, this probably won't work for you, but that's probably not an issue with stuff like at(1) and split(1). Joe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Jan 25 10:31:13 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id A479A37B402 for ; Fri, 25 Jan 2002 10:31:05 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g0PIRdV04201; Fri, 25 Jan 2002 13:27:39 -0500 (EST) (envelope-from mike) Date: Fri, 25 Jan 2002 13:27:39 -0500 From: Mike Barcroft To: "Tim J. Robbins" Cc: freebsd-standards@FreeBSD.ORG Subject: Re: split(1) -a option patch Message-ID: <20020125132739.B92720@espresso.q9media.com> References: <20020124210956.A13091@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020124210956.A13091@descent.robbins.dropbear.id.au>; from tim@robbins.dropbear.id.au on Thu, Jan 24, 2002 at 09:09:56PM +1100 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Tim J. Robbins writes: > This patch implements -a option of split command to control the number > of letters used to generate filename suffix. Could you please update your patch to -CURRENT sources. There is atleast one change to split.c that hasn't been MFC'd. > diff -ru split.old/split.1 split/split.1 > --- split.old/split.1 Thu Jan 24 21:07:03 2002 > +++ split/split.1 Thu Jan 24 21:06:29 2002 > @@ -40,6 +40,7 @@ > .Nd split a file into pieces > .Sh SYNOPSIS > .Nm > +.Op Fl a Ar suffix_length > .Op Fl b Ar byte_count[k|m] > .Op Fl l Ar line_count > .Op Fl p Ar pattern > @@ -54,6 +55,12 @@ > .Pp > The options are as follows: > .Bl -tag -width Ds > +.It Fl a > +Use > +.Ar suffix_length > +letters to form the suffix of the file name. If > +.Fl a > +is not specified, two letters are used as the suffix. > .It Fl b > Create smaller files > .Ar byte_count Okay. > diff -ru split.old/split.c split/split.c > --- split.old/split.c Thu Jan 24 21:07:03 2002 > +++ split/split.c Thu Jan 24 21:05:07 2002 > @@ -69,6 +69,7 @@ > char fname[MAXPATHLEN]; /* File name prefix. */ > regex_t rgx; > int pflag; > +int sufflen; /* File name suffix length. */ > > void newfile __P((void)); > void split1 __P((void)); > @@ -83,7 +84,7 @@ > int ch; > char *ep, *p; > > - while ((ch = getopt(argc, argv, "-0123456789b:l:p:")) != -1) > + while ((ch = getopt(argc, argv, "-0123456789b:l:p:a:")) != -1) These options need to be kept in alphabetical order. > switch (ch) { > case '0': case '1': case '2': case '3': case '4': > case '5': case '6': case '7': case '8': case '9': > @@ -130,6 +131,11 @@ > errx(EX_USAGE, > "%s: illegal line count", optarg); > break; > + case 'a': /* Suffix length */ Similarly, the case clauses need to be kept in alphabetical order. > + if ((sufflen = strtol(optarg, &ep, 10)) <= 0 || *ep) Return value of strtol() doesn't match type of sufflen. > + err(EX_USAGE, > + "%s: illegal suffix length", optarg); > + break; > default: > usage(); > } > @@ -147,6 +153,9 @@ > if (*argv != NULL) > usage(); > > + if (strlen(fname) + sufflen >= sizeof (fname)) There shouldn't be a space between `sizeof' and `(fname)'. This comparison will probably need some casting to prevent comparing signed and unsigned diagnostics. > + err(EX_USAGE, "suffix is too long"); > + Gratuitous vertical whitespace. > if (pflag && (numlines != 0 || bytecnt != 0)) > usage(); > > @@ -277,6 +286,7 @@ > static long fnum; > static int defname; > static char *fpnt; > + long maxfiles, i, tfnum; This belongs above the other types, since `long' is larger than the other types. Also, `i' comes before `m' in the alphabet. > > if (ofd == -1) { > if (fname[0] == '\0') { > @@ -289,19 +299,24 @@ > } > ofd = fileno(stdout); > } > + > + /* maxfiles = 26^sufflen, but don't use libm */ Sentences end with a period. > + for (maxfiles = 1, i = 0; i < sufflen; i++) > + maxfiles *= 26; > + Extra checking is needed here, since a 32-bit signed integer overflows at a sufflen of 7. > /* > * Hack to increase max files; original code wandered through > - * magic characters. Maximum files is 3 * 26 * 26 == 2028 > + * magic characters. > */ > -#define MAXFILES 676 > - if (fnum == MAXFILES) { > + if (fnum == maxfiles) { > if (!defname || fname[0] == 'z') > errx(EX_DATAERR, "too many files"); > ++fname[0]; > fnum = 0; > } > - fpnt[0] = fnum / 26 + 'a'; > - fpnt[1] = fnum % 26 + 'a'; > + for (tfnum = fnum, i = sufflen; i != 0; i--, tfnum /= 26) > + fpnt[i - 1] = tfnum % 26 + 'a'; > + fpnt[sufflen] = '\0'; Can you explain the purpose of this change? I don't think I completely understand it. > ++fnum; > if (!freopen(fname, "w", stdout)) > err(EX_IOERR, "%s", fname); > @@ -312,6 +327,7 @@ > usage() > { > (void)fprintf(stderr, > -"usage: split [-b byte_count] [-l line_count] [-p pattern] [file [prefix]]\n"); > +"usage: split [-a sufflen] [-b byte_count] [-l line_count] [-p pattern] \n" > +"\t\t[file [prefix]]\n"); This change breaks K&R. Add a new fprintf(). > exit(EX_USAGE); > } Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Jan 25 22: 8: 2 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (082.c.002.mel.iprimus.net.au [203.134.135.82]) by hub.freebsd.org (Postfix) with ESMTP id 96D5237B404; Fri, 25 Jan 2002 22:07:36 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g0Q64N509066; Sat, 26 Jan 2002 17:04:23 +1100 (EST) (envelope-from tim) Date: Sat, 26 Jan 2002 17:04:22 +1100 From: "Tim J. Robbins" To: Mike Barcroft Cc: freebsd-standards@FreeBSD.ORG Subject: Re: split(1) -a option patch Message-ID: <20020126170422.A8594@descent.robbins.dropbear.id.au> References: <20020124210956.A13091@descent.robbins.dropbear.id.au> <20020125132739.B92720@espresso.q9media.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020125132739.B92720@espresso.q9media.com>; from mike@FreeBSD.ORG on Fri, Jan 25, 2002 at 01:27:39PM -0500 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Jan 25, 2002 at 01:27:39PM -0500, Mike Barcroft wrote: > Could you please update your patch to -CURRENT sources. There is > atleast one change to split.c that hasn't been MFC'd. Done. I've corrected the style problems (I hope) and the warnings, added overflow checking when calculating `maxfiles' and fixed usage(). There were also some things in the manual page that needed updating. > > - fpnt[0] = fnum / 26 + 'a'; > > - fpnt[1] = fnum % 26 + 'a'; > > + for (tfnum = fnum, i = sufflen; i != 0; i--, tfnum /= 26) > > + fpnt[i - 1] = tfnum % 26 + 'a'; > > + fpnt[sufflen] = '\0'; > > Can you explain the purpose of this change? I don't think I > completely understand it. Instead of generating a two character suffix, I use a loop to do it more generally. The idea is: Save a copy of the file sequence number (tfnum = fnum) to mess around with. Walk backwards through where the suffix should go, dividing tfnum by 26 and setting the character to the remainder +'a'. Is this simpler? tfnum = fnum; i = sufflen - 1; do { fpnt[i] = tfnum % 26 + 'a'; tfnum /= 26; } while (i >= 0); Patch against -CURRENT is attached. Tim --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="split.diff" Index: split/split.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/split/split.1,v retrieving revision 1.6 diff -u -r1.6 split.1 --- split/split.1 2001/07/15 08:01:34 1.6 +++ split/split.1 2002/01/26 05:55:45 @@ -40,6 +40,7 @@ .Nd split a file into pieces .Sh SYNOPSIS .Nm +.Op Fl a Ar suffix_length .Op Fl b Ar byte_count[k|m] .Op Fl l Ar line_count .Op Fl p Ar pattern @@ -54,6 +55,12 @@ .Pp The options are as follows: .Bl -tag -width Ds +.It Fl a +Use +.Ar suffix_length +letters to form the suffix of the file name. If +.Fl a +is not specified, two letters are used as the suffix. .It Fl b Create smaller files .Ar byte_count @@ -89,22 +96,18 @@ If a second additional argument is specified, it is used as a prefix for the names of the files into which the file is split. In this case, each file into which the file is split is named by the -prefix followed by a lexically ordered suffix in the range of -.Dq Li aa-zz . +prefix followed by a lexically ordered suffix using +.Ar suffix_length +characters in the range +.Dq Li a-z . .Pp If the .Ar name argument is not specified, the file is split into lexically ordered -files named in the range of -.Dq Li xaa-zzz . +files named with prefixes in the range of +.Dq Li x-z +and with suffixes as above. .Sh BUGS -For historical reasons, if you specify -.Ar name , -.Nm -can only create 676 separate -files. -The default naming convention allows 2028 separate files. -.Pp The maximum line length for matching patterns is 65536. .Sh SEE ALSO .Xr re_format 7 Index: split/split.c =================================================================== RCS file: /home/ncvs/src/usr.bin/split/split.c,v retrieving revision 1.8 diff -u -r1.8 split.c --- split/split.c 2001/12/12 23:09:07 1.8 +++ split/split.c 2002/01/26 05:55:46 @@ -67,6 +67,7 @@ char fname[MAXPATHLEN]; /* File name prefix. */ regex_t rgx; int pflag; +long sufflen = 2; /* File name suffix length. */ void newfile __P((void)); void split1 __P((void)); @@ -81,7 +82,7 @@ int ch; char *ep, *p; - while ((ch = getopt(argc, argv, "-0123456789b:l:p:")) != -1) + while ((ch = getopt(argc, argv, "-0123456789a:b:l:p:")) != -1) switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -106,6 +107,11 @@ usage(); ifd = 0; break; + case 'a': /* Suffix length */ + if ((sufflen = strtol(optarg, &ep, 10)) <= 0 || *ep) + err(EX_USAGE, + "%s: illegal suffix length", optarg); + break; case 'b': /* Byte count. */ if ((bytecnt = strtoq(optarg, &ep, 10)) <= 0 || (*ep != '\0' && *ep != 'k' && *ep != 'm')) @@ -145,6 +151,8 @@ if (*argv != NULL) usage(); + if (strlen(fname) + (unsigned long)sufflen >= sizeof(fname)) + err(EX_USAGE, "suffix is too long"); if (pflag && (numlines != 0 || bytecnt != 0)) usage(); @@ -273,6 +281,7 @@ void newfile() { + long i, maxfiles, tfnum; static long fnum; static int defname; static char *fpnt; @@ -288,19 +297,25 @@ } ofd = fileno(stdout); } + + /* maxfiles = 26^sufflen, but don't use libm. */ + for (maxfiles = 1, i = 0; i < sufflen; i++) + if ((maxfiles *= 26) <= 0) + errx(EX_USAGE, "suffix is too long (max %ld)", i); + /* * Hack to increase max files; original code wandered through - * magic characters. Maximum files is 3 * 26 * 26 == 2028 + * magic characters. */ -#define MAXFILES 676 - if (fnum == MAXFILES) { + if (fnum == maxfiles) { if (!defname || fname[0] == 'z') errx(EX_DATAERR, "too many files"); ++fname[0]; fnum = 0; } - fpnt[0] = fnum / 26 + 'a'; - fpnt[1] = fnum % 26 + 'a'; + for (tfnum = fnum, i = sufflen; i != 0; i--, tfnum /= 26) + fpnt[i - 1] = tfnum % 26 + 'a'; + fpnt[sufflen] = '\0'; ++fnum; if (!freopen(fname, "w", stdout)) err(EX_IOERR, "%s", fname); @@ -311,6 +326,7 @@ usage() { (void)fprintf(stderr, -"usage: split [-b byte_count] [-l line_count] [-p pattern] [file [prefix]]\n"); +"usage: split [-a sufflen] [-b byte_count] [-l line_count] [-p pattern]\n"); + (void)fprintf(stderr, "\t\t[file [prefix]]\n"); exit(EX_USAGE); } --gBBFr7Ir9EOA20Yy-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message