diff options
-rw-r--r-- | gr-run-waveform/guile/cat.scm | 12 | ||||
-rw-r--r-- | gr-run-waveform/guile/readline.scm | 3 | ||||
-rw-r--r-- | gr-run-waveform/guile/simple.scm | 22 |
3 files changed, 37 insertions, 0 deletions
diff --git a/gr-run-waveform/guile/cat.scm b/gr-run-waveform/guile/cat.scm new file mode 100644 index 000000000..575f1f508 --- /dev/null +++ b/gr-run-waveform/guile/cat.scm @@ -0,0 +1,12 @@ +;;; This is non-idiomatic, but will exercise the port... +(define (cat input-port) + (let loop ((ch (read-char input-port))) + (if (not (eof-object? ch)) + (begin + (write-char ch (current-output-port)) + (loop (read-char input-port)))))) + +;; # Then start guile and use it +;; guile> (load "/tmp/cat.scm") +;; guile> (cat (open-file "/etc/passwd" "r")) + diff --git a/gr-run-waveform/guile/readline.scm b/gr-run-waveform/guile/readline.scm new file mode 100644 index 000000000..badfa92ae --- /dev/null +++ b/gr-run-waveform/guile/readline.scm @@ -0,0 +1,3 @@ +(use-modules (ice-9 readline)) +(activate-readline) +(read-char) diff --git a/gr-run-waveform/guile/simple.scm b/gr-run-waveform/guile/simple.scm new file mode 100644 index 000000000..af7637be1 --- /dev/null +++ b/gr-run-waveform/guile/simple.scm @@ -0,0 +1,22 @@ +(define filename "ice-9/boot-9") + +;; System default path +(define path %load-path) +path +;; +(define path-with-xyzzy (cons "/-xyzzy-" path)) +path-with-xyzzy +;; +;; look for .scm or no extension +(define extensions '(".scm" "")) + +;; Both of these return "/usr/share/guile/1.8/ice-9/boot-9.scm" +(define result1 (search-path path filename extensions)) + +(define result2 (search-path path-with-xyzzy filename extensions)) + +;; Should return "/usr/share/guile/1.8/ice-9/boot-9.scm" +(define result3 (xyzzy-search-path path filename extensions)) + +;; Should return "/-xyzzy-/ice-9/boot-9.scm" +(define result4 (xyzzy-search-path path-with-xyzzy filename extensions)) |