This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GNU Guile".
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=2f9ae9b1040e1b9339bb0bc8b0013a5346622c44 The branch, master has been updated via 2f9ae9b1040e1b9339bb0bc8b0013a5346622c44 (commit) via 922d417bf4a7c4eb7d956d340161ad6407545ae7 (commit) from 938d46a35d39ec5d7b5fa858a8783136ce24d10d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2f9ae9b1040e1b9339bb0bc8b0013a5346622c44 Merge: 922d417bf4a7c4eb7d956d340161ad6407545ae7 938d46a35d39ec5d7b5fa858a8783136ce24d10d Author: Julian Graham <jul...@transmetropolitan.(none)> Date: Tue Jun 2 09:35:02 2009 -0400 Merge branch 'master' of git://git.savannah.gnu.org/guile commit 922d417bf4a7c4eb7d956d340161ad6407545ae7 Author: Julian Graham <jul...@transmetropolitan.(none)> Date: Thu May 28 18:15:05 2009 -0400 Implementation of SRFI-98 (An interface to access environment variables). * NEWS: Add SRFI-98 to 1.8.7 features. * doc/ref/srfi-modules.text (SRFI-98): Documentation for SRFI-98. * module/srfi/srfi-98.scm: New file. SRFI-98 implementation. * test-suite/tests/srfi-98.test: New file. SRFI-98 unit tests. ----------------------------------------------------------------------- Summary of changes: NEWS | 4 ++ doc/ref/srfi-modules.texi | 20 +++++++++++ module/srfi/{srfi-6.scm => srfi-98.scm} | 29 +++++++++++----- test-suite/tests/{syncase.test => srfi-98.test} | 41 +++++++++++------------ 4 files changed, 64 insertions(+), 30 deletions(-) copy module/srfi/{srfi-6.scm => srfi-98.scm} (52%) copy test-suite/tests/{syncase.test => srfi-98.test} (51%) diff --git a/NEWS b/NEWS index 1785fe8..9aca5d9 100644 --- a/NEWS +++ b/NEWS @@ -50,6 +50,10 @@ simplifies code and reduces both the storage and run-time overhead. Changes in 1.8.7 (since 1.8.6) +* New modules (see the manual for details) + +** `(srfi srfi-98)', an interface to access environment variables + * Bugs fixed ** Fix compilation with `--disable-deprecated' diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index 1fa50b2..7c107e7 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -47,6 +47,7 @@ get the relevant SRFI documents from the SRFI home page * SRFI-61:: A more general `cond' clause * SRFI-69:: Basic hash tables. * SRFI-88:: Keyword objects. +* SRFI-98:: Accessing environment variables. @end menu @@ -3608,6 +3609,25 @@ Return the keyword object whose name is @var{str}. @end example @end deffn +...@node SRFI-98 +...@subsection SRFI-98 Accessing environment variables. +...@cindex SRFI-98 +...@cindex environment variables + +This is a portable wrapper around Guile's built-in support for +interacting with the current environment, @xref{Runtime Environment}. + +...@deffn {Scheme Procedure} get-environment-variable name +Returns a string containing the value of the environment variable +given by the string @code{name}, or @code{#f} if the named +environment variable is not found. This is equivalent to +...@code{(getenv name)}. +...@end deffn + +...@deffn {Scheme Procedure} get-environment-variables +Returns the names and values of all the environment variables as an +association list in which both the keys and the values are strings. +...@end deffn @c srfi-modules.texi ends here diff --git a/module/srfi/srfi-6.scm b/module/srfi/srfi-98.scm similarity index 52% copy from module/srfi/srfi-6.scm copy to module/srfi/srfi-98.scm index 1e455bb..924a205 100644 --- a/module/srfi/srfi-6.scm +++ b/module/srfi/srfi-98.scm @@ -1,6 +1,6 @@ -;;; srfi-6.scm --- Basic String Ports +;;; srfi-98.scm --- An interface to access environment variables -;; Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. +;; Copyright (C) 2009 Free Software Foundation, Inc. ;; ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public @@ -16,18 +16,29 @@ ;; License along with this library; if not, write to the Free Software ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;; Author: Julian Graham <julian.gra...@aya.yale.edu> +;;; Date: 2009-05-26 + ;;; Commentary: +;; This is an implementation of SRFI-98 (An interface to access environment +;; variables). +;; ;; This module is fully documented in the Guile Reference Manual. ;;; Code: -(define-module (srfi srfi-6) - #:re-export (open-input-string open-output-string get-output-string)) - -;; Currently, guile provides these functions by default, so no action -;; is needed, and this file is just a placeholder. +(define-module (srfi srfi-98) + :use-module (srfi srfi-1) + :export (get-environment-variable + get-environment-variables)) -(cond-expand-provide (current-module) '(srfi-6)) +(cond-expand-provide (current-module) '(srfi-98)) -;;; srfi-6.scm ends here +(define get-environment-variable getenv) +(define (get-environment-variables) + (define (string->alist-entry str) + (let ((pvt (string-index str #\=)) + (len (string-length str))) + (and pvt (cons (substring str 0 pvt) (substring str (+ pvt 1) len))))) + (filter-map string->alist-entry (environ))) diff --git a/test-suite/tests/syncase.test b/test-suite/tests/srfi-98.test similarity index 51% copy from test-suite/tests/syncase.test copy to test-suite/tests/srfi-98.test index c681fc3..3fbb1ef 100644 --- a/test-suite/tests/syncase.test +++ b/test-suite/tests/srfi-98.test @@ -1,39 +1,38 @@ -;;;; syncase.test --- test suite for (ice-9 syncase) -*- scheme -*- +;;;; srfi-98.test --- Test suite for Guile's SRFI-98 functions. -*- scheme -*- +;;;; +;;;; Copyright 2009 Free Software Foundation, Inc. ;;;; -;;;; Copyright (C) 2001, 2006 Free Software Foundation, Inc. -;;;; ;;;; This program is free software; you can redistribute it and/or modify ;;;; it under the terms of the GNU General Public License as published by ;;;; the Free Software Foundation; either version 2, or (at your option) ;;;; any later version. -;;;; +;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU General Public License for more details. -;;;; +;;;; ;;;; You should have received a copy of the GNU General Public License ;;;; along with this software; see the file COPYING. If not, write to ;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;;;; Boston, MA 02110-1301 USA -;; These tests are in a module so that the syntax transformer does not -;; affect code outside of this file. -;; -(define-module (test-suite test-syncase) - :use-module (test-suite lib)) +(define-module (test-srfi-98) + #:use-module (srfi srfi-98) + #:use-module (test-suite lib)) + +(with-test-prefix "get-environment-variable" + (pass-if "get-environment-variable retrieves binding" + (putenv "foo=bar") + (equal? (get-environment-variable "foo") "bar")) -(pass-if "(ice-9 syncase) loads" - (false-if-exception - (begin (eval '(use-syntax (ice-9 syncase)) (current-module)) - #t))) + (pass-if "get-environment-variable #f on unbound name" + (unsetenv "foo") + (not (get-environment-variable "foo")))) -(define-syntax plus - (syntax-rules () - ((plus x ...) (+ x ...)))) +(with-test-prefix "get-environment-variables" -(pass-if "basic syncase macro" - (= (plus 1 2 3) (+ 1 2 3))) + (pass-if "get-environment-variables contains binding" + (putenv "foo=bar") + (equal? (assoc-ref (get-environment-variables) "foo") "bar"))) -(pass-if "@ works with syncase" - (eq? run-test (@ (test-suite lib) run-test))) hooks/post-receive -- GNU Guile