guile-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile/guile-core/libguile ChangeLog strop.c str...


From: Martin Grabmueller
Subject: guile/guile-core/libguile ChangeLog strop.c str...
Date: Thu, 03 May 2001 21:59:05 -0700

CVSROOT:        /cvs
Module name:    guile
Changes by:     Martin Grabmueller <address@hidden>     01/05/03 21:59:05

Modified files:
        guile-core/libguile: ChangeLog strop.c strop.h 

Log message:
        * strop.c (scm_string_split): New procedure.
        
        * strop.h (scm_string_split): Added prototype.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/libguile/ChangeLog.diff?cvsroot=OldCVS&tr1=1.1373&tr2=1.1374&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/libguile/strop.c.diff?cvsroot=OldCVS&tr1=1.55&tr2=1.56&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/libguile/strop.h.diff?cvsroot=OldCVS&tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: guile/guile-core/libguile/ChangeLog
diff -u guile/guile-core/libguile/ChangeLog:1.1373 
guile/guile-core/libguile/ChangeLog:1.1374
--- guile/guile-core/libguile/ChangeLog:1.1373  Thu May  3 16:42:31 2001
+++ guile/guile-core/libguile/ChangeLog Thu May  3 21:59:05 2001
@@ -1,3 +1,9 @@
+2001-05-04  Martin Grabmueller  <address@hidden>
+
+       * strop.c (scm_string_split): New procedure.
+
+       * strop.h (scm_string_split): Added prototype.
+
 2001-05-04  Gary Houston  <address@hidden>
 
        * socket.c: define uint32_t if netdb.h doesn't.  thanks to
Index: guile/guile-core/libguile/strop.c
diff -u guile/guile-core/libguile/strop.c:1.55 
guile/guile-core/libguile/strop.c:1.56
--- guile/guile-core/libguile/strop.c:1.55      Tue Apr  3 06:19:04 2001
+++ guile/guile-core/libguile/strop.c   Thu May  3 21:59:05 2001
@@ -509,6 +509,55 @@
 #undef FUNC_NAME
 
 
+SCM_DEFINE (scm_string_split, "string-split", 2, 0, 0, 
+           (SCM str, SCM chr),
+           "Split the string @var{str} into the a list of the substrings 
delimited\n"
+           "by appearances of the character @var{chr}.  Note that an empty 
substring\n"
+           "between separator characters will result in an empty string in 
the\n"
+           "result list.\n"
+           "\n"
+           "@lisp\n"
+           "(string-split \"root:x:0:0:root:/root:/bin/bash\" #\:)\n"
+           "@result{}\n"
+           "(\"root\" \"x\" \"0\" \"0\" \"root\" \"/root\" \"/bin/bash\")\n"
+           "\n"
+           "(string-split \"::\" #\:)\n"
+           "@result{}\n"
+           "(\"\" \"\" \"\")\n"
+           "\n"
+           "(string-split \"\" #\:)\n"
+           "@result{}\n"
+           "(\"\")\n"
+           "@end lisp")
+#define FUNC_NAME s_scm_string_split
+{
+  int idx, last_idx;
+  char * p;
+  int ch;
+  SCM res = SCM_EOL;
+
+  SCM_VALIDATE_STRING (1, str);
+  SCM_VALIDATE_CHAR (2, chr);
+
+  idx = SCM_STRING_LENGTH (str);
+  p = SCM_STRING_CHARS (str);
+  ch = SCM_CHAR (chr);
+  while (idx >= 0)
+    {
+      last_idx = idx;
+      while (idx > 0 && p[idx - 1] != ch)
+       idx--;
+      if (idx >= 0)
+       {
+         res = scm_cons (scm_makfromstr (p + idx, last_idx - idx, 0), res);
+         idx--;
+       }
+    }
+  return res;
+}
+#undef FUNC_NAME
+
+
 SCM_DEFINE (scm_string_ci_to_symbol, "string-ci->symbol", 1, 0, 0, 
            (SCM str),
            "Return the symbol whose name is @var{str}.  @var{str} is\n"
Index: guile/guile-core/libguile/strop.h
diff -u guile/guile-core/libguile/strop.h:1.11 
guile/guile-core/libguile/strop.h:1.12
--- guile/guile-core/libguile/strop.h:1.11      Mon Jun 12 05:28:24 2000
+++ guile/guile-core/libguile/strop.h   Thu May  3 21:59:05 2001
@@ -64,6 +64,7 @@
 extern SCM scm_string_downcase (SCM v);
 extern SCM scm_string_capitalize_x (SCM v);
 extern SCM scm_string_capitalize (SCM v);
+extern SCM scm_string_split (SCM str, SCM chr);
 extern SCM scm_string_ci_to_symbol (SCM v);
 
 #define scm_substring_move_left_x scm_substring_move_x



reply via email to

[Prev in Thread] Current Thread [Next in Thread]