9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: dexen deVries <dexen.devries@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>,
	plan9port-dev@googlegroups.com
Subject: Re: [9fans] split(1): -e vs. -n, -f [patch]
Date: Mon, 30 Dec 2013 14:50:31 +0100	[thread overview]
Message-ID: <10779629.UHQpvY9d1Y@coil> (raw)
In-Reply-To: <462816165.fiyU6ZYvxS@coil>

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

On Monday 30 of December 2013 11:10:45 you wrote: 
> both behavior and code indicate that split(1)'s  `-e' (split by regular
> expression) doesn't play along with either `-n' (line count) or `-f' (output
> file prefix). the former is somewhat understandable, but the later is
> strange in lieu of `-s' (output file suffix) working just fine.
> 
> that by accident or is there some rationale?


-- 
dexen deVries

[[[↓][→]]]

[-- Attachment #2: 0001-make-stat-1-s-e-play-along-with-f-output-file-prefix.patch --]
[-- Type: text/x-patch, Size: 1146 bytes --]

>From 01ae77413e4249776124727e797b0172e7874987 Mon Sep 17 00:00:00 2001
From: dexen deVries <dexen.devries@gmail.com>
Date: Mon, 30 Dec 2013 15:47:24 +0100
Subject: [PATCH] make stat(1)'s `-e' play along with `-f' (output file
 prefix)

also make the file pathname buffer a bit larger.
---
 src/cmd/split.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/cmd/split.c b/src/cmd/split.c
index e758786..4820930 100644
--- a/src/cmd/split.c
+++ b/src/cmd/split.c
@@ -8,7 +8,7 @@ char	digit[] = "0123456789";
 char	*suffix = "";
 char	*stem = "x";
 char	suff[] = "aa";
-char	name[200];
+char	name[2048];
 Biobuf	bout;
 Biobuf	*output = &bout;

@@ -130,9 +130,11 @@ int
 matchfile(Resub *match)
 {
 	if(match[1].s.sp) {
-		int len = match[1].e.ep - match[1].s.sp;
-		strncpy(name, match[1].s.sp, len);
-		strcpy(name+len, suffix);
+		int len_match = match[1].e.ep - match[1].s.sp;
+		int len_stem = strlen(stem);
+		strcpy(name, stem);
+		strncpy(name+len_stem, match[1].s.sp, len_match);
+		strcpy(name+len_stem+len_match, suffix);
 		openf();
 		return 1;
 	}
--
1.7.12.1


  reply	other threads:[~2013-12-30 13:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-30 10:10 [9fans] split(1): -e vs. -n, -f dexen deVries
2013-12-30 13:50 ` dexen deVries [this message]
2013-12-30 16:12 ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10779629.UHQpvY9d1Y@coil \
    --to=dexen.devries@gmail.com \
    --cc=9fans@9fans.net \
    --cc=plan9port-dev@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).