From nobody@FreeBSD.org  Sat Sep  8 23:29:13 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D6D4116A41A
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  8 Sep 2007 23:29:13 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 9E3EA13C45A
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  8 Sep 2007 23:29:13 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l88NTDYb049764
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 8 Sep 2007 23:29:13 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l88NTDFF049763;
	Sat, 8 Sep 2007 23:29:13 GMT
	(envelope-from nobody)
Message-Id: <200709082329.l88NTDFF049763@www.freebsd.org>
Date: Sat, 8 Sep 2007 23:29:13 GMT
From: Marcin Gryszkalis <mg@fork.pl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] decimal suffix in split
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         116209
>Category:       bin
>Synopsis:       [patch] [request] decimal suffix in split(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    eadler
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 08 23:30:01 GMT 2007
>Closed-Date:    Thu Jun 13 21:12:49 UTC 2013
>Last-Modified:  Thu Jun 13 21:12:49 UTC 2013
>Originator:     Marcin Gryszkalis
>Release:        FreeBSD 6.2-RELEASE i386
>Organization:
>Environment:
FreeBSD smb.obligo.pl 6.2-RELEASE-p4 FreeBSD 6.2-RELEASE-p4 #1: Mon Apr 30 19:49:09 CEST 2007     root@smb.obligo.pl:/aux/obj/aux/src/sys/MGKERNEL  i386
>Description:
This is patch that adds -d flag to use decimal suffixes (00, 01, 02...)
instead of traditional (aa, ab). Makes split [more] compatible with GNU
split.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- split.c	Sun Jul 11 16:44:23 2004
+++ split.c.new	Sun Sep  9 01:08:21 2007
@@ -71,6 +71,7 @@
 char	 fname[MAXPATHLEN];		/* File name prefix. */
 regex_t	 rgx;
 int	 pflag;
+int	 dflag;
 long	 sufflen = 2;			/* File name suffix length. */
 
 void newfile(void);
@@ -88,7 +89,7 @@
 
 	setlocale(LC_ALL, "");
 
-	while ((ch = getopt(argc, argv, "-0123456789a:b:l:p:")) != -1)
+	while ((ch = getopt(argc, argv, "-0123456789a:b:l:p:d")) != -1)
 		switch (ch) {
 		case '0': case '1': case '2': case '3': case '4':
 		case '5': case '6': case '7': case '8': case '9':
@@ -147,6 +148,9 @@
 				errx(EX_USAGE,
 				    "%s: illegal line count", optarg);
 			break;
+        case 'd': /* decimal suffix */
+            dflag = 1;
+            break;
 		default:
 			usage();
 		}
@@ -301,6 +305,8 @@
 	static long fnum;
 	static int defname;
 	static char *fpnt;
+    char beg, end;
+    int pattlen;
 
 	if (ofd == -1) {
 		if (fname[0] == '\0') {
@@ -314,9 +320,19 @@
 		ofd = fileno(stdout);
 	}
 
+    if (dflag) { 
+        beg = '0'; 
+        end = '9';
+    } else {
+        beg = 'a';
+        end = 'z';
+    }
+
+    pattlen = end - beg + 1;
+
 	/* maxfiles = 26^sufflen, but don't use libm. */
 	for (maxfiles = 1, i = 0; i < sufflen; i++)
-		if ((maxfiles *= 26) <= 0)
+		if ((maxfiles *= pattlen) <= 0)
 			errx(EX_USAGE, "suffix is too long (max %ld)", i);
 
 	/*
@@ -324,7 +340,7 @@
 	 * magic characters.
 	 */
 	if (fnum == maxfiles) {
-		if (!defname || fname[0] == 'z')
+		if (!defname || fname[0] == end)
 			errx(EX_DATAERR, "too many files");
 		++fname[0];
 		fnum = 0;
@@ -334,8 +350,8 @@
 	tfnum = fnum;
 	i = sufflen - 1;
 	do {
-		fpnt[i] = tfnum % 26 + 'a';
-		tfnum /= 26;
+		fpnt[i] = tfnum % pattlen + beg;
+		tfnum /= pattlen;
 	} while (i-- > 0);
 	fpnt[sufflen] = '\0';
 


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: eadler 
State-Changed-When: Fri May 10 04:23:21 UTC 2013 
State-Changed-Why:  
Comitted r250432 


Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Fri May 10 04:23:21 UTC 2013 
Responsible-Changed-Why:  
Comitted r250432 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116209 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/116209: commit references a PR
Date: Fri, 10 May 2013 04:23:16 +0000 (UTC)

 Author: eadler
 Date: Fri May 10 04:23:03 2013
 New Revision: 250432
 URL: http://svnweb.freebsd.org/changeset/base/250432
 
 Log:
   Implement 'split -d' which allows a numeric suffix instead of an
   alphabetic one.
   
   PR:		bin/116209
   Submitted by:	Marcin Gryszkalis <mg@fork.pl> (adapted from)
   Reviewed by:	will
   MFC after:	1 week
 
 Modified:
   head/usr.bin/split/split.1
   head/usr.bin/split/split.c
 
 Modified: head/usr.bin/split/split.1
 ==============================================================================
 --- head/usr.bin/split/split.1	Fri May 10 03:49:05 2013	(r250431)
 +++ head/usr.bin/split/split.1	Fri May 10 04:23:03 2013	(r250432)
 @@ -36,10 +36,12 @@
  .Nd split a file into pieces
  .Sh SYNOPSIS
  .Nm
 +.Fl d
  .Op Fl l Ar line_count
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl b Ar byte_count Ns
  .Oo
  .Sm off
 @@ -49,10 +51,12 @@
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl n Ar chunk_count
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl p Ar pattern
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
 @@ -108,6 +112,8 @@ or
  is appended to the number, the file is split into
  .Ar byte_count
  gigabyte pieces.
 +.It Fl d
 +Use a numeric suffix instead of a alphabetic suffix.
  .It Fl l Ar line_count
  Create split files
  .Ar line_count
 
 Modified: head/usr.bin/split/split.c
 ==============================================================================
 --- head/usr.bin/split/split.c	Fri May 10 03:49:05 2013	(r250431)
 +++ head/usr.bin/split/split.c	Fri May 10 04:23:03 2013	(r250432)
 @@ -51,6 +51,7 @@ static const char sccsid[] = "@(#)split.
  #include <inttypes.h>
  #include <limits.h>
  #include <locale.h>
 +#include <stdbool.h>
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
 @@ -70,6 +71,7 @@ static char	 bfr[MAXBSIZE];		/* I/O buff
  static char	 fname[MAXPATHLEN];	/* File name prefix. */
  static regex_t	 rgx;
  static int	 pflag;
 +static bool	 dflag;
  static long	 sufflen = 2;		/* File name suffix length. */
  
  static void newfile(void);
 @@ -88,7 +90,8 @@ main(int argc, char **argv)
  
  	setlocale(LC_ALL, "");
  
 -	while ((ch = getopt(argc, argv, "0123456789a:b:l:n:p:")) != -1)
 +	dflag = false;
 +	while ((ch = getopt(argc, argv, "0123456789a:b:dl:n:p:")) != -1)
  		switch (ch) {
  		case '0': case '1': case '2': case '3': case '4':
  		case '5': case '6': case '7': case '8': case '9':
 @@ -131,6 +134,9 @@ main(int argc, char **argv)
  				errx(EX_USAGE, "%s: offset too large", optarg);
  			bytecnt = (off_t)(bytecnti * scale);
  			break;
 +		case 'd':		/* Decimal suffix */
 +			dflag = true;
 +			break;
  		case 'l':		/* Line count. */
  			if (numlines != 0)
  				usage();
 @@ -348,6 +354,8 @@ newfile(void)
  	long i, maxfiles, tfnum;
  	static long fnum;
  	static char *fpnt;
 +	char beg, end;
 +	int pattlen;
  
  	if (ofd == -1) {
  		if (fname[0] == '\0') {
 @@ -359,9 +367,19 @@ newfile(void)
  		ofd = fileno(stdout);
  	}
  
 -	/* maxfiles = 26^sufflen, but don't use libm. */
 +	if (dflag) {
 +		beg = '0';
 +		end = '9';
 +	}
 +	else {
 +		beg = 'a';
 +		end = 'z';
 +	}
 +	pattlen = end - beg + 1;
 +
 +	/* maxfiles = pattlen^sufflen, but don't use libm. */
  	for (maxfiles = 1, i = 0; i < sufflen; i++)
 -		if ((maxfiles *= 26) <= 0)
 +		if ((maxfiles *= pattlen) <= 0)
  			errx(EX_USAGE, "suffix is too long (max %ld)", i);
  
  	if (fnum == maxfiles)
 @@ -371,8 +389,8 @@ newfile(void)
  	tfnum = fnum;
  	i = sufflen - 1;
  	do {
 -		fpnt[i] = tfnum % 26 + 'a';
 -		tfnum /= 26;
 +		fpnt[i] = tfnum % pattlen + beg;
 +		tfnum /= pattlen;
  	} while (i-- > 0);
  	fpnt[sufflen] = '\0';
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/116209: commit references a PR
Date: Thu, 13 Jun 2013 21:06:41 +0000 (UTC)

 Author: eadler
 Date: Thu Jun 13 21:06:17 2013
 New Revision: 251711
 URL: http://svnweb.freebsd.org/changeset/base/251711
 
 Log:
   MFC r227183,r229905,r250432,r250451,r250882:
   
   	- Add missing static keywords to split(1)
   
   	- Fix warning when compiling with gcc46:
   	 error: variable 'defname' set but not use
   
   	- Implement 'split -d' which allows a numeric suffix instead of an
   	alphabetic one.
   
   	- Bump .Dd for recent content change.
   	Avoid signed overflow in error handling code.
   
   PR:		bin/116209
 
 Modified:
   stable/9/usr.bin/split/split.1
   stable/9/usr.bin/split/split.c
 Directory Properties:
   stable/9/usr.bin/split/   (props changed)
 
 Modified: stable/9/usr.bin/split/split.1
 ==============================================================================
 --- stable/9/usr.bin/split/split.1	Thu Jun 13 21:06:17 2013	(r251710)
 +++ stable/9/usr.bin/split/split.1	Thu Jun 13 21:06:17 2013	(r251711)
 @@ -28,7 +28,7 @@
  .\"	@(#)split.1	8.3 (Berkeley) 4/16/94
  .\" $FreeBSD$
  .\"
 -.Dd September 2, 2010
 +.Dd May 9, 2013
  .Dt SPLIT 1
  .Os
  .Sh NAME
 @@ -36,10 +36,12 @@
  .Nd split a file into pieces
  .Sh SYNOPSIS
  .Nm
 +.Fl d
  .Op Fl l Ar line_count
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl b Ar byte_count Ns
  .Oo
  .Sm off
 @@ -49,10 +51,12 @@
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl n Ar chunk_count
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl p Ar pattern
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
 @@ -108,6 +112,8 @@ or
  is appended to the number, the file is split into
  .Ar byte_count
  gigabyte pieces.
 +.It Fl d
 +Use a numeric suffix instead of a alphabetic suffix.
  .It Fl l Ar line_count
  Create split files
  .Ar line_count
 
 Modified: stable/9/usr.bin/split/split.c
 ==============================================================================
 --- stable/9/usr.bin/split/split.c	Thu Jun 13 21:06:17 2013	(r251710)
 +++ stable/9/usr.bin/split/split.c	Thu Jun 13 21:06:17 2013	(r251711)
 @@ -51,6 +51,7 @@ static const char sccsid[] = "@(#)split.
  #include <inttypes.h>
  #include <limits.h>
  #include <locale.h>
 +#include <stdbool.h>
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
 @@ -61,16 +62,17 @@ static const char sccsid[] = "@(#)split.
  
  #define DEFLINE	1000			/* Default num lines per file. */
  
 -off_t	 bytecnt;			/* Byte count to split on. */
 -off_t	 chunks = 0;			/* Chunks count to split into. */
 -long	 numlines;			/* Line count to split on. */
 -int	 file_open;			/* If a file open. */
 -int	 ifd = -1, ofd = -1;		/* Input/output file descriptors. */
 -char	 bfr[MAXBSIZE];			/* I/O buffer. */
 -char	 fname[MAXPATHLEN];		/* File name prefix. */
 -regex_t	 rgx;
 -int	 pflag;
 -long	 sufflen = 2;			/* File name suffix length. */
 +static off_t	 bytecnt;		/* Byte count to split on. */
 +static off_t	 chunks = 0;		/* Chunks count to split into. */
 +static long	 numlines;		/* Line count to split on. */
 +static int	 file_open;		/* If a file open. */
 +static int	 ifd = -1, ofd = -1;	/* Input/output file descriptors. */
 +static char	 bfr[MAXBSIZE];		/* I/O buffer. */
 +static char	 fname[MAXPATHLEN];	/* File name prefix. */
 +static regex_t	 rgx;
 +static int	 pflag;
 +static bool	 dflag;
 +static long	 sufflen = 2;		/* File name suffix length. */
  
  static void newfile(void);
  static void split1(void);
 @@ -88,7 +90,8 @@ main(int argc, char **argv)
  
  	setlocale(LC_ALL, "");
  
 -	while ((ch = getopt(argc, argv, "0123456789a:b:l:n:p:")) != -1)
 +	dflag = false;
 +	while ((ch = getopt(argc, argv, "0123456789a:b:dl:n:p:")) != -1)
  		switch (ch) {
  		case '0': case '1': case '2': case '3': case '4':
  		case '5': case '6': case '7': case '8': case '9':
 @@ -131,6 +134,9 @@ main(int argc, char **argv)
  				errx(EX_USAGE, "%s: offset too large", optarg);
  			bytecnt = (off_t)(bytecnti * scale);
  			break;
 +		case 'd':		/* Decimal suffix */
 +			dflag = true;
 +			break;
  		case 'l':		/* Line count. */
  			if (numlines != 0)
  				usage();
 @@ -348,6 +354,8 @@ newfile(void)
  	long i, maxfiles, tfnum;
  	static long fnum;
  	static char *fpnt;
 +	char beg, end;
 +	int pattlen;
  
  	if (ofd == -1) {
  		if (fname[0] == '\0') {
 @@ -359,10 +367,22 @@ newfile(void)
  		ofd = fileno(stdout);
  	}
  
 -	/* maxfiles = 26^sufflen, but don't use libm. */
 +	if (dflag) {
 +		beg = '0';
 +		end = '9';
 +	}
 +	else {
 +		beg = 'a';
 +		end = 'z';
 +	}
 +	pattlen = end - beg + 1;
 +
 +	/* maxfiles = pattlen^sufflen, but don't use libm. */
  	for (maxfiles = 1, i = 0; i < sufflen; i++)
 -		if ((maxfiles *= 26) <= 0)
 +		if (LONG_MAX / pattlen < maxfiles)
  			errx(EX_USAGE, "suffix is too long (max %ld)", i);
 +		else
 +			maxfiles *= pattlen;
  
  	if (fnum == maxfiles)
  		errx(EX_DATAERR, "too many files");
 @@ -371,8 +391,8 @@ newfile(void)
  	tfnum = fnum;
  	i = sufflen - 1;
  	do {
 -		fpnt[i] = tfnum % 26 + 'a';
 -		tfnum /= 26;
 +		fpnt[i] = tfnum % pattlen + beg;
 +		tfnum /= pattlen;
  	} while (i-- > 0);
  	fpnt[sufflen] = '\0';
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/116209: commit references a PR
Date: Thu, 13 Jun 2013 21:06:25 +0000 (UTC)

 Author: eadler
 Date: Thu Jun 13 21:06:17 2013
 New Revision: 251710
 URL: http://svnweb.freebsd.org/changeset/base/251710
 
 Log:
   MFC r227183,r229905,r250432,r250451,r250882:
   
   	- Add missing static keywords to split(1)
   
   	- Fix warning when compiling with gcc46:
   	 error: variable 'defname' set but not use
   
   	- Implement 'split -d' which allows a numeric suffix instead of an
   	alphabetic one.
   
   	- Bump .Dd for recent content change.
   	Avoid signed overflow in error handling code.
   
   PR:		bin/116209
 
 Modified:
   stable/8/usr.bin/split/split.1
   stable/8/usr.bin/split/split.c
 Directory Properties:
   stable/8/usr.bin/split/   (props changed)
 
 Modified: stable/8/usr.bin/split/split.1
 ==============================================================================
 --- stable/8/usr.bin/split/split.1	Thu Jun 13 21:05:38 2013	(r251709)
 +++ stable/8/usr.bin/split/split.1	Thu Jun 13 21:06:17 2013	(r251710)
 @@ -32,7 +32,7 @@
  .\"	@(#)split.1	8.3 (Berkeley) 4/16/94
  .\" $FreeBSD$
  .\"
 -.Dd September 2, 2010
 +.Dd May 9, 2013
  .Dt SPLIT 1
  .Os
  .Sh NAME
 @@ -40,10 +40,12 @@
  .Nd split a file into pieces
  .Sh SYNOPSIS
  .Nm
 +.Fl d
  .Op Fl l Ar line_count
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl b Ar byte_count Ns
  .Oo
  .Sm off
 @@ -53,10 +55,12 @@
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl n Ar chunk_count
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
  .Nm
 +.Fl d
  .Fl p Ar pattern
  .Op Fl a Ar suffix_length
  .Op Ar file Op Ar prefix
 @@ -112,6 +116,8 @@ or
  is appended to the number, the file is split into
  .Ar byte_count
  gigabyte pieces.
 +.It Fl d
 +Use a numeric suffix instead of a alphabetic suffix.
  .It Fl l Ar line_count
  Create split files
  .Ar line_count
 
 Modified: stable/8/usr.bin/split/split.c
 ==============================================================================
 --- stable/8/usr.bin/split/split.c	Thu Jun 13 21:05:38 2013	(r251709)
 +++ stable/8/usr.bin/split/split.c	Thu Jun 13 21:06:17 2013	(r251710)
 @@ -55,6 +55,7 @@ static const char sccsid[] = "@(#)split.
  #include <inttypes.h>
  #include <limits.h>
  #include <locale.h>
 +#include <stdbool.h>
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
 @@ -65,16 +66,17 @@ static const char sccsid[] = "@(#)split.
  
  #define DEFLINE	1000			/* Default num lines per file. */
  
 -off_t	 bytecnt;			/* Byte count to split on. */
 -off_t	 chunks = 0;			/* Chunks count to split into. */
 -long	 numlines;			/* Line count to split on. */
 -int	 file_open;			/* If a file open. */
 -int	 ifd = -1, ofd = -1;		/* Input/output file descriptors. */
 -char	 bfr[MAXBSIZE];			/* I/O buffer. */
 -char	 fname[MAXPATHLEN];		/* File name prefix. */
 -regex_t	 rgx;
 -int	 pflag;
 -long	 sufflen = 2;			/* File name suffix length. */
 +static off_t	 bytecnt;		/* Byte count to split on. */
 +static off_t	 chunks = 0;		/* Chunks count to split into. */
 +static long	 numlines;		/* Line count to split on. */
 +static int	 file_open;		/* If a file open. */
 +static int	 ifd = -1, ofd = -1;	/* Input/output file descriptors. */
 +static char	 bfr[MAXBSIZE];		/* I/O buffer. */
 +static char	 fname[MAXPATHLEN];	/* File name prefix. */
 +static regex_t	 rgx;
 +static int	 pflag;
 +static bool	 dflag;
 +static long	 sufflen = 2;		/* File name suffix length. */
  
  static void newfile(void);
  static void split1(void);
 @@ -92,7 +94,8 @@ main(int argc, char **argv)
  
  	setlocale(LC_ALL, "");
  
 -	while ((ch = getopt(argc, argv, "0123456789a:b:l:n:p:")) != -1)
 +	dflag = false;
 +	while ((ch = getopt(argc, argv, "0123456789a:b:dl:n:p:")) != -1)
  		switch (ch) {
  		case '0': case '1': case '2': case '3': case '4':
  		case '5': case '6': case '7': case '8': case '9':
 @@ -135,6 +138,9 @@ main(int argc, char **argv)
  				errx(EX_USAGE, "%s: offset too large", optarg);
  			bytecnt = (off_t)(bytecnti * scale);
  			break;
 +		case 'd':		/* Decimal suffix */
 +			dflag = true;
 +			break;
  		case 'l':		/* Line count. */
  			if (numlines != 0)
  				usage();
 @@ -352,6 +358,8 @@ newfile(void)
  	long i, maxfiles, tfnum;
  	static long fnum;
  	static char *fpnt;
 +	char beg, end;
 +	int pattlen;
  
  	if (ofd == -1) {
  		if (fname[0] == '\0') {
 @@ -363,10 +371,22 @@ newfile(void)
  		ofd = fileno(stdout);
  	}
  
 -	/* maxfiles = 26^sufflen, but don't use libm. */
 +	if (dflag) {
 +		beg = '0';
 +		end = '9';
 +	}
 +	else {
 +		beg = 'a';
 +		end = 'z';
 +	}
 +	pattlen = end - beg + 1;
 +
 +	/* maxfiles = pattlen^sufflen, but don't use libm. */
  	for (maxfiles = 1, i = 0; i < sufflen; i++)
 -		if ((maxfiles *= 26) <= 0)
 +		if (LONG_MAX / pattlen < maxfiles)
  			errx(EX_USAGE, "suffix is too long (max %ld)", i);
 +		else
 +			maxfiles *= pattlen;
  
  	if (fnum == maxfiles)
  		errx(EX_DATAERR, "too many files");
 @@ -375,8 +395,8 @@ newfile(void)
  	tfnum = fnum;
  	i = sufflen - 1;
  	do {
 -		fpnt[i] = tfnum % 26 + 'a';
 -		tfnum /= 26;
 +		fpnt[i] = tfnum % pattlen + beg;
 +		tfnum /= pattlen;
  	} while (i-- > 0);
  	fpnt[sufflen] = '\0';
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Thu Jun 13 21:12:48 UTC 2013 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=116209 
>Unformatted:
