[Commit] nickle ChangeLog,1.28,1.29 string.5c,1.2,1.3
Bart Massey
commit at keithp.com
Sun Apr 11 02:33:28 PDT 2004
Committed by: bart
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv23268
Modified Files:
ChangeLog string.5c
Log Message:
Added split() function
Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/nickle/ChangeLog,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- a/ChangeLog 11 Apr 2004 07:02:11 -0000 1.28
+++ b/ChangeLog 11 Apr 2004 09:33:25 -0000 1.29
@@ -1,3 +1,8 @@
+2004-04-11 Bart Massey <bart at cs.pdx.edu>
+
+ * string.5c: (split):
+ Add split function ala awk.
+
2004-04-11 Keith Packard <keithp at keithp.com>
* configure.in:
Index: string.5c
===================================================================
RCS file: /local/src/CVS/nickle/string.5c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/string.5c 1 Nov 2002 20:47:51 -0000 1.2
+++ b/string.5c 11 Apr 2004 09:33:25 -0000 1.3
@@ -22,4 +22,22 @@
return (substr(name, 0, n));
}
+ public string[*] split(string s, string sep) {
+ string[...] ss = {};
+ int i = -1;
+ int j = 0;
+ while(j < length(s)) {
+ if (index(sep, new(s[j])) >= 0) {
+ ss[dim(ss)] = substr(s, i + 1, j - i - 1);
+ i = j;
+ }
+ j++;
+ }
+ if (i + 1 >= length(s))
+ ss[dim(ss)] = "";
+ else
+ ss[dim(ss)] = substr(s, i + 1, j - i - 1);
+ return ss;
+ }
+
}
More information about the Commit
mailing list