* [PATCH] SRFI-37 bugfix
@ 2008-03-06 10:53 Ludovic Courtès
2008-03-12 17:01 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Ludovic Courtès @ 2008-03-06 10:53 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 158 bytes --]
Hi,
I'm considering the attached SRFI-37 fix that allows short names of
argument-less options to be actually used.
Stephen: OK to apply?
Thanks,
Ludovic.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: The patch --]
[-- Type: text/x-patch, Size: 2231 bytes --]
Index: srfi/srfi-37.scm
===================================================================
RCS file: /sources/guile/guile/guile-core/srfi/srfi-37.scm,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 srfi-37.scm
--- srfi/srfi-37.scm 18 Jul 2007 21:39:24 -0000 1.2.2.2
+++ srfi/srfi-37.scm 6 Mar 2008 10:50:04 -0000
@@ -1,6 +1,6 @@
;;; 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
;; modify it under the terms of the GNU Lesser General Public
@@ -151,7 +151,9 @@
;; followed by the remaining short options in (car ARGS).
(define (short-option position)
(if (>= position (string-length (car args)))
- (next-arg)
+ (begin
+ (set! args (cdr args))
+ (next-arg))
(let* ((opt-name (string-ref (car args) position))
(option-here (hash-ref lookup opt-name)))
(cond ((not option-here)
Index: test-suite/tests/srfi-37.test
===================================================================
RCS file: /sources/guile/guile/guile-core/test-suite/tests/srfi-37.test,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 srfi-37.test
--- test-suite/tests/srfi-37.test 18 Jul 2007 21:39:24 -0000 1.1.2.2
+++ test-suite/tests/srfi-37.test 6 Mar 2008 10:50:04 -0000
@@ -1,6 +1,6 @@
;;;; 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
;;;; it under the terms of the GNU General Public License as published by
@@ -94,4 +94,16 @@
(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)
+ '()))))
+
)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-12 17:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-06 10:53 [PATCH] SRFI-37 bugfix Ludovic Courtès
2008-03-12 17:01 ` Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).