mirror of https://github.com/GNOME/gimp.git
Added strbreakup, strcat, strcmp, string-trim, string-trim-left,
2006-10-26 Kevin Cozens <kcozens@cvs.gnome.org> * plug-ins/script-fu/scripts/script-fu-compat.init: Added strbreakup, strcat, strcmp, string-trim, string-trim-left, string-trim-right, and unstrbreakup.
This commit is contained in:
parent
5c3b00190b
commit
897ed62182
|
@ -1,3 +1,9 @@
|
|||
2006-10-26 Kevin Cozens <kcozens@cvs.gnome.org>
|
||||
|
||||
* plug-ins/script-fu/scripts/script-fu-compat.init: Added strbreakup,
|
||||
strcat, strcmp, string-trim, string-trim-left, string-trim-right, and
|
||||
unstrbreakup.
|
||||
|
||||
2006-10-26 Jakub Steiner <jimmac@ximian.com>
|
||||
|
||||
* stock-display-filter-proof:
|
||||
|
@ -253,9 +259,10 @@
|
|||
|
||||
2006-10-24 Kevin Cozens <kcozens@cvs.gnome.org>
|
||||
|
||||
* plug-ins/script-fu/scheme-wrapper.c: Reworded two error messages.
|
||||
* plug-ins/script-fu/scheme-wrapper.c (marshall_proc_db_call):
|
||||
Break out of for loop before i gets updated when error was detected
|
||||
to make sure error message reports correct parameter number.
|
||||
Reworded two error messages.
|
||||
|
||||
2006-10-24 Simon Budig <simon@gimp.org>
|
||||
|
||||
|
|
|
@ -128,10 +128,92 @@
|
|||
;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))
|
||||
)
|
||||
|
||||
(if (< start end)
|
||||
(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.
|
||||
|
||||
|
@ -142,6 +224,7 @@
|
|||
(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 +313,16 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define (strcmp str1 str2)
|
||||
(if (string<? str1 str2)
|
||||
-1
|
||||
(if (string>? str1 str2)
|
||||
1
|
||||
0
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(define (trunc n)
|
||||
(inexact->exact (truncate n))
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue