texmacs-dev
[Top][All Lists]
Advanced

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

[Texmacs-dev] Patch: string-tokenize


From: Norbert Nemec
Subject: [Texmacs-dev] Patch: string-tokenize
Date: Fri, 09 Feb 2007 11:24:28 +0100
User-agent: Thunderbird 2.0b2 (X11/20070116)

Hi there,

seems that the function string-tokenize, defined in
progs/kernel/library/base.scm collides with a guile-standard-function of
the same name. (Maybe the problem only came up with guile-1.8.1)

The attached patch fixes the problem by renaming the texmacs-specific
verstion to string-tokenize-by-char

Greetings,
Norbert
Index: texmacs/TeXmacs/progs/convert/mathml/mathtm.scm
===================================================================
--- texmacs.orig/TeXmacs/progs/convert/mathml/mathtm.scm        2007-02-09 
10:53:05.000000000 +0100
+++ texmacs/TeXmacs/progs/convert/mathml/mathtm.scm     2007-02-09 
10:59:52.000000000 +0100
@@ -135,7 +135,7 @@
 (define (mathtm-mfenced env a c)
   (let* ((open (car (or (assoc-ref a 'open) '("("))))
         (close (car (or (assoc-ref a 'close) '(")"))))
-        (seps (string-tokenize (car (or (assoc-ref a 'separators) '("")))
+        (seps (string-tokenize-by-char (car (or (assoc-ref a 'separators) 
'("")))
                                #\space)))
     (if (== seps '("")) (set! seps '()))
     (mathtm env `(m:mrow (m:mo ,open)
@@ -145,7 +145,7 @@
 (define (mathtm-menclose env a c)
   (let* ((args (mathtm-args env c))
         (notation (car (or (assoc-ref a 'notation) '(""))))
-        (l (if (== notation "") '() (string-tokenize notation #\space))))
+        (l (if (== notation "") '() (string-tokenize-by-char notation 
#\space))))
     (if (in? "updiagonalstrike" l)
        `((neg ,(mathtm-serial env args)))
        args)))
@@ -309,7 +309,7 @@
 
 (define (mathtm-row-format a)
   (cond ((func? a 'columnalign)
-        (with l (string-tokenize (cadr a) #\space)
+        (with l (string-tokenize-by-char (cadr a) #\space)
           (mathtm-row-halign l 1)))
        ((and (func? a 'rowalign) (mathtm-valign (cadr a)))
         `((cwith "1" "-1" "cell-valign" ,(mathtm-valign (cadr a)))))
@@ -345,10 +345,10 @@
 
 (define (mathtm-table-format a)
   (cond ((func? a 'columnalign)
-        (with l (string-tokenize (cadr a) #\space)
+        (with l (string-tokenize-by-char (cadr a) #\space)
           (mathtm-table-halign l 1)))
        ((func? a 'rowalign)
-        (with l (string-tokenize (cadr a) #\space)
+        (with l (string-tokenize-by-char (cadr a) #\space)
           (mathtm-table-valign l 1)))
        (else '())))
 
Index: texmacs/TeXmacs/progs/kernel/library/base.scm
===================================================================
--- texmacs.orig/TeXmacs/progs/kernel/library/base.scm  2007-02-09 
10:53:05.000000000 +0100
+++ texmacs/TeXmacs/progs/kernel/library/base.scm       2007-02-09 
10:59:52.000000000 +0100
@@ -140,27 +140,21 @@
   (map list->string
        (list-fold-right string-split-lines/kons '(()) (string->list s))))
 
-(define (string-search-separator s sep)
-  (if (char? sep)
-      (string-index s sep)
-      (with pos (string-search-forwards sep 0 s)
-       (and (>= pos 0) pos))))
-
-(provide-public (string-tokenize s sep)
+(provide-public (string-tokenize-by-char s sep)
   "Cut string @s into pieces using @sep as a separator."
-  (with d (string-search-separator s sep)
+  (with d (string-index s sep)
     (if d
        (cons (substring s 0 d)
-             (string-tokenize (substring s (+ 1 d) (string-length s)) sep))
+             (string-tokenize-by-char (substring s (+ 1 d) (string-length s)) 
sep))
        (list s))))
 
-(define-public (string-tokenize-n s sep n)
-  "As @string-tokenize, but only cut first @n pieces"
-  (with d (string-search-separator s sep)
+(define-public (string-tokenize-by-char-n s sep n)
+  "As @string-tokenize-by-char, but only cut first @n pieces"
+  (with d (string-index s sep)
     (if (or (= n 0) (not d))
        (list s)
        (cons (substring s 0 d)
-             (string-tokenize-n (substring s (+ 1 d) (string-length s))
+             (string-tokenize-by-char-n (substring s (+ 1 d) (string-length s))
                                 sep
                                 (- n 1))))))
 
@@ -173,7 +167,7 @@
 
 (define-public (string-tokenize-comma s)
   "Cut string @s into pieces using comma as a separator and remove whitespace."
-  (map string-trim-both (string-tokenize s #\,)))
+  (map string-trim-both (string-tokenize-by-char s #\,)))
 
 (define-public (string-recompose-comma l)
   "Turn list @l of strings into comma separated string."
@@ -190,7 +184,7 @@
 
 (define-public (string->alist s)
   "Parse @s of the form \"var1=val1/.../varn=valn\" as an association list."
-  (map string->property-pair (string-tokenize s "/")))
+  (map string->property-pair (string-tokenize-by-char s #\/)))
 
 (define-public (alist->string l)
   "Pretty print the association list @l as a string."


reply via email to

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