[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Texmacs-dev] Re: Patch: string-tokenize
From: |
Norbert Nemec |
Subject: |
[Texmacs-dev] Re: Patch: string-tokenize |
Date: |
Fri, 09 Feb 2007 13:34:10 +0100 |
User-agent: |
Thunderbird 2.0b2 (X11/20070116) |
Sorry, missed one part of the patch in the first mail. Here is the
complete version.
Norbert Nemec wrote:
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
11:09:56.000000000 +0100
+++ texmacs/TeXmacs/progs/convert/mathml/mathtm.scm 2007-02-09
11:13:28.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
11:09:56.000000000 +0100
+++ texmacs/TeXmacs/progs/kernel/library/base.scm 2007-02-09
11:13:28.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."
Index: texmacs/TeXmacs/progs/doc/docgrep.scm
===================================================================
--- texmacs.orig/TeXmacs/progs/doc/docgrep.scm 2007-02-09 11:13:28.000000000
+0100
+++ texmacs/TeXmacs/progs/doc/docgrep.scm 2007-02-09 13:01:12.000000000
+0100
@@ -46,7 +46,7 @@
`(concat (item* (concat
,(object->string (quotient (* (cdr l) 100) highest-score))
"%"))
- (hlink ,(cAr (string-tokenize (car l) #\/)) ,(car l))))
+ (hlink ,(cAr (string-tokenize-by-char (car l) #\/)) ,(car l))))
(define (make-translate . args)
(with s (apply string-append args)
@@ -54,7 +54,7 @@
(define (build-link-page keyword file-list)
(let* ((lan (get-output-language))
- (keyword-list (string-tokenize keyword #\space))
+ (keyword-list (string-tokenize-by-char keyword #\space))
(the-result (get-score-list keyword-list file-list))
;;(the-result (get-final-sorted-results keyword file-list))
(text (make-translate "No matches found for ``" keyword "''."))
@@ -91,7 +91,7 @@
(define (docgrep what path . patterns)
(let* ((l1 (map (lambda (pat) (url-collect path pat)) patterns))
(l2 (map url->string l1))
- (l3 (append-map (cut string-tokenize <> #\:) l2)))
+ (l3 (append-map (cut string-tokenize-by-char <> #\:) l2)))
(build-link-page what l3)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;