1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Fix SRFI-37 `args-fold' with short option names of argument-less options.

This commit is contained in:
Ludovic Courtès 2008-03-12 17:01:19 +00:00
parent bbb6fc4fc2
commit 62c5382b88
5 changed files with 34 additions and 4 deletions

7
NEWS
View file

@ -46,6 +46,12 @@ Changes in 1.8.5 (since 1.8.4)
Previously, expressions like `(match '((foo) (bar)) (((_ ...) ...) #t))' Previously, expressions like `(match '((foo) (bar)) (((_ ...) ...) #t))'
would trigger an unbound variable error for `match:andmap'. would trigger an unbound variable error for `match:andmap'.
** `(oop goops describe)' now properly provides the `describe' feature
** Fixed `args-fold' from `(srfi srfi-37)'
Previously, parsing short option names of argument-less options would
lead to a stack overflow.
** Fixed type-checking for the second argument of `eval' ** Fixed type-checking for the second argument of `eval'
** Fixed build issue for GNU/Linux on IA64 ** Fixed build issue for GNU/Linux on IA64
** Fixed build issues on NetBSD 1.6 ** Fixed build issues on NetBSD 1.6
@ -53,7 +59,6 @@ would trigger an unbound variable error for `match:andmap'.
** Fixed build issue with DEC/Compaq/HP's compiler ** Fixed build issue with DEC/Compaq/HP's compiler
** Fixed `scm_from_complex_double' build issue on FreeBSD ** Fixed `scm_from_complex_double' build issue on FreeBSD
** Fixed `alloca' build issue on FreeBSD 6 ** Fixed `alloca' build issue on FreeBSD 6
** `(oop goops describe)' now properly provides the `describe' feature
* Changes to the distribution * Changes to the distribution

View file

@ -1,3 +1,9 @@
2008-03-12 Ludovic Courtès <ludo@gnu.org>
* srfi-37.scm (args-fold)[short-option]: Set ARGS to `(cdr
args)' before calling `next-arg'. This fixes parsing of
argument-less options when using short names.
2008-01-22 Neil Jerram <neil@ossau.uklinux.net> 2008-01-22 Neil Jerram <neil@ossau.uklinux.net>
* srfi-39.scm: Update copyright statement to LGPL. * srfi-39.scm: Update copyright statement to LGPL.

View file

@ -1,6 +1,6 @@
;;; srfi-37.scm --- args-fold ;;; srfi-37.scm --- args-fold
;; Copyright (C) 2007 Free Software Foundation, Inc. ;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
;; ;;
;; This library is free software; you can redistribute it and/or ;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public ;; modify it under the terms of the GNU Lesser General Public
@ -151,7 +151,9 @@ program-arguments in ARGS, as decided by the OPTIONS'
;; followed by the remaining short options in (car ARGS). ;; followed by the remaining short options in (car ARGS).
(define (short-option position) (define (short-option position)
(if (>= position (string-length (car args))) (if (>= position (string-length (car args)))
(next-arg) (begin
(set! args (cdr args))
(next-arg))
(let* ((opt-name (string-ref (car args) position)) (let* ((opt-name (string-ref (car args) position))
(option-here (hash-ref lookup opt-name))) (option-here (hash-ref lookup opt-name)))
(cond ((not option-here) (cond ((not option-here)

View file

@ -1,3 +1,8 @@
2008-03-12 Ludovic Courtès <ludo@gnu.org>
* tests/srfi-37.test (short options without arguments): New
test.
2008-02-23 Neil Jerram <neil@ossau.uklinux.net> 2008-02-23 Neil Jerram <neil@ossau.uklinux.net>
* standalone/test-with-guile-module.c: Updated to GNU coding * standalone/test-with-guile-module.c: Updated to GNU coding

View file

@ -1,6 +1,6 @@
;;;; srfi-37.test --- Test suite for SRFI 37 -*- scheme -*- ;;;; srfi-37.test --- Test suite for SRFI 37 -*- scheme -*-
;;;; ;;;;
;;;; Copyright (C) 2007 Free Software Foundation, Inc. ;;;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
;;;; ;;;;
;;;; This program is free software; you can redistribute it and/or modify ;;;; 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 ;;;; it under the terms of the GNU General Public License as published by
@ -94,4 +94,16 @@
(lambda (opt name arg k) #f) (lambda (opt name arg k) #f)
'())))) '()))))
(pass-if "short options without arguments"
;; In Guile 1.8.4 and earlier, using short names of argument-less options
;; would lead to a stack overflow.
(let ((arg-proc (lambda (opt name arg k)
(acons name arg k))))
(equal? '((#\x . #f))
(args-fold '("-x")
(list (option '(#\x) #f #f arg-proc))
(lambda (opt name arg k) #f)
(lambda (opt name arg k) #f)
'()))))
) )