Commit e1eed0c4 authored by Kevin Cozens's avatar Kevin Cozens Committed by Kevin Cozens

Added strbreakup, strcat, strcmp, string-trim, string-trim-left,

2006-11-08  Kevin Cozens  <kcozens@cvs.gnome.org>

	* scripts/script-fu-compat.init: Added strbreakup, strcat, strcmp,
	string-trim, string-trim-left, string-trim-right, and unstrbreakup.
parent bf4b2294
2006-11-08 Kevin Cozens <kcozens@cvs.gnome.org>
* scripts/script-fu-compat.init: Added strbreakup, strcat, strcmp,
string-trim, string-trim-left, string-trim-right, and unstrbreakup.
2006-10-24 Kevin Cozens <kcozens@cvs.gnome.org>
* scripts/*.scm: Updated the scripts to bring them in-line with the
......
......@@ -128,10 +128,90 @@
;Items below this line are for compatability with Script-Fu but
;may be useful enough to keep around
(define (strbreakup str sep)
(let* (
(seplen (string-length sep))
(start 0)
(end (string-length str))
(i start)
(l)
)
(if (= seplen 0)
(set! l (list str))
(begin
(while (<= i (- end seplen))
(if (substring-equal? sep str i (+ i seplen))
(begin
(if (= start 0)
(set! l (list (substring str start i)))
(set! l (append l (list (substring str start i))))
)
(set! start (+ i seplen))
(set! i (+ i seplen -1))
)
)
(set! i (+ i 1))
)
(set! l (append l (list (substring str start end))))
)
)
l
)
)
(define (substring-equal? str str2 start end)
(string=? str (substring str2 start end))
)
(define (string-trim str)
(string-trim-right (string-trim-left str))
)
(define (string-trim-left str)
(let (
(strlen string-length str)
(i 0)
)
(while (and (< i strlen)
(char-whitespace? (string-ref str i))
)
(set! i (+ i 1))
)
(substring str i (string-length str))
)
)
(define (string-trim-right str)
(let ((i (- (string-length str) 1)))
(while (and (>= i 0)
(char-whitespace? (string-ref str i))
)
(set! i (- i 1))
)
(substring str 0 (+ i 1))
)
)
(define (unstrbreakup stringlist sep)
(let ((str (car stringlist)))
(while (not (null? stringlist))
(set! str (string-append str sep (car stringlist)))
(set! stringlist (cdr stringlist))
)
str
)
)
;Items below this line are deprecated and should not be used in new scripts.
......@@ -139,9 +219,10 @@
(define aref array-ref)
(define fopen open-input-file)
(define mapcar map)
(define nreverse reverse)
(define nil '())
(define nreverse reverse)
(define pow expt)
(define strcat string-append)
(define string-lessp string<?)
(define symbol-bound? defined?)
(define the-environment current-environment)
......@@ -230,6 +311,16 @@
)
)
(define (strcmp str1 str2)
(if (string<? str1 str2)
-1
(if (string>? str1 str2)
1
0
)
)
)
(define (trunc n)
(inexact->exact (truncate n))
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment