From 3b58a13b8b848679ba01ad9dfbb030cbd9d3d061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 7 Jun 2007 08:44:27 +0000 Subject: [PATCH] Changes from arch/CVS synchronization --- NEWS | 1 + doc/ref/ChangeLog | 5 +++++ doc/ref/api-control.texi | 2 +- libguile/ChangeLog | 6 ++++++ libguile/posix.c | 10 ++++++++-- test-suite/ChangeLog | 7 +++++++ test-suite/lib.scm | 3 +++ test-suite/tests/posix.test | 21 +++++++++++++++++++-- 8 files changed, 50 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 9948a0b36..6281bb4de 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,7 @@ extensions.) ** `*' returns exact 0 for "(* inexact 0)" This follows what it always did for "(* 0 inexact)". ** SRFI-19: Value returned by `(current-time time-process)' was incorrect +** `ttyname' no longer crashes when passed a non-tty argument ** Build problems on Solaris fixed ** Build problems on Mingw fixed diff --git a/doc/ref/ChangeLog b/doc/ref/ChangeLog index 53b2b620b..17b58a02a 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,8 @@ +2007-06-07 Ludovic Courtès + + * api-control.texi (Dynamic Wind): Fixed typo. Reported by + Norman Hardy. + 2007-05-16 Ludovic Courtès * posix.texi (Network Sockets and Communication): Fixed typo: diff --git a/doc/ref/api-control.texi b/doc/ref/api-control.texi index 512733cd5..ed6411f29 100644 --- a/doc/ref/api-control.texi +++ b/doc/ref/api-control.texi @@ -1164,7 +1164,7 @@ lexical variables, this will be, well, inconvenient. Therefore, Guile offers the functions @code{scm_dynwind_begin} and @code{scm_dynwind_end} to delimit a dynamic extent. Within this -dynamic extent, which is calles a @dfn{dynwind context}, you can +dynamic extent, which is called a @dfn{dynwind context}, you can perform various @dfn{dynwind actions} that control what happens when the dynwind context is entered or left. For example, you can register a cleanup routine with @code{scm_dynwind_unwind_handler} that is diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 73f1c2cff..89e93cd9f 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,9 @@ +2007-06-07 Ludovic Courtès + + * posix.c (scm_ttyname): Check whether RESULT is NULL before + making a string from it (reported by Dan McMahill). Don't call + `scm_from_locale_string ()' before the mutex is released. + 2007-03-08 Kevin Ryde * struct.c, struct.h (scm_make_vtable): New function, providing diff --git a/libguile/posix.c b/libguile/posix.c index 6de302b6f..887977cf0 100644 --- a/libguile/posix.c +++ b/libguile/posix.c @@ -834,7 +834,7 @@ SCM_DEFINE (scm_ttyname, "ttyname", 1, 0, 0, { char *result; int fd, err; - SCM ret; + SCM ret = SCM_BOOL_F; port = SCM_COERCE_OUTPORT (port); SCM_VALIDATE_OPPORT (1, port); @@ -843,9 +843,12 @@ SCM_DEFINE (scm_ttyname, "ttyname", 1, 0, 0, fd = SCM_FPORT_FDES (port); scm_i_scm_pthread_mutex_lock (&scm_i_misc_mutex); + SCM_SYSCALL (result = ttyname (fd)); err = errno; - ret = scm_from_locale_string (result); + if (result != NULL) + result = strdup (result); + scm_i_pthread_mutex_unlock (&scm_i_misc_mutex); if (!result) @@ -853,6 +856,9 @@ SCM_DEFINE (scm_ttyname, "ttyname", 1, 0, 0, errno = err; SCM_SYSERROR; } + else + ret = scm_take_locale_string (result); + return ret; } #undef FUNC_NAME diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index 4befac551..5eef6e318 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,10 @@ +2007-06-07 Ludovic Courtès + + * lib.scm (exception:system-error): New variable. + + * tests/posix.test (ttyname): New test prefix. Catches a bug + reported by Dan McMahill. + 2007-05-09 Ludovic Courtès * tests/srfi-19.test ((current-time time-tai) works): Use `time?'. diff --git a/test-suite/lib.scm b/test-suite/lib.scm index 111d470e1..2daf95c60 100644 --- a/test-suite/lib.scm +++ b/test-suite/lib.scm @@ -29,6 +29,7 @@ exception:wrong-num-args exception:wrong-type-arg exception:numerical-overflow exception:struct-set!-denied + exception:system-error exception:miscellaneous-error exception:string-contains-nul @@ -257,6 +258,8 @@ (cons 'numerical-overflow "^Numerical overflow")) (define exception:struct-set!-denied (cons 'misc-error "^set! denied for field")) +(define exception:system-error + (cons 'system-error ".*")) (define exception:miscellaneous-error (cons 'misc-error "^.*")) diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test index cd76a44ec..e93d1689f 100644 --- a/test-suite/tests/posix.test +++ b/test-suite/tests/posix.test @@ -1,6 +1,6 @@ ;;;; posix.test --- Test suite for Guile POSIX functions. -*- scheme -*- ;;;; -;;;; Copyright 2003, 2004, 2006 Free Software Foundation, Inc. +;;;; Copyright 2003, 2004, 2006, 2007 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 @@ -17,7 +17,8 @@ ;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ;;;; Boston, MA 02110-1301 USA -(use-modules (test-suite lib)) +(define-module (test-suite test-posix) + :use-module (test-suite lib)) ;; FIXME: The following exec tests are disabled since on an i386 debian with @@ -145,3 +146,19 @@ (putenv "FOO=") (unsetenv "FOO") (not (getenv "FOO")))) + +;; +;; ttyname +;; + +(with-test-prefix "ttyname" + + (pass-if-exception "non-tty argument" exception:system-error + ;; This used to crash in 1.8.1 and earlier. + (let ((file (false-if-exception + (open-output-file "/dev/null")))) + (if (not file) + (throw 'unsupported) + (ttyname file))))) + +