GNU bug report logs - #14913
csplit: add -i/--initial-value=N option

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Severity: wishlist; Reported by: Jeremy Wright <JWright@HIDDEN>; Keywords: patch; dated Fri, 19 Jul 2013 20:04:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Assaf Gordon <assafgordon@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Changed bug title to 'csplit: add -i/--initial-value=N option' from '[PATCH] :2013-07-19 Jeremy Wright <jwright@HIDDEN>' Request was from Assaf Gordon <assafgordon@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 14913 <at> debbugs.gnu.org:


Received: (at 14913) by debbugs.gnu.org; 20 Jul 2013 09:26:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 20 05:26:37 2013
Received: from localhost ([127.0.0.1]:39030 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1V0TQy-0007Vh-NA
	for submit <at> debbugs.gnu.org; Sat, 20 Jul 2013 05:26:37 -0400
Received: from mail1.vodafone.ie ([213.233.128.43]:54611)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <P@HIDDEN>) id 1V0TQw-0007VP-P9
 for 14913 <at> debbugs.gnu.org; Sat, 20 Jul 2013 05:26:35 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AiUPAIdW6lFtTTi4/2dsb2JhbAABDE2DO8EcAwGBKIMYAQEBBDIBRhALDQEKCRYPCQMCAQIBRQYNAQUCAQGIGKRWkiWPMCwzB4N+A54jjho
Received: from unknown (HELO [192.168.1.79]) ([109.77.56.184])
 by mail1.vodafone.ie with ESMTP; 20 Jul 2013 10:26:28 +0100
Message-ID: <51EA57C4.3040306@HIDDEN>
Date: Sat, 20 Jul 2013 10:26:28 +0100
From: =?ISO-8859-1?Q?P=E1draig_Brady?= <P@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:17.0) Gecko/20130110 Thunderbird/17.0.2
MIME-Version: 1.0
To: Jeremy Wright <JWright@HIDDEN>
Subject: Re: bug#14913: [PATCH] :2013-07-19 Jeremy Wright
 <jwright@HIDDEN>
References: <64D7AB922143DC4390461C102DFDD5F220383DD8@HIDDEN>
In-Reply-To: <64D7AB922143DC4390461C102DFDD5F220383DD8@HIDDEN>
X-Enigmail-Version: 1.5.1
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 14913
Cc: 14913 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

On 07/19/2013 08:56 PM, Jeremy Wright wrote:
> * src/csplit.c (make_filename): Added initial value (-i) option
> to start output file counter at a specific given value.
> ---
>  src/csplit.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/src/csplit.c b/src/csplit.c
> index 7a36e67..c97790e 100644
> --- a/src/csplit.c
> +++ b/src/csplit.c
> @@ -169,6 +169,10 @@ static bool elide_empty_files;
>  /* If true, suppress the lines that match the PATTERN */
>  static bool suppress_matched;
>  
> +/* Number to start output file name count */
> +static unsigned int initial_file_number = 0;
> +
> +
>  /* The compiled pattern arguments, which determine how to split
>     the input file. */
>  static struct control *controls;
> @@ -195,6 +199,7 @@ static struct option const longopts[] =
>    {"elide-empty-files", no_argument, NULL, 'z'},
>    {"prefix", required_argument, NULL, 'f'},
>    {"suffix-format", required_argument, NULL, 'b'},
> +  {"initial-value", required_argument, NULL, 'i'},
>    {"suppress-matched", no_argument, NULL, SUPPRESS_MATCHED_OPTION},
>    {GETOPT_HELP_OPTION_DECL},
>    {GETOPT_VERSION_OPTION_DECL},
> @@ -930,9 +935,9 @@ make_filename (unsigned int num)
>  {
>    strcpy (filename_space, prefix);
>    if (suffix)
> -    sprintf (filename_space + strlen (prefix), suffix, num);
> +    sprintf (filename_space + strlen (prefix), suffix, num+initial_file_number);
>    else
> -    sprintf (filename_space + strlen (prefix), "%0*u", digits, num);
> +    sprintf (filename_space + strlen (prefix), "%0*u", digits, num+initial_file_number);
>    return filename_space;
>  }
>  
> @@ -1349,7 +1354,7 @@ main (int argc, char **argv)
>    suppress_matched = false;
>    prefix = DEFAULT_PREFIX;
>  
> -  while ((optc = getopt_long (argc, argv, "f:b:kn:sqz", longopts, NULL)) != -1)
> +  while ((optc = getopt_long (argc, argv, "f:b:kni:sqz", longopts, NULL)) != -1)
>      switch (optc)
>        {
>        case 'f':
> @@ -1379,9 +1384,11 @@ main (int argc, char **argv)
>        case 'z':
>          elide_empty_files = true;
>          break;
> -
> -      case SUPPRESS_MATCHED_OPTION:
> -        suppress_matched = true;
> +      case 'i':
> +        if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK
> +            || MIN (INT_MAX, SIZE_MAX) < val)
> +          error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg);
> +        initial_file_number = val;
>          break;
>  
>        case_GETOPT_HELP_CHAR;
> @@ -1498,6 +1505,7 @@ and output byte counts of each piece to standard output.\n\
>    -n, --digits=DIGITS        use specified number of digits instead of 2\n\
>    -s, --quiet, --silent      do not print counts of output file sizes\n\
>    -z, --elide-empty-files    remove empty output files\n\
> +  -i, --initial-value        starting value for the output files\n\
>  "), stdout);
>        fputs (HELP_OPTION_DESCRIPTION, stdout);
>        fputs (VERSION_OPTION_DESCRIPTION, stdout);
> 

I like this, and it mirrors a recent addition to split(1):
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commit;h=d55d3dd5
Could you detail your use case for this.

thanks,
Pádraig.





Information forwarded to bug-coreutils@HIDDEN:
bug#14913; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Jul 2013 21:22:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 19 17:22:54 2013
Received: from localhost ([127.0.0.1]:38255 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1V0I8Z-0001Tx-HF
	for submit <at> debbugs.gnu.org; Fri, 19 Jul 2013 17:22:54 -0400
Received: from eggs.gnu.org ([208.118.235.92]:40002)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <CKelso@HIDDEN>) id 1V0HN1-0008Cs-Ua
 for submit <at> debbugs.gnu.org; Fri, 19 Jul 2013 16:33:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <CKelso@HIDDEN>) id 1V0HMt-0004my-SK
 for submit <at> debbugs.gnu.org; Fri, 19 Jul 2013 16:33:38 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:54787)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <CKelso@HIDDEN>) id 1V0HMt-0004mu-QN
 for submit <at> debbugs.gnu.org; Fri, 19 Jul 2013 16:33:35 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:41705)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <CKelso@HIDDEN>) id 1V0HMr-0000yk-54
 for bug-coreutils@HIDDEN; Fri, 19 Jul 2013 16:33:35 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <CKelso@HIDDEN>) id 1V0HMo-0004ko-ER
 for bug-coreutils@HIDDEN; Fri, 19 Jul 2013 16:33:33 -0400
Received: from exprod7og101.obsmtp.com ([64.18.2.155]:36955)
 by eggs.gnu.org with smtp (Exim 4.71)
 (envelope-from <CKelso@HIDDEN>) id 1V0HMn-0004kA-QZ
 for bug-coreutils@HIDDEN; Fri, 19 Jul 2013 16:33:30 -0400
Received: from mail.agjunction.com ([208.77.56.102]) by
 exprod7ob101.postini.com ([64.18.6.12]) with SMTP
 ID DSNKUemil/dyApNwdcxFHNulTOomdvrvvpWj@HIDDEN;
 Fri, 19 Jul 2013 13:33:29 PDT
Received: from CORMS1.hemi.corp.local ([fe80::9972:a72e:aa93:d4d0]) by
 COROW1.hemi.corp.local ([fe80::dd41:c533:e8df:fe9b%10]) with mapi id
 14.02.0283.003; Fri, 19 Jul 2013 13:33:27 -0700
From: Casey Kelso <CKelso@HIDDEN>
To: Jeremy Wright <JWright@HIDDEN>, "bug-coreutils@HIDDEN"
 <bug-coreutils@HIDDEN>
Subject: RE: [PATCH] :2013-07-19    Jeremy Wright   <jwright@HIDDEN>
Thread-Topic: [PATCH] :2013-07-19    Jeremy Wright   <jwright@HIDDEN>
Thread-Index: Ac6EuhqO4QdwX/ETTxG+exlsi49JHgABRfIJ
Date: Fri, 19 Jul 2013 20:33:27 +0000
Message-ID: <741D96C5C962E5469A6F6FCFA3FF4A8E20560068@HIDDEN>
References: <64D7AB922143DC4390461C102DFDD5F220383DD8@HIDDEN>
In-Reply-To: <64D7AB922143DC4390461C102DFDD5F220383DD8@HIDDEN>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [172.17.29.87]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -2.4 (--)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 19 Jul 2013 17:22:48 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Cool. Where do you store the initial seed value between boots?=0A=
=0A=
Casey Kelso=0A=
Software Manager | Ag Junction=0A=
480-348-6310 | ckelso@HIDDEN | http://www.agjunction.com=0A=
=0A=
=0A=
________________________________________=0A=
From: Jeremy Wright=0A=
Sent: Friday, July 19, 2013 12:56 PM=0A=
To: bug-coreutils@HIDDEN=0A=
Subject: [PATCH] :2013-07-19    Jeremy Wright   <jwright@HIDDEN>=0A=
=0A=
* src/csplit.c (make_filename): Added initial value (-i) option=0A=
to start output file counter at a specific given value.=0A=
---=0A=
 src/csplit.c | 20 ++++++++++++++------=0A=
 1 file changed, 14 insertions(+), 6 deletions(-)=0A=
=0A=
diff --git a/src/csplit.c b/src/csplit.c=0A=
index 7a36e67..c97790e 100644=0A=
--- a/src/csplit.c=0A=
+++ b/src/csplit.c=0A=
@@ -169,6 +169,10 @@ static bool elide_empty_files;=0A=
 /* If true, suppress the lines that match the PATTERN */=0A=
 static bool suppress_matched;=0A=
=0A=
+/* Number to start output file name count */=0A=
+static unsigned int initial_file_number =3D 0;=0A=
+=0A=
+=0A=
 /* The compiled pattern arguments, which determine how to split=0A=
    the input file. */=0A=
 static struct control *controls;=0A=
@@ -195,6 +199,7 @@ static struct option const longopts[] =3D=0A=
   {"elide-empty-files", no_argument, NULL, 'z'},=0A=
   {"prefix", required_argument, NULL, 'f'},=0A=
   {"suffix-format", required_argument, NULL, 'b'},=0A=
+  {"initial-value", required_argument, NULL, 'i'},=0A=
   {"suppress-matched", no_argument, NULL, SUPPRESS_MATCHED_OPTION},=0A=
   {GETOPT_HELP_OPTION_DECL},=0A=
   {GETOPT_VERSION_OPTION_DECL},=0A=
@@ -930,9 +935,9 @@ make_filename (unsigned int num)=0A=
 {=0A=
   strcpy (filename_space, prefix);=0A=
   if (suffix)=0A=
-    sprintf (filename_space + strlen (prefix), suffix, num);=0A=
+    sprintf (filename_space + strlen (prefix), suffix, num+initial_file_nu=
mber);=0A=
   else=0A=
-    sprintf (filename_space + strlen (prefix), "%0*u", digits, num);=0A=
+    sprintf (filename_space + strlen (prefix), "%0*u", digits, num+initial=
_file_number);=0A=
   return filename_space;=0A=
 }=0A=
=0A=
@@ -1349,7 +1354,7 @@ main (int argc, char **argv)=0A=
   suppress_matched =3D false;=0A=
   prefix =3D DEFAULT_PREFIX;=0A=
=0A=
-  while ((optc =3D getopt_long (argc, argv, "f:b:kn:sqz", longopts, NULL))=
 !=3D -1)=0A=
+  while ((optc =3D getopt_long (argc, argv, "f:b:kni:sqz", longopts, NULL)=
) !=3D -1)=0A=
     switch (optc)=0A=
       {=0A=
       case 'f':=0A=
@@ -1379,9 +1384,11 @@ main (int argc, char **argv)=0A=
       case 'z':=0A=
         elide_empty_files =3D true;=0A=
         break;=0A=
-=0A=
-      case SUPPRESS_MATCHED_OPTION:=0A=
-        suppress_matched =3D true;=0A=
+      case 'i':=0A=
+        if (xstrtoul (optarg, NULL, 10, &val, "") !=3D LONGINT_OK=0A=
+            || MIN (INT_MAX, SIZE_MAX) < val)=0A=
+          error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg);=0A=
+        initial_file_number =3D val;=0A=
         break;=0A=
=0A=
       case_GETOPT_HELP_CHAR;=0A=
@@ -1498,6 +1505,7 @@ and output byte counts of each piece to standard outp=
ut.\n\=0A=
   -n, --digits=3DDIGITS        use specified number of digits instead of 2=
\n\=0A=
   -s, --quiet, --silent      do not print counts of output file sizes\n\=
=0A=
   -z, --elide-empty-files    remove empty output files\n\=0A=
+  -i, --initial-value        starting value for the output files\n\=0A=
 "), stdout);=0A=
       fputs (HELP_OPTION_DESCRIPTION, stdout);=0A=
       fputs (VERSION_OPTION_DESCRIPTION, stdout);=0A=
--=0A=
1.8.1.2=0A=




Information forwarded to bug-coreutils@HIDDEN:
bug#14913; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Jul 2013 20:03:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 19 16:03:27 2013
Received: from localhost ([127.0.0.1]:38092 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1V0Gti-00072N-7N
	for submit <at> debbugs.gnu.org; Fri, 19 Jul 2013 16:03:27 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58224)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <JWright@HIDDEN>) id 1V0GnZ-0006gd-NQ
 for submit <at> debbugs.gnu.org; Fri, 19 Jul 2013 15:57:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <JWright@HIDDEN>) id 1V0GnR-0001wb-PF
 for submit <at> debbugs.gnu.org; Fri, 19 Jul 2013 15:57:00 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:35032)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <JWright@HIDDEN>) id 1V0GnR-0001wM-Ll
 for submit <at> debbugs.gnu.org; Fri, 19 Jul 2013 15:56:57 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59896)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <JWright@HIDDEN>) id 1V0GnN-00015K-QW
 for bug-coreutils@HIDDEN; Fri, 19 Jul 2013 15:56:57 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <JWright@HIDDEN>) id 1V0GnL-0001tu-5p
 for bug-coreutils@HIDDEN; Fri, 19 Jul 2013 15:56:53 -0400
Received: from exprod7og123.obsmtp.com ([64.18.2.24]:44093)
 by eggs.gnu.org with smtp (Exim 4.71)
 (envelope-from <JWright@HIDDEN>) id 1V0GnK-0001tS-Up
 for bug-coreutils@HIDDEN; Fri, 19 Jul 2013 15:56:51 -0400
Received: from mail.agjunction.com ([208.77.56.102]) by
 exprod7ob123.postini.com ([64.18.6.12]) with SMTP
 ID DSNKUemaAFPbc4wwKF9QHp68GJwGpZgVuU+X@HIDDEN;
 Fri, 19 Jul 2013 12:56:50 PDT
Received: from CORMS1.hemi.corp.local ([fe80::9972:a72e:aa93:d4d0]) by
 COROW1.hemi.corp.local ([fe80::dd41:c533:e8df:fe9b%10]) with mapi id
 14.02.0283.003; Fri, 19 Jul 2013 12:56:48 -0700
From: Jeremy Wright <JWright@HIDDEN>
To: "bug-coreutils@HIDDEN" <bug-coreutils@HIDDEN>
Subject: [PATCH] :2013-07-19    Jeremy Wright   <jwright@HIDDEN>
Thread-Topic: [PATCH] :2013-07-19    Jeremy Wright   <jwright@HIDDEN>
Thread-Index: Ac6EuhqO4QdwX/ETTxG+exlsi49JHg==
Date: Fri, 19 Jul 2013 19:56:48 +0000
Message-ID: <64D7AB922143DC4390461C102DFDD5F220383DD8@HIDDEN>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [172.17.29.83]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -2.4 (--)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 19 Jul 2013 16:03:24 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

* src/csplit.c (make_filename): Added initial value (-i) option
to start output file counter at a specific given value.
---
 src/csplit.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/csplit.c b/src/csplit.c
index 7a36e67..c97790e 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -169,6 +169,10 @@ static bool elide_empty_files;
 /* If true, suppress the lines that match the PATTERN */
 static bool suppress_matched;
=20
+/* Number to start output file name count */
+static unsigned int initial_file_number =3D 0;
+
+
 /* The compiled pattern arguments, which determine how to split
    the input file. */
 static struct control *controls;
@@ -195,6 +199,7 @@ static struct option const longopts[] =3D
   {"elide-empty-files", no_argument, NULL, 'z'},
   {"prefix", required_argument, NULL, 'f'},
   {"suffix-format", required_argument, NULL, 'b'},
+  {"initial-value", required_argument, NULL, 'i'},
   {"suppress-matched", no_argument, NULL, SUPPRESS_MATCHED_OPTION},
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
@@ -930,9 +935,9 @@ make_filename (unsigned int num)
 {
   strcpy (filename_space, prefix);
   if (suffix)
-    sprintf (filename_space + strlen (prefix), suffix, num);
+    sprintf (filename_space + strlen (prefix), suffix, num+initial_file_nu=
mber);
   else
-    sprintf (filename_space + strlen (prefix), "%0*u", digits, num);
+    sprintf (filename_space + strlen (prefix), "%0*u", digits, num+initial=
_file_number);
   return filename_space;
 }
=20
@@ -1349,7 +1354,7 @@ main (int argc, char **argv)
   suppress_matched =3D false;
   prefix =3D DEFAULT_PREFIX;
=20
-  while ((optc =3D getopt_long (argc, argv, "f:b:kn:sqz", longopts, NULL))=
 !=3D -1)
+  while ((optc =3D getopt_long (argc, argv, "f:b:kni:sqz", longopts, NULL)=
) !=3D -1)
     switch (optc)
       {
       case 'f':
@@ -1379,9 +1384,11 @@ main (int argc, char **argv)
       case 'z':
         elide_empty_files =3D true;
         break;
-
-      case SUPPRESS_MATCHED_OPTION:
-        suppress_matched =3D true;
+      case 'i':
+        if (xstrtoul (optarg, NULL, 10, &val, "") !=3D LONGINT_OK
+            || MIN (INT_MAX, SIZE_MAX) < val)
+          error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg);
+        initial_file_number =3D val;
         break;
=20
       case_GETOPT_HELP_CHAR;
@@ -1498,6 +1505,7 @@ and output byte counts of each piece to standard outp=
ut.\n\
   -n, --digits=3DDIGITS        use specified number of digits instead of 2=
\n\
   -s, --quiet, --silent      do not print counts of output file sizes\n\
   -z, --elide-empty-files    remove empty output files\n\
+  -i, --initial-value        starting value for the output files\n\
 "), stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
--=20
1.8.1.2




Acknowledgement sent to Jeremy Wright <JWright@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#14913; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 19 Oct 2018 01:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.