/usr/share/gimp/2.0/scripts/script-fu-compat.init is in gimp-data 2.8.16-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | ;The Scheme code in this file provides some compatibility with scripts that
;were originally written for use with the older SIOD based Script-Fu plug-in
;of GIMP.
;
;All items defined in this file except for the random number routines are
;deprecated. Existing scripts should be updated to avoid the use of the
;compability functions and define statements which follow the random number
;generator routines.
;
;The items marked as deprecated at the end of this file may be removed
;at some later date.
;The random number generator routines below have been slightly reformatted.
;A couple of define blocks which are not needed have been commented out.
;The original file was called rand2.scm and can be found in:
;http://www-2.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/scheme/code/math/random/
; Minimal Standard Random Number Generator
; Park & Miller, CACM 31(10), Oct 1988, 32 bit integer version.
; better constants, as proposed by Park.
; By Ozan Yigit
;(define *seed* 1)
(define (srand seed)
(set! *seed* seed)
*seed*
)
(define (msrg-rand)
(let (
(A 48271)
(M 2147483647)
(Q 44488)
(R 3399)
)
(let* (
(hi (quotient *seed* Q))
(lo (modulo *seed* Q))
(test (- (* A lo) (* R hi)))
)
(if (> test 0)
(set! *seed* test)
(set! *seed* (+ test M))
)
)
)
*seed*
)
; poker test
; seed 1
; cards 0-9 inclusive (random 10)
; five cards per hand
; 10000 hands
;
; Poker Hand Example Probability Calculated
; 5 of a kind (aaaaa) 0.0001 0
; 4 of a kind (aaaab) 0.0045 0.0053
; Full house (aaabb) 0.009 0.0093
; 3 of a kind (aaabc) 0.072 0.0682
; two pairs (aabbc) 0.108 0.1104
; Pair (aabcd) 0.504 0.501
; Bust (abcde) 0.3024 0.3058
(define (random n)
(let* (
(n (inexact->exact (truncate n)))
(M 2147483647)
(slop (modulo M n))
)
(let loop ((r (msrg-rand)))
(if (> r slop)
(modulo r n)
(loop (msrg-rand))
)
)
)
)
;(define (rngtest)
; (display "implementation ")
; (srand 1)
; (do
; ( (n 0 (+ n 1)) )
; ( (>= n 10000) )
; (msrg-rand)
; )
; (if (= *seed* 399268537)
; (display "looks correct.")
; (begin
; (display "failed.")
; (newline)
; (display " current seed ") (display *seed*)
; (newline)
; (display " correct seed 399268537")
; )
; )
; (newline)
;)
;This macro defines a while loop which is needed by some older scripts.
;This is here since it is not defined in R5RS and could be handy to have.
;This while macro was found at:
;http://www.aracnet.com/~briand/scheme_eval.html
(define-macro (while test . body)
`(let loop ()
(cond
(,test
,@body
(loop)
)
)
)
)
;The following define block(s) require the tsx extension to be loaded
(define (realtime)
(car (gettimeofday))
)
;Items below this line are for compatability with Script-Fu but
;may be useful enough to keep around
(define (delq item lis)
(let ((l '()))
(unless (null? lis)
(while (pair? lis)
(if (<> item (car lis))
(set! l (append l (list (car lis))))
)
(set! lis (cdr lis))
)
)
l
)
)
(define (make-list count fill)
(vector->list (make-vector count fill))
)
(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 (string-downcase str)
(list->string (map char-downcase (string->list str)))
)
(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 (string-upcase str)
(list->string (map char-upcase (string->list str)))
)
(define (substring-equal? str str2 start end)
(string=? str (substring str2 start end))
)
(define (unbreakupstr stringlist sep)
(let ((str (car stringlist)))
(set! stringlist (cdr 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.
(define aset vector-set!)
(define aref vector-ref)
(define fopen open-input-file)
(define mapcar map)
(define nil '())
(define nreverse reverse)
(define pow expt)
(define prin1 write)
(define (print obj . port)
(apply write obj port)
(newline)
)
(define strcat string-append)
(define string-lessp string<?)
(define symbol-bound? defined?)
(define the-environment current-environment)
(define *pi*
(* 4 (atan 1.0))
)
(define (butlast x)
(if (= (length x) 1)
'()
(reverse (cdr (reverse x)))
)
)
(define (cons-array count type)
(case type
((long) (make-vector count 0))
((short) (make-vector count 0))
((byte) (make-vector count 0))
((double) (make-vector count 0.0))
((string) (vector->list (make-vector count "")))
(else type)
)
)
(define (fmod a b)
(- a (* (truncate (/ a b)) b))
)
(define (fread arg1 file)
(define (fread-get-chars count file)
(let (
(str "")
(c 0)
)
(while (> count 0)
(set! count (- count 1))
(set! c (read-char file))
(if (eof-object? c)
(set! count 0)
(set! str (string-append str (make-string 1 c)))
)
)
(if (eof-object? c)
()
str
)
)
)
(if (number? arg1)
(begin
(set! arg1 (inexact->exact (truncate arg1)))
(fread-get-chars arg1 file)
)
(begin
(set! arg1 (fread-get-chars (string-length arg1) file))
(string-length arg1)
)
)
)
(define (last x)
(cons (car (reverse x)) '())
)
(define (nth k list)
(list-ref list k)
)
(define (prog1 form1 . form2)
(let ((a form1))
(if (not (null? form2))
form2
)
a
)
)
(define (rand . modulus)
(if (null? modulus)
(msrg-rand)
(apply random modulus)
)
)
(define (strcmp str1 str2)
(if (string<? str1 str2)
-1
(if (string>? str1 str2)
1
0
)
)
)
(define (trunc n)
(inexact->exact (truncate n))
)
(define verbose
(lambda n
(if (or (null? n) (not (number? (car n))))
0
(car n)
)
)
)
|