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

[[[↓][→]]]
>From 01ae77413e4249776124727e797b0172e7874987 Mon Sep 17 00:00:00 2001
From: dexen deVries <dexen.devr...@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 via email to