Index: doc/howto.txt ================================================================== --- doc/howto.txt +++ doc/howto.txt @@ -95,10 +95,14 @@ (s:any->number val) ii. Random string (session:make-rand-string len) + + iii. string to number for pgint + +(s:any->pgint val) ====================================================================== 9. Forms and input (s:form 'action "login.login" 'method "post" Index: doc/stml-manual.odt ================================================================== --- doc/stml-manual.odt +++ doc/stml-manual.odt cannot compute difference between binary files Index: misc-stml.scm ================================================================== --- misc-stml.scm +++ misc-stml.scm @@ -199,20 +199,21 @@ (else #f))) ;; NB// this is *illegal* pgint (define (s:illegal-pgint val) (cond - ((> n 2147483647) 1) - ((< n -2147483648) -1) + ((> val 2147483647) 1) + ((< val -2147483648) -1) (else #f))) (define (s:any->pgint val) (let ((n (s:any->number val))) (if n - (if (s:illegal-pgint val) + (if (s:illegal-pgint n) #f - n)))) + n) + n))) ;; string is a string and non-zero length (define (misc:non-zero-string str) (if (and (string? str) (> (string-length str) 0)) Index: tests/test.scm ================================================================== --- tests/test.scm +++ tests/test.scm @@ -121,10 +121,15 @@ #t)) (test "formdat: set!/get" "Yep!" (begin (formdat:set! form "blah" "Yep!") (formdat:get form "blah"))) +(test "s:string->pgint" 123 (s:any->pgint "123")) +(test "s:illegal-pgint (legal)" #f (s:illegal-pgint 1011)) +(test "s:illegal-pgint (illegal big)" 1 (s:illegal-pgint 9999999999)) +(test "s:illegalpgint (illegal small)" -1 (s:illegal-pgint -9999999999)) + ;; The twiki module ;; clean up (system "rm -rf twikis/*") (load "modules/twiki/twiki-mod.scm")