Add support for Guile 2.0.

* configure.ac (GUILE_PKG): Add 2.0.
* gash/textual-ports.scm: New file.
* Makefile.am: Add it.
* gash/lexer.scm, gash/parser.scm, gash/shell.scm: Use it in place of
'(ice-9 textual-ports)'.
* tests/unit/shell.scm: Use it in place of '(ice-9 textual-ports)';
replace '(ice-9 textual-ports)' with '(rnrs io ports)' in sub-scripts;
and add a shim for 'setvbuf'.
This commit is contained in:
Timothy Sample 2019-05-16 20:58:52 -04:00
parent 9af8bb2832
commit df43ca7215
7 changed files with 63 additions and 8 deletions

View File

@ -94,6 +94,7 @@ MODULES = \
gash/script.scm \
gash/shell-utils.scm \
gash/shell.scm \
gash/textual-ports.scm \
gash/util.scm \
gash/word.scm

View File

@ -5,7 +5,7 @@ AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([color-tests silent-rules -Wall -Werror foreign])
AM_SILENT_RULES([yes])
GUILE_PKG([2.2])
GUILE_PKG([2.2 2.0])
GUILE_PROGS
AC_PATH_PROG([COMPRESS], [compress])

View File

@ -17,10 +17,10 @@
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (gash lexer)
#:use-module (gash textual-ports)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 receive)
#:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-26)

View File

@ -18,8 +18,8 @@
(define-module (gash parser)
#:use-module (gash lexer)
#:use-module (gash textual-ports)
#:use-module (ice-9 match)
#:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-41)

View File

@ -2,8 +2,8 @@
#:use-module (gash built-ins)
#:use-module (gash environment)
#:use-module (gash pattern)
#:use-module (gash textual-ports)
#:use-module (ice-9 match)
#:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (sh:and

44
gash/textual-ports.scm Normal file
View File

@ -0,0 +1,44 @@
;;; Gash -- Guile As SHell
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
;;;
;;; This file is part of Gash.
;;;
;;; Gash 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 3 of the License, or
;;; (at your option) any later version.
;;;
;;; Gash 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 Gash. If not, see <http://www.gnu.org/licenses/>.
(define-module (gash textual-ports))
;;; Commentary:
;;;
;;; This module provides is a very simple Guile 2.0 shim for
;;; '(ice-9 textual-ports)'.
;;;
;;; Code:
(cond-expand
((and guile-2 (not guile-2.2))
(use-modules (rnrs io ports))
(define (unget-char port char)
(unread-char char port))
(re-export get-char
get-line
get-string-all
lookahead-char)
(export unget-char))
(else
(use-modules (ice-9 textual-ports))
(re-export get-char
get-line
get-string-all
lookahead-char
unget-char)))

View File

@ -19,9 +19,9 @@
(define-module (test-shell)
#:use-module (gash environment)
#:use-module (gash shell)
#:use-module (gash textual-ports)
#:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (ice-9 textual-ports)
#:use-module (srfi srfi-64)
#:use-module (tests unit automake)
#:use-module (tests unit config))
@ -64,6 +64,16 @@
(delete-recursively directory)
result))
(cond-expand
((and guile-2 (not guile-2.2))
(define* (setvbuf port mode #:optional size)
(let ((mode (match mode
('none _IONBF)
('line _IOLBF)
('block _IOFBF))))
((@ (guile) setvbuf) port mode size))))
(else #f))
(define (%make-script object . forms)
(define (write-script port)
(chmod port #o755)
@ -205,7 +215,7 @@
(display "foo")
(newline)))
(make-script utility
(use-modules (ice-9 textual-ports))
(use-modules (rnrs io ports))
(with-output-to-file ,output
(lambda ()
(display (get-string-all (current-input-port))))))
@ -402,7 +412,7 @@
(make-script utility1
(display "foo\n"))
(make-script utility2
(use-modules (ice-9 textual-ports))
(use-modules (rnrs io ports))
(with-output-to-file ,foo
(lambda ()
(display (get-line (current-input-port))))))
@ -435,7 +445,7 @@
(let ((utility (string-append directory "/utility"))
(foo (string-append directory "/foo.txt")))
(make-script utility
(use-modules (ice-9 textual-ports))
(use-modules (rnrs io ports))
(with-output-to-file ,foo
(lambda ()
(display (get-line (current-input-port))))))