From 8e76ce94a28c02324aa13de835b1e55282b8b760 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Wed, 13 Apr 2011 12:03:50 +0200
Subject: [PATCH 01/48] --disable-threads fix
* libguile/threads.c (do_thread_exit_trampoline, on_thread_exit):
(scm_i_init_thread_for_guile): Only register and unregister threads
with bdw-gc when we are building with threads support. Thanks to
Marijn for the report.
---
libguile/threads.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libguile/threads.c b/libguile/threads.c
index 14bda1d2f..66869e7c3 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -661,7 +661,9 @@ static void *
do_thread_exit_trampoline (struct GC_stack_base *sb, void *v)
{
/* Won't hurt if we are already registered. */
+#if SCM_USE_PTHREAD_THREADS
GC_register_my_thread (sb);
+#endif
return scm_with_guile (do_thread_exit, v);
}
@@ -720,7 +722,7 @@ on_thread_exit (void *v)
scm_i_pthread_setspecific (scm_i_thread_key, NULL);
-#if !SCM_USE_NULL_THREADS
+#if SCM_USE_PTHREAD_THREADS
GC_unregister_my_thread ();
#endif
}
@@ -774,7 +776,7 @@ scm_i_init_thread_for_guile (struct GC_stack_base *base, SCM parent)
*/
scm_i_init_guile (base);
-#ifdef HAVE_GC_ALLOW_REGISTER_THREADS
+#if defined (HAVE_GC_ALLOW_REGISTER_THREADS) && SCM_USE_PTHREAD_THREADS
/* Allow other threads to come in later. */
GC_allow_register_threads ();
#endif
@@ -789,7 +791,9 @@ scm_i_init_thread_for_guile (struct GC_stack_base *base, SCM parent)
scm_i_pthread_mutex_unlock (&scm_i_init_mutex);
/* Register this thread with libgc. */
+#if SCM_USE_PTHREAD_THREADS
GC_register_my_thread (base);
+#endif
guilify_self_1 (base);
guilify_self_2 (parent);
From 37325c9bd2c70d19a663541a4e23f7bf6f86d478 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Wed, 13 Apr 2011 12:16:00 +0200
Subject: [PATCH 02/48] revert 4a2ac0623c3dabb2c8b9d38c27b837dcb2c7fe4e
* module/ice-9/popen.scm (open-pipe*): No need to pump the pipes
guardian here, now that hooks are working again.
---
module/ice-9/popen.scm | 4 ----
1 file changed, 4 deletions(-)
diff --git a/module/ice-9/popen.scm b/module/ice-9/popen.scm
index 5445ecb6b..b3def4a1e 100644
--- a/module/ice-9/popen.scm
+++ b/module/ice-9/popen.scm
@@ -139,10 +139,6 @@ A port to the process (based on pipes) is created and returned.
@var{modes} specifies whether an input, an output or an input-output
port to the process is created: it should be the value of
@code{OPEN_READ}, @code{OPEN_WRITE} or @code{OPEN_BOTH}."
-
- ;; Until we get GC hooks working again, pump the guardian here.
- (reap-pipes)
-
(let* ((port/pid (apply open-process mode command args))
(port (car port/pid)))
(pipe-guardian port)
From 9d6a151fbd54c813194f4907220f9f2f04ff4f1c Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Wed, 13 Apr 2011 12:50:16 +0200
Subject: [PATCH 03/48] (rnrs arithmetic fixnums) fixnum? export a procedure
again
* module/rnrs/arithmetic/fixnums.scm (fixnum?): Restore this export to
be a procedure, not syntax.
(inline-fixnum?): This is what fixnum? was. Use it internally.
---
NEWS | 326 +++++++++++++++++++++++++++++
module/rnrs/arithmetic/fixnums.scm | 19 +-
2 files changed, 338 insertions(+), 7 deletions(-)
diff --git a/NEWS b/NEWS
index 206153ac4..225a4efe6 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,332 @@ Please send Guile bug reports to bug-guile@gnu.org.
Changes in 2.0.1 (since 2.0.0):
+
+
+* New modules (see the manual for details)
+
+** `(ice-9 binary-ports)', XXX
+
+* Memory leak fixes
+
+close-port leaking iconv_t
+
+weak hash table pumping
+
+* doc work
+
+goops mop
+
+* guile.m4 supports linking with rpath
+
+ * guile.m4 (GUILE_FLAGS): Also set GUILE_LIBS and GUILE_LTLIBS. Fix
+ documentation.
+
+* Add omitted exports from `(ice-9 vlist)'.
+
+ * module/ice-9/vlist.scm: Export `vhash-delq' and `vhash-delv'.
+
+* re-enable the after-gc-hook
+
+* chi-top-sequence defines macros before expanding other exps
+
+(begin
+ (define even?
+ (lambda (x)
+ (or (= x 0) (odd? (- x 1)))))
+ (define-syntax odd?
+ (syntax-rules ()
+ ((odd? x) (not (even? x)))))
+ (even? 10))
+
+* flush all input on a read error
+
+ * module/system/repl/repl.scm (flush-all-input): New helper.
+ (prompting-meta-read): Flush all input on a read error, as we could be
+ within some expression or a string or something.
+
+* repl.scm understands comments
+
+ * module/system/repl/repl.scm (read-comment, read-scheme-line-comment)
+ (read-scheme-datum-comment): New helpers.
+ (meta-reader): Take a language instead of a reader. If we have a
+ nonwhitespace char, first check to see that it's a comment, and if so,
+ read it off and loop.
+ (prompting-meta-read): Call meta-reader with the lang.
+
+* Add ,width meta-command to set screen width in debug output
+
+terminal-width by default
+
+* man page updates
+
+Mark Harig
+
+* add ice-9 eval-string
+
+Fly Evaluation in the manual
+
+* add scm_c_public_ref et al
+
+ * libguile/modules.h:
+ * libguile/modules.c (scm_public_lookup, scm_private_lookup)
+ (scm_c_public_lookup, scm_c_private_lookup, scm_public_ref)
+ (scm_private_ref, scm_c_public_ref, scm_c_private_ref)
+ (scm_public_variable, scm_private_variable, scm_c_public_variable)
+ (scm_c_private_variable): New helpers to get at variables and values
+ in modules.
+
+"Accessing Modules from C" in the manual
+
+* add scm_call_{5,6}
+
+ * doc/ref/api-evaluation.texi (Fly Evaluation): Document
+ scm_call_{5,6,n}.
+
+* Add scm_from_latin1_keyword and scm_from_utf8_keyword
+
+ * doc/ref/api-data.texi: Document new functions. Remind users that
+ scm_from_locale_keyword should not be used when the name is a C string
+ constant. Change formal parameter from `str' to `name'.
+
+* srfi-9 define-record-type in nested contexts
+
+* Add `get-string-n' and `get-string-n!' for binary and R6RS ports
+
+* rnrs io ports work
+
+Export `current-input-port', `current-output-port' and
+`current-error-port'.
+
+ Enhance transcoder-related functionality of `(rnrs io ports)'
+
+ * module/rnrs/io/ports.scm (transcoder-eol-style)
+ (transcoder-error-handling-mode): Export these.
+ (textual-port?): Implement this procedure and export it.
+ * module/rnrs.scm: Export these here as well.
+
+ * module/rnrs/io/ports.scm (port-transcoder): Implement this procedure.
+ (binary-port?): Treat only ports without an encoding as binary ports,
+ add docstring.
+ (standard-input-port, standard-output-port, standard-error-port):
+ Ensure these are created without an encoding.
+ (eol-style): Add `none' as enumeration member.
+ (native-eol-style): Switch to `none' from `lf'.
+
+ * test-suite/tests/r6rs-ports.test (7.2.7 Input ports)
+ (8.2.10 Output ports): Test binary-ness of `standard-input-port',
+ `standard-output-port' and `standard-error-port'.
+ (8.2.6 Input and output ports): Add test for `port-transcoder'.
+
+ doc: Remove "lack of support for Unicode I/O and strings".
+
+ * doc/ref/api-io.texi (R6RS I/O Ports): Remove 1.8ish comment.
+
+* add pointer->scm, scm->pointer
+
+ * libguile/foreign.c (scm_pointer_to_scm, scm_scm_to_pointer): New
+ functions, useful to pass and receive SCM values to and from foreign
+ functions.
+
+ * module/system/foreign.scm: Export the new functions.
+
+ * doc/ref/api-foreign.texi (Foreign Variables): Add docs.
+
+* gc-stats update
+
+add heap-allocated-since-gc; fix ,stat.
+
+* allow ,option on-error report instead of debug
+
+"System Commands" in the manual.
+
+* Make VM string literals immutable.
+
+* don't redirect pthread_create et al
+
+ * libguile/bdw-gc.h: Don't do pthread redirects, because we don't want
+ to affect applications' pthread_* bindings.
+
+ * libguile/pthread-threads.h (scm_i_pthread_create)
+ (scm_i_pthread_detach, scm_i_pthread_exit, scm_i_pthread_cancel)
+ (scm_i_pthread_sigmask): Do pthread redirects here, in this internal
+ header.
+
+* Document SRFI-23
+
+ * doc/ref/srfi-modules.texi: mention that we support SRFI 23
+ * module/ice-9/boot-9.scm (%cond-expand-features): add srfi-23
+
+* with-continuation-barrier calls exit(3) _after_ unwinding
+
+ * libguile/continuations.c (scm_handler, c_handler)
+ (scm_c_with_continuation_barrier, scm_with_continuation_barrier):
+ Instead of calling scm_handle_by_message_noexit in the pre-unwind
+ handler, roll our own exception printing in the pre-unwind, and do to
+ exit()-on-quit in the post-unwind handler. This lets the stack unwind
+ at exit-time so that pending dynwinds run.
+
+ * test-suite/tests/continuations.test ("continuations"): Add a test.
+
+* string->pointer and pointer->string have optional encoding arg
+
+"Void Pointers and Byte Access" in the manual.
+
+* Several optimizations for R6RS fixnum arithmetic
+
+* Move `define-inlinable' into the default namespace
+
+ * module/ice-9/boot-9.scm (define-inlineable): Moved here from SRFI-9.
+ * module/srfi/srfi-9 (define-inlinable): Removed here.
+
+ * doc/ref/api-procedures.texi (Inlinable Procedures): Add subsection
+ about `define-inlinable'.
+
+* Implement R6RS' `fixnum?' in a smarter way
+
+ * module/rnrs/arithmetic/fixnums.scm (fixnum?): Implemented using
+ bit-twiddling, and using `define-inlinable'.
+
+commit 882c89636a2a4afa26cff17c7cdbc1d8c1cb2745
+Author: Mark H Weaver
+Date: Wed Apr 6 15:09:42 2011 -0400
+
+ Fix the R6RS exact-integer-sqrt and import into core guile
+
+ * libguile/numbers.c (scm_exact_integer_sqrt): New C procedure to
+ compute exact integer square root and remainder.
+ (scm_i_exact_integer_sqrt): New Scheme procedure `exact-integer-sqrt'
+ from the R6RS, imported into core guile.
+
+ * libguile/numbers.h: Add prototypes.
+
+ * module/rnrs/base.scm: Remove broken stub implementation, which would
+ fail badly when applied to large integers.
+
+ * doc/ref/api-data.texi: Add documentation.
+
+ * doc/ref/r6rs.texi: Change documentation for `exact-integer-sqrt' to a
+ stub that xrefs the core docs, as is done for other operations
+ available in core.
+
+ * test-suite/tests/numbers.test: Add tests.
+
+ * NEWS: Add news entries.
+
+commit adf43b3f081878860ed1d4d5091b9a432b44da90
+Author: Andy Wingo
+Date: Mon Apr 11 10:13:48 2011 +0200
+
+ ignore SIGPIPE in (system repl server)
+
+ * module/system/repl/server.scm (run-server): Ignore SIGPIPE when we run
+ a server, as otherwise a rudely disconnected client could cause the
+ server to quit. Thanks to John Proctor for the report, and Detlev
+ Zundel for the debugging.
+
+commit 15671c6e7fd86160b415b5373b2c1539e23556f3
+Author: Andy Wingo
+Date: Mon Apr 11 11:52:35 2011 +0200
+
+ refactor scm_i_print_symbol_name
+
+ * libguile/print.c (symbol_has_extended_read_syntax)
+ (print_normal_symbol, print_extended_symbol, scm_i_print_symbol_name):
+ Factor scm_i_print_symbol_name into separate routines. Add comments.
+ There are a number of bugs here.
+
+commit d9527cfafdad1046770437a7a59d3745e7243c67
+Author: Andy Wingo
+Date: Mon Apr 11 12:48:06 2011 +0200
+
+ read-extended-symbol handles backslash better, including r6rs hex escapes
+
+ * libguile/read.c (scm_read_extended_symbol): Interpret '\' as an escape
+ character. Due to some historical oddities we have to support '\'
+ before any character, but since we never emitted '\' in front of
+ "normal" characters like 'x' we can interpret "\x..;" to be an R6RS
+ hex escape.
+
+ * test-suite/tests/reader.test ("#{}#"): Add tests.
+
+commit 2e9fc9fc73a8157152e6b2e122ec545d96478c2a
+Author: Andy Wingo
+Date: Mon Apr 11 13:38:27 2011 +0200
+
+ symbols with odd characters print better in #{}#
+
+ * libguile/print.c (symbol_has_extended_read_syntax): Use a more
+ general, unicode-appropriate algorithm. Hopefully doesn't cause
+ any current #{}# cases to be unescaped.
+ (print_extended_symbol): Use more appropriate unicode algorithm, and
+ emit unicode hex escapes instead of our own lame escapes.
+
+ * test-suite/tests/symbols.test: Add tests.
+
+commit b9e22602bb9c7d82500e4e5612bf80e478e28b8c
+Author: Andy Wingo
+Date: Mon Apr 11 13:49:29 2011 +0200
+
+ regen psyntax-pp.scm
+
+ * module/ice-9/psyntax-pp.scm: Regenerate, to take advantage of better
+ #{}# serialization.
+
+commit 62ef23cbb828accf1f5b9622ff17775aa539d354
+Author: Andy Wingo
+Date: Mon Apr 11 17:21:20 2011 +0200
+
+ fix reader.test for --disable-deprecated
+
+ * test-suite/tests/reader.test: Fix deprecated tests; begin-deprecated
+ was splicing in expression context before, which is a no-no.
+
+commit cf9d4a82146556ff45d40d6eec8579082287900e
+Author: Ian Price
+Date: Wed Apr 6 01:53:38 2011 +0100
+
+ Added optional second arg to R6RS log function
+
+ * module/rnrs/base.scm (log): now takes a base argument, using the
+ change of base formula for logs.
+ * test-suite/tests/r6rs-base.test ("log (2nd arg)"): Add test cases.
+
+commit 15993bce1cd0a2e69f11a6ac1725fa7a219c5b7c
+Author: Ian Price
+Date: Wed Apr 6 13:51:44 2011 +0100
+
+ fix assert to return true value.
+
+ * module/rnrs/base.scm (assert): returns value instead of void.
+
+ * test-suite/tests/r6rs-base.test ("assert"): add test cases.
+
+commit c89b45299329d034875429804f18768c1ea96713
+Author: Ian Price
+Date: Fri Apr 8 02:49:20 2011 +0100
+
+ Fix fencepost error in bip_seek
+
+ * libguile/r6rs-ports.c (bip_seek): Fix to allow seeking to end of port.
+
+ * test-suite/tests/r6rs-ports.test ("bytevector input port can seek to
+ very end"): Add tests.
+
+commit dcb1e3b0f8c79d1373f334909fa5d653ec7674eb
+Author: Andy Wingo
+Date: Wed Apr 13 12:03:50 2011 +0200
+
+ --disable-threads fix
+
+ * libguile/threads.c (do_thread_exit_trampoline, on_thread_exit):
+ (scm_i_init_thread_for_guile): Only register and unregister threads
+ with bdw-gc when we are building with threads support. Thanks to
+ Marijn for the report.
+
+
+
+
+
* New procedures (see the manual for details)
** exact-integer-sqrt, imported into core from (rnrs base)
diff --git a/module/rnrs/arithmetic/fixnums.scm b/module/rnrs/arithmetic/fixnums.scm
index 0ce245811..e6261999a 100644
--- a/module/rnrs/arithmetic/fixnums.scm
+++ b/module/rnrs/arithmetic/fixnums.scm
@@ -102,17 +102,20 @@
(define (greatest-fixnum) most-positive-fixnum)
(define (least-fixnum) most-negative-fixnum)
- (define-inlinable (fixnum? obj)
+ (define (fixnum? obj)
+ (not (= 0 (logand 2 (object-address obj)))))
+
+ (define-inlinable (inline-fixnum? obj)
(not (= 0 (logand 2 (object-address obj)))))
(define-syntax assert-fixnum
(syntax-rules ()
((_ arg ...)
- (or (and (fixnum? arg) ...)
+ (or (and (inline-fixnum? arg) ...)
(raise (make-assertion-violation))))))
(define (assert-fixnums args)
- (or (for-all fixnum? args) (raise (make-assertion-violation))))
+ (or (for-all inline-fixnum? args) (raise (make-assertion-violation))))
(define-syntax define-fxop*
(syntax-rules ()
@@ -147,13 +150,15 @@
(define (fx+ fx1 fx2)
(assert-fixnum fx1 fx2)
(let ((r (+ fx1 fx2)))
- (or (fixnum? r) (raise (make-implementation-restriction-violation)))
+ (or (inline-fixnum? r)
+ (raise (make-implementation-restriction-violation)))
r))
(define (fx* fx1 fx2)
(assert-fixnum fx1 fx2)
(let ((r (* fx1 fx2)))
- (or (fixnum? r) (raise (make-implementation-restriction-violation)))
+ (or (inline-fixnum? r)
+ (raise (make-implementation-restriction-violation)))
r))
(define* (fx- fx1 #:optional fx2)
@@ -162,10 +167,10 @@
(begin
(assert-fixnum fx2)
(let ((r (- fx1 fx2)))
- (or (fixnum? r) (raise (make-assertion-violation)))
+ (or (inline-fixnum? r) (raise (make-assertion-violation)))
r))
(let ((r (- fx1)))
- (or (fixnum? r) (raise (make-assertion-violation)))
+ (or (inline-fixnum? r) (raise (make-assertion-violation)))
r)))
(define (fxdiv fx1 fx2)
From 7c81eba25b0ec03b2b6ab2f22d1f1b74d20691ce Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Wed, 13 Apr 2011 14:07:22 +0200
Subject: [PATCH 04/48] update NEWS
* NEWS: Update for 2.0.1.
---
NEWS | 454 ++++++++++++++++++++---------------------------------------
1 file changed, 152 insertions(+), 302 deletions(-)
diff --git a/NEWS b/NEWS
index 225a4efe6..cd12f603c 100644
--- a/NEWS
+++ b/NEWS
@@ -7,343 +7,193 @@ Please send Guile bug reports to bug-guile@gnu.org.
Changes in 2.0.1 (since 2.0.0):
+* Notable changes
-
-* New modules (see the manual for details)
-
-** `(ice-9 binary-ports)', XXX
+** guile.m4 supports linking with rpath
-* Memory leak fixes
+The GUILE_FLAGS macro now sets GUILE_LIBS and GUILE_LTLIBS, which
+include appropriate directives to the linker to include libguile-2.0.so
+in the runtime library lookup path.
-close-port leaking iconv_t
+** `begin' expands macros in its body before other expressions
-weak hash table pumping
+This enables support for programs like the following:
-* doc work
+ (begin
+ (define even?
+ (lambda (x)
+ (or (= x 0) (odd? (- x 1)))))
+ (define-syntax odd?
+ (syntax-rules ()
+ ((odd? x) (not (even? x)))))
+ (even? 10))
-goops mop
+** REPL reader usability enhancements
-* guile.m4 supports linking with rpath
+The REPL now flushes input after a read error, which should prevent one
+error from causing other errors. The REPL also now interprets comments
+as whitespace.
+
+** REPL output has configurable width
+
+The REPL now defaults to output with the current terminal's width, in
+columns. See "Debug Commands" in the manual for more information on
+the ,width command.
+
+** Better C access to the module system
+
+Guile now has convenient C accessors to look up variables or values in
+modules and their public interfaces. See `scm_c_public_ref' and friends
+in "Accessing Modules from C" in the manual.
+
+** Added `scm_call_5', `scm_call_6'
- * guile.m4 (GUILE_FLAGS): Also set GUILE_LIBS and GUILE_LTLIBS. Fix
- documentation.
+See "Fly Evaluation" in the manual.
-* Add omitted exports from `(ice-9 vlist)'.
+** Added `scm_from_latin1_keyword', `scm_from_utf8_keyword'
- * module/ice-9/vlist.scm: Export `vhash-delq' and `vhash-delv'.
+See "Keyword Procedures" in the manual, for more. Note that
+`scm_from_locale_keyword' should not be used when the name is a C string
+constant.
-* re-enable the after-gc-hook
+** R6RS unicode and string I/O work
+
+Added efficient implementations of `get-string-n' and `get-string-n!'
+for binary ports. Exported `current-input-port', `current-output-port'
+and `current-error-port' from `(rnrs io ports)', and enhanced support
+for transcoders.
+
+** Added `pointer->scm', `scm->pointer' to `(system foreign)'
-* chi-top-sequence defines macros before expanding other exps
+These procedure are useful if one needs to pass and receive SCM values
+to and from foreign functions. See "Foreign Variables" in the manual,
+for more.
-(begin
- (define even?
- (lambda (x)
- (or (= x 0) (odd? (- x 1)))))
- (define-syntax odd?
- (syntax-rules ()
- ((odd? x) (not (even? x)))))
- (even? 10))
+** Added `heap-allocated-since-gc' to `(gc-stats)'
-* flush all input on a read error
+Also fixed the long-standing bug in the REPL `,stat' command.
- * module/system/repl/repl.scm (flush-all-input): New helper.
- (prompting-meta-read): Flush all input on a read error, as we could be
- within some expression or a string or something.
-
-* repl.scm understands comments
+** Add `on-error' REPL option
- * module/system/repl/repl.scm (read-comment, read-scheme-line-comment)
- (read-scheme-datum-comment): New helpers.
- (meta-reader): Take a language instead of a reader. If we have a
- nonwhitespace char, first check to see that it's a comment, and if so,
- read it off and loop.
- (prompting-meta-read): Call meta-reader with the lang.
+This option controls what happens when an error occurs at the REPL, and
+defaults to `debug', indicating that Guile should enter the debugger.
+Other values include `report', which will simply print a backtrace
+without entering the debugger. See "System Commands" in the manual.
-* Add ,width meta-command to set screen width in debug output
+** Enforce immutability of string literals
+
+Attempting to mutate a string literal now causes a runtime error.
-terminal-width by default
+** Fix pthread redirection
-* man page updates
+Guile 2.0.0 shipped with headers that, if configured with pthread
+support, would re-define `pthread_create', `pthread_join', and other API
+to redirect to the BDW-GC wrappers, `GC_pthread_create', etc. This was
+unintended, and not necessary: because threads must enter Guile with
+scm_with_guile, Guile can handle thread registration itself, without
+needing to make the GC aware of all threads. This oversight has been
+fixed.
-Mark Harig
+** `with-continuation-barrier' now unwinds on `quit'
-* add ice-9 eval-string
+A throw to `quit' in a continuation barrier will cause Guile to exit.
+Before, it would do so before unwinding to the barrier, which would
+prevent cleanup handlers from running. This has been fixed so that it
+exits only after unwinding.
-Fly Evaluation in the manual
-
-* add scm_c_public_ref et al
+** `string->pointer' and `pointer->string' have optional encoding arg
- * libguile/modules.h:
- * libguile/modules.c (scm_public_lookup, scm_private_lookup)
- (scm_c_public_lookup, scm_c_private_lookup, scm_public_ref)
- (scm_private_ref, scm_c_public_ref, scm_c_private_ref)
- (scm_public_variable, scm_private_variable, scm_c_public_variable)
- (scm_c_private_variable): New helpers to get at variables and values
- in modules.
+This allows users of the FFI to more easily deal in strings with
+particular (non-locale) encodings, like "utf-8". See "Void Pointers and
+Byte Access" in the manual, for more.
-"Accessing Modules from C" in the manual
-
-* add scm_call_{5,6}
+** R6RS fixnum arithmetic optimizations
- * doc/ref/api-evaluation.texi (Fly Evaluation): Document
- scm_call_{5,6,n}.
+R6RS fixnum operations are are still slower than generic arithmetic,
+however.
-* Add scm_from_latin1_keyword and scm_from_utf8_keyword
+** New procedure: `define-inlinable'
- * doc/ref/api-data.texi: Document new functions. Remind users that
- scm_from_locale_keyword should not be used when the name is a C string
- constant. Change formal parameter from `str' to `name'.
+See "Inlinable Procedures" in the manual, for more.
-* srfi-9 define-record-type in nested contexts
+** New procedure: `exact-integer-sqrt'
-* Add `get-string-n' and `get-string-n!' for binary and R6RS ports
-
-* rnrs io ports work
-
-Export `current-input-port', `current-output-port' and
-`current-error-port'.
+See "Integer Operations" in the manual, for more.
- Enhance transcoder-related functionality of `(rnrs io ports)'
-
- * module/rnrs/io/ports.scm (transcoder-eol-style)
- (transcoder-error-handling-mode): Export these.
- (textual-port?): Implement this procedure and export it.
- * module/rnrs.scm: Export these here as well.
-
- * module/rnrs/io/ports.scm (port-transcoder): Implement this procedure.
- (binary-port?): Treat only ports without an encoding as binary ports,
- add docstring.
- (standard-input-port, standard-output-port, standard-error-port):
- Ensure these are created without an encoding.
- (eol-style): Add `none' as enumeration member.
- (native-eol-style): Switch to `none' from `lf'.
-
- * test-suite/tests/r6rs-ports.test (7.2.7 Input ports)
- (8.2.10 Output ports): Test binary-ness of `standard-input-port',
- `standard-output-port' and `standard-error-port'.
- (8.2.6 Input and output ports): Add test for `port-transcoder'.
-
- doc: Remove "lack of support for Unicode I/O and strings".
-
- * doc/ref/api-io.texi (R6RS I/O Ports): Remove 1.8ish comment.
+** "Extended read syntax" for symbols parses better
-* add pointer->scm, scm->pointer
+In #{foo}# symbols, backslashes are now treated as escapes, as the
+symbol-printing code intended. Additionally, "\x" within #{foo}# is now
+interpreted as starting an R6RS hex escape. This is backward compatible
+because the symbol printer would never produce a "\x" before. The
+printer also works better too.
+
+* Manual updates
+
+** GOOPS documentation updates
+
+** New man page
+
+Thanks to Mark Harig for improvements to guile.1.
+
+** SRFI-23 documented
+
+The humble `error' SRFI now has an entry in the manual.
+
+* New modules
+
+** `(ice-9 binary-ports)': XXX, in the manual
+** `(ice-9 eval-string)': "Fly Evaluation", in the manual
- * libguile/foreign.c (scm_pointer_to_scm, scm_scm_to_pointer): New
- functions, useful to pass and receive SCM values to and from foreign
- functions.
-
- * module/system/foreign.scm: Export the new functions.
-
- * doc/ref/api-foreign.texi (Foreign Variables): Add docs.
-
-* gc-stats update
-
-add heap-allocated-since-gc; fix ,stat.
-
-* allow ,option on-error report instead of debug
-
-"System Commands" in the manual.
-
-* Make VM string literals immutable.
-
-* don't redirect pthread_create et al
-
- * libguile/bdw-gc.h: Don't do pthread redirects, because we don't want
- to affect applications' pthread_* bindings.
-
- * libguile/pthread-threads.h (scm_i_pthread_create)
- (scm_i_pthread_detach, scm_i_pthread_exit, scm_i_pthread_cancel)
- (scm_i_pthread_sigmask): Do pthread redirects here, in this internal
- header.
-
-* Document SRFI-23
-
- * doc/ref/srfi-modules.texi: mention that we support SRFI 23
- * module/ice-9/boot-9.scm (%cond-expand-features): add srfi-23
-
-* with-continuation-barrier calls exit(3) _after_ unwinding
-
- * libguile/continuations.c (scm_handler, c_handler)
- (scm_c_with_continuation_barrier, scm_with_continuation_barrier):
- Instead of calling scm_handle_by_message_noexit in the pre-unwind
- handler, roll our own exception printing in the pre-unwind, and do to
- exit()-on-quit in the post-unwind handler. This lets the stack unwind
- at exit-time so that pending dynwinds run.
-
- * test-suite/tests/continuations.test ("continuations"): Add a test.
-
-* string->pointer and pointer->string have optional encoding arg
-
-"Void Pointers and Byte Access" in the manual.
-
-* Several optimizations for R6RS fixnum arithmetic
-
-* Move `define-inlinable' into the default namespace
-
- * module/ice-9/boot-9.scm (define-inlineable): Moved here from SRFI-9.
- * module/srfi/srfi-9 (define-inlinable): Removed here.
-
- * doc/ref/api-procedures.texi (Inlinable Procedures): Add subsection
- about `define-inlinable'.
-
-* Implement R6RS' `fixnum?' in a smarter way
-
- * module/rnrs/arithmetic/fixnums.scm (fixnum?): Implemented using
- bit-twiddling, and using `define-inlinable'.
-
-commit 882c89636a2a4afa26cff17c7cdbc1d8c1cb2745
-Author: Mark H Weaver
-Date: Wed Apr 6 15:09:42 2011 -0400
-
- Fix the R6RS exact-integer-sqrt and import into core guile
-
- * libguile/numbers.c (scm_exact_integer_sqrt): New C procedure to
- compute exact integer square root and remainder.
- (scm_i_exact_integer_sqrt): New Scheme procedure `exact-integer-sqrt'
- from the R6RS, imported into core guile.
-
- * libguile/numbers.h: Add prototypes.
-
- * module/rnrs/base.scm: Remove broken stub implementation, which would
- fail badly when applied to large integers.
-
- * doc/ref/api-data.texi: Add documentation.
-
- * doc/ref/r6rs.texi: Change documentation for `exact-integer-sqrt' to a
- stub that xrefs the core docs, as is done for other operations
- available in core.
-
- * test-suite/tests/numbers.test: Add tests.
-
- * NEWS: Add news entries.
-
-commit adf43b3f081878860ed1d4d5091b9a432b44da90
-Author: Andy Wingo
-Date: Mon Apr 11 10:13:48 2011 +0200
-
- ignore SIGPIPE in (system repl server)
-
- * module/system/repl/server.scm (run-server): Ignore SIGPIPE when we run
- a server, as otherwise a rudely disconnected client could cause the
- server to quit. Thanks to John Proctor for the report, and Detlev
- Zundel for the debugging.
-
-commit 15671c6e7fd86160b415b5373b2c1539e23556f3
-Author: Andy Wingo
-Date: Mon Apr 11 11:52:35 2011 +0200
-
- refactor scm_i_print_symbol_name
-
- * libguile/print.c (symbol_has_extended_read_syntax)
- (print_normal_symbol, print_extended_symbol, scm_i_print_symbol_name):
- Factor scm_i_print_symbol_name into separate routines. Add comments.
- There are a number of bugs here.
-
-commit d9527cfafdad1046770437a7a59d3745e7243c67
-Author: Andy Wingo
-Date: Mon Apr 11 12:48:06 2011 +0200
-
- read-extended-symbol handles backslash better, including r6rs hex escapes
-
- * libguile/read.c (scm_read_extended_symbol): Interpret '\' as an escape
- character. Due to some historical oddities we have to support '\'
- before any character, but since we never emitted '\' in front of
- "normal" characters like 'x' we can interpret "\x..;" to be an R6RS
- hex escape.
-
- * test-suite/tests/reader.test ("#{}#"): Add tests.
-
-commit 2e9fc9fc73a8157152e6b2e122ec545d96478c2a
-Author: Andy Wingo
-Date: Mon Apr 11 13:38:27 2011 +0200
-
- symbols with odd characters print better in #{}#
-
- * libguile/print.c (symbol_has_extended_read_syntax): Use a more
- general, unicode-appropriate algorithm. Hopefully doesn't cause
- any current #{}# cases to be unescaped.
- (print_extended_symbol): Use more appropriate unicode algorithm, and
- emit unicode hex escapes instead of our own lame escapes.
-
- * test-suite/tests/symbols.test: Add tests.
-
-commit b9e22602bb9c7d82500e4e5612bf80e478e28b8c
-Author: Andy Wingo
-Date: Mon Apr 11 13:49:29 2011 +0200
-
- regen psyntax-pp.scm
-
- * module/ice-9/psyntax-pp.scm: Regenerate, to take advantage of better
- #{}# serialization.
-
-commit 62ef23cbb828accf1f5b9622ff17775aa539d354
-Author: Andy Wingo
-Date: Mon Apr 11 17:21:20 2011 +0200
-
- fix reader.test for --disable-deprecated
-
- * test-suite/tests/reader.test: Fix deprecated tests; begin-deprecated
- was splicing in expression context before, which is a no-no.
-
-commit cf9d4a82146556ff45d40d6eec8579082287900e
-Author: Ian Price
-Date: Wed Apr 6 01:53:38 2011 +0100
-
- Added optional second arg to R6RS log function
-
- * module/rnrs/base.scm (log): now takes a base argument, using the
- change of base formula for logs.
- * test-suite/tests/r6rs-base.test ("log (2nd arg)"): Add test cases.
-
-commit 15993bce1cd0a2e69f11a6ac1725fa7a219c5b7c
-Author: Ian Price
-Date: Wed Apr 6 13:51:44 2011 +0100
-
- fix assert to return true value.
-
- * module/rnrs/base.scm (assert): returns value instead of void.
-
- * test-suite/tests/r6rs-base.test ("assert"): add test cases.
-
-commit c89b45299329d034875429804f18768c1ea96713
-Author: Ian Price
-Date: Fri Apr 8 02:49:20 2011 +0100
-
- Fix fencepost error in bip_seek
-
- * libguile/r6rs-ports.c (bip_seek): Fix to allow seeking to end of port.
-
- * test-suite/tests/r6rs-ports.test ("bytevector input port can seek to
- very end"): Add tests.
-
-commit dcb1e3b0f8c79d1373f334909fa5d653ec7674eb
-Author: Andy Wingo
-Date: Wed Apr 13 12:03:50 2011 +0200
-
- --disable-threads fix
-
- * libguile/threads.c (do_thread_exit_trampoline, on_thread_exit):
- (scm_i_init_thread_for_guile): Only register and unregister threads
- with bdw-gc when we are building with threads support. Thanks to
- Marijn for the report.
-
-
-
-
-
-* New procedures (see the manual for details)
-
-** exact-integer-sqrt, imported into core from (rnrs base)
-
* Bugs fixed
-** exact-integer-sqrt now handles large integers correctly
+** Fixed iconv_t memory leak on close-port
+** Fixed some leaks with weak hash tables
+** Export `vhash-delq' and `vhash-delv' from `(ice-9 vlist)'
+** `after-gc-hook' works again
+** `define-record-type' now allowed in nested contexts
+** `exact-integer-sqrt' now handles large integers correctly
+** Fixed C extension examples in manual
+** `vhash-delete' honors HASH argument
+** Make `locale-digit-grouping' more robust
+** Default exception printer robustness fixes
+** Fix presence of non-I CPPFLAGS in `guile-2.0.pc'
+** `read' updates line/column numbers when reading SCSH block comments
+** Fix imports of multiple custom interfaces of same module
+** Fix encoding scanning for non-seekable ports
+** Fix `setter' when called with a non-setter generic
+** Fix f32 and f64 bytevectors to not accept rationals
+** Fix description of the R6RS `finite?' in manual
+** Quotient, remainder and modulo accept inexact integers again
+** Fix `continue' within `while' to take zero arguments
+** Fix alignment for structures in FFI
+** Fix port-filename of stdin, stdout, stderr to match the docs
+** Fix weak hash table-related bug in `define-wrapped-pointer-type'
+** Fix partial continuation application with pending procedure calls
+** scm_{to,from}_locale_string use current locale, not current ports
+** Fix thread cleanup, by using a pthread_key destructor
+** Fix `quit' at the REPL
+** Fix a failure to sync regs in vm bytevector ops
+** Fix (texinfo reflection) to handle nested structures like syntax patterns
+** Fix stexi->html double translation
+** Fix tree-il->scheme fix for
+** Fix compilation of in in single-value context
+** Fix race condition in ensure-writable-dir
+** Fix error message on ,disassemble "non-procedure"
+** Fix prompt and abort with the boot evaluator
+** Fix `procedure->pointer' for functions returning `void'
+** Fix error reporting in dynamic-pointer
+** Fix problems detecting coding: in block comments
+** Fix duplicate load-path and load-compiled-path in compilation environment
+** Add fallback read(2) suppport for .go files if mmap(2) unavailable
+** Fix c32vector-set!, c64vector-set!
+** Fix mistakenly deprecated read syntax for uniform complex vectors
+** Fix parsing of exact numbers with negative exponents
+** Ignore SIGPIPE in (system repl server)
+** Fix optional second arg to R6RS log function
+** Fix R6RS `assert' to return true value.
+** Fix fencepost error when seeking in bytevector input ports
-exact-integer-sqrt now works correctly when applied to very large
-integers (too large to be precisely represented by a C double).
-It has also been imported into core from (rnrs base).
Changes in 2.0.0 (changes since the 1.8.x series):
From 56e313894bc865f2b8f4d2b79f5952f8e7b28807 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 14 Apr 2011 16:04:18 +0200
Subject: [PATCH 05/48] don't warn about non-literal fmt strings for e.g. (_
"foo")
* module/language/tree-il/analyze.scm (const-fmt, format-analysis):
Allow format strings to be gettexted, using the conventional _ name.
---
module/language/tree-il/analyze.scm | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm
index 60a5bcddd..61357f821 100644
--- a/module/language/tree-il/analyze.scm
+++ b/module/language/tree-il/analyze.scm
@@ -1343,6 +1343,27 @@ accurate information is missing from a given `tree-il' element."
min-count max-count))))
(else (error "computer bought the farm" state))))))
+;; Return the literal format pattern for X, or #f.
+(define (const-fmt x)
+ (record-case x
+ (( exp)
+ ;; String literals.
+ (and (string? exp) exp))
+ (( proc args)
+ ;; Gettexted string literals, like `(_ "foo")'.
+ (and (record-case proc
+ (( name) (eq? name '_))
+ (( name) (eq? name '_))
+ (else #f))
+ (pmatch args
+ ((,fmt)
+ (record-case fmt
+ (( exp)
+ (and (string? exp) exp))
+ (else #f)))
+ (else #f))))
+ (else #f)))
+
(define format-analysis
;; Report arity mismatches in the given tree.
(make-tree-analysis
@@ -1355,11 +1376,11 @@ accurate information is missing from a given `tree-il' element."
(define (check-format-args args loc)
(pmatch args
((,port ,fmt . ,rest)
- (guard (const? fmt))
+ (guard (const-fmt fmt))
(if (and (const? port)
(not (boolean? (const-exp port))))
(warning 'format loc 'wrong-port (const-exp port)))
- (let ((fmt (const-exp fmt))
+ (let ((fmt (const-fmt fmt))
(count (length rest)))
(if (string? fmt)
(catch &syntax-error
@@ -1375,6 +1396,9 @@ accurate information is missing from a given `tree-il' element."
(warning 'format loc 'syntax-error key fmt)))
(warning 'format loc 'wrong-format-string fmt))))
((,port ,fmt . ,rest)
+ (if (and (const? port)
+ (not (boolean? (const-exp port))))
+ (warn 'format loc 'wrong-port (const-exp port)))
;; Warn on non-literal format strings, unless they refer to a
;; lexical variable named "fmt".
(if (record-case fmt
From da5d81a1f7a3b51813dba2c5a78b8e17243cde52 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 14 Apr 2011 16:06:07 +0200
Subject: [PATCH 06/48] add (ice-9 command-line)
* module/ice-9/command-line.scm: New module for parsing Guile's command
line, ported from script.c. Includes local eval-string implementation
to make `guile -c 1' faster, by not having to load the compiler.
* module/Makefile.am: Add to build.
---
module/Makefile.am | 1 +
module/ice-9/command-line.scm | 416 ++++++++++++++++++++++++++++++++++
2 files changed, 417 insertions(+)
create mode 100644 module/ice-9/command-line.scm
diff --git a/module/Makefile.am b/module/Makefile.am
index 2685a3a63..42aff1833 100644
--- a/module/Makefile.am
+++ b/module/Makefile.am
@@ -181,6 +181,7 @@ ICE_9_SOURCES = \
ice-9/and-let-star.scm \
ice-9/binary-ports.scm \
ice-9/calling.scm \
+ ice-9/command-line.scm \
ice-9/common-list.scm \
ice-9/control.scm \
ice-9/curried-definitions.scm \
diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm
new file mode 100644
index 000000000..e40006a82
--- /dev/null
+++ b/module/ice-9/command-line.scm
@@ -0,0 +1,416 @@
+;;; Parsing Guile's command-line
+
+;;; Copyright (C) 1994-1998, 2000-2011 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
+;;;; License as published by the Free Software Foundation; either
+;;;; version 3 of the License, or (at your option) any later version.
+;;;;
+;;;; This library 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
+;;;; Lesser General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU Lesser General Public
+;;;; License along with this library; if not, write to the Free Software
+;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+;;; Code:
+
+;;;
+;;; Please be careful not to load up other modules in this file, unless
+;;; they are explicitly requested. Loading modules currently imposes a
+;;; speed penalty of a few stats, an mmap, and some allocation, which
+;;; can range from 1 to 20ms, depending on the state of your disk cache.
+;;; Since `compile-shell-switches' is called even for the most transient
+;;; of command-line programs, we need to keep it lean.
+;;;
+;;; Generally speaking, the goal is for Guile to boot and execute simple
+;;; expressions like "1" within 20ms or less, measured using system time
+;;; from the time of the `guile' invocation to exit.
+;;;
+
+(define-module (ice-9 command-line)
+ #:autoload (system vm vm) (set-default-vm-engine! set-vm-engine! the-vm)
+ #:export (compile-shell-switches
+ version-etc
+ *GPLv3+*
+ *LGPLv3+*
+ emit-bug-reporting-address))
+
+;; An initial stab at i18n.
+(define _ gettext)
+
+(define *GPLv3+*
+ (_ "License GPLv3+: GNU GPL version 3 or later .
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law."))
+
+(define *LGPLv3+*
+ (_ "License LGPLv3+: GNU LGPL 3 or later .
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law."))
+
+;; Display the --version information in the
+;; standard way: command and package names, package version, followed
+;; by a short license notice and a list of up to 10 author names.
+;; If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of
+;; the program. The formats are therefore:
+;; PACKAGE VERSION
+;; or
+;; COMMAND_NAME (PACKAGE) VERSION.
+;;
+;; Based on the version-etc gnulib module.
+;;
+(define* (version-etc package version #:key
+ (port (current-output-port))
+ ;; FIXME: authors
+ (copyright-year 2011)
+ (copyright-holder "Free Software Foundation, Inc.")
+ (copyright (format #f "Copyright (C) ~a ~a"
+ copyright-year copyright-holder))
+ (license *GPLv3+*)
+ command-name
+ packager packager-version)
+ (if command-name
+ (format port "~a (~a) ~a\n" command-name package version)
+ (format port "~a ~a\n" package version))
+
+ (if packager
+ (if packager-version
+ (format port (_ "Packaged by ~a (~a)\n") packager packager-version)
+ (format port (_ "Packaged by ~a\n") packager)))
+
+ (display copyright port)
+ (newline port)
+ (newline port)
+ (display license port)
+ (newline port))
+
+
+;; Display the usual `Report bugs to' stanza.
+;;
+(define* (emit-bug-reporting-address package bug-address #:key
+ (port (current-output-port))
+ (url (string-append
+ "http://www.gnu.org/software/"
+ package
+ "/"))
+ packager packager-bug-address)
+ (format port (_ "\nReport bugs to: ~a\n") bug-address)
+ (if (and packager packager-bug-address)
+ (format port (_ "Report ~a bugs to: ~a\n") packager packager-bug-address))
+ (format port (_ "~a home page: <~a>\n") package url)
+ (format port
+ (_ "General help using GNU software: \n")))
+
+(define *usage*
+ (_ "Evaluate Scheme code, interactively or from a script.
+
+ [-s] FILE load Scheme source code from FILE, and exit
+ -c EXPR evalute Scheme expression EXPR, and exit
+ -- stop scanning arguments; run interactively
+
+The above switches stop argument processing, and pass all
+remaining arguments as the value of (command-line).
+If FILE begins with `-' the -s switch is mandatory.
+
+ -L DIRECTORY add DIRECTORY to the front of the module load path
+ -x EXTENSION add EXTENSION to the front of the load extensions
+ -l FILE load Scheme source code from FILE
+ -e FUNCTION after reading script, apply FUNCTION to
+ command line arguments
+ -ds do -s script at this point
+ --debug start with debugging evaluator and backtraces
+ --no-debug start with normal evaluator
+ Default is to enable debugging for interactive
+ use, but not for `-s' and `-c'.
+ --auto-compile compile source files automatically
+ --no-auto-compile disable automatic source file compilation
+ Default is to enable auto-compilation of source
+ files.
+ --listen[=P] Listen on a local port or a path for REPL clients.
+ If P is not given, the default is local port 37146.
+ -q inhibit loading of user init file
+ --use-srfi=LS load SRFI modules for the SRFIs in LS,
+ which is a list of numbers like \"2,13,14\"
+ -h, --help display this help and exit
+ -v, --version display version information and exit
+ \\ read arguments from following script lines"))
+
+
+(define* (shell-usage name fatal? #:optional fmt . args)
+ (let ((port (if fatal?
+ (current-error-port)
+ (current-output-port))))
+ (if fmt
+ (apply format port fmt args))
+
+ (format port (_ "Usage: ~a [OPTION]... [FILE]...\n") name)
+ (display *usage* port)
+ (newline port)
+
+ (emit-bug-reporting-address
+ "GNU Guile" "bug-guile@gnu.org"
+ #:port port
+ #:url "http://www.gnu.org/software/guile/"
+ #:packager (assq-ref %guile-build-info 'packager)
+ #:packager-bug-address
+ (assq-ref %guile-build-info 'packager-bug-address))
+
+ (if fatal?
+ (exit 1))))
+
+(define (eval-string str)
+ (call-with-input-string
+ str
+ (lambda (port)
+ (let lp ()
+ (let ((exp (read port)))
+ (if (not (eof-object? exp))
+ (begin
+ (eval exp (current-module))
+ (lp))))))))
+
+(define* (compile-shell-switches args #:optional (usage-name "guile"))
+ (let ((arg0 "guile")
+ (do-script '())
+ (entry-point #f)
+ (user-load-path '())
+ (user-extensions '())
+ (interactive? #t)
+ (inhibit-user-init? #f)
+ (turn-on-debugging? #f)
+ (turn-off-debugging? #f))
+
+ (define (error fmt . args)
+ (apply shell-usage usage-name #t fmt args))
+
+ (define (parse args out)
+ (cond
+ ((null? args)
+ (finish args out))
+ (else
+ (let ((arg (car args))
+ (args (cdr args)))
+ (cond
+ ((not (string-prefix? "-" arg)) ; foo
+ ;; If we specified the -ds option, do_script points to the
+ ;; cdr of an expression like (load #f) we replace the car
+ ;; (i.e., the #f) with the script name.
+ (if (pair? do-script)
+ (set-car! do-script arg))
+ (set! arg0 arg)
+ (set! interactive? #f)
+ (finish args
+ (cons `(load ,arg) out)))
+
+ ((string=? arg "-s") ; foo
+ (if (null? args)
+ (error "missing argument to `-s' switch"))
+ (set! arg0 (car args))
+ (if (pair? do-script)
+ (set-car! do-script arg0))
+ (set! interactive? #f)
+ (finish (cdr args)
+ (cons `(load ,arg0) out)))
+
+ ((string=? arg "-c") ; evaluate expr
+ (if (null? args)
+ (error "missing argument to `-c' switch"))
+ (set! interactive? #f)
+ (finish (cdr args)
+ ;; Use our own eval-string to avoid loading (ice-9
+ ;; eval-string), which loads the compiler.
+ (cons `((@@ (ice-9 command-line) eval-string) ,(car args))
+ out)))
+
+ ((string=? arg "--") ; end args go interactive
+ (finish args out))
+
+ ((string=? arg "-l") ; load a file
+ (if (null? args)
+ (error "missing argument to `-l' switch"))
+ (parse (cdr args)
+ (cons `(load ,(car args)) out)))
+
+ ((string=? arg "-L") ; add to %load-path
+ (if (null? args)
+ (error "missing argument to `-L' switch"))
+ (set! user-load-path (cons (car args) user-load-path))
+ (parse (cdr args)
+ out))
+
+ ((string=? arg "-x") ; add to %load-extensions
+ (if (null? args)
+ (error "missing argument to `-L' switch"))
+ (set! user-extensions (cons (car args) user-extensions))
+ (parse (cdr args)
+ out))
+
+ ((string=? arg "-e") ; entry point
+ (if (null? args)
+ (error "missing argument to `-e' switch"))
+ (let* ((port (open-input-string (car args)))
+ (arg1 (read port))
+ (arg2 (read port)))
+ ;; Recognize syntax of certain versions of guile 1.4 and
+ ;; transform to (@ MODULE-NAME FUNC).
+ (set! entry-point
+ (cond
+ ((not (eof-object? arg2))
+ `(@ ,arg1 ,arg2))
+ ((and (pair? arg1)
+ (not (memq (car arg1) '(@ @@)))
+ (and-map symbol? arg1))
+ `(@ ,arg1 main))
+ (else
+ arg1))))
+ (parse (cdr args)
+ out))
+
+ ((string=? arg "-ds") ; do script here
+ ;; We put a dummy "load" expression, and let the -s put the
+ ;; filename in.
+ (if (pair? do-script)
+ (error "the -ds switch may only be specified once")
+ (set! do-script (list #f)))
+ (parse args
+ (cons `(load . ,do-script) out)))
+
+ ((string=? arg "--debug")
+ (set! turn-on-debugging? #t)
+ (set! turn-off-debugging? #f)
+ (parse args out))
+
+ ((string=? arg "--no-debug")
+ (set! turn-off-debugging? #t)
+ (set! turn-on-debugging? #f)
+ (parse args out))
+
+ ;; Do auto-compile on/off now, because the form itself might
+ ;; need this decision.
+ ((string=? arg "--auto-compile")
+ (set! %load-should-auto-compile #t))
+
+ ((string=? arg "--no-auto-compile")
+ (set! %load-should-auto-compile #f))
+
+ ((string=? arg "-q") ; don't load user init
+ (set! inhibit-user-init? #t))
+
+ ((string-prefix? "--use-srfi=" arg)
+ (let ((srfis (map (lambda (x)
+ (let ((n (string->number x)))
+ (if (and n (exact? n) (integer? n) (>= n 0))
+ n
+ (error "invalid SRFI specification"))))
+ (string-split (substring arg 11) #\,))))
+ (if (null? srfis)
+ (error "invalid SRFI specification"))
+ (parse args
+ (cons `(use-srfis ',srfis) out))))
+
+ ((string=? arg "--listen") ; start a repl server
+ (parse args
+ (cons '(@@ (system repl server) (spawn-server)) out)))
+
+ ((string-prefix? "--listen=" arg) ; start a repl server
+ (parse
+ args
+ (cons
+ (let ((where (substring arg 8)))
+ (cond
+ ((string->number where) ; --listen=PORT
+ => (lambda (port)
+ (if (and (integer? port) (exact? port) (>= port 0))
+ (error "invalid port for --listen")
+ `(@@ (system repl server)
+ (spawn-server
+ (make-tcp-server-socket #:port ,port))))))
+ ((string-prefix? "/" where) ; --listen=/PATH/TO/SOCKET
+ `(@@ (system repl server)
+ (spawn-server
+ (make-unix-domain-server-socket #:path ,where))))
+ (else
+ (error "unknown argument to --listen"))))
+ out)))
+
+ ((or (string=? arg "-h") (string=? arg "--help"))
+ (shell-usage usage-name #f)
+ (exit 0))
+
+ ((or (string=? arg "-v") (string=? arg "--version"))
+ (version-etc "GNU Guile" (version)
+ #:command-name "guile"
+ #:packager (assq-ref %guile-build-info 'packager)
+ #:packager-version
+ (assq-ref %guile-build-info 'packager-version))
+ (exit 0))
+
+ (else
+ (error "Unrecognized switch ~a" arg)))))))
+
+ (define (finish args out)
+ ;; Check to make sure the -ds got a -s.
+ (if (and (pair? do-script) (not (car do-script)))
+ (error "the `-ds' switch requires the use of `-s' as well"))
+
+ ;; Make any remaining arguments available to the
+ ;; script/command/whatever.
+ (set-program-arguments (cons arg0 args))
+
+ ;; If debugging was requested, or we are interactive and debugging
+ ;; was not explicitly turned off, use the debug engine.
+ (if (or turn-on-debugging?
+ (and interactive? (not turn-off-debugging?)))
+ (begin
+ (set-default-vm-engine! 'debug)
+ (set-vm-engine! (the-vm) 'debug)))
+
+ ;; Return this value.
+ `(;; It would be nice not to load up (ice-9 control), but the
+ ;; default-prompt-handler is nontrivial.
+ (@ (ice-9 control) %)
+ (begin
+ ;; If we didn't end with a -c or a -s and didn't supply a -q, load
+ ;; the user's customization file.
+ ,@(if (and interactive? (not inhibit-user-init?))
+ '((load-user-init))
+ '())
+
+ ;; Use-specified extensions.
+ ,@(map (lambda (ext)
+ `(set! %load-extensions (cons ,ext %load-extensions)))
+ user-extensions)
+
+ ;; Add the user-specified load path here, so it won't be in
+ ;; effect during the loading of the user's customization file.
+ ,@(map (lambda (path)
+ `(set! %load-path (cons ,path %load-path)))
+ user-load-path)
+
+ ;; Put accumulated actions in their correct order.
+ ,@(reverse! out)
+
+ ;; Handle the `-e' switch, if it was specified.
+ ,@(if entry-point
+ `((,entry-point (command-line)))
+ '())
+ ,(if interactive?
+ ;; If we didn't end with a -c or a -s, start the
+ ;; repl.
+ '((@ (ice-9 top-repl) top-repl))
+ ;; Otherwise, after doing all the other actions
+ ;; prescribed by the command line, quit.
+ '(quit)))))
+
+ (if (pair? args)
+ (begin
+ (set! arg0 (car args))
+ (let ((slash (string-rindex arg0 #\/)))
+ (set! usage-name
+ (if slash (substring arg0 (1+ slash)) arg0)))
+ (parse (cdr args) '()))
+ (parse args '()))))
From 26ac1e3f421f1ef735679f595b3345fdb49336e2 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 14 Apr 2011 16:06:40 +0200
Subject: [PATCH 07/48] add packager info to %build-info
* libguile/load.c (init_build_info): Add packager, packager-version, and
packager-bug-reports to %build-info, if they are available.
---
libguile/load.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/libguile/load.c b/libguile/load.c
index c2380b94e..701b34b39 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -933,6 +933,21 @@ init_build_info ()
SCM val = scm_from_locale_string (info[i].value);
*loc = scm_acons (key, val, *loc);
}
+#ifdef PACKAGE_PACKAGER
+ *loc = scm_acons (scm_from_latin1_symbol ("packager"),
+ scm_from_latin1_string (PACKAGE_PACKAGER),
+ *loc);
+#endif
+#ifdef PACKAGE_PACKAGER_VERSION
+ *loc = scm_acons (scm_from_latin1_symbol ("packager-version"),
+ scm_from_latin1_string (PACKAGE_PACKAGER_VERSION),
+ *loc);
+#endif
+#ifdef PACKAGE_PACKAGER_BUG_REPORTS
+ *loc = scm_acons (scm_from_latin1_symbol ("packager-bug-reports"),
+ scm_from_latin1_string (PACKAGE_PACKAGER_BUG_REPORTS),
+ *loc);
+#endif
}
From 1693983a61de92a7a29b99e9769774fbb9b90942 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 14 Apr 2011 16:15:47 +0200
Subject: [PATCH 08/48] script.c calls out to (ice-9 command-line)
* libguile/script.c (scm_shell_usage): Call (ice-9 command-line)'s
shell-usage.
(scm_compile_shell_switches): Likewise, call (ice-9 command-line)'s
compile-shell-switches.
---
libguile/script.c | 465 ++--------------------------------------------
1 file changed, 16 insertions(+), 449 deletions(-)
diff --git a/libguile/script.c b/libguile/script.c
index bff7142e8..7f6116242 100644
--- a/libguile/script.c
+++ b/libguile/script.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 1994-1998, 2000-2011 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 License
* as published by the Free Software Foundation; either version 3 of
@@ -357,464 +357,31 @@ char *scm_usage_name = 0;
void
scm_shell_usage (int fatal, char *message)
{
- FILE *fp = (fatal ? stderr : stdout);
-
- if (message)
- fprintf (fp, "%s\n", message);
-
- fprintf (fp,
- "Usage: %s [OPTION]... [FILE]...\n"
- "Evaluate Scheme code, interactively or from a script.\n"
- "\n"
- " [-s] FILE load Scheme source code from FILE, and exit\n"
- " -c EXPR evalute Scheme expression EXPR, and exit\n"
- " -- stop scanning arguments; run interactively\n\n"
- "The above switches stop argument processing, and pass all\n"
- "remaining arguments as the value of (command-line).\n"
- "If FILE begins with `-' the -s switch is mandatory.\n"
- "\n"
- " -L DIRECTORY add DIRECTORY to the front of the module load path\n"
- " -x EXTENSION add EXTENSION to the front of the load extensions\n"
- " -l FILE load Scheme source code from FILE\n"
- " -e FUNCTION after reading script, apply FUNCTION to\n"
- " command line arguments\n"
- " -ds do -s script at this point\n"
- " --debug start with debugging evaluator and backtraces\n"
- " --no-debug start with normal evaluator\n"
- " Default is to enable debugging for interactive\n"
- " use, but not for `-s' and `-c'.\n"
- " --auto-compile compile source files automatically\n"
- " --no-auto-compile disable automatic source file compilation\n"
- " Default is to enable auto-compilation of source\n"
- " files.\n"
- " --listen[=P] Listen on a local port or a path for REPL clients.\n"
- " If P is not given, the default is local port 37146.\n"
- " -q inhibit loading of user init file\n"
- " --use-srfi=LS load SRFI modules for the SRFIs in LS,\n"
- " which is a list of numbers like \"2,13,14\"\n"
- " -h, --help display this help and exit\n"
- " -v, --version display version information and exit\n"
- " \\ read arguments from following script lines\n",
- scm_usage_name);
-
- emit_bug_reporting_address ();
-
- if (fatal)
- exit (fatal);
+ scm_call_3 (scm_c_private_ref ("ice-9 command-line",
+ "shell-usage"),
+ (scm_usage_name
+ ? scm_from_locale_string (scm_usage_name)
+ : scm_from_latin1_string ("guile")),
+ scm_from_bool (fatal),
+ (message
+ ? scm_from_locale_string (message)
+ : SCM_BOOL_F));
}
-/* Some symbols used by the command-line compiler. */
-SCM_SYMBOL (sym_load, "load");
-SCM_SYMBOL (sym_eval_string, "eval-string");
-SCM_SYMBOL (sym_command_line, "command-line");
-SCM_SYMBOL (sym_begin, "begin");
-SCM_SYMBOL (sym_load_user_init, "load-user-init");
-SCM_SYMBOL (sym_ice_9, "ice-9");
-SCM_SYMBOL (sym_top_repl, "top-repl");
-SCM_SYMBOL (sym_quit, "quit");
-SCM_SYMBOL (sym_use_srfis, "use-srfis");
-SCM_SYMBOL (sym_load_path, "%load-path");
-SCM_SYMBOL (sym_load_extensions, "%load-extensions");
-SCM_SYMBOL (sym_set_x, "set!");
-SCM_SYMBOL (sym_sys_load_should_auto_compile, "%load-should-auto-compile");
-SCM_SYMBOL (sym_cons, "cons");
-SCM_SYMBOL (sym_at, "@");
-SCM_SYMBOL (sym_atat, "@@");
-SCM_SYMBOL (sym_main, "main");
-
/* Given an array of command-line switches, return a Scheme expression
to carry out the actions specified by the switches.
-
- If you told me this should have been written in Scheme, I'd
- probably agree. I'd say I didn't feel comfortable doing that in
- the present system. You'd say, well, fix the system so you are
- comfortable doing that. I'd agree again. *shrug*
*/
-static char guile[] = "guile";
-
-static int
-all_symbols (SCM list)
-{
- while (scm_is_pair (list))
- {
- if (!scm_is_symbol (SCM_CAR (list)))
- return 0;
- list = SCM_CDR (list);
- }
- return 1;
-}
-
SCM
scm_compile_shell_switches (int argc, char **argv)
{
- SCM tail = SCM_EOL; /* We accumulate the list backwards,
- and then reverse! it before we
- return it. */
- SCM do_script = SCM_EOL; /* The element of the list containing
- the "load" command, in case we get
- the "-ds" switch. */
- SCM entry_point = SCM_EOL; /* for -e switch */
- SCM user_load_path = SCM_EOL; /* for -L switch */
- SCM user_extensions = SCM_EOL;/* for -x switch */
- int interactive = 1; /* Should we go interactive when done? */
- int inhibit_user_init = 0; /* Don't load user init file */
- int turn_on_debugging = 0;
- int dont_turn_on_debugging = 0;
-
- int i;
- char *argv0 = guile;
-
- if (argc > 0)
- {
- argv0 = argv[0];
- scm_usage_name = strrchr (argv[0], '/');
- if (! scm_usage_name)
- scm_usage_name = argv[0];
- else
- scm_usage_name++;
- }
- if (! scm_usage_name)
- scm_usage_name = guile;
-
- for (i = 1; i < argc; i++)
- {
- if ((! strcmp (argv[i], "-s")) || (argv[i][0] != '-')) /* load script */
- {
- if ((argv[i][0] == '-') && (++i >= argc))
- scm_shell_usage (1, "missing argument to `-s' switch");
-
- /* If we specified the -ds option, do_script points to the
- cdr of an expression like (load #f); we replace the car
- (i.e., the #f) with the script name. */
- if (!scm_is_null (do_script))
- {
- SCM_SETCAR (do_script, scm_from_locale_string (argv[i]));
- do_script = SCM_EOL;
- }
- else
- /* Construct an application of LOAD to the script name. */
- tail = scm_cons (scm_cons2 (sym_load,
- scm_from_locale_string (argv[i]),
- SCM_EOL),
- tail);
- argv0 = argv[i];
- i++;
- interactive = 0;
- break;
- }
-
- else if (! strcmp (argv[i], "-c")) /* evaluate expr */
- {
- if (++i >= argc)
- scm_shell_usage (1, "missing argument to `-c' switch");
- tail = scm_cons (scm_cons2 (sym_eval_string,
- scm_from_locale_string (argv[i]),
- SCM_EOL),
- tail);
- i++;
- interactive = 0;
- break;
- }
-
- else if (! strcmp (argv[i], "--")) /* end args; go interactive */
- {
- i++;
- break;
- }
-
- else if (! strcmp (argv[i], "-l")) /* load a file */
- {
- if (++i < argc)
- tail = scm_cons (scm_cons2 (sym_load,
- scm_from_locale_string (argv[i]),
- SCM_EOL),
- tail);
- else
- scm_shell_usage (1, "missing argument to `-l' switch");
- }
-
- else if (! strcmp (argv[i], "-L")) /* add to %load-path */
- {
- if (++i < argc)
- user_load_path =
- scm_cons (scm_list_3 (sym_set_x,
- sym_load_path,
- scm_list_3 (sym_cons,
- scm_from_locale_string (argv[i]),
- sym_load_path)),
- user_load_path);
- else
- scm_shell_usage (1, "missing argument to `-L' switch");
- }
-
- else if (! strcmp (argv[i], "-x")) /* add to %load-extensions */
- {
- if (++i < argc)
- user_extensions =
- scm_cons (scm_list_3 (sym_set_x,
- sym_load_extensions,
- scm_list_3 (sym_cons,
- scm_from_locale_string (argv[i]),
- sym_load_extensions)),
- user_extensions);
- else
- scm_shell_usage (1, "missing argument to `-x' switch");
- }
-
- else if (! strcmp (argv[i], "-e")) /* entry point */
- {
- if (++i < argc)
- {
- SCM port
- = scm_open_input_string (scm_from_locale_string (argv[i]));
- SCM arg1 = scm_read (port);
- SCM arg2 = scm_read (port);
-
- /* Recognize syntax of certain versions of Guile 1.4 and
- transform to (@ MODULE-NAME FUNC).
- */
- if (scm_is_false (scm_eof_object_p (arg2)))
- entry_point = scm_list_3 (sym_at, arg1, arg2);
- else if (scm_is_pair (arg1)
- && !(scm_is_eq (SCM_CAR (arg1), sym_at)
- || scm_is_eq (SCM_CAR (arg1), sym_atat))
- && all_symbols (arg1))
- entry_point = scm_list_3 (sym_at, arg1, sym_main);
- else
- entry_point = arg1;
- }
- else
- scm_shell_usage (1, "missing argument to `-e' switch");
- }
-
- else if (! strcmp (argv[i], "-ds")) /* do script here */
- {
- /* We put a dummy "load" expression, and let the -s put the
- filename in. */
- if (!scm_is_null (do_script))
- scm_shell_usage (1, "the -ds switch may only be specified once");
- do_script = scm_cons (SCM_BOOL_F, SCM_EOL);
- tail = scm_cons (scm_cons (sym_load, do_script),
- tail);
- }
-
- else if (! strcmp (argv[i], "--debug"))
- {
- turn_on_debugging = 1;
- dont_turn_on_debugging = 0;
- }
-
- else if (! strcmp (argv[i], "--no-debug"))
- {
- dont_turn_on_debugging = 1;
- turn_on_debugging = 0;
- }
-
- /* Do auto-compile on/off now, because the form itself might need this
- decision. */
- else if (! strcmp (argv[i], "--auto-compile"))
- scm_variable_set_x (scm_c_lookup ("%load-should-auto-compile"),
- SCM_BOOL_T);
-
- else if (! strcmp (argv[i], "--no-auto-compile"))
- scm_variable_set_x (scm_c_lookup ("%load-should-auto-compile"),
- SCM_BOOL_F);
-
- else if (! strcmp (argv[i], "-q")) /* don't load user init */
- inhibit_user_init = 1;
-
- else if (! strncmp (argv[i], "--use-srfi=", 11)) /* load SRFIs */
- {
- SCM srfis = SCM_EOL; /* List of requested SRFIs. */
- char * p = argv[i] + 11;
- while (*p)
- {
- long num;
- char * end;
-
- num = strtol (p, &end, 10);
- if (end - p > 0)
- {
- srfis = scm_cons (scm_from_long (num), srfis);
- if (*end)
- {
- if (*end == ',')
- p = end + 1;
- else
- scm_shell_usage (1, "invalid SRFI specification");
- }
- else
- break;
- }
- else
- scm_shell_usage (1, "invalid SRFI specification");
- }
- if (scm_ilength (srfis) <= 0)
- scm_shell_usage (1, "invalid SRFI specification");
- srfis = scm_reverse_x (srfis, SCM_UNDEFINED);
- tail = scm_cons (scm_list_2 (sym_use_srfis,
- scm_list_2 (scm_sym_quote, srfis)),
- tail);
- }
-
- else if (! strncmp (argv[i], "--listen", 8) /* start a repl server */
- && (argv[i][8] == '\0' || argv[i][8] == '='))
- {
- const char default_template[] =
- "(@@ (system repl server) (spawn-server))";
- const char port_template[] =
- "(@@ (system repl server)"
- " (spawn-server (make-tcp-server-socket #:port ~a)))";
- const char path_template[] =
- "(@@ (system repl server)"
- " (spawn-server (make-unix-domain-server-socket #:path ~s)))";
-
- SCM form_str = SCM_BOOL_F;
- char * p = argv[i] + 8;
-
- if (*p == '=')
- {
- p++;
- if (*p > '0' && *p <= '9')
- {
- /* --listen=PORT */
- SCM port = scm_string_to_number (scm_from_locale_string (p),
- SCM_UNDEFINED);
-
- if (scm_is_false (port))
- scm_shell_usage (1, "invalid port for --listen");
-
- form_str =
- scm_simple_format (SCM_BOOL_F,
- scm_from_locale_string (port_template),
- scm_list_1 (port));
- }
- else if (*p == '/')
- {
- /* --listen=/PATH/TO/SOCKET */
- SCM path = scm_from_locale_string (p);
-
- form_str =
- scm_simple_format (SCM_BOOL_F,
- scm_from_locale_string (path_template),
- scm_list_1 (path));
- }
- else
- {
- /* unknown --listen arg */
- scm_shell_usage (1, "unknown argument to --listen");
- }
- }
- else
- form_str = scm_from_locale_string (default_template);
-
- tail = scm_cons (scm_read (scm_open_input_string (form_str)), tail);
- }
-
- else if (! strcmp (argv[i], "-h")
- || ! strcmp (argv[i], "--help"))
- {
- scm_shell_usage (0, 0);
- exit (EXIT_SUCCESS);
- }
-
- else if (! strcmp (argv[i], "-v")
- || ! strcmp (argv[i], "--version"))
- {
- /* Print version number. */
- version_etc (stdout, scm_usage_name, PACKAGE_NAME, PACKAGE_VERSION,
- /* XXX: Use gettext for the string below. */
- "the Guile developers", NULL);
- exit (EXIT_SUCCESS);
- }
-
- else
- {
- fprintf (stderr, "%s: Unrecognized switch `%s'\n",
- scm_usage_name, argv[i]);
- scm_shell_usage (1, 0);
- }
- }
-
- /* Check to make sure the -ds got a -s. */
- if (!scm_is_null (do_script))
- scm_shell_usage (1, "the `-ds' switch requires the use of `-s' as well");
-
- /* Make any remaining arguments available to the
- script/command/whatever. */
- scm_set_program_arguments (argc ? argc - i : 0, argv + i, argv0);
-
- /* Handle the `-e' switch, if it was specified. */
- if (!scm_is_null (entry_point))
- tail = scm_cons (scm_cons2 (entry_point,
- scm_cons (sym_command_line, SCM_EOL),
- SCM_EOL),
- tail);
-
- /* If we didn't end with a -c or a -s, start the repl. */
- if (interactive)
- {
- tail = scm_cons (scm_list_1 (scm_list_3
- (sym_at,
- scm_list_2 (sym_ice_9, sym_top_repl),
- sym_top_repl)),
- tail);
- }
- else
- {
- /* After doing all the other actions prescribed by the command line,
- quit. */
- tail = scm_cons (scm_cons (sym_quit, SCM_EOL),
- tail);
- }
-
- /* After the following line, actions will be added to the front. */
- tail = scm_reverse_x (tail, SCM_UNDEFINED);
-
- /* add the user-specified load path here, so it won't be in effect
- during the loading of the user's customization file. */
- if(!scm_is_null(user_load_path))
- {
- tail = scm_append_x( scm_cons2(user_load_path, tail, SCM_EOL) );
- }
-
- if (!scm_is_null (user_extensions))
- tail = scm_append_x (scm_cons2 (user_extensions, tail, SCM_EOL));
-
- /* If we didn't end with a -c or a -s and didn't supply a -q, load
- the user's customization file. */
- if (interactive && !inhibit_user_init)
- {
- tail = scm_cons (scm_cons (sym_load_user_init, SCM_EOL), tail);
- }
-
- /* If debugging was requested, or we are interactive and debugging
- was not explicitly turned off, use the debug engine. */
- if (turn_on_debugging || (interactive && !dont_turn_on_debugging))
- {
- scm_c_set_default_vm_engine_x (SCM_VM_DEBUG_ENGINE);
- scm_c_set_vm_engine_x (scm_the_vm (), SCM_VM_DEBUG_ENGINE);
- }
-
- {
- SCM val = scm_cons (sym_begin, tail);
-
- /* Wrap the expression in a prompt. */
- val = scm_list_2 (scm_list_3 (scm_sym_at,
- scm_list_2 (scm_from_latin1_symbol ("ice-9"),
- scm_from_latin1_symbol ("control")),
- scm_from_latin1_symbol ("%")),
- val);
-
-#if 0
- scm_write (val, SCM_UNDEFINED);
- scm_newline (SCM_UNDEFINED);
-#endif
-
- return val;
- }
+ return scm_call_2 (scm_c_public_ref ("ice-9 command-line",
+ "compile-shell-switches"),
+ scm_makfromstrs (argc, argv),
+ (scm_usage_name
+ ? scm_from_locale_string (scm_usage_name)
+ : scm_from_latin1_string ("guile")));
}
From e07f0a55660b6329089ab88103502094bda2b98e Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 14 Apr 2011 16:18:56 +0200
Subject: [PATCH 09/48] guile -v prints LGPLv3+.
* module/ice-9/command-line.scm (compile-shell-switches): Though Guile
may be distributed under the GPLv3, Guile is actually LGPLv3+.
---
module/ice-9/command-line.scm | 1 +
1 file changed, 1 insertion(+)
diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm
index e40006a82..9fa7135ae 100644
--- a/module/ice-9/command-line.scm
+++ b/module/ice-9/command-line.scm
@@ -343,6 +343,7 @@ If FILE begins with `-' the -s switch is mandatory.
((or (string=? arg "-v") (string=? arg "--version"))
(version-etc "GNU Guile" (version)
+ #:license *LGPLv3+*
#:command-name "guile"
#:packager (assq-ref %guile-build-info 'packager)
#:packager-version
From 90779ad9a1d8b2533ad8495753677aebf5626571 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 14 Apr 2011 16:46:49 +0200
Subject: [PATCH 10/48] fix embarrassing bugs in (ice-9 command-line)
* module/ice-9/command-line.scm (compile-shell-switches): Whoops, fix a
few cases that forgot to loop back to the beginning.
---
module/ice-9/command-line.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm
index 9fa7135ae..9797364e4 100644
--- a/module/ice-9/command-line.scm
+++ b/module/ice-9/command-line.scm
@@ -292,13 +292,16 @@ If FILE begins with `-' the -s switch is mandatory.
;; Do auto-compile on/off now, because the form itself might
;; need this decision.
((string=? arg "--auto-compile")
- (set! %load-should-auto-compile #t))
+ (set! %load-should-auto-compile #t)
+ (parse args out))
((string=? arg "--no-auto-compile")
- (set! %load-should-auto-compile #f))
+ (set! %load-should-auto-compile #f)
+ (parse args out))
((string=? arg "-q") ; don't load user init
- (set! inhibit-user-init? #t))
+ (set! inhibit-user-init? #t)
+ (parse args out))
((string-prefix? "--use-srfi=" arg)
(let ((srfis (map (lambda (x)
From 3936cebc77bfbde57bb3fe904b26943e54a9d618 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 14 Apr 2011 16:53:18 +0200
Subject: [PATCH 11/48] fix analyze.scm literal string warnings
* module/language/tree-il/analyze.scm (const-fmt): Return any literal
value, not just strings. The string case is checked later.
---
module/language/tree-il/analyze.scm | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm
index 61357f821..23eff2ce2 100644
--- a/module/language/tree-il/analyze.scm
+++ b/module/language/tree-il/analyze.scm
@@ -1347,10 +1347,9 @@ accurate information is missing from a given `tree-il' element."
(define (const-fmt x)
(record-case x
(( exp)
- ;; String literals.
- (and (string? exp) exp))
+ exp)
(( proc args)
- ;; Gettexted string literals, like `(_ "foo")'.
+ ;; Gettexted literals, like `(_ "foo")'.
(and (record-case proc
(( name) (eq? name '_))
(( name) (eq? name '_))
@@ -1358,8 +1357,7 @@ accurate information is missing from a given `tree-il' element."
(pmatch args
((,fmt)
(record-case fmt
- (( exp)
- (and (string? exp) exp))
+ (( exp) exp)
(else #f)))
(else #f))))
(else #f)))
From 022ae742d171fb9ef3db7aab59b4e029edd2ff02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Thu, 14 Apr 2011 23:14:14 +0200
Subject: [PATCH 12/48] Add tests for `-Wformat' and gettext.
* test-suite/tests/tree-il.test ("warnings")["non-literal format string
using gettext", "one missing argument, gettext"]: New tests.
---
test-suite/tests/tree-il.test | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test
index 8ea244343..1b86b99fc 100644
--- a/test-suite/tests/tree-il.test
+++ b/test-suite/tests/tree-il.test
@@ -1153,6 +1153,13 @@
(number? (string-contains (car w)
"non-literal format string")))))
+ (pass-if "non-literal format string using gettext"
+ (null? (call-with-warnings
+ (lambda ()
+ (compile '(format #t (_ "~A ~A!") "hello" "world")
+ #:opts %opts-w-format
+ #:to 'assembly)))))
+
(pass-if "wrong format string"
(let ((w (call-with-warnings
(lambda ()
@@ -1190,6 +1197,16 @@
(number? (string-contains (car w)
"expected 1, got 0")))))
+ (pass-if "one missing argument, gettext"
+ (let ((w (call-with-warnings
+ (lambda ()
+ (compile '(format some-port (_ "foo ~A~%"))
+ #:opts %opts-w-format
+ #:to 'assembly)))))
+ (and (= (length w) 1)
+ (number? (string-contains (car w)
+ "expected 1, got 0")))))
+
(pass-if "two missing arguments"
(let ((w (call-with-warnings
(lambda ()
From 22072f2155f657ff229bf8aaaa00318b60e8d6e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Thu, 14 Apr 2011 23:16:21 +0200
Subject: [PATCH 13/48] Include in `posix.c'.
* configure.ac: Check for .
* libguile/posix.c [HAVE_SCHED_H]: Include , for
`sched_setaffinity' & co.
Reported by Marco Maggi .
---
configure.ac | 3 ++-
libguile/posix.c | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 45438c8a1..2b5662997 100644
--- a/configure.ac
+++ b/configure.ac
@@ -644,12 +644,13 @@ AC_SUBST([SCM_I_GSC_HAVE_STRUCT_DIRENT64])
# this file instead of
# process.h - mingw specific
# langinfo.h, nl_types.h - SuS v2
+# sched.h - missing on MinGW
#
AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h malloc.h memory.h process.h string.h \
regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
-direct.h langinfo.h nl_types.h machine/fpu.h poll.h])
+direct.h langinfo.h nl_types.h machine/fpu.h poll.h sched.h])
# Reasons for testing:
# nl_item - lacking on Cygwin
diff --git a/libguile/posix.c b/libguile/posix.c
index a5c72624c..422aadbe5 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -27,6 +27,10 @@
#include
#include
+#ifdef HAVE_SCHED_H
+# include
+#endif
+
#include "libguile/_scm.h"
#include "libguile/dynwind.h"
#include "libguile/fports.h"
From 073167ef7b803067bcc8be19925fac1a48577bd8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Thu, 14 Apr 2011 23:42:28 +0200
Subject: [PATCH 14/48] Allow compilation with `--disable-posix'.
Reported by Dmitry Dzhus .
* configure.ac: Remove `AC_LIBOBJ([filesys])'. Document
`--disable-posix' as omitting non-essential POSIX interfaces.
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
Add `filesys.c'.
(DOT_DOC_FILES): Add `filesys.doc'.
(EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): Remove
`filesys.c'.
* libguile/posix.c (scm_mkstemp, scm_access): Move to `filesys.c'.
(scm_init_posix): Move `R_OK' etc. to `filesys.c'.
* libguile/filesys.c (scm_chown, scm_chmod, scm_umask, scm_open_fdes,
scm_open, scm_close, scm_close_fdes, scm_link, scm_tc16_dir,
scm_directory_stream_p, scm_opendir, scm_readdir, scm_rewinddir,
scm_closedir, scm_dir_print, scm_dir_free, scm_chdir, scm_getcwd,
set_element, fill_select_type, get_element, retrieve_select_type,
scm_select, scm_fcntl, scm_fsync, scm_symlink, scm_readlink,
scm_lstat, scm_copy_file): Conditionalize on HAVE_POSIX.
(scm_mkstemp, scm_access): New functions.
(scm_init_filesys): Conditionalize `scm_tc16_dir', `O_RDONLY', etc. on
HAVE_POSIX. Define `R_OK', `W_OK', etc.
* libguile/fports.c (fport_print): Use `scm_ttyname' only when
HAVE_POSIX.
* libguile/i18n.c (lock_locale_mutex, unlock_locale_mutex): New
functions. Update users of `scm_i_locale_mutex' to use them.
* libguile/init.c (scm_i_init_guile): Always call `scm_init_filesys'.
* meta/guile-tools.in (main): Use `setlocale' only when it is defined.
* module/ice-9/boot-9.scm: Always load `ice-9/posix'.
---
configure.ac | 5 +-
libguile/Makefile.am | 4 +-
libguile/filesys.c | 503 +++++++++++++++++++++++++---------------
libguile/fports.c | 9 +-
libguile/i18n.c | 35 ++-
libguile/init.c | 2 +-
libguile/posix.c | 106 ---------
meta/guile-tools.in | 4 +-
module/ice-9/boot-9.scm | 5 +-
9 files changed, 358 insertions(+), 315 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2b5662997..fe7777365 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,7 +127,7 @@ AC_ARG_ENABLE(guile-debug,
fi)
AC_ARG_ENABLE(posix,
- [ --disable-posix omit posix interfaces],,
+ [ --disable-posix omit non-essential POSIX interfaces],,
enable_posix=yes)
AC_ARG_ENABLE(networking,
@@ -230,10 +230,9 @@ if test "$use_modules" != no; then
fi
if test "$enable_posix" = yes; then
- AC_LIBOBJ([filesys])
AC_LIBOBJ([posix])
AC_DEFINE([HAVE_POSIX], 1,
- [Define this if you want support for POSIX system calls in Guile.])
+ [Define this if you want support for non-essential POSIX system calls in Guile.])
fi
if test "$enable_networking" = yes; then
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index ac27eb8fb..29de79167 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -138,6 +138,7 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = \
expand.c \
extensions.c \
feature.c \
+ filesys.c \
fluids.c \
foreign.c \
fports.c \
@@ -342,6 +343,7 @@ DOT_DOC_FILES = \
expand.doc \
extensions.doc \
feature.doc \
+ filesys.doc \
fluids.doc \
foreign.doc \
fports.doc \
@@ -425,7 +427,7 @@ BUILT_SOURCES = cpp-E.c cpp-SIG.c libpath.h \
EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = _scm.h \
memmove.c strerror.c \
dynl.c regex-posix.c \
- filesys.c posix.c net_db.c socket.c \
+ posix.c net_db.c socket.c \
debug-malloc.c mkstemp.c \
win32-uname.c win32-dirent.c win32-socket.c \
locale-categories.h
diff --git a/libguile/filesys.c b/libguile/filesys.c
index 96752bcd7..fab8ab41d 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -18,6 +18,10 @@
+/* This file contains POSIX file system access procedures. Procedures
+ essential to the compiler and run-time (`stat', `canonicalize-path',
+ etc.) are compiled even with `--disable-posix'. */
+
/* See stime.c for comments on why _POSIX_C_SOURCE is not always defined. */
#define _LARGEFILE64_SOURCE /* ask for stat64 etc */
@@ -158,6 +162,8 @@
+#ifdef HAVE_POSIX
+
/* {Permissions}
*/
@@ -203,64 +209,6 @@ SCM_DEFINE (scm_chown, "chown", 3, 0, 0,
#undef FUNC_NAME
#endif /* HAVE_CHOWN */
-
-SCM_DEFINE (scm_chmod, "chmod", 2, 0, 0,
- (SCM object, SCM mode),
- "Changes the permissions of the file referred to by @var{obj}.\n"
- "@var{obj} can be a string containing a file name or a port or integer file\n"
- "descriptor which is open on a file (in which case @code{fchmod} is used\n"
- "as the underlying system call).\n"
- "@var{mode} specifies\n"
- "the new permissions as a decimal number, e.g., @code{(chmod \"foo\" #o755)}.\n"
- "The return value is unspecified.")
-#define FUNC_NAME s_scm_chmod
-{
- int rv;
- int fdes;
-
- object = SCM_COERCE_OUTPORT (object);
-
- if (scm_is_integer (object) || SCM_OPFPORTP (object))
- {
- if (scm_is_integer (object))
- fdes = scm_to_int (object);
- else
- fdes = SCM_FPORT_FDES (object);
- SCM_SYSCALL (rv = fchmod (fdes, scm_to_int (mode)));
- }
- else
- {
- STRING_SYSCALL (object, c_object,
- rv = chmod (c_object, scm_to_int (mode)));
- }
- if (rv == -1)
- SCM_SYSERROR;
- return SCM_UNSPECIFIED;
-}
-#undef FUNC_NAME
-
-SCM_DEFINE (scm_umask, "umask", 0, 1, 0,
- (SCM mode),
- "If @var{mode} is omitted, returns a decimal number representing the current\n"
- "file creation mask. Otherwise the file creation mask is set to\n"
- "@var{mode} and the previous value is returned.\n\n"
- "E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18.")
-#define FUNC_NAME s_scm_umask
-{
- mode_t mask;
- if (SCM_UNBNDP (mode))
- {
- mask = umask (0);
- umask (mask);
- }
- else
- {
- mask = umask (scm_to_uint (mode));
- }
- return scm_from_uint (mask);
-}
-#undef FUNC_NAME
-
SCM_DEFINE (scm_open_fdes, "open-fdes", 2, 1, 0,
@@ -386,6 +334,8 @@ SCM_DEFINE (scm_close_fdes, "close-fdes", 1, 0, 0,
}
#undef FUNC_NAME
+#endif /* HAVE_POSIX */
+
/* {Files}
*/
@@ -653,6 +603,8 @@ SCM_DEFINE (scm_stat, "stat", 1, 1, 0,
#undef FUNC_NAME
+#ifdef HAVE_POSIX
+
/* {Modifying Directories}
*/
@@ -677,103 +629,6 @@ SCM_DEFINE (scm_link, "link", 2, 0, 0,
#undef FUNC_NAME
#endif /* HAVE_LINK */
-#ifdef HAVE_RENAME
-#define my_rename rename
-#else
-static int
-my_rename (const char *oldname, const char *newname)
-{
- int rv;
-
- SCM_SYSCALL (rv = link (oldname, newname));
- if (rv == 0)
- {
- SCM_SYSCALL (rv = unlink (oldname));
- if (rv != 0)
- /* unlink failed. remove new name */
- SCM_SYSCALL (unlink (newname));
- }
- return rv;
-}
-#endif
-
-SCM_DEFINE (scm_rename, "rename-file", 2, 0, 0,
- (SCM oldname, SCM newname),
- "Renames the file specified by @var{oldname} to @var{newname}.\n"
- "The return value is unspecified.")
-#define FUNC_NAME s_scm_rename
-{
- int rv;
-
- STRING2_SYSCALL (oldname, c_oldname,
- newname, c_newname,
- rv = my_rename (c_oldname, c_newname));
- if (rv != 0)
- SCM_SYSERROR;
- return SCM_UNSPECIFIED;
-}
-#undef FUNC_NAME
-
-
-SCM_DEFINE (scm_delete_file, "delete-file", 1, 0, 0,
- (SCM str),
- "Deletes (or \"unlinks\") the file specified by @var{path}.")
-#define FUNC_NAME s_scm_delete_file
-{
- int ans;
- STRING_SYSCALL (str, c_str, ans = unlink (c_str));
- if (ans != 0)
- SCM_SYSERROR;
- return SCM_UNSPECIFIED;
-}
-#undef FUNC_NAME
-
-#ifdef HAVE_MKDIR
-SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
- (SCM path, SCM mode),
- "Create a new directory named by @var{path}. If @var{mode} is omitted\n"
- "then the permissions of the directory file are set using the current\n"
- "umask. Otherwise they are set to the decimal value specified with\n"
- "@var{mode}. The return value is unspecified.")
-#define FUNC_NAME s_scm_mkdir
-{
- int rv;
- mode_t mask;
-
- if (SCM_UNBNDP (mode))
- {
- mask = umask (0);
- umask (mask);
- STRING_SYSCALL (path, c_path, rv = mkdir (c_path, 0777 ^ mask));
- }
- else
- {
- STRING_SYSCALL (path, c_path, rv = mkdir (c_path, scm_to_uint (mode)));
- }
- if (rv != 0)
- SCM_SYSERROR;
- return SCM_UNSPECIFIED;
-}
-#undef FUNC_NAME
-#endif /* HAVE_MKDIR */
-
-#ifdef HAVE_RMDIR
-SCM_DEFINE (scm_rmdir, "rmdir", 1, 0, 0,
- (SCM path),
- "Remove the existing directory named by @var{path}. The directory must\n"
- "be empty for this to succeed. The return value is unspecified.")
-#define FUNC_NAME s_scm_rmdir
-{
- int val;
-
- STRING_SYSCALL (path, c_path, val = rmdir (c_path));
- if (val != 0)
- SCM_SYSERROR;
- return SCM_UNSPECIFIED;
-}
-#undef FUNC_NAME
-#endif
-
/* {Examining Directories}
@@ -971,38 +826,6 @@ SCM_DEFINE (scm_chdir, "chdir", 1, 0, 0,
}
#undef FUNC_NAME
-#ifdef HAVE_GETCWD
-SCM_DEFINE (scm_getcwd, "getcwd", 0, 0, 0,
- (),
- "Return the name of the current working directory.")
-#define FUNC_NAME s_scm_getcwd
-{
- char *rv;
- size_t size = 100;
- char *wd;
- SCM result;
-
- wd = scm_malloc (size);
- while ((rv = getcwd (wd, size)) == 0 && errno == ERANGE)
- {
- free (wd);
- size *= 2;
- wd = scm_malloc (size);
- }
- if (rv == 0)
- {
- int save_errno = errno;
- free (wd);
- errno = save_errno;
- SCM_SYSERROR;
- }
- result = scm_from_locale_stringn (wd, strlen (wd));
- free (wd);
- return result;
-}
-#undef FUNC_NAME
-#endif /* HAVE_GETCWD */
-
#ifdef HAVE_SELECT
@@ -1509,6 +1332,300 @@ SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0,
}
#undef FUNC_NAME
+#endif /* HAVE_POSIX */
+
+
+/* Essential procedures used in (system base compile). */
+
+#ifdef HAVE_GETCWD
+SCM_DEFINE (scm_getcwd, "getcwd", 0, 0, 0,
+ (),
+ "Return the name of the current working directory.")
+#define FUNC_NAME s_scm_getcwd
+{
+ char *rv;
+ size_t size = 100;
+ char *wd;
+ SCM result;
+
+ wd = scm_malloc (size);
+ while ((rv = getcwd (wd, size)) == 0 && errno == ERANGE)
+ {
+ free (wd);
+ size *= 2;
+ wd = scm_malloc (size);
+ }
+ if (rv == 0)
+ {
+ int save_errno = errno;
+ free (wd);
+ errno = save_errno;
+ SCM_SYSERROR;
+ }
+ result = scm_from_locale_stringn (wd, strlen (wd));
+ free (wd);
+ return result;
+}
+#undef FUNC_NAME
+#endif /* HAVE_GETCWD */
+
+#ifdef HAVE_MKDIR
+SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
+ (SCM path, SCM mode),
+ "Create a new directory named by @var{path}. If @var{mode} is omitted\n"
+ "then the permissions of the directory file are set using the current\n"
+ "umask. Otherwise they are set to the decimal value specified with\n"
+ "@var{mode}. The return value is unspecified.")
+#define FUNC_NAME s_scm_mkdir
+{
+ int rv;
+ mode_t mask;
+
+ if (SCM_UNBNDP (mode))
+ {
+ mask = umask (0);
+ umask (mask);
+ STRING_SYSCALL (path, c_path, rv = mkdir (c_path, 0777 ^ mask));
+ }
+ else
+ {
+ STRING_SYSCALL (path, c_path, rv = mkdir (c_path, scm_to_uint (mode)));
+ }
+ if (rv != 0)
+ SCM_SYSERROR;
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+#endif /* HAVE_MKDIR */
+
+#ifdef HAVE_RMDIR
+SCM_DEFINE (scm_rmdir, "rmdir", 1, 0, 0,
+ (SCM path),
+ "Remove the existing directory named by @var{path}. The directory must\n"
+ "be empty for this to succeed. The return value is unspecified.")
+#define FUNC_NAME s_scm_rmdir
+{
+ int val;
+
+ STRING_SYSCALL (path, c_path, val = rmdir (c_path));
+ if (val != 0)
+ SCM_SYSERROR;
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+#endif
+
+#ifdef HAVE_RENAME
+#define my_rename rename
+#else
+static int
+my_rename (const char *oldname, const char *newname)
+{
+ int rv;
+
+ SCM_SYSCALL (rv = link (oldname, newname));
+ if (rv == 0)
+ {
+ SCM_SYSCALL (rv = unlink (oldname));
+ if (rv != 0)
+ /* unlink failed. remove new name */
+ SCM_SYSCALL (unlink (newname));
+ }
+ return rv;
+}
+#endif
+
+SCM_DEFINE (scm_rename, "rename-file", 2, 0, 0,
+ (SCM oldname, SCM newname),
+ "Renames the file specified by @var{oldname} to @var{newname}.\n"
+ "The return value is unspecified.")
+#define FUNC_NAME s_scm_rename
+{
+ int rv;
+
+ STRING2_SYSCALL (oldname, c_oldname,
+ newname, c_newname,
+ rv = my_rename (c_oldname, c_newname));
+ if (rv != 0)
+ SCM_SYSERROR;
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+
+SCM_DEFINE (scm_delete_file, "delete-file", 1, 0, 0,
+ (SCM str),
+ "Deletes (or \"unlinks\") the file specified by @var{path}.")
+#define FUNC_NAME s_scm_delete_file
+{
+ int ans;
+ STRING_SYSCALL (str, c_str, ans = unlink (c_str));
+ if (ans != 0)
+ SCM_SYSERROR;
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_access, "access?", 2, 0, 0,
+ (SCM path, SCM how),
+ "Test accessibility of a file under the real UID and GID of the\n"
+ "calling process. The return is @code{#t} if @var{path} exists\n"
+ "and the permissions requested by @var{how} are all allowed, or\n"
+ "@code{#f} if not.\n"
+ "\n"
+ "@var{how} is an integer which is one of the following values,\n"
+ "or a bitwise-OR (@code{logior}) of multiple values.\n"
+ "\n"
+ "@defvar R_OK\n"
+ "Test for read permission.\n"
+ "@end defvar\n"
+ "@defvar W_OK\n"
+ "Test for write permission.\n"
+ "@end defvar\n"
+ "@defvar X_OK\n"
+ "Test for execute permission.\n"
+ "@end defvar\n"
+ "@defvar F_OK\n"
+ "Test for existence of the file. This is implied by each of the\n"
+ "other tests, so there's no need to combine it with them.\n"
+ "@end defvar\n"
+ "\n"
+ "It's important to note that @code{access?} does not simply\n"
+ "indicate what will happen on attempting to read or write a\n"
+ "file. In normal circumstances it does, but in a set-UID or\n"
+ "set-GID program it doesn't because @code{access?} tests the\n"
+ "real ID, whereas an open or execute attempt uses the effective\n"
+ "ID.\n"
+ "\n"
+ "A program which will never run set-UID/GID can ignore the\n"
+ "difference between real and effective IDs, but for maximum\n"
+ "generality, especially in library functions, it's best not to\n"
+ "use @code{access?} to predict the result of an open or execute,\n"
+ "instead simply attempt that and catch any exception.\n"
+ "\n"
+ "The main use for @code{access?} is to let a set-UID/GID program\n"
+ "determine what the invoking user would have been allowed to do,\n"
+ "without the greater (or perhaps lesser) privileges afforded by\n"
+ "the effective ID. For more on this, see ``Testing File\n"
+ "Access'' in The GNU C Library Reference Manual.")
+#define FUNC_NAME s_scm_access
+{
+ int rv;
+ char *c_path;
+
+ c_path = scm_to_locale_string (path);
+ rv = access (c_path, scm_to_int (how));
+ free (c_path);
+
+ return scm_from_bool (!rv);
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_chmod, "chmod", 2, 0, 0,
+ (SCM object, SCM mode),
+ "Changes the permissions of the file referred to by @var{obj}.\n"
+ "@var{obj} can be a string containing a file name or a port or integer file\n"
+ "descriptor which is open on a file (in which case @code{fchmod} is used\n"
+ "as the underlying system call).\n"
+ "@var{mode} specifies\n"
+ "the new permissions as a decimal number, e.g., @code{(chmod \"foo\" #o755)}.\n"
+ "The return value is unspecified.")
+#define FUNC_NAME s_scm_chmod
+{
+ int rv;
+ int fdes;
+
+ object = SCM_COERCE_OUTPORT (object);
+
+ if (scm_is_integer (object) || SCM_OPFPORTP (object))
+ {
+ if (scm_is_integer (object))
+ fdes = scm_to_int (object);
+ else
+ fdes = SCM_FPORT_FDES (object);
+ SCM_SYSCALL (rv = fchmod (fdes, scm_to_int (mode)));
+ }
+ else
+ {
+ STRING_SYSCALL (object, c_object,
+ rv = chmod (c_object, scm_to_int (mode)));
+ }
+ if (rv == -1)
+ SCM_SYSERROR;
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_umask, "umask", 0, 1, 0,
+ (SCM mode),
+ "If @var{mode} is omitted, returns a decimal number representing the current\n"
+ "file creation mask. Otherwise the file creation mask is set to\n"
+ "@var{mode} and the previous value is returned.\n\n"
+ "E.g., @code{(umask #o022)} sets the mask to octal 22, decimal 18.")
+#define FUNC_NAME s_scm_umask
+{
+ mode_t mask;
+ if (SCM_UNBNDP (mode))
+ {
+ mask = umask (0);
+ umask (mask);
+ }
+ else
+ {
+ mask = umask (scm_to_uint (mode));
+ }
+ return scm_from_uint (mask);
+}
+#undef FUNC_NAME
+
+#ifndef HAVE_MKSTEMP
+extern int mkstemp (char *);
+#endif
+
+SCM_DEFINE (scm_mkstemp, "mkstemp!", 1, 0, 0,
+ (SCM tmpl),
+ "Create a new unique file in the file system and return a new\n"
+ "buffered port open for reading and writing to the file.\n"
+ "\n"
+ "@var{tmpl} is a string specifying where the file should be\n"
+ "created: it must end with @samp{XXXXXX} and those @samp{X}s\n"
+ "will be changed in the string to return the name of the file.\n"
+ "(@code{port-filename} on the port also gives the name.)\n"
+ "\n"
+ "POSIX doesn't specify the permissions mode of the file, on GNU\n"
+ "and most systems it's @code{#o600}. An application can use\n"
+ "@code{chmod} to relax that if desired. For example\n"
+ "@code{#o666} less @code{umask}, which is usual for ordinary\n"
+ "file creation,\n"
+ "\n"
+ "@example\n"
+ "(let ((port (mkstemp! (string-copy \"/tmp/myfile-XXXXXX\"))))\n"
+ " (chmod port (logand #o666 (lognot (umask))))\n"
+ " ...)\n"
+ "@end example")
+#define FUNC_NAME s_scm_mkstemp
+{
+ char *c_tmpl;
+ int rv;
+
+ scm_dynwind_begin (0);
+
+ c_tmpl = scm_to_locale_string (tmpl);
+ scm_dynwind_free (c_tmpl);
+
+ SCM_SYSCALL (rv = mkstemp (c_tmpl));
+ if (rv == -1)
+ SCM_SYSERROR;
+
+ scm_substring_move_x (scm_from_locale_string (c_tmpl),
+ SCM_INUM0, scm_string_length (tmpl),
+ tmpl, SCM_INUM0);
+
+ scm_dynwind_end ();
+ return scm_fdes_to_port (rv, "w+", tmpl);
+}
+#undef FUNC_NAME
+
/* Filename manipulation */
@@ -1703,12 +1820,11 @@ scm_i_relativize_path (SCM path, SCM in_path)
void
scm_init_filesys ()
{
+#ifdef HAVE_POSIX
scm_tc16_dir = scm_make_smob_type ("directory", 0);
scm_set_smob_free (scm_tc16_dir, scm_dir_free);
scm_set_smob_print (scm_tc16_dir, scm_dir_print);
- scm_dot_string = scm_from_locale_string (".");
-
#ifdef O_RDONLY
scm_c_define ("O_RDONLY", scm_from_int (O_RDONLY));
#endif
@@ -1770,6 +1886,15 @@ scm_init_filesys ()
#ifdef FD_CLOEXEC
scm_c_define ("FD_CLOEXEC", scm_from_int (FD_CLOEXEC));
#endif
+#endif /* HAVE_POSIX */
+
+ /* `access' symbols. */
+ scm_c_define ("R_OK", scm_from_int (R_OK));
+ scm_c_define ("W_OK", scm_from_int (W_OK));
+ scm_c_define ("X_OK", scm_from_int (X_OK));
+ scm_c_define ("F_OK", scm_from_int (F_OK));
+
+ scm_dot_string = scm_from_locale_string (".");
#include "libguile/filesys.x"
}
diff --git a/libguile/fports.c b/libguile/fports.c
index fdc8f467b..0b84d4413 100644
--- a/libguile/fports.c
+++ b/libguile/fports.c
@@ -1,5 +1,6 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
- *
+/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+ * 2004, 2006, 2007, 2008, 2009, 2010, 2011 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 License
* as published by the Free Software Foundation; either version 3 of
@@ -637,8 +638,8 @@ fport_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
scm_puts (SCM_PTOBNAME (SCM_PTOBNUM (exp)), port);
scm_putc (' ', port);
fdes = (SCM_FSTREAM (exp))->fdes;
-
-#ifdef HAVE_TTYNAME
+
+#if (defined HAVE_TTYNAME) && (defined HAVE_POSIX)
if (isatty (fdes))
scm_display (scm_ttyname (exp), port);
else
diff --git a/libguile/i18n.c b/libguile/i18n.c
index fc651fd7e..6ee159b73 100644
--- a/libguile/i18n.c
+++ b/libguile/i18n.c
@@ -82,6 +82,25 @@ setlocale (int category, const char *name)
/* Helper stringification macro. */
#define SCM_I18N_STRINGIFY(_name) # _name
+/* Acquiring and releasing the locale lock. */
+
+static inline void
+lock_locale_mutex (void)
+{
+#ifdef HAVE_POSIX
+ scm_i_pthread_mutex_lock (&scm_i_locale_mutex);
+#else
+#endif
+}
+
+static inline void
+unlock_locale_mutex (void)
+{
+#ifdef HAVE_POSIX
+ scm_i_pthread_mutex_unlock (&scm_i_locale_mutex);
+#else
+#endif
+}
/* Locale objects, string and character collation, and other locale-dependent
@@ -421,7 +440,7 @@ leave_locale_section (const scm_t_locale_settings *settings)
/* Restore the previous locale settings. */
(void)restore_locale_settings (settings);
- scm_i_pthread_mutex_unlock (&scm_i_locale_mutex);
+ unlock_locale_mutex ();
}
/* Enter a locked locale section. */
@@ -431,12 +450,12 @@ enter_locale_section (scm_t_locale locale,
{
int err;
- scm_i_pthread_mutex_lock (&scm_i_locale_mutex);
+ lock_locale_mutex ();
err = get_current_locale_settings (prev_locale);
if (err)
{
- scm_i_pthread_mutex_unlock (&scm_i_locale_mutex);
+ unlock_locale_mutex ();
return err;
}
@@ -483,7 +502,7 @@ get_current_locale (SCM *result)
c_locale = scm_gc_malloc (sizeof (* c_locale), "locale");
- scm_i_pthread_mutex_lock (&scm_i_locale_mutex);
+ lock_locale_mutex ();
c_locale->category_mask = LC_ALL_MASK;
c_locale->base_locale = SCM_UNDEFINED;
@@ -498,7 +517,7 @@ get_current_locale (SCM *result)
else
err = EINVAL;
- scm_i_pthread_mutex_unlock (&scm_i_locale_mutex);
+ unlock_locale_mutex ();
if (err)
scm_gc_free (c_locale, sizeof (* c_locale), "locale");
@@ -1490,7 +1509,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
http://opengroup.org/onlinepubs/007908799/xsh/nl_langinfo.html for
details. */
- scm_i_pthread_mutex_lock (&scm_i_locale_mutex);
+ lock_locale_mutex ();
if (c_locale != NULL)
{
#ifdef USE_GNU_LOCALE_API
@@ -1506,7 +1525,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
lsec_err = get_current_locale_settings (&lsec_prev_locale);
if (lsec_err)
- scm_i_pthread_mutex_unlock (&scm_i_locale_mutex);
+ unlock_locale_mutex ();
else
{
lsec_err = install_locale (c_locale);
@@ -1540,7 +1559,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
}
c_result = strdup (c_result);
- scm_i_pthread_mutex_unlock (&scm_i_locale_mutex);
+ unlock_locale_mutex ();
if (c_result == NULL)
result = SCM_BOOL_F;
diff --git a/libguile/init.c b/libguile/init.c
index 8b3b8cd33..874184615 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -455,8 +455,8 @@ scm_i_init_guile (void *base)
scm_init_numbers ();
scm_init_options ();
scm_init_pairs ();
-#ifdef HAVE_POSIX
scm_init_filesys (); /* Requires smob_prehistory */
+#ifdef HAVE_POSIX
scm_init_posix ();
#endif
#ifdef HAVE_REGCOMP
diff --git a/libguile/posix.c b/libguile/posix.c
index 422aadbe5..bfcefaee3 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1329,54 +1329,6 @@ SCM_DEFINE (scm_tmpnam, "tmpnam", 0, 0, 0,
#endif
-#ifndef HAVE_MKSTEMP
-extern int mkstemp (char *);
-#endif
-
-SCM_DEFINE (scm_mkstemp, "mkstemp!", 1, 0, 0,
- (SCM tmpl),
- "Create a new unique file in the file system and return a new\n"
- "buffered port open for reading and writing to the file.\n"
- "\n"
- "@var{tmpl} is a string specifying where the file should be\n"
- "created: it must end with @samp{XXXXXX} and those @samp{X}s\n"
- "will be changed in the string to return the name of the file.\n"
- "(@code{port-filename} on the port also gives the name.)\n"
- "\n"
- "POSIX doesn't specify the permissions mode of the file, on GNU\n"
- "and most systems it's @code{#o600}. An application can use\n"
- "@code{chmod} to relax that if desired. For example\n"
- "@code{#o666} less @code{umask}, which is usual for ordinary\n"
- "file creation,\n"
- "\n"
- "@example\n"
- "(let ((port (mkstemp! (string-copy \"/tmp/myfile-XXXXXX\"))))\n"
- " (chmod port (logand #o666 (lognot (umask))))\n"
- " ...)\n"
- "@end example")
-#define FUNC_NAME s_scm_mkstemp
-{
- char *c_tmpl;
- int rv;
-
- scm_dynwind_begin (0);
-
- c_tmpl = scm_to_locale_string (tmpl);
- scm_dynwind_free (c_tmpl);
-
- SCM_SYSCALL (rv = mkstemp (c_tmpl));
- if (rv == -1)
- SCM_SYSERROR;
-
- scm_substring_move_x (scm_from_locale_string (c_tmpl),
- SCM_INUM0, scm_string_length (tmpl),
- tmpl, SCM_INUM0);
-
- scm_dynwind_end ();
- return scm_fdes_to_port (rv, "w+", tmpl);
-}
-#undef FUNC_NAME
-
SCM_DEFINE (scm_tmpfile, "tmpfile", 0, 0, 0,
(void),
"Return an input/output port to a unique temporary file\n"
@@ -1489,58 +1441,6 @@ SCM_DEFINE (scm_utime, "utime", 1, 5, 0,
}
#undef FUNC_NAME
-SCM_DEFINE (scm_access, "access?", 2, 0, 0,
- (SCM path, SCM how),
- "Test accessibility of a file under the real UID and GID of the\n"
- "calling process. The return is @code{#t} if @var{path} exists\n"
- "and the permissions requested by @var{how} are all allowed, or\n"
- "@code{#f} if not.\n"
- "\n"
- "@var{how} is an integer which is one of the following values,\n"
- "or a bitwise-OR (@code{logior}) of multiple values.\n"
- "\n"
- "@defvar R_OK\n"
- "Test for read permission.\n"
- "@end defvar\n"
- "@defvar W_OK\n"
- "Test for write permission.\n"
- "@end defvar\n"
- "@defvar X_OK\n"
- "Test for execute permission.\n"
- "@end defvar\n"
- "@defvar F_OK\n"
- "Test for existence of the file. This is implied by each of the\n"
- "other tests, so there's no need to combine it with them.\n"
- "@end defvar\n"
- "\n"
- "It's important to note that @code{access?} does not simply\n"
- "indicate what will happen on attempting to read or write a\n"
- "file. In normal circumstances it does, but in a set-UID or\n"
- "set-GID program it doesn't because @code{access?} tests the\n"
- "real ID, whereas an open or execute attempt uses the effective\n"
- "ID.\n"
- "\n"
- "A program which will never run set-UID/GID can ignore the\n"
- "difference between real and effective IDs, but for maximum\n"
- "generality, especially in library functions, it's best not to\n"
- "use @code{access?} to predict the result of an open or execute,\n"
- "instead simply attempt that and catch any exception.\n"
- "\n"
- "The main use for @code{access?} is to let a set-UID/GID program\n"
- "determine what the invoking user would have been allowed to do,\n"
- "without the greater (or perhaps lesser) privileges afforded by\n"
- "the effective ID. For more on this, see ``Testing File\n"
- "Access'' in The GNU C Library Reference Manual.")
-#define FUNC_NAME s_scm_access
-{
- int rv;
-
- WITH_STRING (path, c_path,
- rv = access (c_path, scm_to_int (how)));
- return scm_from_bool (!rv);
-}
-#undef FUNC_NAME
-
SCM_DEFINE (scm_getpid, "getpid", 0, 0, 0,
(),
"Return an integer representing the current process ID.")
@@ -2222,12 +2122,6 @@ scm_init_posix ()
scm_c_define ("WUNTRACED", scm_from_int (WUNTRACED));
#endif
- /* access() symbols. */
- scm_c_define ("R_OK", scm_from_int (R_OK));
- scm_c_define ("W_OK", scm_from_int (W_OK));
- scm_c_define ("X_OK", scm_from_int (X_OK));
- scm_c_define ("F_OK", scm_from_int (F_OK));
-
#ifdef LC_COLLATE
scm_c_define ("LC_COLLATE", scm_from_int (LC_COLLATE));
#endif
diff --git a/meta/guile-tools.in b/meta/guile-tools.in
index a0822aefe..7f156ffd9 100755
--- a/meta/guile-tools.in
+++ b/meta/guile-tools.in
@@ -174,7 +174,9 @@ There is NO WARRANTY, to the extent permitted by law.
(else (values (reverse options) args))))))
(define (main args)
- (setlocale LC_ALL "")
+ (if (defined? 'setlocale)
+ (setlocale LC_ALL ""))
+
(call-with-values (lambda () (getopt args *option-grammar*))
(lambda (options args)
(cond
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 327e3fa31..800410c23 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -957,8 +957,9 @@ VALUE."
-(if (provided? 'posix)
- (primitive-load-path "ice-9/posix"))
+;; Load `posix.scm' even when not (provided? 'posix) so that we get the
+;; `stat' accessors.
+(primitive-load-path "ice-9/posix")
(if (provided? 'socket)
(primitive-load-path "ice-9/networking"))
From ee037cee3e3e545936e04e8bed3f7e0670a4ec11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Fri, 15 Apr 2011 09:09:30 +0200
Subject: [PATCH 15/48] Build `filesys.x'.
* libguile/Makefile.am (DOT_X_FILES): Add `filesys.x'.
---
libguile/Makefile.am | 1 +
1 file changed, 1 insertion(+)
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index 29de79167..4790cd917 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -243,6 +243,7 @@ DOT_X_FILES = \
expand.x \
extensions.x \
feature.x \
+ filesys.x \
fluids.x \
foreign.x \
fports.x \
From 1e56cff2337d4f6b0a9f3363ea1cb3ac5287a6ed Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Fri, 15 Apr 2011 11:27:27 +0200
Subject: [PATCH 16/48] add --fresh-auto-compile
* doc/ref/api-evaluation.texi (Compilation): Add discussion of
--fresh-auto-compile.
* doc/ref/scheme-scripts.texi (Invoking Guile): Add --fresh-auto-compile
option.
* NEWS: Add entry.
* libguile/load.c: Define %fresh-auto-compile.
(scm_primitive_load_path): Use it here.
(scm_init_load_should_auto_compile): Init from GUILE_AUTO_COMPILE env
var, with a value of "fresh".
* module/ice-9/boot-9.scm (load-in-vicinity): Auto-compilation cache is
stale if %fresh-auto-compile is true.
* module/ice-9/command-line.scm (compile-shell-switches): Parse out
--fresh-auto-compile.
---
NEWS | 5 +++++
doc/ref/api-evaluation.texi | 9 +++++++++
doc/ref/scheme-scripts.texi | 5 +++++
libguile/load.c | 27 +++++++++++++++++++++++++--
module/ice-9/boot-9.scm | 3 ++-
module/ice-9/command-line.scm | 8 +++++++-
6 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index cd12f603c..4f0c22040 100644
--- a/NEWS
+++ b/NEWS
@@ -128,6 +128,11 @@ interpreted as starting an R6RS hex escape. This is backward compatible
because the symbol printer would never produce a "\x" before. The
printer also works better too.
+** Added --force-auto-compile option
+
+This allows a user to invalidate the auto-compilation cache. It's
+usually not needed. See "Compilation" in the manual, for a discussion.
+
* Manual updates
** GOOPS documentation updates
diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi
index 682e84498..9430c744d 100644
--- a/doc/ref/api-evaluation.texi
+++ b/doc/ref/api-evaluation.texi
@@ -586,6 +586,15 @@ computation are fulfilled by macros and closures. Of course one good
counterexample is the REPL itself, or any code that reads expressions
from a port.)
+Automatic compilation generally works transparently, without any need
+for user intervention. However Guile does not yet do proper dependency
+tracking, so that if file @file{@var{a}.scm} uses macros from
+@file{@var{b}.scm}, and @var{@var{b}.scm} changes, @code{@var{a}.scm}
+would not be automatically recompiled. To forcibly invalidate the
+auto-compilation cache, pass the @code{--fresh-auto-compile} option to
+Guile, or set the @code{GUILE_AUTO_COMPILE} environment variable to
+@code{fresh} (instead of to @code{0} or @code{1}).
+
For more information on the compiler itself, see @ref{Compiling to the
Virtual Machine}. For information on the virtual machine, see @ref{A
Virtual Machine for Guile}.
diff --git a/doc/ref/scheme-scripts.texi b/doc/ref/scheme-scripts.texi
index 0ad1becf3..c7d22a4e9 100644
--- a/doc/ref/scheme-scripts.texi
+++ b/doc/ref/scheme-scripts.texi
@@ -227,6 +227,11 @@ development.
@item --auto-compile
Compile source files automatically (default behavior).
+@vnew{2.0.1}
+
+@item --fresh-auto-compile
+Treat the auto-compilation cache as invalid, forcing recompilation.
+
@vnew{2.0}
@item --no-auto-compile
diff --git a/libguile/load.c b/libguile/load.c
index 701b34b39..b0137a11b 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -210,6 +210,9 @@ static SCM *scm_loc_load_compiled_extensions;
/* Whether we should try to auto-compile. */
static SCM *scm_loc_load_should_auto_compile;
+/* Whether to treat all auto-compiled files as stale. */
+static SCM *scm_loc_fresh_auto_compile;
+
/* The fallback path for auto-compilation */
static SCM *scm_loc_compile_fallback_path;
@@ -824,6 +827,7 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
if (scm_is_false (compiled_filename)
&& scm_is_true (full_filename)
&& scm_is_true (*scm_loc_compile_fallback_path)
+ && scm_is_false (*scm_loc_fresh_auto_compile)
&& scm_is_pair (*scm_loc_load_compiled_extensions)
&& scm_is_string (scm_car (*scm_loc_load_compiled_extensions)))
{
@@ -857,6 +861,7 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
if (!compiled_is_fallback
&& scm_is_true (*scm_loc_compile_fallback_path)
+ && scm_is_false (*scm_loc_fresh_auto_compile)
&& scm_is_pair (*scm_loc_load_compiled_extensions)
&& scm_is_string (scm_car (*scm_loc_load_compiled_extensions)))
{
@@ -971,6 +976,8 @@ scm_init_load ()
= SCM_VARIABLE_LOC (scm_c_define ("%compile-fallback-path", SCM_BOOL_F));
scm_loc_load_should_auto_compile
= SCM_VARIABLE_LOC (scm_c_define ("%load-should-auto-compile", SCM_BOOL_F));
+ scm_loc_fresh_auto_compile
+ = SCM_VARIABLE_LOC (scm_c_define ("%fresh-auto-compile", SCM_BOOL_F));
the_reader = scm_make_fluid ();
scm_fluid_set_x (the_reader, SCM_BOOL_F);
@@ -988,8 +995,24 @@ scm_init_load ()
void
scm_init_load_should_auto_compile ()
{
- *scm_loc_load_should_auto_compile =
- scm_from_bool (scm_getenv_int ("GUILE_AUTO_COMPILE", 1));
+ char *auto_compile = getenv ("GUILE_AUTO_COMPILE");
+
+ if (auto_compile && strcmp (auto_compile, "0") == 0)
+ {
+ *scm_loc_load_should_auto_compile = SCM_BOOL_F;
+ *scm_loc_fresh_auto_compile = SCM_BOOL_F;
+ }
+ /* Allow "freshen" also. */
+ else if (auto_compile && strncmp (auto_compile, "fresh", 5) == 0)
+ {
+ *scm_loc_load_should_auto_compile = SCM_BOOL_T;
+ *scm_loc_fresh_auto_compile = SCM_BOOL_T;
+ }
+ else
+ {
+ *scm_loc_load_should_auto_compile = SCM_BOOL_T;
+ *scm_loc_fresh_auto_compile = SCM_BOOL_F;
+ }
}
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 800410c23..84e76bded 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -3290,7 +3290,8 @@ module '(ice-9 q) '(make-q q-length))}."
(catch #t
(lambda ()
(let* ((scmstat (stat name))
- (gostat (stat go-path #f)))
+ (gostat (and (not %fresh-auto-compile)
+ (stat go-path #f))))
(if (and gostat
(or (> (stat:mtime gostat) (stat:mtime scmstat))
(and (= (stat:mtime gostat) (stat:mtime scmstat))
diff --git a/module/ice-9/command-line.scm b/module/ice-9/command-line.scm
index 9797364e4..a34c9a67c 100644
--- a/module/ice-9/command-line.scm
+++ b/module/ice-9/command-line.scm
@@ -127,7 +127,8 @@ If FILE begins with `-' the -s switch is mandatory.
Default is to enable debugging for interactive
use, but not for `-s' and `-c'.
--auto-compile compile source files automatically
- --no-auto-compile disable automatic source file compilation
+ --fresh-auto-compile invalidate auto-compilation cache
+ --no-auto-compile disable automatic source file compilation
Default is to enable auto-compilation of source
files.
--listen[=P] Listen on a local port or a path for REPL clients.
@@ -295,6 +296,11 @@ If FILE begins with `-' the -s switch is mandatory.
(set! %load-should-auto-compile #t)
(parse args out))
+ ((string=? arg "--fresh-auto-compile")
+ (set! %load-should-auto-compile #t)
+ (set! %fresh-auto-compile #t)
+ (parse args out))
+
((string=? arg "--no-auto-compile")
(set! %load-should-auto-compile #f)
(parse args out))
From cc3546b027336c554218351d8a755866c9560948 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Fri, 15 Apr 2011 17:45:52 +0200
Subject: [PATCH 17/48] use gc_start_callback + asyncs for after-gc-hook,
instead of finalizers
* libguile/gc.c (run_before_gc_c_hook, scm_storage_prehistory)
(after_gc_async_thunk, queue_after_gc_hook, scm_init_gc): Instead of
playing our finalizer trick, connect to the GC start callback, and use
it to queue an async after-gc-hook. Seems to fix the after-gc-hook on
non-threaded builds. Though this does re-enable the before-gc C hook,
we don't wire up the Scheme hook because we're in the alloc lock; and
indeed, a before-GC scheme hook isn't a great idea...
---
libguile/gc.c | 68 +++++++++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 32 deletions(-)
diff --git a/libguile/gc.c b/libguile/gc.c
index 8816a61a6..da530ebcf 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -57,6 +57,9 @@ extern unsigned long * __libc_ia64_register_backing_store_base;
#include "libguile/bdw-gc.h"
+/* For GC_set_start_callback. */
+#include
+
#ifdef GUILE_DEBUG_MALLOC
#include "libguile/debug-malloc.h"
#endif
@@ -545,20 +548,9 @@ scm_gc_unregister_roots (SCM *b, unsigned long n)
}
static void
-scm_c_register_gc_callback (void *key, void (*func) (void *, void *),
- void *data)
+run_before_gc_c_hook (void)
{
- if (!key)
- key = GC_MALLOC_ATOMIC (sizeof (void*));
-
- GC_REGISTER_FINALIZER_NO_ORDER (key, func, data, NULL, NULL);
-}
-
-static void
-system_gc_callback (void *key, void *data)
-{
- scm_c_register_gc_callback (key, system_gc_callback, data);
- scm_c_hook_run (&scm_after_gc_c_hook, NULL);
+ scm_c_hook_run (&scm_before_gc_c_hook, NULL);
}
@@ -616,8 +608,6 @@ scm_storage_prehistory ()
scm_c_hook_init (&scm_before_sweep_c_hook, 0, SCM_C_HOOK_NORMAL);
scm_c_hook_init (&scm_after_sweep_c_hook, 0, SCM_C_HOOK_NORMAL);
scm_c_hook_init (&scm_after_gc_c_hook, 0, SCM_C_HOOK_NORMAL);
-
- scm_c_register_gc_callback (NULL, system_gc_callback, NULL);
}
scm_i_pthread_mutex_t scm_i_gc_admin_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
@@ -646,29 +636,31 @@ scm_init_gc_protect_object ()
SCM scm_after_gc_hook;
-static SCM gc_async;
+static SCM after_gc_async_cell;
-/* The function gc_async_thunk causes the execution of the after-gc-hook. It
- * is run after the gc, as soon as the asynchronous events are handled by the
- * evaluator.
+/* The function after_gc_async_thunk causes the execution of the
+ * after-gc-hook. It is run after the gc, as soon as the asynchronous
+ * events are handled by the evaluator.
*/
static SCM
-gc_async_thunk (void)
+after_gc_async_thunk (void)
{
+ /* Fun, no? Hook-run *and* run-hook? */
+ scm_c_hook_run (&scm_after_gc_c_hook, NULL);
scm_c_run_hook (scm_after_gc_hook, SCM_EOL);
return SCM_UNSPECIFIED;
}
-/* The function mark_gc_async is run by the scm_after_gc_c_hook at the end of
- * the garbage collection. The only purpose of this function is to mark the
- * gc_async (which will eventually lead to the execution of the
- * gc_async_thunk).
+/* The function queue_after_gc_hook is run by the scm_before_gc_c_hook
+ * at the end of the garbage collection. The only purpose of this
+ * function is to mark the after_gc_async (which will eventually lead to
+ * the execution of the after_gc_async_thunk).
*/
static void *
-mark_gc_async (void * hook_data SCM_UNUSED,
- void *fn_data SCM_UNUSED,
- void *data SCM_UNUSED)
+queue_after_gc_hook (void * hook_data SCM_UNUSED,
+ void *fn_data SCM_UNUSED,
+ void *data SCM_UNUSED)
{
/* If cell access debugging is enabled, the user may choose to perform
* additional garbage collections after an arbitrary number of cell
@@ -697,10 +689,17 @@ mark_gc_async (void * hook_data SCM_UNUSED,
#if (SCM_DEBUG_CELL_ACCESSES == 1)
if (scm_debug_cells_gc_interval == 0)
- scm_system_async_mark (gc_async);
-#else
- scm_system_async_mark (gc_async);
#endif
+ {
+ scm_i_thread *t = SCM_I_CURRENT_THREAD;
+
+ if (scm_is_false (SCM_CDR (after_gc_async_cell)))
+ {
+ SCM_SETCDR (after_gc_async_cell, t->active_asyncs);
+ t->active_asyncs = after_gc_async_cell;
+ t->pending_asyncs = 1;
+ }
+ }
return NULL;
}
@@ -793,9 +792,14 @@ scm_init_gc ()
scm_after_gc_hook = scm_make_hook (SCM_INUM0);
scm_c_define ("after-gc-hook", scm_after_gc_hook);
- gc_async = scm_c_make_gsubr ("%gc-thunk", 0, 0, 0, gc_async_thunk);
+ /* When the async is to run, the cdr of the gc_async pair gets set to
+ the asyncs queue of the current thread. */
+ after_gc_async_cell = scm_cons (scm_c_make_gsubr ("%after-gc-thunk", 0, 0, 0,
+ after_gc_async_thunk),
+ SCM_BOOL_F);
- scm_c_hook_add (&scm_after_gc_c_hook, mark_gc_async, NULL, 0);
+ scm_c_hook_add (&scm_before_gc_c_hook, queue_after_gc_hook, NULL, 0);
+ GC_set_start_callback (run_before_gc_c_hook);
#include "libguile/gc.x"
}
From 631e49ed767a877fc1776dc5b07818512fdc8c06 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Fri, 15 Apr 2011 18:05:23 +0200
Subject: [PATCH 18/48] weak hash table vacuum on before-gc C hook
* libguile/hashtab.c (weak_gc_callback)
(scm_c_register_weak_gc_callback): Change implementation to use the
before-gc C hook instead of the after-gc finalizers.
---
libguile/hashtab.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/libguile/hashtab.c b/libguile/hashtab.c
index a76c03812..f5c86a56f 100644
--- a/libguile/hashtab.c
+++ b/libguile/hashtab.c
@@ -418,32 +418,31 @@ SCM_DEFINE (scm_make_hash_table, "make-hash-table", 0, 1, 0,
}
#undef FUNC_NAME
-static void
-weak_gc_callback (void *ptr, void *data)
+static void*
+weak_gc_callback (void *hook_data, void *fn_data, void *data)
{
- void **weak = ptr;
- void *val = *weak;
+ void **weak = fn_data;
+ void *val = weak[0];
+ void (*callback) (SCM) = weak[1];
if (val)
- {
- void (*callback) (SCM) = data;
+ callback (PTR2SCM (val));
+ else
+ scm_c_hook_remove (&scm_before_gc_c_hook, weak_gc_callback, weak);
- GC_REGISTER_FINALIZER_NO_ORDER (ptr, weak_gc_callback, data, NULL, NULL);
-
- callback (PTR2SCM (val));
- }
+ return NULL;
}
static void
scm_c_register_weak_gc_callback (SCM obj, void (*callback) (SCM))
{
- void **weak = GC_MALLOC_ATOMIC (sizeof (void**));
+ void **weak = GC_MALLOC_ATOMIC (sizeof (void*) * 2);
- *weak = SCM2PTR (obj);
+ weak[0] = SCM2PTR (obj);
+ weak[1] = (void*)callback;
GC_GENERAL_REGISTER_DISAPPEARING_LINK (weak, SCM2PTR (obj));
- GC_REGISTER_FINALIZER_NO_ORDER (weak, weak_gc_callback, (void*)callback,
- NULL, NULL);
+ scm_c_hook_add (&scm_before_gc_c_hook, weak_gc_callback, weak, 0);
}
SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 0, 1, 0,
From 66b229d56ec8f3e023a76b9ebcf8c9fed7640834 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Fri, 15 Apr 2011 18:31:06 +0200
Subject: [PATCH 19/48] pre-GC_set_start_callback compatibility
* configure.ac: Add a check for GC_set_start_callback.
* libguile/gc.c (scm_i_gc): If we don't have GC_set_start_callback, run
the before-gc hook manually here.
(scm_init_gc): Otherwise set it as a start callback.
* libguile/hashtab.c (weak_gc_callback, weak_gc_hook)
(weak_gc_finalizer, scm_c_register_weak_gc_callback): Fix to work
either way, with or without GC_set_start_callback.
---
configure.ac | 2 +-
libguile/gc.c | 6 ++++++
libguile/hashtab.c | 39 +++++++++++++++++++++++++++++++--------
3 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index fe7777365..3bb6bf6c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1238,7 +1238,7 @@ save_LIBS="$LIBS"
LIBS="$BDW_GC_LIBS $LIBS"
CFLAGS="$BDW_GC_CFLAGS $CFLAGS"
-AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask])
+AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask GC_set_start_callback])
# Though the `GC_do_blocking ()' symbol is present in GC 7.1, it is not
# declared, and has a different type (returning void instead of
diff --git a/libguile/gc.c b/libguile/gc.c
index da530ebcf..341af6ff2 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -355,6 +355,9 @@ SCM_DEFINE (scm_gc, "gc", 0, 0, 0,
void
scm_i_gc (const char *what)
{
+#ifndef HAVE_GC_SET_START_CALLBACK
+ run_before_gc_c_hook ();
+#endif
GC_gcollect ();
}
@@ -799,7 +802,10 @@ scm_init_gc ()
SCM_BOOL_F);
scm_c_hook_add (&scm_before_gc_c_hook, queue_after_gc_hook, NULL, 0);
+
+#ifdef HAVE_GC_SET_START_CALLBACK
GC_set_start_callback (run_before_gc_c_hook);
+#endif
#include "libguile/gc.x"
}
diff --git a/libguile/hashtab.c b/libguile/hashtab.c
index f5c86a56f..48660d75c 100644
--- a/libguile/hashtab.c
+++ b/libguile/hashtab.c
@@ -418,20 +418,39 @@ SCM_DEFINE (scm_make_hash_table, "make-hash-table", 0, 1, 0,
}
#undef FUNC_NAME
-static void*
-weak_gc_callback (void *hook_data, void *fn_data, void *data)
+/* The before-gc C hook only runs if GC_set_start_callback is available,
+ so if not, fall back on a finalizer-based implementation. */
+static int
+weak_gc_callback (void **weak)
{
- void **weak = fn_data;
void *val = weak[0];
void (*callback) (SCM) = weak[1];
- if (val)
- callback (PTR2SCM (val));
- else
- scm_c_hook_remove (&scm_before_gc_c_hook, weak_gc_callback, weak);
+ if (!val)
+ return 0;
+
+ callback (PTR2SCM (val));
+
+ return 1;
+}
+
+#ifdef HAVE_GC_SET_START_CALLBACK
+static void*
+weak_gc_hook (void *hook_data, void *fn_data, void *data)
+{
+ if (!weak_gc_callback (fn_data))
+ scm_c_hook_remove (&scm_before_gc_c_hook, weak_gc_hook, fn_data);
return NULL;
}
+#else
+static void
+weak_gc_finalizer (void *ptr, void *data)
+{
+ if (weak_gc_callback (ptr))
+ GC_REGISTER_FINALIZER_NO_ORDER (ptr, weak_gc_finalizer, data, NULL, NULL);
+}
+#endif
static void
scm_c_register_weak_gc_callback (SCM obj, void (*callback) (SCM))
@@ -442,7 +461,11 @@ scm_c_register_weak_gc_callback (SCM obj, void (*callback) (SCM))
weak[1] = (void*)callback;
GC_GENERAL_REGISTER_DISAPPEARING_LINK (weak, SCM2PTR (obj));
- scm_c_hook_add (&scm_before_gc_c_hook, weak_gc_callback, weak, 0);
+#ifdef HAVE_GC_SET_START_CALLBACK
+ scm_c_hook_add (&scm_before_gc_c_hook, weak_gc_hook, weak, 0);
+#else
+ GC_REGISTER_FINALIZER_NO_ORDER (weak, weak_gc_finalizer, NULL, NULL, NULL);
+#endif
}
SCM_DEFINE (scm_make_weak_key_hash_table, "make-weak-key-hash-table", 0, 1, 0,
From 0fbdbe6c840d26f3910dfdcfe4049f8769786c24 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Fri, 15 Apr 2011 16:41:34 +0000
Subject: [PATCH 20/48] fix pre-GC_set_start_callback compilation
* libguile/gc.c: Move declaration of run_before_gc_hook up.
---
libguile/gc.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/libguile/gc.c b/libguile/gc.c
index 341af6ff2..7d2724c5f 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -198,6 +198,13 @@ scm_t_c_hook scm_after_sweep_c_hook;
scm_t_c_hook scm_after_gc_c_hook;
+static void
+run_before_gc_c_hook (void)
+{
+ scm_c_hook_run (&scm_before_gc_c_hook, NULL);
+}
+
+
/* GC Statistics Keeping
*/
unsigned long scm_gc_ports_collected = 0;
@@ -550,12 +557,6 @@ scm_gc_unregister_roots (SCM *b, unsigned long n)
scm_gc_unregister_root (p);
}
-static void
-run_before_gc_c_hook (void)
-{
- scm_c_hook_run (&scm_before_gc_c_hook, NULL);
-}
-
From 68a78738a4a3248c8c5ea1965936998763ff2d2e Mon Sep 17 00:00:00 2001
From: Mark H Weaver
Date: Tue, 19 Apr 2011 23:59:17 -0400
Subject: [PATCH 21/48] Clarify the units of returned lengths in string
conversion functions
* doc/ref/api-data.texi (Conversion to/from C): In descriptions of
scm_to_stringn and scm_to_{latin1,utf8,utf32}, clarify that the
returned length is in units of bytes or code points, not characters.
Also change NULL to @code{NULL} in a few places.
---
doc/ref/api-data.texi | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 760039a32..0cae22fdf 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -4280,13 +4280,13 @@ strings to Scheme.
@deftypefn {C Function} char *scm_to_stringn (SCM str, size_t *lenp, const char *encoding, scm_t_string_failed_conversion_handler handler)
This function returns a newly allocated C string from the Guile string
-@var{str}. The length of the string will be returned in @var{lenp}.
-The character encoding of the C string is passed as the ASCII,
+@var{str}. The length of the returned string in bytes will be returned in
+@var{lenp}. The character encoding of the C string is passed as the ASCII,
null-terminated C string @var{encoding}. The @var{handler} parameter
gives a strategy for dealing with characters that cannot be converted
into @var{encoding}.
-If @var{lenp} is NULL, this function will return a null-terminated C
+If @var{lenp} is @code{NULL}, this function will return a null-terminated C
string. It will throw an error if the string contains a null
character.
@end deftypefn
@@ -4325,11 +4325,14 @@ in @var{str} in the case of @code{scm_from_utf32_stringn}.
@deftypefnx {C function} scm_t_wchar *scm_to_utf32_stringn (SCM str, size_t *lenp)
Return a newly allocated, ISO-8859-1-, UTF-8-, or UTF-32-encoded C string
from Scheme string @var{str}. An error is thrown when @var{str}
-string cannot be converted to the specified encoding. If @var{lenp} is
+cannot be converted to the specified encoding. If @var{lenp} is
@code{NULL}, the returned C string will be null terminated, and an error
will be thrown if the C string would otherwise contain null
-characters. If @var{lenp} is not NULL, the length of the string is
-returned in @var{lenp}, and the string is not null terminated.
+characters. If @var{lenp} is not @code{NULL}, the string is not null terminated,
+and the length of the returned string is returned in @var{lenp}. The length
+returned is the number of bytes for @code{scm_to_latin1_stringn} and
+@code{scm_to_utf8_stringn}; it is the number of elements (code points)
+for @code{scm_to_utf32_stringn}.
@end deftypefn
@node String Internals
From c3d8450c757d1a98b44b3556a334bbebe1ad6f37 Mon Sep 17 00:00:00 2001
From: Mark H Weaver
Date: Thu, 21 Apr 2011 09:56:11 -0400
Subject: [PATCH 22/48] Clarify units of string length in decription of
scm_from_stringn
* doc/ref/api-data.texi (Conversion to/from C): In description of
scm_from_stringn, clarify that the length is specified in bytes.
---
doc/ref/api-data.texi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 0cae22fdf..9825bef86 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -4293,7 +4293,7 @@ character.
@deftypefn {C Function} SCM scm_from_stringn (const char *str, size_t len, const char *encoding, scm_t_string_failed_conversion_handler handler)
This function returns a scheme string from the C string @var{str}. The
-length of the C string is input as @var{len}. The encoding of the C
+length in bytes of the C string is input as @var{len}. The encoding of the C
string is passed as the ASCII, null-terminated C string @code{encoding}.
The @var{handler} parameters suggests a strategy for dealing with
unconvertable characters.
From 514ff6ea075f436795ee121b4abeac8a5affe866 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 21 Apr 2011 12:27:49 +0200
Subject: [PATCH 23/48] add test that libunistring was built with iconv support
* configure.ac: Add check that libunistring was built with iconv
support. Thanks to Mark Weaver for the debugging and test program.
---
configure.ac | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/configure.ac b/configure.ac
index 3bb6bf6c3..1e85b5740 100644
--- a/configure.ac
+++ b/configure.ac
@@ -874,6 +874,27 @@ if test "x$LTLIBUNISTRING" = "x"; then
AC_MSG_ERROR([GNU libunistring is required, please install it.])
fi
+AC_MSG_CHECKING([that libunistring was built with iconv support])
+save_LIBS=$LIBS
+LIBS="$LIBS $LIBUNISTRING"
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include
+#include
+int
+main (int argc, char *argv[])
+{
+ size_t result_size;
+ return (NULL == u32_conv_from_encoding ("ASCII", iconveh_question_mark,
+ "a", 1,
+ NULL, NULL, &result_size));
+}
+]])],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ AC_MSG_ERROR([No iconv support. Please recompile libunistring with iconv enabled.])]
+ [AC_MSG_RESULT([yes, hopefully (cross-compiling)])])
+LIBS=$save_LIBS
+
dnl Libffi is needed to compile Guile's foreign function interface, but its
dnl interface isn't exposed in Guile's API.
PKG_CHECK_MODULES(LIBFFI, libffi)
From ed756f7817005317eba674cd9b4bb3153e2d5e2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Fri, 22 Apr 2011 16:18:14 +0200
Subject: [PATCH 24/48] Increase the timeout of timing-sensitive thread tests.
* test-suite/tests/threads.test ("timed locking succeeds if mutex
unlocked within timeout", "timed unlocking returns #t if condition
signaled", "timed joining succeeds if thread exits within timeout"):
Increase the timeout. Reported by Dale P. Smith .
---
test-suite/tests/threads.test | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/test-suite/tests/threads.test b/test-suite/tests/threads.test
index 2ffffb59b..1166247c4 100644
--- a/test-suite/tests/threads.test
+++ b/test-suite/tests/threads.test
@@ -1,6 +1,6 @@
;;;; threads.test --- Tests for Guile threading. -*- scheme -*-
;;;;
-;;;; Copyright 2003, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+;;;; Copyright 2003, 2006, 2007, 2009, 2010, 2011 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
@@ -213,7 +213,7 @@
(signal-condition-variable c)
(unlock-mutex cm)
(lock-mutex m
- (+ (current-time) 2))))))
+ (+ (current-time) 5))))))
(lock-mutex m)
(wait-condition-variable c cm)
(unlock-mutex cm)
@@ -257,7 +257,7 @@
(unlock-mutex m2
c2
(+ (current-time)
- 2))))))
+ 5))))))
(wait-condition-variable c1 m1)
(unlock-mutex m1)
(lock-mutex m2)
@@ -292,7 +292,7 @@
(pass-if "timed joining succeeds if thread exits within timeout"
(let ((t (begin-thread (begin (sleep 1) #t))))
- (join-thread t (+ (current-time) 2))))
+ (join-thread t (+ (current-time) 5))))
(pass-if "asyncs are still working 1"
(asyncs-still-working?))
From a508fbdb01373aed4aed5378806454672e8e702c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Fri, 22 Apr 2011 16:40:58 +0200
Subject: [PATCH 25/48] Fix typo in `configure.ac'.
* configure.ac: Add missing comma in `AC_RUN_IFELSE' invocation.
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 1e85b5740..7708fb4f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -891,7 +891,7 @@ main (int argc, char *argv[])
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
- AC_MSG_ERROR([No iconv support. Please recompile libunistring with iconv enabled.])]
+ AC_MSG_ERROR([No iconv support. Please recompile libunistring with iconv enabled.])],
[AC_MSG_RESULT([yes, hopefully (cross-compiling)])])
LIBS=$save_LIBS
From 969bb92e9b13068abadb22eb7ab13c7f6616d266 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Fri, 22 Apr 2011 16:58:18 +0200
Subject: [PATCH 26/48] Turn the libunistring/iconv configure check into a
macro.
* acinclude.m4 (GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT): New macro.
* configure.ac: Use it.
---
acinclude.m4 | 29 +++++++++++++++++++++++++++++
configure.ac | 24 ++++--------------------
2 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index 3dbea2a0b..0938671c0 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -470,6 +470,35 @@ AC_DEFUN([GUILE_READLINE], [
AC_SUBST(LIBGUILEREADLINE_INTERFACE)
])
+dnl GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT
+dnl
+dnl Check whether libunistring has iconv support. When it lacks iconv
+dnl support, `mem_iconveh' returns -1 (ENOSYS) and conversions from one
+dnl codeset to another do not work.
+AC_DEFUN([GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT], [
+ AC_CACHE_CHECK([whether libunistring was built with iconv support],
+ [ac_cv_libunistring_with_iconv_support], [
+ save_LIBS=$LIBS
+ LIBS="$LIBS $LIBUNISTRING"
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include
+ #include
+ int
+ main (int argc, char *argv[])
+ {
+ size_t result_size;
+ return (NULL == u32_conv_from_encoding ("ASCII", iconveh_question_mark,
+ "a", 1,
+ NULL, NULL, &result_size));
+ }
+ ]])],
+ [ac_cv_libunistring_with_iconv_support=yes],
+ [ac_cv_libunistring_with_iconv_support=no],
+ [ac_cv_libunistring_with_iconv_support=yes])
+ LIBS=$save_LIBS
+ ])
+])
+
dnl Declare file $1 to be a script that needs configuring,
dnl and arrange to make it executable in the process.
AC_DEFUN([GUILE_CONFIG_SCRIPT],[AC_CONFIG_FILES([$1],[chmod +x $1])])
diff --git a/configure.ac b/configure.ac
index 7708fb4f8..685f9c18b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -874,26 +874,10 @@ if test "x$LTLIBUNISTRING" = "x"; then
AC_MSG_ERROR([GNU libunistring is required, please install it.])
fi
-AC_MSG_CHECKING([that libunistring was built with iconv support])
-save_LIBS=$LIBS
-LIBS="$LIBS $LIBUNISTRING"
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include
-#include
-int
-main (int argc, char *argv[])
-{
- size_t result_size;
- return (NULL == u32_conv_from_encoding ("ASCII", iconveh_question_mark,
- "a", 1,
- NULL, NULL, &result_size));
-}
-]])],
- [AC_MSG_RESULT([yes])],
- [AC_MSG_RESULT([no])
- AC_MSG_ERROR([No iconv support. Please recompile libunistring with iconv enabled.])],
- [AC_MSG_RESULT([yes, hopefully (cross-compiling)])])
-LIBS=$save_LIBS
+GUILE_LIBUNISTRING_WITH_ICONV_SUPPORT
+if test "x$ac_cv_libunistring_with_iconv_support" != "xyes"; then
+ AC_MSG_ERROR([No iconv support. Please recompile libunistring with iconv enabled.])
+fi
dnl Libffi is needed to compile Guile's foreign function interface, but its
dnl interface isn't exposed in Guile's API.
From 96128014bfaabe9e123c4f4928ce4c20427eaa53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Fri, 22 Apr 2011 23:55:37 +0200
Subject: [PATCH 27/48] Make sure binary ports pass `binary-port?' regardless
of the locale.
* libguile/r6rs-ports.c (make_bip, make_cbip, make_bop, make_cbop):
Set `c_port->encoding' to NULL.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input
Ports")["bytevector-input-port is binary"]: New test.
("7.2.7 Input Ports")["make-custom-binary-input-port"]: Make sure PORT
passes `binary-port?' and `input-port?'.
("8.2.10 Output ports")["bytevector-output-port is binary"]: New test.
["make-custom-binary-output"]: Rename to...
["make-custom-binary-output-port"]: ... this.
* test-suite/tests/ports.test ("string ports")["read-char, wrong
encoding, error", "read-char, wrong encoding, escape", "read-char,
wrong encoding, substitute", "peek-char, wrong encoding, error"]: Use
`set-port-encoding!' instead of `%default-port-encoding' to set the
encoding of bytevector input ports.
* test-suite/tests/rdelim.test ("read-line")["decoding error", "decoding
error, substitute"]: Likewise.
* doc/ref/api-io.texi (R6RS Port Manipulation): Document `binary-port?'
and `textual-port?'.
* doc/ref/r6rs.texi (R6RS Incompatibilities): Mention the soft
distinction between textual and binary ports.
---
doc/ref/api-io.texi | 25 +++++++++++++++++++++++++
doc/ref/r6rs.texi | 7 ++++++-
libguile/r6rs-ports.c | 20 ++++++++++++++++----
test-suite/tests/ports.test | 16 ++++++++--------
test-suite/tests/r6rs-ports.test | 15 ++++++++++++---
test-suite/tests/rdelim.test | 8 ++++----
6 files changed, 71 insertions(+), 20 deletions(-)
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index 02c184986..4786d79a4 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -1229,6 +1229,31 @@ Call @var{proc}, passing it @var{port} and closing @var{port} upon exit
of @var{proc}. Return the return values of @var{proc}.
@end deffn
+@deffn {Scheme Procedure} binary-port? port
+Return @code{#t} if @var{port} is a @dfn{binary port}, suitable for
+binary data input/output.
+
+Note that internally Guile does not differentiate between binary and
+textual ports, unlike the R6RS. Thus, this procedure returns true when
+@var{port} does not have an associated encoding---i.e., when
+@code{(port-encoding @var{port})} is @code{#f} (@pxref{Ports,
+port-encoding}). This is the case for ports returned by R6RS procedures
+such as @code{open-bytevector-input-port} and
+@code{make-custom-binary-output-port}.
+
+However, Guile currently does not prevent use of textual I/O procedures
+such as @code{display} or @code{read-char} with binary ports. Doing so
+``upgrades'' the port from binary to textual, under the ISO-8859-1
+encoding. Likewise, Guile does not prevent use of
+@code{set-port-encoding!} on a binary port, which also turns it into a
+``textual'' port.
+@end deffn
+
+@deffn {Scheme Procedure} textual-port? port
+Always return @var{#t}, as all ports can be used for textual I/O in
+Guile.
+@end deffn
+
@node R6RS Binary Input
@subsubsection Binary Input
diff --git a/doc/ref/r6rs.texi b/doc/ref/r6rs.texi
index bc569ed69..2fe8d7b76 100644
--- a/doc/ref/r6rs.texi
+++ b/doc/ref/r6rs.texi
@@ -93,8 +93,13 @@ implement in a backward-compatible way. Suggestions and/or patches would
be appreciated.
@item
-The @code{(rnrs io ports)} module is mostly unimplemented. Work is
+The @code{(rnrs io ports)} module is incomplete. Work is
ongoing to fix this.
+
+@item
+Guile does not prevent use of textual I/O procedures on binary ports.
+More generally, it does not make a sharp distinction between binary and
+textual ports (@pxref{R6RS Port Manipulation, binary-port?}).
@end itemize
@node R6RS Standard Libraries
diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index 7473db94b..b9d52829f 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -87,6 +87,10 @@ make_bip (SCM bv)
scm_i_scm_pthread_mutex_lock (&scm_i_port_table_mutex);
port = scm_new_port_table_entry (bytevector_input_port_type);
+ c_port = SCM_PTAB_ENTRY (port);
+
+ /* Match the expectation of `binary-port?'. */
+ c_port->encoding = NULL;
/* Prevent BV from being GC'd. */
SCM_SETSTREAM (port, SCM_UNPACK (bv));
@@ -95,7 +99,6 @@ make_bip (SCM bv)
c_bv = (char *) SCM_BYTEVECTOR_CONTENTS (bv);
c_len = SCM_BYTEVECTOR_LENGTH (bv);
- c_port = SCM_PTAB_ENTRY (port);
c_port->read_pos = c_port->read_buf = (unsigned char *) c_bv;
c_port->read_end = (unsigned char *) c_bv + c_len;
c_port->read_buf_size = c_len;
@@ -312,12 +315,15 @@ make_cbip (SCM read_proc, SCM get_position_proc,
scm_i_pthread_mutex_lock (&scm_i_port_table_mutex);
port = scm_new_port_table_entry (custom_binary_input_port_type);
+ c_port = SCM_PTAB_ENTRY (port);
+
+ /* Match the expectation of `binary-port?'. */
+ c_port->encoding = NULL;
/* Attach it the method vector. */
SCM_SETSTREAM (port, SCM_UNPACK (method_vector));
/* Have the port directly access the buffer (bytevector). */
- c_port = SCM_PTAB_ENTRY (port);
c_port->read_pos = c_port->read_buf = (unsigned char *) c_bv;
c_port->read_end = (unsigned char *) c_bv;
c_port->read_buf_size = c_len;
@@ -827,11 +833,14 @@ make_bop (void)
scm_i_pthread_mutex_lock (&scm_i_port_table_mutex);
port = scm_new_port_table_entry (bytevector_output_port_type);
+ c_port = SCM_PTAB_ENTRY (port);
+
+ /* Match the expectation of `binary-port?'. */
+ c_port->encoding = NULL;
buf = (scm_t_bop_buffer *) scm_gc_malloc (sizeof (* buf), SCM_GC_BOP);
bop_buffer_init (buf);
- c_port = SCM_PTAB_ENTRY (port);
c_port->write_buf = c_port->write_pos = c_port->write_end = NULL;
c_port->write_buf_size = 0;
@@ -983,12 +992,15 @@ make_cbop (SCM write_proc, SCM get_position_proc,
scm_i_pthread_mutex_lock (&scm_i_port_table_mutex);
port = scm_new_port_table_entry (custom_binary_output_port_type);
+ c_port = SCM_PTAB_ENTRY (port);
+
+ /* Match the expectation of `binary-port?'. */
+ c_port->encoding = NULL;
/* Attach it the method vector. */
SCM_SETSTREAM (port, SCM_UNPACK (method_vector));
/* Have the port directly access the buffer (bytevector). */
- c_port = SCM_PTAB_ENTRY (port);
c_port->write_buf = c_port->write_pos = c_port->write_end = NULL;
c_port->write_buf_size = c_port->read_buf_size = 0;
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index 72b58aea5..9d3000cc1 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -463,10 +463,10 @@
(= (port-column p) 0))))
(pass-if "read-char, wrong encoding, error"
- (let ((p (with-fluids ((%default-port-encoding "UTF-8"))
- (open-bytevector-input-port #vu8(255 65 66 67)))))
+ (let ((p (open-bytevector-input-port #vu8(255 65 66 67))))
(catch 'decoding-error
(lambda ()
+ (set-port-encoding! p "UTF-8")
(set-port-conversion-strategy! p 'error)
(read-char p)
#f)
@@ -483,10 +483,10 @@
(pass-if "read-char, wrong encoding, escape"
;; `escape' should behave exactly like `error'.
- (let ((p (with-fluids ((%default-port-encoding "UTF-8"))
- (open-bytevector-input-port #vu8(255 65 66 67)))))
+ (let ((p (open-bytevector-input-port #vu8(255 65 66 67))))
(catch 'decoding-error
(lambda ()
+ (set-port-encoding! p "UTF-8")
(set-port-conversion-strategy! p 'escape)
(read-char p)
#f)
@@ -502,8 +502,8 @@
(eof-object? (read-char port)))))))
(pass-if "read-char, wrong encoding, substitute"
- (let ((p (with-fluids ((%default-port-encoding "UTF-8"))
- (open-bytevector-input-port #vu8(255 206 187 206 188)))))
+ (let ((p (open-bytevector-input-port #vu8(255 206 187 206 188))))
+ (set-port-encoding! p "UTF-8")
(set-port-conversion-strategy! p 'substitute)
(equal? (list (read-char p) (read-char p) (read-char p))
'(#\? #\λ #\μ))))
@@ -518,8 +518,8 @@
#f)
(lambda (key subr message errno p)
(eq? p port)))))))
- (let ((p (with-fluids ((%default-port-encoding "UTF-8"))
- (open-bytevector-input-port #vu8(255 65 66 67)))))
+ (let ((p (open-bytevector-input-port #vu8(255 65 66 67))))
+ (set-port-encoding! p "UTF-8")
(set-port-conversion-strategy! p 'error)
;; `peek-char' should repeatedly raise an error.
diff --git a/test-suite/tests/r6rs-ports.test b/test-suite/tests/r6rs-ports.test
index 01d8235fa..06431bb76 100644
--- a/test-suite/tests/r6rs-ports.test
+++ b/test-suite/tests/r6rs-ports.test
@@ -294,6 +294,10 @@
(equal? (read-to-string port) str)))
+ (pass-if "bytevector-input-port is binary"
+ (with-fluids ((%default-port-encoding "UTF-8"))
+ (binary-port? (open-bytevector-input-port #vu8(1 2 3)))))
+
(pass-if-exception "bytevector-input-port is read-only"
exception:wrong-type-arg
@@ -350,7 +354,9 @@
(port (make-custom-binary-input-port "the port" read!
#f #f #f)))
- (bytevector=? (get-bytevector-all port) source)))
+ (and (binary-port? port)
+ (input-port? port)
+ (bytevector=? (get-bytevector-all port) source))))
(pass-if "custom binary input port does not support `port-position'"
(let* ((str "Hello Port!")
@@ -422,7 +428,10 @@
(put-bytevector port source)
(and (bytevector=? (get-content) source)
(bytevector=? (get-content) (make-bytevector 0))))))
-
+
+ (pass-if "bytevector-output-port is binary"
+ (binary-port? (open-bytevector-output-port)))
+
(pass-if "open-bytevector-output-port [extract after close]"
(let-values (((port get-content)
(open-bytevector-output-port)))
@@ -468,7 +477,7 @@
(bytevector=? (get-content) source)
(bytevector=? (get-content) (make-bytevector 0))))))
- (pass-if "make-custom-binary-output"
+ (pass-if "make-custom-binary-output-port"
(let ((port (make-custom-binary-output-port "cbop"
(lambda (x y z) 0)
#f #f #f)))
diff --git a/test-suite/tests/rdelim.test b/test-suite/tests/rdelim.test
index f827f62a0..e61fc9246 100644
--- a/test-suite/tests/rdelim.test
+++ b/test-suite/tests/rdelim.test
@@ -72,8 +72,8 @@
(eof-object? (read-line p)))))
(pass-if "decoding error"
- (let ((p (with-fluids ((%default-port-encoding "UTF-8"))
- (open-bytevector-input-port #vu8(65 255 66 67 68)))))
+ (let ((p (open-bytevector-input-port #vu8(65 255 66 67 68))))
+ (set-port-encoding! p "UTF-8")
(set-port-conversion-strategy! p 'error)
(catch 'decoding-error
(lambda ()
@@ -87,8 +87,8 @@
(eof-object? (read-line p)))))))
(pass-if "decoding error, substitute"
- (let ((p (with-fluids ((%default-port-encoding "UTF-8"))
- (open-bytevector-input-port #vu8(65 255 66 67 68)))))
+ (let ((p (open-bytevector-input-port #vu8(65 255 66 67 68))))
+ (set-port-encoding! p "UTF-8")
(set-port-conversion-strategy! p 'substitute)
(and (string=? (read-line p) "A?BCD")
(eof-object? (read-line p))))))
From 912308835dd0d3af61976cf1a4c19b60cb348b68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Mon, 25 Apr 2011 16:44:54 +0200
Subject: [PATCH 28/48] Make `scm_i_ensure_signal_delivery_thread' call in
Guile mode.
* libguile/threads.c (on_thread_exit): Move
`scm_i_ensure_signal_delivery_thread' call...
(do_thread_exit): ... here.
---
libguile/threads.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libguile/threads.c b/libguile/threads.c
index 66869e7c3..4de819395 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -613,6 +613,10 @@ do_thread_exit (void *v)
{
scm_i_thread *t = (scm_i_thread *) v;
+ /* Ensure the signal handling thread has been launched, because we might be
+ shutting it down. This needs to be done in Guile mode. */
+ scm_i_ensure_signal_delivery_thread ();
+
if (!scm_is_false (t->cleanup_handler))
{
SCM ptr = t->cleanup_handler;
@@ -687,10 +691,6 @@ on_thread_exit (void *v)
case but it doesn't hurt to be consistent. */
scm_i_pthread_setspecific (scm_i_thread_key, t);
- /* Ensure the signal handling thread has been launched, because we might be
- shutting it down. */
- scm_i_ensure_signal_delivery_thread ();
-
/* Scheme-level thread finalizers and other cleanup needs to happen in
guile mode. */
GC_call_with_stack_base (do_thread_exit_trampoline, t);
From 4a235623391dd0d3d46f87dcf00d152e1787c191 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Fri, 22 Apr 2011 12:29:50 +0200
Subject: [PATCH 29/48] Add pthread-related tests.
* test-suite/standalone/Makefile.am (test_scm_spawn_thread_CFLAGS,
test_scm_spawn_thread_LDADD, test_pthread_create_CFLAGS,
test_pthread_create_LDADD, test_pthread_create_secondary_CFLAGS,
test_pthread_create_secondary_LDADD): New variables.
(check_PROGRAMS)[BUILD_PTHREAD_SUPPORT]: Add `test-scm-spawn-thread',
`test-pthread_create', `test-pthread_create-secondary'.
(TESTS)[BUILD_PTHREAD_SUPPORT]: Likewise.
* test-suite/standalone/test-scm-spawn-thread.c,
test-suite/standalone/test-pthread-create.c,
test-suite/standalone/test-pthread-create-secondary.c: New files.
---
.gitignore | 3 +
test-suite/standalone/Makefile.am | 15 ++++
.../test-pthread-create-secondary.c | 85 +++++++++++++++++++
test-suite/standalone/test-pthread-create.c | 63 ++++++++++++++
test-suite/standalone/test-scm-spawn-thread.c | 62 ++++++++++++++
5 files changed, 228 insertions(+)
create mode 100644 test-suite/standalone/test-pthread-create-secondary.c
create mode 100644 test-suite/standalone/test-pthread-create.c
create mode 100644 test-suite/standalone/test-scm-spawn-thread.c
diff --git a/.gitignore b/.gitignore
index f24e589e5..a0eeeca76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -139,3 +139,6 @@ INSTALL
/.sc-start-*
/lib/math.h
/lib/sys/time.h
+/test-suite/standalone/test-scm-spawn-thread
+/test-suite/standalone/test-pthread-create
+/test-suite/standalone/test-pthread-create-secondary
diff --git a/test-suite/standalone/Makefile.am b/test-suite/standalone/Makefile.am
index b21edd20d..cf1fc4fe3 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -198,6 +198,21 @@ test_scm_with_guile_LDADD = $(LIBGUILE_LDADD)
check_PROGRAMS += test-scm-with-guile
TESTS += test-scm-with-guile
+test_scm_spawn_thread_CFLAGS = ${test_cflags}
+test_scm_spawn_thread_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-scm-spawn-thread
+TESTS += test-scm-spawn-thread
+
+test_pthread_create_CFLAGS = ${test_cflags}
+test_pthread_create_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-pthread-create
+TESTS += test-pthread-create
+
+test_pthread_create_secondary_CFLAGS = ${test_cflags} $(BDW_GC_CFLAGS)
+test_pthread_create_secondary_LDADD = $(LIBGUILE_LDADD)
+check_PROGRAMS += test-pthread-create-secondary
+TESTS += test-pthread-create-secondary
+
else
EXTRA_DIST += test-with-guile-module.c test-scm-with-guile.c
diff --git a/test-suite/standalone/test-pthread-create-secondary.c b/test-suite/standalone/test-pthread-create-secondary.c
new file mode 100644
index 000000000..fe39c2a26
--- /dev/null
+++ b/test-suite/standalone/test-pthread-create-secondary.c
@@ -0,0 +1,85 @@
+/* Copyright (C) 2011 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 License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* Test whether threads created with `pthread_create' work, and whether
+ a secondary thread can call `scm_with_guile'. (bug #32436). */
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+
+#include
+#include
+#include
+
+#include
+
+
+/* Up to GC 7.2alpha5, calling `GC_INIT' from a secondary thread would
+ lead to a segfault. This was fixed in BDW-GC on 2011-04-16 by Ivan
+ Maidanski. See
+ for details. */
+
+#if (GC_VERSION_MAJOR > 7) \
+ || ((GC_VERSION_MAJOR == 7) && (GC_VERSION_MINOR > 2)) \
+ || ((GC_VERSION_MAJOR == 7) && (GC_VERSION_MINOR == 2) \
+ && (GC_ALPHA_VERSION > 5))
+
+static void *
+do_something (void *arg)
+{
+ scm_list_copy (scm_make_list (scm_from_int (1234), SCM_BOOL_T));
+ scm_gc ();
+ return NULL;
+}
+
+static void *
+thread (void *arg)
+{
+ scm_with_guile (do_something, NULL);
+ return NULL;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int i;
+
+ for (i = 0; i < 77; i++)
+ {
+ pthread_t thr;
+
+ pthread_create (&thr, NULL, thread, NULL);
+ pthread_join (thr, NULL);
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
+#else /* GC < 7.2 */
+
+int
+main (int argc, char *argv[])
+{
+ /* Skip. */
+ return 77;
+}
+
+#endif /* GC < 7.2 */
diff --git a/test-suite/standalone/test-pthread-create.c b/test-suite/standalone/test-pthread-create.c
new file mode 100644
index 000000000..8d9617b58
--- /dev/null
+++ b/test-suite/standalone/test-pthread-create.c
@@ -0,0 +1,63 @@
+/* Copyright (C) 2011 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 License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* Test whether threads created with `pthread_create' work (bug #32436)
+ when then main thread is the one that initializes Guile. */
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+
+#include
+#include
+#include
+
+static void *
+do_something (void *arg)
+{
+ scm_list_copy (scm_make_list (scm_from_int (1234), SCM_BOOL_T));
+ scm_gc ();
+ return NULL;
+}
+
+static void *
+thread (void *arg)
+{
+ scm_with_guile (do_something, NULL);
+ return NULL;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int i;
+ pthread_t thr;
+
+ scm_init_guile ();
+
+ do_something (NULL);
+
+ for (i = 0; i < 77; i++)
+ {
+ pthread_create (&thr, NULL, thread, NULL);
+ pthread_join (thr, NULL);
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/test-suite/standalone/test-scm-spawn-thread.c b/test-suite/standalone/test-scm-spawn-thread.c
new file mode 100644
index 000000000..b632ab0fe
--- /dev/null
+++ b/test-suite/standalone/test-scm-spawn-thread.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 2011 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 License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+/* Test whether a thread created with `scm_spawn_thread' can be joined.
+ See for the
+ original report. */
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+
+#include
+
+#include
+#include
+
+static SCM
+thread_main (void *data)
+{
+ return SCM_BOOL_T;
+}
+
+static SCM
+thread_handler (void *data, SCM key, SCM args)
+{
+ return SCM_BOOL_T;
+}
+
+static void *
+inner_main (void *data)
+{
+ SCM thread, timeout;
+
+ thread = scm_spawn_thread (thread_main, 0, thread_handler, 0);
+ timeout = scm_from_unsigned_integer (time (NULL) + 10);
+ return (void *) scm_join_thread_timed (thread, timeout, SCM_BOOL_F);
+}
+
+
+int
+main (int argc, char **argv)
+{
+ SCM result;
+
+ result = PTR2SCM (scm_with_guile (inner_main, 0));
+ return scm_is_true (result) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
From bbec4602457ed3e139e9dae99b4b495a3bc5eb71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Mon, 25 Apr 2011 22:36:30 +0200
Subject: [PATCH 30/48] Make the `sizeof (mpz_t)' check at compile-time.
* libguile/init.c (scm_i_init_guile): Remove the `sizeof (mpz_t)'
run-time check.
* libguile/numbers.c: Add a compile-time check for `sizeof (mpz_t)'.
---
libguile/init.c | 7 -------
libguile/numbers.c | 5 +++++
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/libguile/init.c b/libguile/init.c
index 874184615..94de5c90a 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -381,13 +381,6 @@ scm_i_init_guile (void *base)
if (scm_initialized_p)
return;
- if (sizeof (mpz_t) > (3 * sizeof (scm_t_bits)))
- {
- fprintf (stderr,
- "GMP's mpz_t must fit into a double_cell,"
- "but doesn't seem to here.\n");
- }
-
scm_storage_prehistory ();
scm_threads_prehistory (base); /* requires storage_prehistory */
scm_weaks_prehistory (); /* requires storage_prehistory */
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 74753812b..742f4d1fe 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -45,6 +45,8 @@
# include
#endif
+#include
+
#include
#include
#include
@@ -68,6 +70,9 @@
#include "libguile/eq.h"
+/* GMP's `mpz_t' must fit into a double cell. */
+verify (sizeof (mpz_t) <= (2 * sizeof (scm_t_bits)));
+
/* values per glibc, if not already defined */
#ifndef M_LOG10E
#define M_LOG10E 0.43429448190325182765
From d20912e67d810ce5eb9dc1b8f8afd8c22aa2451b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Mon, 25 Apr 2011 22:41:58 +0200
Subject: [PATCH 31/48] Move `{total,current}-processor-count' outside of
`posix.c'.
* libguile/posix.c (scm_total_processor_count,
scm_current_processor_count): Move to...
* libguile/threads.c: ... here.
* libguile/posix.h (scm_total_processor_count,
scm_current_processor_count): Move declarations to...
* libguile/threads.h: ... here.
* test-suite/tests/posix.test ("nproc"): Move tests to...
* test-suite/tests/threads.test: ... here.
---
libguile/posix.c | 31 -------------------------------
libguile/posix.h | 5 ++---
libguile/threads.c | 34 ++++++++++++++++++++++++++++++++++
libguile/threads.h | 3 +++
test-suite/tests/posix.test | 13 -------------
test-suite/tests/threads.test | 14 ++++++++++++++
6 files changed, 53 insertions(+), 47 deletions(-)
diff --git a/libguile/posix.c b/libguile/posix.c
index bfcefaee3..15b38e79c 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -142,7 +142,6 @@ extern char *ttyname();
#endif
#include /* from Gnulib */
-#include
/* Some Unix systems don't define these. CPP hair is dangerous, but
this seems safe enough... */
@@ -1895,36 +1894,6 @@ SCM_DEFINE (scm_setaffinity, "setaffinity", 2, 0, 0,
#endif /* HAVE_SCHED_SETAFFINITY */
-SCM_DEFINE (scm_total_processor_count, "total-processor-count", 0, 0, 0,
- (void),
- "Return the total number of processors of the machine, which\n"
- "is guaranteed to be at least 1. A ``processor'' here is a\n"
- "thread execution unit, which can be either:\n\n"
- "@itemize\n"
- "@item an execution core in a (possibly multi-core) chip, in a\n"
- " (possibly multi- chip) module, in a single computer, or\n"
- "@item a thread execution unit inside a core in the case of\n"
- " @dfn{hyper-threaded} CPUs.\n"
- "@end itemize\n\n"
- "Which of the two definitions is used, is unspecified.\n")
-#define FUNC_NAME s_scm_total_processor_count
-{
- return scm_from_ulong (num_processors (NPROC_ALL));
-}
-#undef FUNC_NAME
-
-SCM_DEFINE (scm_current_processor_count, "current-processor-count", 0, 0, 0,
- (void),
- "Like @code{total-processor-count}, but return the number of\n"
- "processors available to the current process. See\n"
- "@code{setaffinity} and @code{getaffinity} for more\n"
- "information.\n")
-#define FUNC_NAME s_scm_current_processor_count
-{
- return scm_from_ulong (num_processors (NPROC_CURRENT));
-}
-#undef FUNC_NAME
-
#if HAVE_GETPASS
SCM_DEFINE (scm_getpass, "getpass", 1, 0, 0,
diff --git a/libguile/posix.h b/libguile/posix.h
index e2e19ddd2..92f8b3514 100644
--- a/libguile/posix.h
+++ b/libguile/posix.h
@@ -3,7 +3,8 @@
#ifndef SCM_POSIX_H
#define SCM_POSIX_H
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2003, 2006, 2008,
+ * 2009, 2010, 2011 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 License
@@ -91,8 +92,6 @@ SCM_API SCM scm_sethostname (SCM name);
SCM_API SCM scm_gethostname (void);
SCM_API SCM scm_getaffinity (SCM pid);
SCM_API SCM scm_setaffinity (SCM pid, SCM cpu_set);
-SCM_API SCM scm_total_processor_count (void);
-SCM_API SCM scm_current_processor_count (void);
SCM_INTERNAL void scm_init_posix (void);
SCM_INTERNAL scm_i_pthread_mutex_t scm_i_locale_mutex;
diff --git a/libguile/threads.c b/libguile/threads.c
index 4de819395..f49696b1d 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -39,6 +39,7 @@
#endif
#include
+#include
#include "libguile/validate.h"
#include "libguile/root.h"
@@ -2010,6 +2011,39 @@ scm_c_thread_exited_p (SCM thread)
}
#undef FUNC_NAME
+SCM_DEFINE (scm_total_processor_count, "total-processor-count", 0, 0, 0,
+ (void),
+ "Return the total number of processors of the machine, which\n"
+ "is guaranteed to be at least 1. A ``processor'' here is a\n"
+ "thread execution unit, which can be either:\n\n"
+ "@itemize\n"
+ "@item an execution core in a (possibly multi-core) chip, in a\n"
+ " (possibly multi- chip) module, in a single computer, or\n"
+ "@item a thread execution unit inside a core in the case of\n"
+ " @dfn{hyper-threaded} CPUs.\n"
+ "@end itemize\n\n"
+ "Which of the two definitions is used, is unspecified.\n")
+#define FUNC_NAME s_scm_total_processor_count
+{
+ return scm_from_ulong (num_processors (NPROC_ALL));
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_current_processor_count, "current-processor-count", 0, 0, 0,
+ (void),
+ "Like @code{total-processor-count}, but return the number of\n"
+ "processors available to the current process. See\n"
+ "@code{setaffinity} and @code{getaffinity} for more\n"
+ "information.\n")
+#define FUNC_NAME s_scm_current_processor_count
+{
+ return scm_from_ulong (num_processors (NPROC_CURRENT));
+}
+#undef FUNC_NAME
+
+
+
+
static scm_i_pthread_cond_t wake_up_cond;
static int threads_initialized_p = 0;
diff --git a/libguile/threads.h b/libguile/threads.h
index 9e44684e1..609262a19 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -230,6 +230,9 @@ SCM_API int scm_pthread_cond_timedwait (pthread_cond_t *cond,
SCM_API unsigned int scm_std_sleep (unsigned int);
SCM_API unsigned long scm_std_usleep (unsigned long);
+SCM_API SCM scm_total_processor_count (void);
+SCM_API SCM scm_current_processor_count (void);
+
#endif /* SCM_THREADS_H */
/*
diff --git a/test-suite/tests/posix.test b/test-suite/tests/posix.test
index 79f3a92ae..9679042a6 100644
--- a/test-suite/tests/posix.test
+++ b/test-suite/tests/posix.test
@@ -198,16 +198,3 @@
(setaffinity (getpid) mask)
(equal? mask (getaffinity (getpid))))
(throw 'unresolved))))
-
-;;
-;; nproc
-;;
-
-(with-test-prefix "nproc"
-
- (pass-if "total-processor-count"
- (>= (total-processor-count) 1))
-
- (pass-if "current-processor-count"
- (and (>= (current-processor-count) 1)
- (>= (total-processor-count) (current-processor-count)))))
diff --git a/test-suite/tests/threads.test b/test-suite/tests/threads.test
index 1166247c4..db002f245 100644
--- a/test-suite/tests/threads.test
+++ b/test-suite/tests/threads.test
@@ -463,3 +463,17 @@
(lambda () (lock-mutex m))
(lambda key (set! success #t)))
success)))))
+
+
+;;
+;; nproc
+;;
+
+(with-test-prefix "nproc"
+
+ (pass-if "total-processor-count"
+ (>= (total-processor-count) 1))
+
+ (pass-if "current-processor-count"
+ (and (>= (current-processor-count) 1)
+ (>= (total-processor-count) (current-processor-count)))))
From d0476fa2b061638879fed89cd8d79add6f586448 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Mon, 25 Apr 2011 22:52:00 +0200
Subject: [PATCH 32/48] Compile more file system related procedures when
`--disable-posix'.
* libguile/filesys.c (scm_tc16_dir, scm_directory_stream_p, scm_opendir,
scm_readdir, scm_rewinddir, scm_closedir, scm_dir_print,
scm_dir_free, scm_lstat): Compile unconditionally.
---
libguile/filesys.c | 402 ++++++++++++++++++++++-----------------------
1 file changed, 200 insertions(+), 202 deletions(-)
diff --git a/libguile/filesys.c b/libguile/filesys.c
index fab8ab41d..b43536f0a 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -602,6 +602,31 @@ SCM_DEFINE (scm_stat, "stat", 1, 1, 0,
}
#undef FUNC_NAME
+#ifdef HAVE_LSTAT
+SCM_DEFINE (scm_lstat, "lstat", 1, 0, 0,
+ (SCM str),
+ "Similar to @code{stat}, but does not follow symbolic links, i.e.,\n"
+ "it will return information about a symbolic link itself, not the\n"
+ "file it points to. @var{path} must be a string.")
+#define FUNC_NAME s_scm_lstat
+{
+ int rv;
+ struct stat_or_stat64 stat_temp;
+
+ STRING_SYSCALL (str, c_str, rv = lstat_or_lstat64 (c_str, &stat_temp));
+ if (rv != 0)
+ {
+ int en = errno;
+
+ SCM_SYSERROR_MSG ("~A: ~S",
+ scm_list_2 (scm_strerror (scm_from_int (en)), str),
+ en);
+ }
+ return scm_stat2scm (&stat_temp);
+}
+#undef FUNC_NAME
+#endif /* HAVE_LSTAT */
+
#ifdef HAVE_POSIX
@@ -629,183 +654,6 @@ SCM_DEFINE (scm_link, "link", 2, 0, 0,
#undef FUNC_NAME
#endif /* HAVE_LINK */
-
-
-/* {Examining Directories}
- */
-
-scm_t_bits scm_tc16_dir;
-
-
-SCM_DEFINE (scm_directory_stream_p, "directory-stream?", 1, 0, 0,
- (SCM obj),
- "Return a boolean indicating whether @var{object} is a directory\n"
- "stream as returned by @code{opendir}.")
-#define FUNC_NAME s_scm_directory_stream_p
-{
- return scm_from_bool (SCM_DIRP (obj));
-}
-#undef FUNC_NAME
-
-
-SCM_DEFINE (scm_opendir, "opendir", 1, 0, 0,
- (SCM dirname),
- "Open the directory specified by @var{path} and return a directory\n"
- "stream.")
-#define FUNC_NAME s_scm_opendir
-{
- DIR *ds;
- STRING_SYSCALL (dirname, c_dirname, ds = opendir (c_dirname));
- if (ds == NULL)
- SCM_SYSERROR;
- SCM_RETURN_NEWSMOB (scm_tc16_dir | (SCM_DIR_FLAG_OPEN<<16), ds);
-}
-#undef FUNC_NAME
-
-
-/* FIXME: The glibc manual has a portability note that readdir_r may not
- null-terminate its return string. The circumstances outlined for this
- are not clear, nor is it clear what should be done about it. Lets use
- NAMLEN and worry about what else should be done if/when someone can
- figure it out. */
-
-SCM_DEFINE (scm_readdir, "readdir", 1, 0, 0,
- (SCM port),
- "Return (as a string) the next directory entry from the directory stream\n"
- "@var{stream}. If there is no remaining entry to be read then the\n"
- "end of file object is returned.")
-#define FUNC_NAME s_scm_readdir
-{
- struct dirent_or_dirent64 *rdent;
-
- SCM_VALIDATE_DIR (1, port);
- if (!SCM_DIR_OPEN_P (port))
- SCM_MISC_ERROR ("Directory ~S is not open.", scm_list_1 (port));
-
-#if HAVE_READDIR_R
- /* As noted in the glibc manual, on various systems (such as Solaris) the
- d_name[] field is only 1 char and you're expected to size the dirent
- buffer for readdir_r based on NAME_MAX. The SCM_MAX expressions below
- effectively give either sizeof(d_name) or NAME_MAX+1, whichever is
- bigger.
-
- On solaris 10 there's no NAME_MAX constant, it's necessary to use
- pathconf(). We prefer NAME_MAX though, since it should be a constant
- and will therefore save a system call. We also prefer it since dirfd()
- is not available everywhere.
-
- An alternative to dirfd() would be to open() the directory and then use
- fdopendir(), if the latter is available. That'd let us hold the fd
- somewhere in the smob, or just the dirent size calculated once. */
- {
- struct dirent_or_dirent64 de; /* just for sizeof */
- DIR *ds = (DIR *) SCM_SMOB_DATA_1 (port);
-#ifdef NAME_MAX
- char buf [SCM_MAX (sizeof (de),
- sizeof (de) - sizeof (de.d_name) + NAME_MAX + 1)];
-#else
- char *buf;
- long name_max = fpathconf (dirfd (ds), _PC_NAME_MAX);
- if (name_max == -1)
- SCM_SYSERROR;
- buf = alloca (SCM_MAX (sizeof (de),
- sizeof (de) - sizeof (de.d_name) + name_max + 1));
-#endif
-
- errno = 0;
- SCM_SYSCALL (readdir_r_or_readdir64_r (ds, (struct dirent_or_dirent64 *) buf, &rdent));
- if (errno != 0)
- SCM_SYSERROR;
- if (! rdent)
- return SCM_EOF_VAL;
-
- return (rdent ? scm_from_locale_stringn (rdent->d_name, NAMLEN (rdent))
- : SCM_EOF_VAL);
- }
-#else
- {
- SCM ret;
- scm_dynwind_begin (0);
- scm_i_dynwind_pthread_mutex_lock (&scm_i_misc_mutex);
-
- errno = 0;
- SCM_SYSCALL (rdent = readdir_or_readdir64 ((DIR *) SCM_SMOB_DATA_1 (port)));
- if (errno != 0)
- SCM_SYSERROR;
-
- ret = (rdent ? scm_from_locale_stringn (rdent->d_name, NAMLEN (rdent))
- : SCM_EOF_VAL);
-
- scm_dynwind_end ();
- return ret;
- }
-#endif
-}
-#undef FUNC_NAME
-
-
-SCM_DEFINE (scm_rewinddir, "rewinddir", 1, 0, 0,
- (SCM port),
- "Reset the directory port @var{stream} so that the next call to\n"
- "@code{readdir} will return the first directory entry.")
-#define FUNC_NAME s_scm_rewinddir
-{
- SCM_VALIDATE_DIR (1, port);
- if (!SCM_DIR_OPEN_P (port))
- SCM_MISC_ERROR ("Directory ~S is not open.", scm_list_1 (port));
-
- rewinddir ((DIR *) SCM_SMOB_DATA_1 (port));
-
- return SCM_UNSPECIFIED;
-}
-#undef FUNC_NAME
-
-
-SCM_DEFINE (scm_closedir, "closedir", 1, 0, 0,
- (SCM port),
- "Close the directory stream @var{stream}.\n"
- "The return value is unspecified.")
-#define FUNC_NAME s_scm_closedir
-{
- SCM_VALIDATE_DIR (1, port);
-
- if (SCM_DIR_OPEN_P (port))
- {
- int sts;
-
- SCM_SYSCALL (sts = closedir ((DIR *) SCM_SMOB_DATA_1 (port)));
- if (sts != 0)
- SCM_SYSERROR;
-
- SCM_SET_SMOB_DATA_0 (port, scm_tc16_dir);
- }
-
- return SCM_UNSPECIFIED;
-}
-#undef FUNC_NAME
-
-
-static int
-scm_dir_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
-{
- scm_puts ("#<", port);
- if (!SCM_DIR_OPEN_P (exp))
- scm_puts ("closed: ", port);
- scm_puts ("directory stream ", port);
- scm_uintprint (SCM_SMOB_DATA_1 (exp), 16, port);
- scm_putc ('>', port);
- return 1;
-}
-
-
-static size_t
-scm_dir_free (SCM p)
-{
- if (SCM_DIR_OPEN_P (p))
- closedir ((DIR *) SCM_SMOB_DATA_1 (p));
- return 0;
-}
-
/* {Navigating Directories}
*/
@@ -1250,31 +1098,6 @@ SCM_DEFINE (scm_readlink, "readlink", 1, 0, 0,
#undef FUNC_NAME
#endif /* HAVE_READLINK */
-#ifdef HAVE_LSTAT
-SCM_DEFINE (scm_lstat, "lstat", 1, 0, 0,
- (SCM str),
- "Similar to @code{stat}, but does not follow symbolic links, i.e.,\n"
- "it will return information about a symbolic link itself, not the\n"
- "file it points to. @var{path} must be a string.")
-#define FUNC_NAME s_scm_lstat
-{
- int rv;
- struct stat_or_stat64 stat_temp;
-
- STRING_SYSCALL (str, c_str, rv = lstat_or_lstat64 (c_str, &stat_temp));
- if (rv != 0)
- {
- int en = errno;
-
- SCM_SYSERROR_MSG ("~A: ~S",
- scm_list_2 (scm_strerror (scm_from_int (en)), str),
- en);
- }
- return scm_stat2scm (&stat_temp);
-}
-#undef FUNC_NAME
-#endif /* HAVE_LSTAT */
-
SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0,
(SCM oldfile, SCM newfile),
"Copy the file specified by @var{path-from} to @var{path-to}.\n"
@@ -1814,6 +1637,181 @@ scm_i_relativize_path (SCM path, SCM in_path)
return SCM_BOOL_F;
}
+
+/* Examining directories. These procedures are used by `check-guile'
+ and thus compiled unconditionally. */
+
+scm_t_bits scm_tc16_dir;
+
+
+SCM_DEFINE (scm_directory_stream_p, "directory-stream?", 1, 0, 0,
+ (SCM obj),
+ "Return a boolean indicating whether @var{object} is a directory\n"
+ "stream as returned by @code{opendir}.")
+#define FUNC_NAME s_scm_directory_stream_p
+{
+ return scm_from_bool (SCM_DIRP (obj));
+}
+#undef FUNC_NAME
+
+
+SCM_DEFINE (scm_opendir, "opendir", 1, 0, 0,
+ (SCM dirname),
+ "Open the directory specified by @var{path} and return a directory\n"
+ "stream.")
+#define FUNC_NAME s_scm_opendir
+{
+ DIR *ds;
+ STRING_SYSCALL (dirname, c_dirname, ds = opendir (c_dirname));
+ if (ds == NULL)
+ SCM_SYSERROR;
+ SCM_RETURN_NEWSMOB (scm_tc16_dir | (SCM_DIR_FLAG_OPEN<<16), ds);
+}
+#undef FUNC_NAME
+
+
+/* FIXME: The glibc manual has a portability note that readdir_r may not
+ null-terminate its return string. The circumstances outlined for this
+ are not clear, nor is it clear what should be done about it. Lets use
+ NAMLEN and worry about what else should be done if/when someone can
+ figure it out. */
+
+SCM_DEFINE (scm_readdir, "readdir", 1, 0, 0,
+ (SCM port),
+ "Return (as a string) the next directory entry from the directory stream\n"
+ "@var{stream}. If there is no remaining entry to be read then the\n"
+ "end of file object is returned.")
+#define FUNC_NAME s_scm_readdir
+{
+ struct dirent_or_dirent64 *rdent;
+
+ SCM_VALIDATE_DIR (1, port);
+ if (!SCM_DIR_OPEN_P (port))
+ SCM_MISC_ERROR ("Directory ~S is not open.", scm_list_1 (port));
+
+#if HAVE_READDIR_R
+ /* As noted in the glibc manual, on various systems (such as Solaris) the
+ d_name[] field is only 1 char and you're expected to size the dirent
+ buffer for readdir_r based on NAME_MAX. The SCM_MAX expressions below
+ effectively give either sizeof(d_name) or NAME_MAX+1, whichever is
+ bigger.
+
+ On solaris 10 there's no NAME_MAX constant, it's necessary to use
+ pathconf(). We prefer NAME_MAX though, since it should be a constant
+ and will therefore save a system call. We also prefer it since dirfd()
+ is not available everywhere.
+
+ An alternative to dirfd() would be to open() the directory and then use
+ fdopendir(), if the latter is available. That'd let us hold the fd
+ somewhere in the smob, or just the dirent size calculated once. */
+ {
+ struct dirent_or_dirent64 de; /* just for sizeof */
+ DIR *ds = (DIR *) SCM_SMOB_DATA_1 (port);
+#ifdef NAME_MAX
+ char buf [SCM_MAX (sizeof (de),
+ sizeof (de) - sizeof (de.d_name) + NAME_MAX + 1)];
+#else
+ char *buf;
+ long name_max = fpathconf (dirfd (ds), _PC_NAME_MAX);
+ if (name_max == -1)
+ SCM_SYSERROR;
+ buf = alloca (SCM_MAX (sizeof (de),
+ sizeof (de) - sizeof (de.d_name) + name_max + 1));
+#endif
+
+ errno = 0;
+ SCM_SYSCALL (readdir_r_or_readdir64_r (ds, (struct dirent_or_dirent64 *) buf, &rdent));
+ if (errno != 0)
+ SCM_SYSERROR;
+ if (! rdent)
+ return SCM_EOF_VAL;
+
+ return (rdent ? scm_from_locale_stringn (rdent->d_name, NAMLEN (rdent))
+ : SCM_EOF_VAL);
+ }
+#else
+ {
+ SCM ret;
+ scm_dynwind_begin (0);
+ scm_i_dynwind_pthread_mutex_lock (&scm_i_misc_mutex);
+
+ errno = 0;
+ SCM_SYSCALL (rdent = readdir_or_readdir64 ((DIR *) SCM_SMOB_DATA_1 (port)));
+ if (errno != 0)
+ SCM_SYSERROR;
+
+ ret = (rdent ? scm_from_locale_stringn (rdent->d_name, NAMLEN (rdent))
+ : SCM_EOF_VAL);
+
+ scm_dynwind_end ();
+ return ret;
+ }
+#endif
+}
+#undef FUNC_NAME
+
+
+SCM_DEFINE (scm_rewinddir, "rewinddir", 1, 0, 0,
+ (SCM port),
+ "Reset the directory port @var{stream} so that the next call to\n"
+ "@code{readdir} will return the first directory entry.")
+#define FUNC_NAME s_scm_rewinddir
+{
+ SCM_VALIDATE_DIR (1, port);
+ if (!SCM_DIR_OPEN_P (port))
+ SCM_MISC_ERROR ("Directory ~S is not open.", scm_list_1 (port));
+
+ rewinddir ((DIR *) SCM_SMOB_DATA_1 (port));
+
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+
+SCM_DEFINE (scm_closedir, "closedir", 1, 0, 0,
+ (SCM port),
+ "Close the directory stream @var{stream}.\n"
+ "The return value is unspecified.")
+#define FUNC_NAME s_scm_closedir
+{
+ SCM_VALIDATE_DIR (1, port);
+
+ if (SCM_DIR_OPEN_P (port))
+ {
+ int sts;
+
+ SCM_SYSCALL (sts = closedir ((DIR *) SCM_SMOB_DATA_1 (port)));
+ if (sts != 0)
+ SCM_SYSERROR;
+
+ SCM_SET_SMOB_DATA_0 (port, scm_tc16_dir);
+ }
+
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+
+static int
+scm_dir_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
+{
+ scm_puts ("#<", port);
+ if (!SCM_DIR_OPEN_P (exp))
+ scm_puts ("closed: ", port);
+ scm_puts ("directory stream ", port);
+ scm_uintprint (SCM_SMOB_DATA_1 (exp), 16, port);
+ scm_putc ('>', port);
+ return 1;
+}
+
+
+static size_t
+scm_dir_free (SCM p)
+{
+ if (SCM_DIR_OPEN_P (p))
+ closedir ((DIR *) SCM_SMOB_DATA_1 (p));
+ return 0;
+}
From eb0ffdd8190bff165120b881ca3e1702be82c83a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Mon, 25 Apr 2011 23:54:47 +0200
Subject: [PATCH 33/48] Fix `#ifdef HAVE_CONFIG_H' stanza in some stand-alone
tests.
* test-suite/standalone/test-asmobs-lib.c,
test-suite/standalone/test-extensions-lib.c,
test-suite/standalone/test-ffi-lib.c,
test-suite/standalone/test-list.c,
test-suite/standalone/test-num2integral.c,
test-suite/standalone/test-with-guile-module.c: Change `#ifndef
HAVE_CONFIG_H' to `#ifdef HAVE_CONFIG_H' (!).
---
test-suite/standalone/test-asmobs-lib.c | 2 +-
test-suite/standalone/test-extensions-lib.c | 2 +-
test-suite/standalone/test-ffi-lib.c | 2 +-
test-suite/standalone/test-list.c | 2 +-
test-suite/standalone/test-num2integral.c | 2 +-
test-suite/standalone/test-with-guile-module.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/test-suite/standalone/test-asmobs-lib.c b/test-suite/standalone/test-asmobs-lib.c
index c88556ab2..03ac76447 100644
--- a/test-suite/standalone/test-asmobs-lib.c
+++ b/test-suite/standalone/test-asmobs-lib.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include
#endif
diff --git a/test-suite/standalone/test-extensions-lib.c b/test-suite/standalone/test-extensions-lib.c
index 7c8678895..cc03a9eba 100644
--- a/test-suite/standalone/test-extensions-lib.c
+++ b/test-suite/standalone/test-extensions-lib.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include
#endif
diff --git a/test-suite/standalone/test-ffi-lib.c b/test-suite/standalone/test-ffi-lib.c
index 364e6a684..a89b6aa94 100644
--- a/test-suite/standalone/test-ffi-lib.c
+++ b/test-suite/standalone/test-ffi-lib.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include
#endif
diff --git a/test-suite/standalone/test-list.c b/test-suite/standalone/test-list.c
index 2efaf5c88..b51a2a18e 100644
--- a/test-suite/standalone/test-list.c
+++ b/test-suite/standalone/test-list.c
@@ -18,7 +18,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include
#endif
diff --git a/test-suite/standalone/test-num2integral.c b/test-suite/standalone/test-num2integral.c
index af995ecd8..6a44fb75a 100644
--- a/test-suite/standalone/test-num2integral.c
+++ b/test-suite/standalone/test-num2integral.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include
#endif
diff --git a/test-suite/standalone/test-with-guile-module.c b/test-suite/standalone/test-with-guile-module.c
index 154f4f23f..4e22ff5da 100644
--- a/test-suite/standalone/test-with-guile-module.c
+++ b/test-suite/standalone/test-with-guile-module.c
@@ -16,7 +16,7 @@
* 02110-1301 USA
*/
-#ifndef HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include
#endif
From dd7d0148f221c3180ab6f31c8742aaf4d0e5926a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Mon, 25 Apr 2011 23:27:31 +0200
Subject: [PATCH 34/48] Update Gnulib to v0.0-5158-g7d06b32; remove `strcase'
and `version-etc-fsf'.
* m4/gnulib-cache.m4: Remove `strcase' and `version-etc-fsf'.
* configure.ac (POTENTIAL_GCC_CFLAGS): Remove `-Wundef'.
* libguile/script.c: Don't include .
---
build-aux/gendocs.sh | 4 +-
build-aux/useless-if-before-free | 6 +-
configure.ac | 4 +-
doc/gendocs_template | 31 ++--
lib/Makefile.am | 236 ++++++++++++++-----------
lib/arpa_inet.in.h | 4 +-
lib/canonicalize-lgpl.c | 3 +-
lib/close-hook.h | 72 --------
lib/close.c | 4 +-
lib/{close-hook.c => fd-hook.c} | 63 +++++--
lib/fd-hook.h | 119 +++++++++++++
lib/malloc.c | 5 +-
lib/malloca.c | 4 +-
lib/netdb.in.h | 3 +-
lib/read.c | 59 +++++++
lib/sockets.c | 43 ++++-
lib/stat-time.h | 2 +-
lib/stdio.in.h | 280 ++++++++++++++++++++++++++++--
lib/stdlib.in.h | 14 +-
lib/strcasecmp.c | 63 -------
lib/strftime.c | 11 +-
lib/string.in.h | 15 +-
lib/strings.in.h | 94 ----------
lib/strncasecmp.c | 63 -------
lib/sys_socket.in.h | 18 +-
lib/sys_stat.in.h | 16 +-
lib/{stdarg.in.h => sys_uio.in.h} | 41 +++--
lib/unistd.in.h | 27 ++-
lib/unistr.in.h | 28 +--
lib/verify.h | 61 +++++--
lib/version-etc-fsf.c | 30 ----
lib/version-etc.c | 258 ---------------------------
lib/version-etc.h | 78 ---------
lib/wchar.in.h | 88 +++++++++-
lib/write.c | 87 ++++++++--
libguile/script.c | 2 -
m4/alloca.m4 | 3 +-
m4/byteswap.m4 | 3 +-
m4/errno_h.m4 | 3 +-
m4/float_h.m4 | 3 +-
m4/getaddrinfo.m4 | 7 +-
m4/gnulib-cache.m4 | 4 +-
m4/gnulib-common.m4 | 5 +-
m4/gnulib-comp.m4 | 54 ++----
m4/iconv_h.m4 | 4 +-
m4/memchr.m4 | 16 +-
m4/netinet_in_h.m4 | 3 +-
m4/read.m4 | 20 +++
m4/socklen.m4 | 50 ++++--
m4/sockpfaf.m4 | 28 ++-
m4/stdarg.m4 | 75 --------
m4/stdbool.m4 | 3 +-
m4/stddef_h.m4 | 6 +-
m4/stdint.m4 | 3 +-
m4/stdio_h.m4 | 60 ++++++-
m4/strcase.m4 | 44 -----
m4/string_h.m4 | 3 +-
m4/strings_h.m4 | 39 -----
m4/sys_socket_h.m4 | 8 +-
m4/sys_uio_h.m4 | 31 ++++
m4/unistd_h.m4 | 87 +++++-----
m4/version-etc.m4 | 33 ----
m4/write.m4 | 12 +-
maint.mk | 71 ++++++--
64 files changed, 1362 insertions(+), 1252 deletions(-)
delete mode 100644 lib/close-hook.h
rename lib/{close-hook.c => fd-hook.c} (51%)
create mode 100644 lib/fd-hook.h
create mode 100644 lib/read.c
delete mode 100644 lib/strcasecmp.c
delete mode 100644 lib/strings.in.h
delete mode 100644 lib/strncasecmp.c
rename lib/{stdarg.in.h => sys_uio.in.h} (59%)
delete mode 100644 lib/version-etc-fsf.c
delete mode 100644 lib/version-etc.c
delete mode 100644 lib/version-etc.h
create mode 100644 m4/read.m4
delete mode 100644 m4/stdarg.m4
delete mode 100644 m4/strcase.m4
delete mode 100644 m4/strings_h.m4
create mode 100644 m4/sys_uio_h.m4
delete mode 100644 m4/version-etc.m4
diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index 34ef112e3..c8abd55fb 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -2,7 +2,7 @@
# gendocs.sh -- generate a GNU manual in many formats. This script is
# mentioned in maintain.texi. See the help message below for usage details.
-scriptversion=2010-11-29.11
+scriptversion=2011-04-08.14
# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
# Foundation, Inc.
@@ -305,10 +305,10 @@ if test -n "$docbook"; then
docbook_xml_gz_size=`calcsize "$outdir/$PACKAGE-db.xml.gz"`
mv $PACKAGE-db.xml "$outdir/"
+ split_html_db_dir=html_node_db
cmd="${DOCBOOK2HTML} -o $split_html_db_dir \"${outdir}/$PACKAGE-db.xml\""
echo "Generating docbook HTML... ($cmd)"
eval "$cmd"
- split_html_db_dir=html_node_db
(
cd ${split_html_db_dir} || exit 1
tar -czf "$abs_outdir/${PACKAGE}.html_node_db.tar.gz" -- *.html
diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free
index a6c228bcf..b8f5a2635 100755
--- a/build-aux/useless-if-before-free
+++ b/build-aux/useless-if-before-free
@@ -4,7 +4,7 @@ eval '(exit $?0)' && eval 'exec perl -wST "$0" ${1+"$@"}'
# Detect instances of "if (p) free (p);".
# Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces.
-my $VERSION = '2011-01-09 01:39'; # UTC
+my $VERSION = '2011-04-20 13:43'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
@@ -132,7 +132,7 @@ sub is_NULL ($)
while ($line =~
/\b(if\s*\(\s*([^)]+?)(?:\s*!=\s*([^)]+?))?\s*\)
# 1 2 3
- (?: \s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)|
+ (?: \s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;|
\s*\{\s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;\s*\}))/sxg)
{
my $all = $1;
@@ -179,7 +179,7 @@ free=xfree
git grep -l -z "$free *(" \
| xargs -0 useless-if-before-free -l --name="$free" \
| xargs -0 perl -0x3b -pi -e \
- 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\))/$2/s'
+ 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?:\s*\([^)]+\))?\s*\1\s*\)\s*;)/$2/s'
# Use the following to remove redundant uses of kfree inside braces.
# Note that -0777 puts perl in slurp-whole-file mode;
diff --git a/configure.ac b/configure.ac
index 685f9c18b..c34114825 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1519,8 +1519,10 @@ case "$GCC" in
## less than exasperating.
## -Wpointer-arith was here too, but something changed in gcc/glibc
## and it became equally exasperating (gcc 2.95 and/or glibc 2.1.2).
+ ## -Wundef was removed because Gnulib prevented it (see
+ ## .)
POTENTIAL_GCC_CFLAGS="-Wall -Wmissing-prototypes \
- -Wdeclaration-after-statement -Wundef \
+ -Wdeclaration-after-statement \
-Wswitch-enum"
# Do this here so we don't screw up any of the tests above that might
# not be "warning free"
diff --git a/doc/gendocs_template b/doc/gendocs_template
index ccce0be2a..0c557243e 100644
--- a/doc/gendocs_template
+++ b/doc/gendocs_template
@@ -3,12 +3,6 @@
%%TITLE%%
-
-
-
-
-
-
Free Software Foundation
last updated %%DATE%%
@@ -66,29 +60,28 @@ this helps support FSF activities.
(This page generated by the %%SCRIPTNAME%%
script.)
-
-
-
-
-
-
+
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 5d0c22971..217fcf6a4 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil close connect duplocale environ extensions flock floor fpieee frexp full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen locale log1p maintainer-makefile malloc-gnu malloca nproc putenv recv recvfrom send sendto setsockopt shutdown socket stat-time stdlib strcase strftime striconveh string sys_stat trunc verify version-etc-fsf vsnprintf warnings wchar
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil close connect duplocale environ extensions flock floor fpieee frexp full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen locale log1p maintainer-makefile malloc-gnu malloca nproc putenv recv recvfrom send sendto setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat trunc verify vsnprintf warnings wchar
AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
@@ -78,12 +78,17 @@ BUILT_SOURCES += $(ALLOCA_H)
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-alloca.h: alloca.in.h
+if GL_GENERATE_ALLOCA_H
+alloca.h: alloca.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
cat $(srcdir)/alloca.in.h; \
} > $@-t && \
mv -f $@-t $@
+else
+alloca.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += alloca.h alloca.h-t
EXTRA_DIST += alloca.in.h
@@ -127,7 +132,7 @@ BUILT_SOURCES += arpa/inet.h
# We need the following in order to create when the system
# doesn't have one.
-arpa/inet.h: arpa_inet.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) arpa
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -169,12 +174,17 @@ BUILT_SOURCES += $(BYTESWAP_H)
# We need the following in order to create when the system
# doesn't have one.
-byteswap.h: byteswap.in.h
+if GL_GENERATE_BYTESWAP_H
+byteswap.h: byteswap.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
cat $(srcdir)/byteswap.in.h; \
} > $@-t && \
mv -f $@-t $@
+else
+byteswap.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += byteswap.h byteswap.h-t
EXTRA_DIST += byteswap.in.h
@@ -251,14 +261,6 @@ EXTRA_libgnu_la_SOURCES += close.c
## end gnulib module close
-## begin gnulib module close-hook
-
-libgnu_la_SOURCES += close-hook.c
-
-EXTRA_DIST += close-hook.h
-
-## end gnulib module close-hook
-
## begin gnulib module connect
@@ -290,7 +292,8 @@ BUILT_SOURCES += $(ERRNO_H)
# We need the following in order to create when the system
# doesn't have one that is POSIX compliant.
-errno.h: errno.in.h
+if GL_GENERATE_ERRNO_H
+errno.h: errno.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -306,6 +309,10 @@ errno.h: errno.in.h
< $(srcdir)/errno.in.h; \
} > $@-t && \
mv $@-t $@
+else
+errno.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += errno.h errno.h-t
EXTRA_DIST += errno.in.h
@@ -321,13 +328,22 @@ EXTRA_libgnu_la_SOURCES += fclose.c
## end gnulib module fclose
+## begin gnulib module fd-hook
+
+libgnu_la_SOURCES += fd-hook.c
+
+EXTRA_DIST += fd-hook.h
+
+## end gnulib module fd-hook
+
## begin gnulib module float
BUILT_SOURCES += $(FLOAT_H)
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-float.h: float.in.h
+if GL_GENERATE_FLOAT_H
+float.h: float.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -337,6 +353,10 @@ float.h: float.in.h
< $(srcdir)/float.in.h; \
} > $@-t && \
mv $@-t $@
+else
+float.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += float.h float.h-t
EXTRA_DIST += float.in.h
@@ -374,6 +394,10 @@ EXTRA_libgnu_la_SOURCES += frexp.c
libgnu_la_SOURCES += full-read.h full-read.c
+EXTRA_DIST += full-write.c
+
+EXTRA_libgnu_la_SOURCES += full-write.c
+
## end gnulib module full-read
## begin gnulib module full-write
@@ -488,7 +512,8 @@ BUILT_SOURCES += $(ICONV_H)
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-iconv.h: iconv.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+if GL_GENERATE_ICONV_H
+iconv.h: iconv.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -506,6 +531,10 @@ iconv.h: iconv.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
< $(srcdir)/iconv.in.h; \
} > $@-t && \
mv $@-t $@
+else
+iconv.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += iconv.h iconv.h-t
EXTRA_DIST += iconv.in.h
@@ -644,7 +673,7 @@ BUILT_SOURCES += locale.h
# We need the following in order to create when the system
# doesn't have one that provides all definitions.
-locale.h: locale.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -716,7 +745,7 @@ BUILT_SOURCES += math.h
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-math.h: math.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
@@ -839,7 +868,7 @@ BUILT_SOURCES += netdb.h
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+netdb.h: netdb.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -870,7 +899,8 @@ BUILT_SOURCES += $(NETINET_IN_H)
# We need the following in order to create when the system
# doesn't have one.
-netinet/in.h: netinet_in.in.h
+if GL_GENERATE_NETINET_IN_H
+netinet/in.h: netinet_in.in.h $(top_builddir)/config.status
$(AM_V_at)$(MKDIR_P) netinet
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -882,6 +912,10 @@ netinet/in.h: netinet_in.in.h
< $(srcdir)/netinet_in.in.h; \
} > $@-t && \
mv $@-t $@
+else
+netinet/in.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t
MOSTLYCLEANDIRS += netinet
@@ -913,6 +947,15 @@ EXTRA_libgnu_la_SOURCES += putenv.c
## end gnulib module putenv
+## begin gnulib module read
+
+
+EXTRA_DIST += read.c
+
+EXTRA_libgnu_la_SOURCES += read.c
+
+## end gnulib module read
+
## begin gnulib module readlink
@@ -952,9 +995,9 @@ EXTRA_libgnu_la_SOURCES += safe-read.c
## begin gnulib module safe-write
-EXTRA_DIST += safe-write.c safe-write.h
+EXTRA_DIST += safe-read.c safe-write.c safe-write.h
-EXTRA_libgnu_la_SOURCES += safe-write.c
+EXTRA_libgnu_la_SOURCES += safe-read.c safe-write.c
## end gnulib module safe-write
@@ -1042,40 +1085,23 @@ EXTRA_DIST += stat-time.h
## end gnulib module stat-time
-## begin gnulib module stdarg
-
-BUILT_SOURCES += $(STDARG_H)
-
-# We need the following in order to create when the system
-# doesn't have one that works with the given compiler.
-stdarg.h: stdarg.in.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \
- < $(srcdir)/stdarg.in.h; \
- } > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += stdarg.h stdarg.h-t
-
-EXTRA_DIST += stdarg.in.h
-
-## end gnulib module stdarg
-
## begin gnulib module stdbool
BUILT_SOURCES += $(STDBOOL_H)
# We need the following in order to create when the system
# doesn't have one that works.
-stdbool.h: stdbool.in.h
+if GL_GENERATE_STDBOOL_H
+stdbool.h: stdbool.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
} > $@-t && \
mv $@-t $@
+else
+stdbool.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += stdbool.h stdbool.h-t
EXTRA_DIST += stdbool.in.h
@@ -1088,7 +1114,8 @@ BUILT_SOURCES += $(STDDEF_H)
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-stddef.h: stddef.in.h
+if GL_GENERATE_STDDEF_H
+stddef.h: stddef.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1100,6 +1127,10 @@ stddef.h: stddef.in.h
< $(srcdir)/stddef.in.h; \
} > $@-t && \
mv $@-t $@
+else
+stddef.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += stddef.h stddef.h-t
EXTRA_DIST += stddef.in.h
@@ -1112,7 +1143,8 @@ BUILT_SOURCES += $(STDINT_H)
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-stdint.h: stdint.in.h
+if GL_GENERATE_STDINT_H
+stdint.h: stdint.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
@@ -1144,6 +1176,10 @@ stdint.h: stdint.in.h
< $(srcdir)/stdint.in.h; \
} > $@-t && \
mv $@-t $@
+else
+stdint.h: $(top_builddir)/config.status
+ rm -f $@
+endif
MOSTLYCLEANFILES += stdint.h stdint.h-t
EXTRA_DIST += stdint.in.h
@@ -1156,7 +1192,7 @@ BUILT_SOURCES += stdio.h
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1166,20 +1202,27 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \
-e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
-e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
+ -e 's|@''GNULIB_FGETC''@|$(GNULIB_FGETC)|g' \
+ -e 's|@''GNULIB_FGETS''@|$(GNULIB_FGETS)|g' \
-e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \
-e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \
-e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \
-e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \
-e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \
-e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \
+ -e 's|@''GNULIB_FREAD''@|$(GNULIB_FREAD)|g' \
-e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \
+ -e 's|@''GNULIB_FSCANF''@|$(GNULIB_FSCANF)|g' \
-e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \
-e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \
-e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
-e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
-e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \
+ -e 's|@''GNULIB_GETC''@|$(GNULIB_GETC)|g' \
+ -e 's|@''GNULIB_GETCHAR''@|$(GNULIB_GETCHAR)|g' \
-e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \
-e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \
+ -e 's|@''GNULIB_GETS''@|$(GNULIB_GETS)|g' \
-e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \
-e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \
-e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \
@@ -1192,14 +1235,18 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \
-e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \
-e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \
+ -e 's|@''GNULIB_SCANF''@|$(GNULIB_SCANF)|g' \
-e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
-e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
+ -e 's|@''GNULIB_STDIO_H_NONBLOCKING''@|$(GNULIB_STDIO_H_NONBLOCKING)|g' \
-e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \
-e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \
-e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
-e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \
-e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \
-e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
+ -e 's|@''GNULIB_VFSCANF''@|$(GNULIB_VFSCANF)|g' \
+ -e 's|@''GNULIB_VSCANF''@|$(GNULIB_VSCANF)|g' \
-e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \
-e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
-e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
@@ -1241,6 +1288,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \
-e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
-e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
+ -e 's|@''REPLACE_STDIO_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|g' \
-e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
-e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \
-e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
@@ -1267,7 +1315,7 @@ BUILT_SOURCES += stdlib.h
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1350,15 +1398,6 @@ EXTRA_DIST += stdlib.in.h
## end gnulib module stdlib
-## begin gnulib module strcase
-
-
-EXTRA_DIST += strcasecmp.c strncasecmp.c
-
-EXTRA_libgnu_la_SOURCES += strcasecmp.c strncasecmp.c
-
-## end gnulib module strcase
-
## begin gnulib module strftime
@@ -1385,7 +1424,7 @@ BUILT_SOURCES += string.h
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1451,6 +1490,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
-e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
+ -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
-e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
-e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
@@ -1473,39 +1513,13 @@ EXTRA_DIST += string.in.h
## end gnulib module string
-## begin gnulib module strings
-
-BUILT_SOURCES += strings.h
-
-# We need the following in order to create when the system
-# doesn't have one that works with the given compiler.
-strings.h: strings.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
- -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
- -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
- -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/strings.in.h; \
- } > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += strings.h strings.h-t
-
-EXTRA_DIST += strings.in.h
-
-## end gnulib module strings
-
## begin gnulib module sys_file
BUILT_SOURCES += sys/file.h
# We need the following in order to create when the system
# has one that is incomplete.
-sys/file.h: sys_file.in.h $(WARN_ON_USE_H)
+sys/file.h: sys_file.in.h $(top_builddir)/config.status $(WARN_ON_USE_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -1533,7 +1547,7 @@ BUILT_SOURCES += sys/socket.h
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-sys/socket.h: sys_socket.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -1583,7 +1597,7 @@ BUILT_SOURCES += sys/stat.h
# We need the following in order to create when the system
# has one that is incomplete.
-sys/stat.h: sys_stat.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -1642,7 +1656,7 @@ BUILT_SOURCES += sys/time.h
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-sys/time.h: sys_time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -1667,13 +1681,38 @@ EXTRA_DIST += sys_time.in.h
## end gnulib module sys_time
+## begin gnulib module sys_uio
+
+BUILT_SOURCES += sys/uio.h
+
+# We need the following in order to create when the system
+# doesn't have one that works with the given compiler.
+sys/uio.h: sys_uio.in.h $(top_builddir)/config.status
+ $(AM_V_at)$(MKDIR_P) sys
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \
+ -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \
+ < $(srcdir)/sys_uio.in.h; \
+ } > $@-t && \
+ mv -f $@-t $@
+MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_uio.in.h
+
+## end gnulib module sys_uio
+
## begin gnulib module time
BUILT_SOURCES += time.h
# We need the following in order to create when the system
# doesn't have one that works with the given compiler.
-time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1732,7 +1771,7 @@ BUILT_SOURCES += unistd.h
# We need the following in order to create an empty placeholder for
# when the system doesn't have one.
-unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
@@ -1768,6 +1807,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
-e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
-e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \
+ -e 's|@''GNULIB_READ''@|$(GNULIB_READ)|g' \
-e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
-e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
-e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
@@ -1776,6 +1816,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \
-e 's|@''GNULIB_TTYNAME_R''@|$(GNULIB_TTYNAME_R)|g' \
-e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \
+ -e 's|@''GNULIB_UNISTD_H_NONBLOCKING''@|$(GNULIB_UNISTD_H_NONBLOCKING)|g' \
-e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
-e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \
-e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \
@@ -1836,6 +1877,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
-e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
-e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
+ -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
-e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
-e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
-e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
@@ -1984,18 +2026,6 @@ libgnu_la_SOURCES += verify.h
## end gnulib module verify
-## begin gnulib module version-etc
-
-libgnu_la_SOURCES += version-etc.h version-etc.c
-
-## end gnulib module version-etc
-
-## begin gnulib module version-etc-fsf
-
-libgnu_la_SOURCES += version-etc-fsf.c
-
-## end gnulib module version-etc-fsf
-
## begin gnulib module vsnprintf
@@ -2030,7 +2060,7 @@ BUILT_SOURCES += wchar.h
# We need the following in order to create when the system
# version does not work standalone.
-wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h
index 3df6fd2a4..1fa1f5289 100644
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -27,8 +27,8 @@
# include /* for __GLIBC__ */
#endif
-/* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
- under MinGW.
+/* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and
+ for pulling in winsock2.h etc. under MinGW.
But avoid namespace pollution on glibc systems. */
#ifndef __GLIBC__
# include
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 7e2fdbd5e..73ed4f8f9 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -16,6 +16,7 @@
along with this program. If not, see . */
#ifndef _LIBC
+# define _GL_USE_STDLIB_ALLOC 1
# include
#endif
@@ -68,8 +69,6 @@
# endif
# define __readlink readlink
# define __set_errno(e) errno = (e)
-/* Use the system functions, not the gnulib overrides in this file. */
-# undef malloc
# ifndef MAXSYMLINKS
# ifdef SYMLOOP_MAX
# define MAXSYMLINKS SYMLOOP_MAX
diff --git a/lib/close-hook.h b/lib/close-hook.h
deleted file mode 100644
index adcf11c22..000000000
--- a/lib/close-hook.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Hook for making the close() function extensible.
- Copyright (C) 2009-2011 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 3 of the License, 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see . */
-
-
-#ifndef CLOSE_HOOK_H
-#define CLOSE_HOOK_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Currently, this entire code is only needed for the handling of sockets
- on native Windows platforms. */
-#if WINDOWS_SOCKETS
-
-
-/* An element of the list of close hooks.
- The fields of this structure are considered private. */
-struct close_hook
-{
- /* Doubly linked list. */
- struct close_hook *private_next;
- struct close_hook *private_prev;
- /* Function that treats the types of FD that it knows about and calls
- execute_close_hooks (FD, REMAINING_LIST) as a fallback. */
- int (*private_fn) (int fd, const struct close_hook *remaining_list);
-};
-
-/* This type of function closes FD, applying special knowledge for the FD
- types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST)
- for the other FD types. */
-typedef int (*close_hook_fn) (int fd, const struct close_hook *remaining_list);
-
-/* Execute the close hooks in REMAINING_LIST.
- Return 0 or -1, like close() would do. */
-extern int execute_close_hooks (int fd, const struct close_hook *remaining_list);
-
-/* Execute all close hooks.
- Return 0 or -1, like close() would do. */
-extern int execute_all_close_hooks (int fd);
-
-/* Add a function to the list of close hooks.
- The LINK variable points to a piece of memory which is guaranteed to be
- accessible until the corresponding call to unregister_close_hook. */
-extern void register_close_hook (close_hook_fn hook, struct close_hook *link);
-
-/* Removes a function from the list of close hooks. */
-extern void unregister_close_hook (struct close_hook *link);
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CLOSE_HOOK_H */
diff --git a/lib/close.c b/lib/close.c
index 9d72f7cad..378c4f145 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -19,7 +19,7 @@
/* Specification. */
#include
-#include "close-hook.h"
+#include "fd-hook.h"
/* Override close() to call into other gnulib modules. */
@@ -28,7 +28,7 @@ rpl_close (int fd)
#undef close
{
#if WINDOWS_SOCKETS
- int retval = execute_all_close_hooks (fd);
+ int retval = execute_all_close_hooks (close, fd);
#else
int retval = close (fd);
#endif
diff --git a/lib/close-hook.c b/lib/fd-hook.c
similarity index 51%
rename from lib/close-hook.c
rename to lib/fd-hook.c
index 0fdf32358..40fbeeb34 100644
--- a/lib/close-hook.c
+++ b/lib/fd-hook.c
@@ -1,4 +1,4 @@
-/* Hook for making the close() function extensible.
+/* Hook for making making file descriptor functions close(), ioctl() extensible.
Copyright (C) 2009-2011 Free Software Foundation, Inc.
Written by Bruno Haible , 2009.
@@ -18,13 +18,9 @@
#include
/* Specification. */
-#include "close-hook.h"
+#include "fd-hook.h"
#include
-#include
-
-#undef close
-
/* Currently, this entire code is only needed for the handling of sockets
on native Windows platforms. */
@@ -32,49 +28,77 @@
/* The first and last link in the doubly linked list.
Initially the list is empty. */
-static struct close_hook anchor = { &anchor, &anchor, NULL };
+static struct fd_hook anchor = { &anchor, &anchor, NULL, NULL };
int
-execute_close_hooks (int fd, const struct close_hook *remaining_list)
+execute_close_hooks (const struct fd_hook *remaining_list, gl_close_fn primary,
+ int fd)
{
if (remaining_list == &anchor)
/* End of list reached. */
- return close (fd);
+ return primary (fd);
else
- return remaining_list->private_fn (fd, remaining_list->private_next);
+ return remaining_list->private_close_fn (remaining_list->private_next,
+ primary, fd);
}
int
-execute_all_close_hooks (int fd)
+execute_all_close_hooks (gl_close_fn primary, int fd)
{
- return execute_close_hooks (fd, anchor.private_next);
+ return execute_close_hooks (anchor.private_next, primary, fd);
+}
+
+int
+execute_ioctl_hooks (const struct fd_hook *remaining_list, gl_ioctl_fn primary,
+ int fd, int request, void *arg)
+{
+ if (remaining_list == &anchor)
+ /* End of list reached. */
+ return primary (fd, request, arg);
+ else
+ return remaining_list->private_ioctl_fn (remaining_list->private_next,
+ primary, fd, request, arg);
+}
+
+int
+execute_all_ioctl_hooks (gl_ioctl_fn primary,
+ int fd, int request, void *arg)
+{
+ return execute_ioctl_hooks (anchor.private_next, primary, fd, request, arg);
}
void
-register_close_hook (close_hook_fn hook, struct close_hook *link)
+register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook, struct fd_hook *link)
{
+ if (close_hook == NULL)
+ close_hook = execute_close_hooks;
+ if (ioctl_hook == NULL)
+ ioctl_hook = execute_ioctl_hooks;
+
if (link->private_next == NULL && link->private_prev == NULL)
{
/* Add the link to the doubly linked list. */
link->private_next = anchor.private_next;
link->private_prev = &anchor;
- link->private_fn = hook;
+ link->private_close_fn = close_hook;
+ link->private_ioctl_fn = ioctl_hook;
anchor.private_next->private_prev = link;
anchor.private_next = link;
}
else
{
/* The link is already in use. */
- if (link->private_fn != hook)
+ if (link->private_close_fn != close_hook
+ || link->private_ioctl_fn != ioctl_hook)
abort ();
}
}
void
-unregister_close_hook (struct close_hook *link)
+unregister_fd_hook (struct fd_hook *link)
{
- struct close_hook *next = link->private_next;
- struct close_hook *prev = link->private_prev;
+ struct fd_hook *next = link->private_next;
+ struct fd_hook *prev = link->private_prev;
if (next != NULL && prev != NULL)
{
@@ -84,7 +108,8 @@ unregister_close_hook (struct close_hook *link)
/* Clear the link, to mark it unused. */
link->private_next = NULL;
link->private_prev = NULL;
- link->private_fn = NULL;
+ link->private_close_fn = NULL;
+ link->private_ioctl_fn = NULL;
}
}
diff --git a/lib/fd-hook.h b/lib/fd-hook.h
new file mode 100644
index 000000000..aab4d913c
--- /dev/null
+++ b/lib/fd-hook.h
@@ -0,0 +1,119 @@
+/* Hook for making making file descriptor functions close(), ioctl() extensible.
+ Copyright (C) 2009-2011 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 3 of the License, 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see . */
+
+
+#ifndef FD_HOOK_H
+#define FD_HOOK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Currently, this entire code is only needed for the handling of sockets
+ on native Windows platforms. */
+#if WINDOWS_SOCKETS
+
+
+/* Type of function that closes FD. */
+typedef int (*gl_close_fn) (int fd);
+
+/* Type of function that applies a control request to FD. */
+typedef int (*gl_ioctl_fn) (int fd, int request, void *arg);
+
+/* An element of the list of file descriptor hooks.
+ In CLOS (Common Lisp Object System) speak, it consists of an "around"
+ method for the close() function and an "around" method for the ioctl()
+ function.
+ The fields of this structure are considered private. */
+struct fd_hook
+{
+ /* Doubly linked list. */
+ struct fd_hook *private_next;
+ struct fd_hook *private_prev;
+ /* Function that treats the types of FD that it knows about and calls
+ execute_close_hooks (REMAINING_LIST, PRIMARY, FD) as a fallback. */
+ int (*private_close_fn) (const struct fd_hook *remaining_list,
+ gl_close_fn primary,
+ int fd);
+ /* Function that treats the types of FD that it knows about and calls
+ execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) as a
+ fallback. */
+ int (*private_ioctl_fn) (const struct fd_hook *remaining_list,
+ gl_ioctl_fn primary,
+ int fd, int request, void *arg);
+};
+
+/* This type of function closes FD, applying special knowledge for the FD
+ types it knows about, and calls
+ execute_close_hooks (REMAINING_LIST, PRIMARY, FD)
+ for the other FD types.
+ In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
+ and PRIMARY is the "primary" method for close(). */
+typedef int (*close_hook_fn) (const struct fd_hook *remaining_list,
+ gl_close_fn primary,
+ int fd);
+
+/* Execute the close hooks in REMAINING_LIST, with PRIMARY as "primary" method.
+ Return 0 or -1, like close() would do. */
+extern int execute_close_hooks (const struct fd_hook *remaining_list,
+ gl_close_fn primary,
+ int fd);
+
+/* Execute all close hooks, with PRIMARY as "primary" method.
+ Return 0 or -1, like close() would do. */
+extern int execute_all_close_hooks (gl_close_fn primary, int fd);
+
+/* This type of function applies a control request to FD, applying special
+ knowledge for the FD types it knows about, and calls
+ execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG)
+ for the other FD types.
+ In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
+ and PRIMARY is the "primary" method for ioctl(). */
+typedef int (*ioctl_hook_fn) (const struct fd_hook *remaining_list,
+ gl_ioctl_fn primary,
+ int fd, int request, void *arg);
+
+/* Execute the ioctl hooks in REMAINING_LIST, with PRIMARY as "primary" method.
+ Return 0 or -1, like ioctl() would do. */
+extern int execute_ioctl_hooks (const struct fd_hook *remaining_list,
+ gl_ioctl_fn primary,
+ int fd, int request, void *arg);
+
+/* Execute all ioctl hooks, with PRIMARY as "primary" method.
+ Return 0 or -1, like ioctl() would do. */
+extern int execute_all_ioctl_hooks (gl_ioctl_fn primary,
+ int fd, int request, void *arg);
+
+/* Add a function pair to the list of file descriptor hooks.
+ CLOSE_HOOK and IOCTL_HOOK may be NULL, indicating no change.
+ The LINK variable points to a piece of memory which is guaranteed to be
+ accessible until the corresponding call to unregister_fd_hook. */
+extern void register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook,
+ struct fd_hook *link);
+
+/* Removes a hook from the list of file descriptor hooks. */
+extern void unregister_fd_hook (struct fd_hook *link);
+
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* FD_HOOK_H */
diff --git a/lib/malloc.c b/lib/malloc.c
index 6a417c37a..b06ef3f18 100644
--- a/lib/malloc.c
+++ b/lib/malloc.c
@@ -18,6 +18,7 @@
/* written by Jim Meyering and Bruno Haible */
+#define _GL_USE_STDLIB_ALLOC 1
#include
/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
#ifdef malloc
@@ -28,14 +29,10 @@
# define NEED_MALLOC_GNU 1
#endif
-/* Specification. */
#include
#include
-/* Call the system's malloc below. */
-#undef malloc
-
/* Allocate an N-byte block of memory from the heap.
If N is zero, allocate a 1-byte block. */
diff --git a/lib/malloca.c b/lib/malloca.c
index b79e7d7a6..7bb1fbec5 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -16,6 +16,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+#define _GL_USE_STDLIB_ALLOC 1
#include
/* Specification. */
@@ -23,9 +24,6 @@
#include "verify.h"
-/* Use the system functions, not the gnulib overrides in this file. */
-#undef malloc
-
/* The speed critical point in this file is freea() applied to an alloca()
result: it must be fast, to match the speed of alloca(). The speed of
mmalloca() and freea() in the other case are not critical, because they
diff --git a/lib/netdb.in.h b/lib/netdb.in.h
index 21e3d55eb..5b64e486b 100644
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -37,7 +37,8 @@
#ifndef _GL_NETDB_H
#define _GL_NETDB_H
-/* Get netdb.h definitions such as struct hostent for MinGW. */
+/* Get definitions such as 'socklen_t' on IRIX 6.5 and OSF/1 4.0 and
+ 'struct hostent' on MinGW. */
#include
/* The definition of _GL_ARG_NONNULL is copied here. */
diff --git a/lib/read.c b/lib/read.c
new file mode 100644
index 000000000..d161a40c2
--- /dev/null
+++ b/lib/read.c
@@ -0,0 +1,59 @@
+/* POSIX compatible read() function.
+ Copyright (C) 2008-2011 Free Software Foundation, Inc.
+ Written by Bruno Haible , 2011.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 3 of the License, 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see . */
+
+#include
+
+/* Specification. */
+#include
+
+/* Replace this function only if module 'nonblocking' is requested. */
+#if GNULIB_NONBLOCKING
+
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+# include
+# include
+
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include
+
+ssize_t
+rpl_read (int fd, void *buf, size_t count)
+#undef read
+{
+ ssize_t ret = read (fd, buf, count);
+
+ if (ret < 0
+ && GetLastError () == ERROR_NO_DATA)
+ {
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ if (GetFileType (h) == FILE_TYPE_PIPE)
+ {
+ /* h is a pipe or socket. */
+ DWORD state;
+ if (GetNamedPipeHandleState (h, &state, NULL, NULL, NULL, NULL, 0)
+ && (state & PIPE_NOWAIT) != 0)
+ /* h is a pipe in non-blocking mode.
+ Change errno from EINVAL to EAGAIN. */
+ errno = EAGAIN;
+ }
+ }
+ return ret;
+}
+
+# endif
+#endif
diff --git a/lib/sockets.c b/lib/sockets.c
index 27da15f8d..25ab97f3d 100644
--- a/lib/sockets.c
+++ b/lib/sockets.c
@@ -27,13 +27,15 @@
/* This includes winsock2.h on MinGW. */
# include
-# include "close-hook.h"
+# include "fd-hook.h"
/* Get set_winsock_errno, FD_TO_SOCKET etc. */
# include "w32sock.h"
static int
-close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
+close_fd_maybe_socket (const struct fd_hook *remaining_list,
+ gl_close_fn primary,
+ int fd)
{
SOCKET sock;
WSANETWORKEVENTS ev;
@@ -64,10 +66,38 @@ close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
}
else
/* Some other type of file descriptor. */
- return execute_close_hooks (fd, remaining_list);
+ return execute_close_hooks (remaining_list, primary, fd);
}
-static struct close_hook close_sockets_hook;
+static int
+ioctl_fd_maybe_socket (const struct fd_hook *remaining_list,
+ gl_ioctl_fn primary,
+ int fd, int request, void *arg)
+{
+ SOCKET sock;
+ WSANETWORKEVENTS ev;
+
+ /* Test whether fd refers to a socket. */
+ sock = FD_TO_SOCKET (fd);
+ ev.lNetworkEvents = 0xDEADBEEF;
+ WSAEnumNetworkEvents (sock, NULL, &ev);
+ if (ev.lNetworkEvents != 0xDEADBEEF)
+ {
+ /* fd refers to a socket. */
+ if (ioctlsocket (sock, request, arg) < 0)
+ {
+ set_winsock_errno ();
+ return -1;
+ }
+ else
+ return 0;
+ }
+ else
+ /* Some other type of file descriptor. */
+ return execute_ioctl_hooks (remaining_list, primary, fd, request, arg);
+}
+
+static struct fd_hook fd_sockets_hook;
static int initialized_sockets_version /* = 0 */;
@@ -90,7 +120,8 @@ gl_sockets_startup (int version _GL_UNUSED)
return 2;
if (initialized_sockets_version == 0)
- register_close_hook (close_fd_maybe_socket, &close_sockets_hook);
+ register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket,
+ &fd_sockets_hook);
initialized_sockets_version = version;
}
@@ -107,7 +138,7 @@ gl_sockets_cleanup (void)
initialized_sockets_version = 0;
- unregister_close_hook (&close_sockets_hook);
+ unregister_fd_hook (&fd_sockets_hook);
err = WSACleanup ();
if (err != 0)
diff --git a/lib/stat-time.h b/lib/stat-time.h
index b4a914c71..47a288a7e 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -175,7 +175,7 @@ get_stat_birthtime (struct stat const *st)
using zero. Attempt to work around this problem. Alas, this can
report failure even for valid time stamps. Also, NetBSD
sometimes returns junk in the birth time fields; work around this
- bug if it it is detected. There's no need to detect negative
+ bug if it is detected. There's no need to detect negative
tv_nsec junk as negative tv_nsec already indicates an error. */
if (t.tv_sec == 0 || 1000000000 <= t.tv_nsec)
t.tv_nsec = -1;
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 4a82174de..b4469a9b8 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -67,9 +67,45 @@
#else
# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
#endif
-#define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+
+/* _GL_ATTRIBUTE_FORMAT_PRINTF
+ indicates to GCC that the function takes a format string and arguments,
+ where the format string directives are the ones standardized by ISO C99
+ and POSIX. */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
+#else
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
+#endif
+
+/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
+ except that it indicates to GCC that the supported format string directives
+ are the ones of the system printf(), rather than the ones standardized by
+ ISO C99 and POSIX. */
+#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
+/* _GL_ATTRIBUTE_FORMAT_SCANF
+ indicates to GCC that the function takes a format string and arguments,
+ where the format string directives are the ones standardized by ISO C99
+ and POSIX. */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
+#else
+# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
+#endif
+
+/* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
+ except that it indicates to GCC that the supported format string directives
+ are the ones of the system scanf(), rather than the ones standardized by
+ ISO C99 and POSIX. */
+#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
+
/* Solaris 10 declares renameat in , not in . */
/* But in any case avoid namespace pollution on glibc systems. */
#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
@@ -158,11 +194,34 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
"use gnulib module fflush for portable POSIX compliance");
#endif
-/* It is very rare that the developer ever has full control of stdin,
- so any use of gets warrants an unconditional warning. Assume it is
- always declared, since it is required by C89. */
-#undef gets
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+#if @GNULIB_FGETC@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fgetc
+# define fgetc rpl_fgetc
+# endif
+_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
+# endif
+_GL_CXXALIASWARN (fgetc);
+#endif
+
+#if @GNULIB_FGETS@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fgets
+# define fgets rpl_fgets
+# endif
+_GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream)
+ _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fgets);
+#endif
#if @GNULIB_FOPEN@
# if @REPLACE_FOPEN@
@@ -186,14 +245,20 @@ _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
- || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
+ || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define fprintf rpl_fprintf
# endif
# define GNULIB_overrides_fprintf 1
+# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
_GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
_GL_ARG_NONNULL ((1, 2)));
+# else
+_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
# else
_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
@@ -239,7 +304,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
#endif
#if @GNULIB_FPUTC@
-# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fputc
# define fputc rpl_fputc
@@ -253,7 +318,7 @@ _GL_CXXALIASWARN (fputc);
#endif
#if @GNULIB_FPUTS@
-# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fputs
# define fputs rpl_fputs
@@ -267,6 +332,21 @@ _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
_GL_CXXALIASWARN (fputs);
#endif
+#if @GNULIB_FREAD@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fread
+# define fread rpl_fread
+# endif
+_GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)
+ _GL_ARG_NONNULL ((4)));
+_GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
+# else
+_GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
+# endif
+_GL_CXXALIASWARN (fread);
+#endif
+
#if @GNULIB_FREOPEN@
# if @REPLACE_FREOPEN@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -291,6 +371,22 @@ _GL_WARN_ON_USE (freopen,
"use gnulib module freopen for portability");
#endif
+#if @GNULIB_FSCANF@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fscanf
+# define fscanf rpl_fscanf
+# endif
+_GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...));
+# else
+_GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...));
+# endif
+_GL_CXXALIASWARN (fscanf);
+#endif
+
/* Set up the following warnings, based on which modules are in use.
GNU Coding Standards discourage the use of fseek, since it imposes
@@ -483,7 +579,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
#if @GNULIB_FWRITE@
-# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fwrite
# define fwrite rpl_fwrite
@@ -496,10 +592,55 @@ _GL_CXXALIAS_RPL (fwrite, size_t,
# else
_GL_CXXALIAS_SYS (fwrite, size_t,
(const void *ptr, size_t s, size_t n, FILE *stream));
+
+/* Work around glibc bug 11959
+ ,
+ which sometimes causes an unwanted diagnostic for fwrite calls.
+ This affects only function declaration attributes, so it's not
+ needed for C++. */
+# if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL
+static inline size_t _GL_ARG_NONNULL ((1, 4))
+rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
+{
+ size_t r = fwrite (ptr, s, n, stream);
+ (void) r;
+ return r;
+}
+# undef fwrite
+# define fwrite rpl_fwrite
+# endif
# endif
_GL_CXXALIASWARN (fwrite);
#endif
+#if @GNULIB_GETC@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getc
+# define getc rpl_fgetc
+# endif
+_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
+# else
+_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
+# endif
+_GL_CXXALIASWARN (getc);
+#endif
+
+#if @GNULIB_GETCHAR@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getchar
+# define getchar rpl_getchar
+# endif
+_GL_FUNCDECL_RPL (getchar, int, (void));
+_GL_CXXALIAS_RPL (getchar, int, (void));
+# else
+_GL_CXXALIAS_SYS (getchar, int, (void));
+# endif
+_GL_CXXALIASWARN (getchar);
+#endif
+
#if @GNULIB_GETDELIM@
/* Read input, up to (and including) the next occurrence of DELIMITER, from
STREAM, store it in *LINEPTR (and NUL-terminate it).
@@ -576,6 +717,26 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
# endif
#endif
+#if @GNULIB_GETS@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gets
+# define gets rpl_gets
+# endif
+_GL_FUNCDECL_RPL (gets, char *, (char *s) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (gets, char *, (char *s));
+# else
+_GL_CXXALIAS_SYS (gets, char *, (char *s));
+# undef gets
+# endif
+_GL_CXXALIASWARN (gets);
+/* It is very rare that the developer ever has full control of stdin,
+ so any use of gets warrants an unconditional warning. Assume it is
+ always declared, since it is required by C89. */
+_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+#endif
+
+
#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
struct obstack;
/* Grow an obstack with formatted output. Return the number of
@@ -671,18 +832,27 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
- || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
+ || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
# if defined __GNUC__
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
/* Don't break __attribute__((format(printf,M,N))). */
# define printf __printf__
# endif
+# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
_GL_FUNCDECL_RPL_1 (__printf__, int,
(const char *format, ...)
__asm__ (@ASM_SYMBOL_PREFIX@
_GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
_GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
_GL_ARG_NONNULL ((1)));
+# else
+_GL_FUNCDECL_RPL_1 (__printf__, int,
+ (const char *format, ...)
+ __asm__ (@ASM_SYMBOL_PREFIX@
+ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
+ _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
+ _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
# else
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -711,7 +881,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
#endif
#if @GNULIB_PUTC@
-# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef putc
# define putc rpl_fputc
@@ -725,7 +895,7 @@ _GL_CXXALIASWARN (putc);
#endif
#if @GNULIB_PUTCHAR@
-# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef putchar
# define putchar rpl_putchar
@@ -739,7 +909,7 @@ _GL_CXXALIASWARN (putchar);
#endif
#if @GNULIB_PUTS@
-# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef puts
# define puts rpl_puts
@@ -823,6 +993,37 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
# endif
#endif
+#if @GNULIB_SCANF@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if defined __GNUC__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef scanf
+/* Don't break __attribute__((format(scanf,M,N))). */
+# define scanf __scanf__
+# endif
+_GL_FUNCDECL_RPL_1 (__scanf__, int,
+ (const char *format, ...)
+ __asm__ (@ASM_SYMBOL_PREFIX@
+ _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...));
+# else
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef scanf
+# define scanf rpl_scanf
+# endif
+_GL_FUNCDECL_RPL (scanf, int, (const char *format, ...)
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (scanf, int, (const char *format, ...));
+# endif
+# else
+_GL_CXXALIAS_SYS (scanf, int, (const char *format, ...));
+# endif
+_GL_CXXALIASWARN (scanf);
+#endif
+
#if @GNULIB_SNPRINTF@
# if @REPLACE_SNPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -982,14 +1183,20 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
- || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
+ || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define vfprintf rpl_vfprintf
# endif
# define GNULIB_overrides_vfprintf 1
+# if @GNULIB_VFPRINTF_POSIX@
_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
_GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
_GL_ARG_NONNULL ((1, 2)));
+# else
+_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
# else
/* Need to cast, because on Solaris, the third parameter is
@@ -1010,16 +1217,41 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
"POSIX compliance");
#endif
+#if @GNULIB_VFSCANF@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef vfscanf
+# define vfscanf rpl_vfscanf
+# endif
+_GL_FUNCDECL_RPL (vfscanf, int,
+ (FILE *stream, const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (vfscanf, int,
+ (FILE *stream, const char *format, va_list args));
+# else
+_GL_CXXALIAS_SYS (vfscanf, int,
+ (FILE *stream, const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vfscanf);
+#endif
+
#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
- || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
+ || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define vprintf rpl_vprintf
# endif
# define GNULIB_overrides_vprintf 1
+# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
_GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
_GL_ARG_NONNULL ((1)));
+# else
+_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
+ _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
# else
/* Need to cast, because on Solaris, the second parameter is
@@ -1039,6 +1271,22 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
"POSIX compliance");
#endif
+#if @GNULIB_VSCANF@
+# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef vscanf
+# define vscanf rpl_vscanf
+# endif
+_GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args)
+ _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args));
+# else
+_GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args));
+# endif
+_GL_CXXALIASWARN (vscanf);
+#endif
+
#if @GNULIB_VSNPRINTF@
# if @REPLACE_VSNPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 980b909af..9651e94cd 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -255,9 +255,14 @@ _GL_WARN_ON_USE (ptsname, "grantpt is not portable - "
# endif
#endif
+/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
+ rely on GNU or POSIX semantics for malloc and realloc (for example,
+ by never specifying a zero size), so it does not need malloc or
+ realloc to be redefined. */
#if @GNULIB_MALLOC_POSIX@
# if @REPLACE_MALLOC@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
+ || _GL_USE_STDLIB_ALLOC)
# undef malloc
# define malloc rpl_malloc
# endif
@@ -267,7 +272,7 @@ _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
# endif
_GL_CXXALIASWARN (malloc);
-#elif defined GNULIB_POSIXCHECK
+#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
# undef malloc
/* Assume malloc is always declared. */
_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
@@ -531,7 +536,8 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
#if @GNULIB_REALLOC_POSIX@
# if @REPLACE_REALLOC@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
+ || _GL_USE_STDLIB_ALLOC)
# undef realloc
# define realloc rpl_realloc
# endif
@@ -541,7 +547,7 @@ _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
# endif
_GL_CXXALIASWARN (realloc);
-#elif defined GNULIB_POSIXCHECK
+#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
# undef realloc
/* Assume realloc is always declared. */
_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
diff --git a/lib/strcasecmp.c b/lib/strcasecmp.c
deleted file mode 100644
index a98a3a0ca..000000000
--- a/lib/strcasecmp.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Case-insensitive string comparison function.
- Copyright (C) 1998-1999, 2005-2007, 2009-2011 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include
-
-/* Specification. */
-#include
-
-#include
-#include
-
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
-/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
- greater than zero if S1 is lexicographically less than, equal to or greater
- than S2.
- Note: This function does not work with multibyte strings! */
-
-int
-strcasecmp (const char *s1, const char *s2)
-{
- const unsigned char *p1 = (const unsigned char *) s1;
- const unsigned char *p2 = (const unsigned char *) s2;
- unsigned char c1, c2;
-
- if (p1 == p2)
- return 0;
-
- do
- {
- c1 = TOLOWER (*p1);
- c2 = TOLOWER (*p2);
-
- if (c1 == '\0')
- break;
-
- ++p1;
- ++p2;
- }
- while (c1 == c2);
-
- if (UCHAR_MAX <= INT_MAX)
- return c1 - c2;
- else
- /* On machines where 'char' and 'int' are types of the same size, the
- difference of two 'unsigned char' values - including the sign bit -
- doesn't fit in an 'int'. */
- return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
-}
diff --git a/lib/strftime.c b/lib/strftime.c
index be7750de1..df09be9ca 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -172,15 +172,16 @@ extern char *tzname[];
#define add(n, f) \
do \
{ \
- int _n = (n); \
- int _delta = width - _n; \
- int _incr = _n + (_delta > 0 ? _delta : 0); \
- if ((size_t) _incr >= maxsize - i) \
+ size_t _n = (n); \
+ size_t _w = (width < 0 ? 0 : width); \
+ size_t _incr = _n < _w ? _w : _n; \
+ if (_incr >= maxsize - i) \
return 0; \
if (p) \
{ \
- if (digits == 0 && _delta > 0) \
+ if (digits == 0 && _n < _w) \
{ \
+ size_t _delta = width - _n; \
if (pad == L_('0')) \
memset_zero (p, _delta); \
else \
diff --git a/lib/string.in.h b/lib/string.in.h
index 3926c0c60..9eb0d5c30 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -277,17 +277,28 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
/* Find the first occurrence of C in S or the final NUL byte. */
#if @GNULIB_STRCHRNUL@
-# if ! @HAVE_STRCHRNUL@
+# if @REPLACE_STRCHRNUL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strchrnul rpl_strchrnul
+# endif
+_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
+ _GL_ATTRIBUTE_PURE
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strchrnul, char *,
+ (const char *str, int ch));
+# else
+# if ! @HAVE_STRCHRNUL@
_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
_GL_ATTRIBUTE_PURE
_GL_ARG_NONNULL ((1)));
-# endif
+# endif
/* On some systems, this function is defined as an overloaded function:
extern "C++" { const char * std::strchrnul (const char *, int); }
extern "C++" { char * std::strchrnul (char *, int); } */
_GL_CXXALIAS_SYS_CAST2 (strchrnul,
char *, (char const *__s, int __c_in),
char const *, (char const *__s, int __c_in));
+# endif
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
diff --git a/lib/strings.in.h b/lib/strings.in.h
deleted file mode 100644
index d8f1770c8..000000000
--- a/lib/strings.in.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* A substitute .
-
- Copyright (C) 2007-2011 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#ifndef _GL_STRINGS_H
-
-#if __GNUC__ >= 3
-@PRAGMA_SYSTEM_HEADER@
-#endif
-@PRAGMA_COLUMNS@
-
-/* The include_next requires a split double-inclusion guard. */
-#@INCLUDE_NEXT@ @NEXT_STRINGS_H@
-
-#ifndef _GL_STRINGS_H
-#define _GL_STRINGS_H
-
-
-/* The definition of _GL_ARG_NONNULL is copied here. */
-
-/* The definition of _GL_WARN_ON_USE is copied here. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
- greater than zero if S1 is lexicographically less than, equal to or greater
- than S2.
- Note: This function does not work in multibyte locales. */
-#if ! @HAVE_STRCASECMP@
-extern int strcasecmp (char const *s1, char const *s2)
- _GL_ARG_NONNULL ((1, 2));
-#endif
-#if defined GNULIB_POSIXCHECK
-/* strcasecmp() does not work with multibyte strings:
- POSIX says that it operates on "strings", and "string" in POSIX is defined
- as a sequence of bytes, not of characters. */
-# undef strcasecmp
-# if HAVE_RAW_DECL_STRCASECMP
-_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
- "strings in multibyte locales - "
- "use mbscasecmp if you care about "
- "internationalization, or use c_strcasecmp , "
- "gnulib module c-strcase) if you want a locale "
- "independent function");
-# endif
-#endif
-
-/* Compare no more than N bytes of strings S1 and S2, ignoring case,
- returning less than, equal to or greater than zero if S1 is
- lexicographically less than, equal to or greater than S2.
- Note: This function cannot work correctly in multibyte locales. */
-#if ! @HAVE_DECL_STRNCASECMP@
-extern int strncasecmp (char const *s1, char const *s2, size_t n)
- _GL_ARG_NONNULL ((1, 2));
-#endif
-#if defined GNULIB_POSIXCHECK
-/* strncasecmp() does not work with multibyte strings:
- POSIX says that it operates on "strings", and "string" in POSIX is defined
- as a sequence of bytes, not of characters. */
-# undef strncasecmp
-# if HAVE_RAW_DECL_STRNCASECMP
-_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
- "strings in multibyte locales - "
- "use mbsncasecmp or mbspcasecmp if you care about "
- "internationalization, or use c_strncasecmp , "
- "gnulib module c-strcase) if you want a locale "
- "independent function");
-# endif
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GL_STRING_H */
-#endif /* _GL_STRING_H */
diff --git a/lib/strncasecmp.c b/lib/strncasecmp.c
deleted file mode 100644
index 35cd4cccd..000000000
--- a/lib/strncasecmp.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* strncasecmp.c -- case insensitive string comparator
- Copyright (C) 1998-1999, 2005-2007, 2009-2011 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
-#include
-
-/* Specification. */
-#include
-
-#include
-#include
-
-#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
-
-/* Compare no more than N bytes of strings S1 and S2, ignoring case,
- returning less than, equal to or greater than zero if S1 is
- lexicographically less than, equal to or greater than S2.
- Note: This function cannot work correctly in multibyte locales. */
-
-int
-strncasecmp (const char *s1, const char *s2, size_t n)
-{
- register const unsigned char *p1 = (const unsigned char *) s1;
- register const unsigned char *p2 = (const unsigned char *) s2;
- unsigned char c1, c2;
-
- if (p1 == p2 || n == 0)
- return 0;
-
- do
- {
- c1 = TOLOWER (*p1);
- c2 = TOLOWER (*p2);
-
- if (--n == 0 || c1 == '\0')
- break;
-
- ++p1;
- ++p2;
- }
- while (c1 == c2);
-
- if (UCHAR_MAX <= INT_MAX)
- return c1 - c2;
- else
- /* On machines where 'char' and 'int' are types of the same size, the
- difference of two 'unsigned char' values - including the sign bit -
- doesn't fit in an 'int'. */
- return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
-}
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index 12f6d1bc7..c13f33663 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -50,6 +50,10 @@
. */
# include
+/* On FreeBSD 6.4, defines some macros that assume that NULL
+ is defined. */
+# include
+
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
@@ -142,7 +146,6 @@ struct sockaddr_storage
suggests that getaddrinfo should be available on all Windows
releases. */
-
# if @HAVE_WINSOCK2_H@
# include
# endif
@@ -173,6 +176,19 @@ typedef int socklen_t;
# endif
+/* For struct iovec */
+# include
+
+/* Rudimentary 'struct msghdr'; this works as long as you don't try to
+ access msg_control or msg_controllen. */
+struct msghdr {
+ void *msg_name;
+ socklen_t msg_namelen;
+ struct iovec *msg_iov;
+ int msg_iovlen;
+ int msg_flags;
+};
+
#endif
#if @HAVE_WINSOCK2_H@
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 3755e4e64..cc5ab1b37 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -355,7 +355,11 @@ _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
#if @GNULIB_FUTIMENS@
-# if @REPLACE_FUTIMENS@
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
+ implementation relies on futimesat, which on Solaris 10 makes an invocation
+ to futimens that is meant to invoke the libc's futimens(), not gnulib's
+ futimens(). */
+# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef futimens
# define futimens rpl_futimens
@@ -368,7 +372,9 @@ _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
# endif
_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
# endif
+# if @HAVE_FUTIMENS@
_GL_CXXALIASWARN (futimens);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef futimens
# if HAVE_RAW_DECL_FUTIMENS
@@ -612,7 +618,11 @@ _GL_WARN_ON_USE (stat, "stat is unportable - "
#if @GNULIB_UTIMENSAT@
-# if @REPLACE_UTIMENSAT@
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
+ implementation relies on futimesat, which on Solaris 10 makes an invocation
+ to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
+ utimensat(). */
+# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef utimensat
# define utimensat rpl_utimensat
@@ -631,7 +641,9 @@ _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
struct timespec const times[2], int flag));
# endif
+# if @HAVE_UTIMENSAT@
_GL_CXXALIASWARN (utimensat);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef utimensat
# if HAVE_RAW_DECL_UTIMENSAT
diff --git a/lib/stdarg.in.h b/lib/sys_uio.in.h
similarity index 59%
rename from lib/stdarg.in.h
rename to lib/sys_uio.in.h
index 957fa9a8b..28aea2838 100644
--- a/lib/stdarg.in.h
+++ b/lib/sys_uio.in.h
@@ -1,5 +1,5 @@
-/* Substitute for and wrapper around .
- Copyright (C) 2008-2011 Free Software Foundation, Inc.
+/* Substitute for .
+ Copyright (C) 2011 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -15,22 +15,35 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-#ifndef _GL_STDARG_H
-
-#if __GNUC__ >= 3
+# if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
-#endif
+# endif
@PRAGMA_COLUMNS@
+#ifndef _GL_SYS_UIO_H
+
+#if @HAVE_SYS_UIO_H@
+
/* The include_next requires a split double-inclusion guard. */
-#@INCLUDE_NEXT@ @NEXT_STDARG_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_UIO_H@
-#ifndef _GL_STDARG_H
-#define _GL_STDARG_H
-
-#ifndef va_copy
-# define va_copy(a,b) ((a) = (b))
#endif
-#endif /* _GL_STDARG_H */
-#endif /* _GL_STDARG_H */
+#ifndef _GL_SYS_UIO_H
+#define _GL_SYS_UIO_H
+
+#if !@HAVE_SYS_UIO_H@
+/* A platform that lacks . */
+/* Get 'ssize_t'. */
+# include
+
+/* All known platforms that lack also lack any declaration
+ of struct iovec in any other header. */
+struct iovec {
+ void *iov_base;
+ size_t iov_len;
+};
+#endif
+
+#endif /* _GL_SYS_UIO_H */
+#endif /* _GL_SYS_UIO_H */
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index adc9b24df..1bbab0fe1 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -97,7 +97,8 @@
# include
#endif
-#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
+#if (@GNULIB_READ@ || @GNULIB_WRITE@ \
+ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
|| @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
/* Get ssize_t. */
# include
@@ -1105,6 +1106,28 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
#endif
+#if @GNULIB_READ@
+/* Read up to COUNT bytes from file descriptor FD into the buffer starting
+ at BUF. See the POSIX:2001 specification
+ . */
+# if @REPLACE_READ@ && @GNULIB_UNISTD_H_NONBLOCKING@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef read
+# define read rpl_read
+# endif
+_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
+# else
+/* Need to cast, because on mingw, the third parameter is
+ unsigned int count
+ and the return type is 'int'. */
+_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
+# endif
+_GL_CXXALIASWARN (read);
+#endif
+
+
#if @GNULIB_READLINK@
/* Read the contents of the symbolic link FILE and place the first BUFSIZE
bytes of it into BUF. Return the number of bytes placed into BUF if
@@ -1359,7 +1382,7 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
/* Write up to COUNT bytes starting at BUF to file descriptor FD.
See the POSIX:2001 specification
. */
-# if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
+# if @REPLACE_WRITE@ && (@GNULIB_UNISTD_H_NONBLOCKING@ || @GNULIB_UNISTD_H_SIGPIPE@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef write
# define write rpl_write
diff --git a/lib/unistr.in.h b/lib/unistr.in.h
index a06c6b47b..c665aa8a5 100644
--- a/lib/unistr.in.h
+++ b/lib/unistr.in.h
@@ -134,7 +134,7 @@ extern int
/* The variants with _safe suffix are safe, even if the library is compiled
without --enable-safety. */
-#if defined GNULIB_UNISTR_U8_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U8_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n);
@@ -157,7 +157,7 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
# endif
#endif
-#if defined GNULIB_UNISTR_U16_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U16_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n);
@@ -180,7 +180,7 @@ u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n)
# endif
#endif
-#if defined GNULIB_UNISTR_U32_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U32_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n);
@@ -191,11 +191,11 @@ u32_mbtouc_unsafe (ucs4_t *puc,
{
uint32_t c = *s;
-# ifdef CONFIG_UNICODE_SAFETY
+# if CONFIG_UNICODE_SAFETY
if (c < 0xd800 || (c >= 0xe000 && c < 0x110000))
# endif
*puc = c;
-# ifdef CONFIG_UNICODE_SAFETY
+# if CONFIG_UNICODE_SAFETY
else
/* invalid multibyte character */
*puc = 0xfffd;
@@ -205,7 +205,7 @@ u32_mbtouc_unsafe (ucs4_t *puc,
# endif
#endif
-#if defined GNULIB_UNISTR_U8_MBTOUC || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U8_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n);
@@ -228,7 +228,7 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
# endif
#endif
-#if defined GNULIB_UNISTR_U16_MBTOUC || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U16_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n);
@@ -251,7 +251,7 @@ u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n)
# endif
#endif
-#if defined GNULIB_UNISTR_U32_MBTOUC || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U32_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n);
@@ -279,17 +279,17 @@ u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER)
/* Similar to u*_mbtouc(), except that the return value gives more details
about the failure, similar to mbrtowc(). */
-#if defined GNULIB_UNISTR_U8_MBTOUCR || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U8_MBTOUCR || HAVE_LIBUNISTRING
extern int
u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n);
#endif
-#if defined GNULIB_UNISTR_U16_MBTOUCR || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U16_MBTOUCR || HAVE_LIBUNISTRING
extern int
u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n);
#endif
-#if defined GNULIB_UNISTR_U32_MBTOUCR || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U32_MBTOUCR || HAVE_LIBUNISTRING
extern int
u32_mbtoucr (ucs4_t *puc, const uint32_t *s, size_t n);
#endif
@@ -300,7 +300,7 @@ extern int
/* Similar to wctomb(), except that s must not be NULL, and the argument n
must be specified. */
-#if defined GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING
/* Auxiliary function, also used by u8_chr, u8_strchr, u8_strrchr. */
extern int
u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n);
@@ -322,7 +322,7 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
# endif
#endif
-#if defined GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING
/* Auxiliary function, also used by u16_chr, u16_strchr, u16_strrchr. */
extern int
u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n);
@@ -344,7 +344,7 @@ u16_uctomb (uint16_t *s, ucs4_t uc, int n)
# endif
#endif
-#if defined GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING
+#if GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_uctomb (uint32_t *s, ucs4_t uc, int n);
diff --git a/lib/verify.h b/lib/verify.h
index a40d58a63..9fa5111b6 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -20,6 +20,26 @@
#ifndef VERIFY_H
# define VERIFY_H 1
+/* Define HAVE__STATIC_ASSERT to 1 if _Static_assert works as per the
+ C1X draft N1548 section 6.7.10. This is supported by GCC 4.6.0 and
+ later, in C mode, and its use here generates easier-to-read diagnostics
+ when verify (R) fails.
+
+ Define HAVE_STATIC_ASSERT to 1 if static_assert works as per the
+ C1X draft N1548 section 7.2 or the C++0X draft N3242 section 7.(4).
+ This will likely be supported by future GCC versions, in C++ mode.
+
+ For now, use this only with GCC. Eventually whether _Static_assert
+ and static_assert works should be determined by 'configure'. */
+# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus
+# define HAVE__STATIC_ASSERT 1
+# endif
+/* The condition (99 < __GNUC__) is temporary, until we know about the
+ first G++ release that supports static_assert. */
+# if (99 < __GNUC__) && defined __cplusplus
+# define HAVE_STATIC_ASSERT 1
+# endif
+
/* Each of these macros verifies that its argument R is nonzero. To
be portable, R should be an integer constant expression. Unlike
assert (R), there is no run-time overhead.
@@ -31,7 +51,12 @@
Symbols ending in "__" are private to this header.
- The code below uses several ideas.
+ If _Static_assert works, verify (R) uses it directly. Similarly,
+ verify_true (R) works by packaging a _Static_assert inside a struct
+ that is an operand of sizeof.
+
+ The code below uses several ideas for C++ compilers, and for C
+ compilers that do not support _Static_assert:
* The first step is ((R) ? 1 : -1). Given an expression R, of
integral or boolean or floating-point type, this yields an
@@ -109,15 +134,9 @@
__COUNTER__ macro that can let us generate unique identifiers for
each dummy function, to suppress this warning.
- * This implementation exploits the fact that GCC does not warn about
- the last declaration mentioned above. If a future version of GCC
- introduces a warning for this, the problem could be worked around
- by using code specialized to GCC, just as __COUNTER__ is already
- being used if available.
-
- #if 4 <= __GNUC__
- # define verify(R) [another version to keep GCC happy]
- #endif
+ * This implementation exploits the fact that older versions of GCC,
+ which do not support _Static_assert, also do not warn about the
+ last declaration mentioned above.
* In C++, any struct definition inside sizeof is invalid.
Use a template type to work around the problem. */
@@ -148,6 +167,20 @@ template
struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
# define verify_true(R) \
(!!sizeof (verify_type__<(R) ? 1 : -1>))
+# elif HAVE__STATIC_ASSERT
+# define verify_true(R) \
+ (!!sizeof \
+ (struct { \
+ _Static_assert (R, "verify_true (" #R ")"); \
+ int verify_dummy__; \
+ }))
+# elif HAVE_STATIC_ASSERT
+# define verify_true(R) \
+ (!!sizeof \
+ (struct { \
+ static_assert (R, "verify_true (" #R ")"); \
+ int verify_dummy__; \
+ }))
# else
# define verify_true(R) \
(!!sizeof \
@@ -157,7 +190,13 @@ template
/* Verify requirement R at compile-time, as a declaration without a
trailing ';'. */
-# define verify(R) \
+# if HAVE__STATIC_ASSERT
+# define verify(R) _Static_assert (R, "verify (" #R ")")
+# elif HAVE_STATIC_ASSERT
+# define verify(R) static_assert (R, "verify (" #R ")")
+# else
+# define verify(R) \
extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)]
+# endif
#endif
diff --git a/lib/version-etc-fsf.c b/lib/version-etc-fsf.c
deleted file mode 100644
index 17c8bc3c4..000000000
--- a/lib/version-etc-fsf.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Variable with FSF copyright information, for version-etc.
- Copyright (C) 1999-2006, 2009-2011 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 3 of the License, 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see . */
-
-/* Written by Jim Meyering. */
-
-#include
-
-/* Specification. */
-#include "version-etc.h"
-
-/* Default copyright goes to the FSF. */
-
-const char version_etc_copyright[] =
- /* Do *not* mark this string for translation. %s is a copyright
- symbol suitable for this locale, and %d is the copyright
- year. */
- "Copyright %s %d Free Software Foundation, Inc.";
diff --git a/lib/version-etc.c b/lib/version-etc.c
deleted file mode 100644
index 60c6f01c7..000000000
--- a/lib/version-etc.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/* Print --version and bug-reporting information in a consistent format.
- Copyright (C) 1999-2011 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 3 of the License, 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see . */
-
-/* Written by Jim Meyering. */
-
-#include
-
-/* Specification. */
-#include "version-etc.h"
-
-#include
-#include
-#include
-
-#if USE_UNLOCKED_IO
-# include "unlocked-io.h"
-#endif
-
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-
-/* If you use AM_INIT_AUTOMAKE's no-define option,
- PACKAGE is not defined. Use PACKAGE_TARNAME instead. */
-#if ! defined PACKAGE && defined PACKAGE_TARNAME
-# define PACKAGE PACKAGE_TARNAME
-#endif
-
-enum { COPYRIGHT_YEAR = 2011 };
-
-/* The three functions below display the --version information the
- standard way.
-
- If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of
- the program. The formats are therefore:
-
- PACKAGE VERSION
-
- or
-
- COMMAND_NAME (PACKAGE) VERSION.
-
- The functions differ in the way they are passed author names. */
-
-/* Display the --version information the standard way.
-
- Author names are given in the array AUTHORS. N_AUTHORS is the
- number of elements in the array. */
-void
-version_etc_arn (FILE *stream,
- const char *command_name, const char *package,
- const char *version,
- const char * const * authors, size_t n_authors)
-{
- if (command_name)
- fprintf (stream, "%s (%s) %s\n", command_name, package, version);
- else
- fprintf (stream, "%s %s\n", package, version);
-
-#ifdef PACKAGE_PACKAGER
-# ifdef PACKAGE_PACKAGER_VERSION
- fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER,
- PACKAGE_PACKAGER_VERSION);
-# else
- fprintf (stream, _("Packaged by %s\n"), PACKAGE_PACKAGER);
-# endif
-#endif
-
- /* TRANSLATORS: Translate "(C)" to the copyright symbol
- (C-in-a-circle), if this symbol is available in the user's
- locale. Otherwise, do not translate "(C)"; leave it as-is. */
- fprintf (stream, version_etc_copyright, _("(C)"), COPYRIGHT_YEAR);
-
- fputs (_("\
-\n\
-License GPLv3+: GNU GPL version 3 or later .\n\
-This is free software: you are free to change and redistribute it.\n\
-There is NO WARRANTY, to the extent permitted by law.\n\
-\n\
-"),
- stream);
-
- switch (n_authors)
- {
- case 0:
- /* The caller must provide at least one author name. */
- abort ();
- case 1:
- /* TRANSLATORS: %s denotes an author name. */
- fprintf (stream, _("Written by %s.\n"), authors[0]);
- break;
- case 2:
- /* TRANSLATORS: Each %s denotes an author name. */
- fprintf (stream, _("Written by %s and %s.\n"), authors[0], authors[1]);
- break;
- case 3:
- /* TRANSLATORS: Each %s denotes an author name. */
- fprintf (stream, _("Written by %s, %s, and %s.\n"),
- authors[0], authors[1], authors[2]);
- break;
- case 4:
- /* TRANSLATORS: Each %s denotes an author name.
- You can use line breaks, estimating that each author name occupies
- ca. 16 screen columns and that a screen line has ca. 80 columns. */
- fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"),
- authors[0], authors[1], authors[2], authors[3]);
- break;
- case 5:
- /* TRANSLATORS: Each %s denotes an author name.
- You can use line breaks, estimating that each author name occupies
- ca. 16 screen columns and that a screen line has ca. 80 columns. */
- fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"),
- authors[0], authors[1], authors[2], authors[3], authors[4]);
- break;
- case 6:
- /* TRANSLATORS: Each %s denotes an author name.
- You can use line breaks, estimating that each author name occupies
- ca. 16 screen columns and that a screen line has ca. 80 columns. */
- fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"),
- authors[0], authors[1], authors[2], authors[3], authors[4],
- authors[5]);
- break;
- case 7:
- /* TRANSLATORS: Each %s denotes an author name.
- You can use line breaks, estimating that each author name occupies
- ca. 16 screen columns and that a screen line has ca. 80 columns. */
- fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"),
- authors[0], authors[1], authors[2], authors[3], authors[4],
- authors[5], authors[6]);
- break;
- case 8:
- /* TRANSLATORS: Each %s denotes an author name.
- You can use line breaks, estimating that each author name occupies
- ca. 16 screen columns and that a screen line has ca. 80 columns. */
- fprintf (stream, _("\
-Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"),
- authors[0], authors[1], authors[2], authors[3], authors[4],
- authors[5], authors[6], authors[7]);
- break;
- case 9:
- /* TRANSLATORS: Each %s denotes an author name.
- You can use line breaks, estimating that each author name occupies
- ca. 16 screen columns and that a screen line has ca. 80 columns. */
- fprintf (stream, _("\
-Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"),
- authors[0], authors[1], authors[2], authors[3], authors[4],
- authors[5], authors[6], authors[7], authors[8]);
- break;
- default:
- /* 10 or more authors. Use an abbreviation, since the human reader
- will probably not want to read the entire list anyway. */
- /* TRANSLATORS: Each %s denotes an author name.
- You can use line breaks, estimating that each author name occupies
- ca. 16 screen columns and that a screen line has ca. 80 columns. */
- fprintf (stream, _("\
-Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
- authors[0], authors[1], authors[2], authors[3], authors[4],
- authors[5], authors[6], authors[7], authors[8]);
- break;
- }
-}
-
-/* Display the --version information the standard way. See the initial
- comment to this module, for more information.
-
- Author names are given in the NULL-terminated array AUTHORS. */
-void
-version_etc_ar (FILE *stream,
- const char *command_name, const char *package,
- const char *version, const char * const * authors)
-{
- size_t n_authors;
-
- for (n_authors = 0; authors[n_authors]; n_authors++)
- ;
- version_etc_arn (stream, command_name, package, version, authors, n_authors);
-}
-
-/* Display the --version information the standard way. See the initial
- comment to this module, for more information.
-
- Author names are given in the NULL-terminated va_list AUTHORS. */
-void
-version_etc_va (FILE *stream,
- const char *command_name, const char *package,
- const char *version, va_list authors)
-{
- size_t n_authors;
- const char *authtab[10];
-
- for (n_authors = 0;
- n_authors < 10
- && (authtab[n_authors] = va_arg (authors, const char *)) != NULL;
- n_authors++)
- ;
- version_etc_arn (stream, command_name, package, version,
- authtab, n_authors);
-}
-
-
-/* Display the --version information the standard way.
-
- If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of
- the program. The formats are therefore:
-
- PACKAGE VERSION
-
- or
-
- COMMAND_NAME (PACKAGE) VERSION.
-
- The authors names are passed as separate arguments, with an additional
- NULL argument at the end. */
-void
-version_etc (FILE *stream,
- const char *command_name, const char *package,
- const char *version, /* const char *author1, ...*/ ...)
-{
- va_list authors;
-
- va_start (authors, version);
- version_etc_va (stream, command_name, package, version, authors);
- va_end (authors);
-}
-
-void
-emit_bug_reporting_address (void)
-{
- /* TRANSLATORS: The placeholder indicates the bug-reporting address
- for this package. Please add _another line_ saying
- "Report translation bugs to <...>\n" with the address for translation
- bugs (typically your translation team's web or email address). */
- printf (_("\nReport bugs to: %s\n"), PACKAGE_BUGREPORT);
-#ifdef PACKAGE_PACKAGER_BUG_REPORTS
- printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER,
- PACKAGE_PACKAGER_BUG_REPORTS);
-#endif
-#ifdef PACKAGE_URL
- printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
-#else
- printf (_("%s home page: \n"),
- PACKAGE_NAME, PACKAGE);
-#endif
- fputs (_("General help using GNU software: \n"),
- stdout);
-}
diff --git a/lib/version-etc.h b/lib/version-etc.h
deleted file mode 100644
index b197ad11f..000000000
--- a/lib/version-etc.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Print --version and bug-reporting information in a consistent format.
- Copyright (C) 1999, 2003, 2005, 2009-2011 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 3 of the License, 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 Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see . */
-
-/* Written by Jim Meyering. */
-
-#ifndef VERSION_ETC_H
-# define VERSION_ETC_H 1
-
-# include
-# include
-
-/* The `sentinel' attribute was added in gcc 4.0. */
-#ifndef _GL_ATTRIBUTE_SENTINEL
-# if 4 <= __GNUC__
-# define _GL_ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
-# else
-# define _GL_ATTRIBUTE_SENTINEL /* empty */
-# endif
-#endif
-
-extern const char version_etc_copyright[];
-
-/* The three functions below display the --version information in the
- standard way: command and package names, package version, followed
- by a short GPLv3+ notice and a list of up to 10 author names.
-
- If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of
- the program. The formats are therefore:
-
- PACKAGE VERSION
-
- or
-
- COMMAND_NAME (PACKAGE) VERSION.
-
- The functions differ in the way they are passed author names: */
-
-/* N_AUTHORS names are supplied in array AUTHORS. */
-extern void version_etc_arn (FILE *stream,
- const char *command_name, const char *package,
- const char *version,
- const char * const * authors, size_t n_authors);
-
-/* Names are passed in the NULL-terminated array AUTHORS. */
-extern void version_etc_ar (FILE *stream,
- const char *command_name, const char *package,
- const char *version, const char * const * authors);
-
-/* Names are passed in the NULL-terminated va_list. */
-extern void version_etc_va (FILE *stream,
- const char *command_name, const char *package,
- const char *version, va_list authors);
-
-/* Names are passed as separate arguments, with an additional
- NULL argument at the end. */
-extern void version_etc (FILE *stream,
- const char *command_name, const char *package,
- const char *version,
- /* const char *author1, ..., NULL */ ...)
- _GL_ATTRIBUTE_SENTINEL;
-
-/* Display the usual `Report bugs to' stanza */
-extern void emit_bug_reporting_address (void);
-
-#endif /* VERSION_ETC_H */
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 4abc8759a..3cc0fc4b3 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -61,9 +61,13 @@
.
BSD/OS 4.0.1 has a bug: , and must be
included before .
+ In some builds of uClibc, is nonexistent and wchar_t is defined
+ by .
But avoid namespace pollution on glibc systems. */
-#ifndef __GLIBC__
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
# include
+#endif
+#ifndef __GLIBC__
# include
# include
#endif
@@ -435,8 +439,22 @@ _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
# if !@HAVE_WMEMCHR@
_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
# endif
-_GL_CXXALIAS_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
+ wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wmemchr,
+ wchar_t *, (const wchar_t *, wchar_t, size_t),
+ const wchar_t *, (const wchar_t *, wchar_t, size_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
+_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
+ (const wchar_t *s, wchar_t c, size_t n));
+# else
_GL_CXXALIASWARN (wmemchr);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wmemchr
# if HAVE_RAW_DECL_WMEMCHR
@@ -776,8 +794,21 @@ _GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
# if !@HAVE_WCSCHR@
_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
# endif
-_GL_CXXALIAS_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcschr (const wchar_t *, wchar_t);
+ wchar_t * std::wcschr (wchar_t *, wchar_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcschr,
+ wchar_t *, (const wchar_t *, wchar_t),
+ const wchar_t *, (const wchar_t *, wchar_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
+_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
+# else
_GL_CXXALIASWARN (wcschr);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wcschr
# if HAVE_RAW_DECL_WCSCHR
@@ -792,8 +823,21 @@ _GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
# if !@HAVE_WCSRCHR@
_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
# endif
-_GL_CXXALIAS_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
+ wchar_t * std::wcsrchr (wchar_t *, wchar_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcsrchr,
+ wchar_t *, (const wchar_t *, wchar_t),
+ const wchar_t *, (const wchar_t *, wchar_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
+_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
+# else
_GL_CXXALIASWARN (wcsrchr);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wcsrchr
# if HAVE_RAW_DECL_WCSRCHR
@@ -843,9 +887,23 @@ _GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
_GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
(const wchar_t *wcs, const wchar_t *accept));
# endif
-_GL_CXXALIAS_SYS (wcspbrk, wchar_t *,
- (const wchar_t *wcs, const wchar_t *accept));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
+ wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcspbrk,
+ wchar_t *, (const wchar_t *, const wchar_t *),
+ const wchar_t *, (const wchar_t *, const wchar_t *));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
+ (wchar_t *wcs, const wchar_t *accept));
+_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
+ (const wchar_t *wcs, const wchar_t *accept));
+# else
_GL_CXXALIASWARN (wcspbrk);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wcspbrk
# if HAVE_RAW_DECL_WCSPBRK
@@ -861,9 +919,23 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
(const wchar_t *haystack, const wchar_t *needle));
# endif
-_GL_CXXALIAS_SYS (wcsstr, wchar_t *,
- (const wchar_t *haystack, const wchar_t *needle));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
+ wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcsstr,
+ wchar_t *, (const wchar_t *, const wchar_t *),
+ const wchar_t *, (const wchar_t *, const wchar_t *));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
+ (wchar_t *haystack, const wchar_t *needle));
+_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
+ (const wchar_t *haystack, const wchar_t *needle));
+# else
_GL_CXXALIASWARN (wcsstr);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wcsstr
# if HAVE_RAW_DECL_WCSSTR
diff --git a/lib/write.c b/lib/write.c
index 7d02daabd..3093df2d8 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -20,8 +20,9 @@
/* Specification. */
#include
-/* Replace this function only if module 'sigpipe' is requested. */
-#if GNULIB_SIGPIPE
+/* Replace this function only if module 'nonblocking' or module 'sigpipe' is
+ requested. */
+#if GNULIB_NONBLOCKING || GNULIB_SIGPIPE
/* On native Windows platforms, SIGPIPE does not exist. When write() is
called on a pipe with no readers, WriteFile() fails with error
@@ -41,21 +42,81 @@ ssize_t
rpl_write (int fd, const void *buf, size_t count)
#undef write
{
- ssize_t ret = write (fd, buf, count);
-
- if (ret < 0)
+ for (;;)
{
- if (GetLastError () == ERROR_NO_DATA
- && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)
+ ssize_t ret = write (fd, buf, count);
+
+ if (ret < 0)
{
- /* Try to raise signal SIGPIPE. */
- raise (SIGPIPE);
- /* If it is currently blocked or ignored, change errno from EINVAL
- to EPIPE. */
- errno = EPIPE;
+# if GNULIB_NONBLOCKING
+ if (errno == ENOSPC)
+ {
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+ if (GetFileType (h) == FILE_TYPE_PIPE)
+ {
+ /* h is a pipe or socket. */
+ DWORD state;
+ if (GetNamedPipeHandleState (h, &state, NULL, NULL, NULL,
+ NULL, 0)
+ && (state & PIPE_NOWAIT) != 0)
+ {
+ /* h is a pipe in non-blocking mode.
+ We can get here in four situations:
+ 1. When the pipe buffer is full.
+ 2. When count <= pipe_buf_size and the number of
+ free bytes in the pipe buffer is < count.
+ 3. When count > pipe_buf_size and the number of free
+ bytes in the pipe buffer is > 0, < pipe_buf_size.
+ 4. When count > pipe_buf_size and the pipe buffer is
+ entirely empty.
+ The cases 1 and 2 are POSIX compliant. In cases 3 and
+ 4 POSIX specifies that write() must split the request
+ and succeed with a partial write. We fix case 4.
+ We don't fix case 3 because it is not essential for
+ programs. */
+ DWORD out_size; /* size of the buffer for outgoing data */
+ DWORD in_size; /* size of the buffer for incoming data */
+ if (GetNamedPipeInfo (h, NULL, &out_size, &in_size, NULL))
+ {
+ size_t reduced_count = count;
+ /* In theory we need only one of out_size, in_size.
+ But I don't know which of the two. The description
+ is ambiguous. */
+ if (out_size != 0 && out_size < reduced_count)
+ reduced_count = out_size;
+ if (in_size != 0 && in_size < reduced_count)
+ reduced_count = in_size;
+ if (reduced_count < count)
+ {
+ /* Attempt to write only the first part. */
+ count = reduced_count;
+ continue;
+ }
+ }
+ /* Change errno from ENOSPC to EAGAIN. */
+ errno = EAGAIN;
+ }
+ }
+ }
+ else
+# endif
+ {
+# if GNULIB_SIGPIPE
+ if (GetLastError () == ERROR_NO_DATA
+ && GetFileType ((HANDLE) _get_osfhandle (fd))
+ == FILE_TYPE_PIPE)
+ {
+ /* Try to raise signal SIGPIPE. */
+ raise (SIGPIPE);
+ /* If it is currently blocked or ignored, change errno from
+ EINVAL to EPIPE. */
+ errno = EPIPE;
+ }
+# endif
+ }
}
+ return ret;
}
- return ret;
}
# endif
diff --git a/libguile/script.c b/libguile/script.c
index 7f6116242..83dcdd5b9 100644
--- a/libguile/script.c
+++ b/libguile/script.c
@@ -27,8 +27,6 @@
#include
#include
-#include
-
#include "libguile/_scm.h"
#include "libguile/eval.h"
#include "libguile/feature.h"
diff --git a/m4/alloca.m4 b/m4/alloca.m4
index e2e8a05a6..689da75a2 100644
--- a/m4/alloca.m4
+++ b/m4/alloca.m4
@@ -1,4 +1,4 @@
-# alloca.m4 serial 10
+# alloca.m4 serial 11
dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
@@ -36,6 +36,7 @@ AC_DEFUN([gl_FUNC_ALLOCA],
ALLOCA_H=alloca.h
fi
AC_SUBST([ALLOCA_H])
+ AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"])
])
# Prerequisites of lib/alloca.c.
diff --git a/m4/byteswap.m4 b/m4/byteswap.m4
index a033acd8d..2d4de4659 100644
--- a/m4/byteswap.m4
+++ b/m4/byteswap.m4
@@ -1,4 +1,4 @@
-# byteswap.m4 serial 3
+# byteswap.m4 serial 4
dnl Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -15,4 +15,5 @@ AC_DEFUN([gl_BYTESWAP],
BYTESWAP_H='byteswap.h'
])
AC_SUBST([BYTESWAP_H])
+ AM_CONDITIONAL([GL_GENERATE_BYTESWAP_H], [test -n "$BYTESWAP_H"])
])
diff --git a/m4/errno_h.m4 b/m4/errno_h.m4
index 687bafff2..a6d37f3b3 100644
--- a/m4/errno_h.m4
+++ b/m4/errno_h.m4
@@ -1,4 +1,4 @@
-# errno_h.m4 serial 8
+# errno_h.m4 serial 9
dnl Copyright (C) 2004, 2006, 2008-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -54,6 +54,7 @@ booboo
ERRNO_H='errno.h'
fi
AC_SUBST([ERRNO_H])
+ AM_CONDITIONAL([GL_GENERATE_ERRNO_H], [test -n "$ERRNO_H"])
gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
gl_REPLACE_ERRNO_VALUE([ENOLINK])
gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
diff --git a/m4/float_h.m4 b/m4/float_h.m4
index 265a4c1a6..21a7529fe 100644
--- a/m4/float_h.m4
+++ b/m4/float_h.m4
@@ -1,4 +1,4 @@
-# float_h.m4 serial 5
+# float_h.m4 serial 6
dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -16,4 +16,5 @@ AC_DEFUN([gl_FLOAT_H],
;;
esac
AC_SUBST([FLOAT_H])
+ AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
])
diff --git a/m4/getaddrinfo.m4 b/m4/getaddrinfo.m4
index 94c276f83..e57623694 100644
--- a/m4/getaddrinfo.m4
+++ b/m4/getaddrinfo.m4
@@ -1,4 +1,4 @@
-# getaddrinfo.m4 serial 23
+# getaddrinfo.m4 serial 24
dnl Copyright (C) 2004-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -105,7 +105,10 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
dnl Including sys/socket.h is wrong for Windows, but Windows does not
dnl have sa_len so the result is correct anyway.
- AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [#include ])
+ AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [
+#include
+#include
+])
AC_CHECK_HEADERS_ONCE([netinet/in.h])
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 2d84c7f24..70f8b9ae5 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil close connect duplocale environ extensions flock floor fpieee frexp full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen locale log1p maintainer-makefile malloc-gnu malloca nproc putenv recv recvfrom send sendto setsockopt shutdown socket stat-time stdlib strcase strftime striconveh string sys_stat trunc verify version-etc-fsf vsnprintf warnings wchar
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil close connect duplocale environ extensions flock floor fpieee frexp full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen locale log1p maintainer-makefile malloc-gnu malloca nproc putenv recv recvfrom send sendto setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat trunc verify vsnprintf warnings wchar
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@@ -77,14 +77,12 @@ gl_MODULES([
socket
stat-time
stdlib
- strcase
strftime
striconveh
string
sys_stat
trunc
verify
- version-etc-fsf
vsnprintf
warnings
wchar
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index ecbf33694..c4d7a20ea 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 23
+# gnulib-common.m4 serial 24
dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -109,7 +109,8 @@ AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
[
dnl Override gl_WARN_ON_USE_PREPARE.
- AC_DEFUN([gl_WARN_ON_USE_PREPARE], [])
+ dnl But hide this definition from 'aclocal'.
+ AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
])
# gl_ASSERT_NO_GNULIB_TESTS
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 8a70734a3..257258734 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -44,7 +44,6 @@ AC_DEFUN([gl_EARLY],
# Code from module canonicalize-lgpl:
# Code from module ceil:
# Code from module close:
- # Code from module close-hook:
# Code from module connect:
# Code from module dosname:
# Code from module duplocale:
@@ -53,6 +52,7 @@ AC_DEFUN([gl_EARLY],
# Code from module extensions:
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
# Code from module fclose:
+ # Code from module fd-hook:
# Code from module float:
# Code from module flock:
# Code from module floor:
@@ -110,6 +110,7 @@ AC_DEFUN([gl_EARLY],
# Code from module nproc:
# Code from module pathmax:
# Code from module putenv:
+ # Code from module read:
# Code from module readlink:
# Code from module recv:
# Code from module recvfrom:
@@ -129,26 +130,19 @@ AC_DEFUN([gl_EARLY],
# Code from module ssize_t:
# Code from module stat:
# Code from module stat-time:
- # Code from module stdarg:
- dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode
- dnl for the builtin va_copy to work. With Autoconf 2.60 or later,
- dnl AC_PROG_CC_STDC arranges for this. With older Autoconf AC_PROG_CC_STDC
- dnl shouldn't hurt, though installers are on their own to set c99 mode.
- AC_REQUIRE([AC_PROG_CC_STDC])
# Code from module stdbool:
# Code from module stddef:
# Code from module stdint:
# Code from module stdio:
# Code from module stdlib:
- # Code from module strcase:
# Code from module strftime:
# Code from module striconveh:
# Code from module string:
- # Code from module strings:
# Code from module sys_file:
# Code from module sys_socket:
# Code from module sys_stat:
# Code from module sys_time:
+ # Code from module sys_uio:
# Code from module time:
# Code from module time_r:
# Code from module trunc:
@@ -165,8 +159,6 @@ AC_DEFUN([gl_EARLY],
# Code from module vasnprintf:
# Code from module vc-list-files:
# Code from module verify:
- # Code from module version-etc:
- # Code from module version-etc-fsf:
# Code from module vsnprintf:
# Code from module warn-on-use:
# Code from module warnings:
@@ -227,7 +219,6 @@ AC_DEFUN([gl_INIT],
# Code from module close:
gl_FUNC_CLOSE
gl_UNISTD_MODULE_INDICATOR([close])
- # Code from module close-hook:
# Code from module connect:
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
if test "$ac_cv_header_winsock2_h" = yes; then
@@ -247,6 +238,7 @@ AC_DEFUN([gl_INIT],
# Code from module fclose:
gl_FUNC_FCLOSE
gl_STDIO_MODULE_INDICATOR([fclose])
+ # Code from module fd-hook:
# Code from module float:
gl_FLOAT_H
# Code from module flock:
@@ -299,9 +291,9 @@ AC_DEFUN([gl_INIT],
# builds, so use a shell variable to bypass this.
GNUmakefile=GNUmakefile
m4_if(m4_version_compare([2.61a.100],
- m4_defn([m4_PACKAGE_VERSION])), [1], [],
+ m4_defn([m4_PACKAGE_VERSION])), [1], [],
[AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [],
- [GNUmakefile=$GNUmakefile])])
+ [GNUmakefile=$GNUmakefile])])
# Code from module gnupload:
# Code from module gperf:
# Code from module havelib:
@@ -394,6 +386,9 @@ AC_DEFUN([gl_INIT],
# Code from module putenv:
gl_FUNC_PUTENV
gl_STDLIB_MODULE_INDICATOR([putenv])
+ # Code from module read:
+ gl_FUNC_READ
+ gl_UNISTD_MODULE_INDICATOR([read])
# Code from module readlink:
gl_FUNC_READLINK
gl_UNISTD_MODULE_INDICATOR([readlink])
@@ -474,8 +469,6 @@ AC_DEFUN([gl_INIT],
# Code from module stat-time:
gl_STAT_TIME
gl_STAT_BIRTHTIME
- # Code from module stdarg:
- gl_STDARG_H
# Code from module stdbool:
AM_STDBOOL_H
# Code from module stddef:
@@ -486,8 +479,6 @@ AC_DEFUN([gl_INIT],
gl_STDIO_H
# Code from module stdlib:
gl_STDLIB_H
- # Code from module strcase:
- gl_STRCASE
# Code from module strftime:
gl_FUNC_GNU_STRFTIME
# Code from module striconveh:
@@ -497,8 +488,6 @@ AC_DEFUN([gl_INIT],
fi
# Code from module string:
gl_HEADER_STRING_H
- # Code from module strings:
- gl_HEADER_STRINGS_H
# Code from module sys_file:
gl_HEADER_SYS_FILE_H
AC_PROG_MKDIR_P
@@ -511,6 +500,9 @@ AC_DEFUN([gl_INIT],
# Code from module sys_time:
gl_HEADER_SYS_TIME_H
AC_PROG_MKDIR_P
+ # Code from module sys_uio:
+ gl_HEADER_SYS_UIO
+ AC_PROG_MKDIR_P
# Code from module time:
gl_HEADER_TIME_H
# Code from module time_r:
@@ -545,9 +537,6 @@ AC_DEFUN([gl_INIT],
gl_FUNC_VASNPRINTF
# Code from module vc-list-files:
# Code from module verify:
- # Code from module version-etc:
- gl_VERSION_ETC
- # Code from module version-etc-fsf:
# Code from module vsnprintf:
gl_FUNC_VSNPRINTF
gl_STDIO_MODULE_INDICATOR([vsnprintf])
@@ -726,14 +715,14 @@ AC_DEFUN([gl_FILE_LIST], [
lib/c-strncasecmp.c
lib/canonicalize-lgpl.c
lib/ceil.c
- lib/close-hook.c
- lib/close-hook.h
lib/close.c
lib/connect.c
lib/dosname.h
lib/duplocale.c
lib/errno.in.h
lib/fclose.c
+ lib/fd-hook.c
+ lib/fd-hook.h
lib/float+.h
lib/float.in.h
lib/flock.c
@@ -788,6 +777,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/printf-parse.c
lib/printf-parse.h
lib/putenv.c
+ lib/read.c
lib/readlink.c
lib/recv.c
lib/recvfrom.c
@@ -806,24 +796,21 @@ AC_DEFUN([gl_FILE_LIST], [
lib/sockets.h
lib/stat-time.h
lib/stat.c
- lib/stdarg.in.h
lib/stdbool.in.h
lib/stddef.in.h
lib/stdint.in.h
lib/stdio.in.h
lib/stdlib.in.h
- lib/strcasecmp.c
lib/strftime.c
lib/strftime.h
lib/striconveh.c
lib/striconveh.h
lib/string.in.h
- lib/strings.in.h
- lib/strncasecmp.c
lib/sys_file.in.h
lib/sys_socket.in.h
lib/sys_stat.in.h
lib/sys_time.in.h
+ lib/sys_uio.in.h
lib/time.in.h
lib/time_r.c
lib/trunc.c
@@ -841,9 +828,6 @@ AC_DEFUN([gl_FILE_LIST], [
lib/vasnprintf.c
lib/vasnprintf.h
lib/verify.h
- lib/version-etc-fsf.c
- lib/version-etc.c
- lib/version-etc.h
lib/vsnprintf.c
lib/w32sock.h
lib/wchar.in.h
@@ -915,6 +899,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/pathmax.m4
m4/printf.m4
m4/putenv.m4
+ m4/read.m4
m4/readlink.m4
m4/safe-read.m4
m4/safe-write.m4
@@ -928,28 +913,25 @@ AC_DEFUN([gl_FILE_LIST], [
m4/ssize_t.m4
m4/stat-time.m4
m4/stat.m4
- m4/stdarg.m4
m4/stdbool.m4
m4/stddef_h.m4
m4/stdint.m4
m4/stdint_h.m4
m4/stdio_h.m4
m4/stdlib_h.m4
- m4/strcase.m4
m4/strftime.m4
m4/string_h.m4
- m4/strings_h.m4
m4/sys_file_h.m4
m4/sys_socket_h.m4
m4/sys_stat_h.m4
m4/sys_time_h.m4
+ m4/sys_uio_h.m4
m4/time_h.m4
m4/time_r.m4
m4/tm_gmtoff.m4
m4/trunc.m4
m4/unistd_h.m4
m4/vasnprintf.m4
- m4/version-etc.m4
m4/visibility.m4
m4/vsnprintf.m4
m4/warn-on-use.m4
diff --git a/m4/iconv_h.m4 b/m4/iconv_h.m4
index abfacffb4..8cca7fd80 100644
--- a/m4/iconv_h.m4
+++ b/m4/iconv_h.m4
@@ -1,4 +1,4 @@
-# iconv_h.m4 serial 7
+# iconv_h.m4 serial 8
dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -18,6 +18,7 @@ AC_DEFUN([gl_REPLACE_ICONV_H],
[
AC_REQUIRE([gl_ICONV_H_DEFAULTS])
ICONV_H='iconv.h'
+ AM_CONDITIONAL([GL_GENERATE_ICONV_H], [test -n "$ICONV_H"])
])
AC_DEFUN([gl_ICONV_MODULE_INDICATOR],
@@ -36,4 +37,5 @@ AC_DEFUN([gl_ICONV_H_DEFAULTS],
REPLACE_ICONV_OPEN=0; AC_SUBST([REPLACE_ICONV_OPEN])
REPLACE_ICONV_UTF=0; AC_SUBST([REPLACE_ICONV_UTF])
ICONV_H=''; AC_SUBST([ICONV_H])
+ AM_CONDITIONAL([GL_GENERATE_ICONV_H], [test -n "$ICONV_H"])
])
diff --git a/m4/memchr.m4 b/m4/memchr.m4
index 3c2b31391..a544e2b4e 100644
--- a/m4/memchr.m4
+++ b/m4/memchr.m4
@@ -1,4 +1,4 @@
-# memchr.m4 serial 10
+# memchr.m4 serial 11
dnl Copyright (C) 2002-2004, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -11,10 +11,16 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
- dnl These days, we assume memchr is present. But just in case...
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- AC_CHECK_FUNCS_ONCE([memchr])
- if test $ac_cv_func_memchr = yes; then
+ m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [
+ dnl These days, we assume memchr is present. But if support for old
+ dnl platforms is desired:
+ AC_CHECK_FUNCS_ONCE([memchr])
+ if test $ac_cv_func_memchr = no; then
+ HAVE_MEMCHR=0
+ fi
+ ])
+ if test $HAVE_MEMCHR = 1; then
# Detect platform-specific bugs in some versions of glibc:
# memchr should not dereference anything with length 0
# http://bugzilla.redhat.com/499689
@@ -73,8 +79,6 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
if test "$gl_cv_func_memchr_works" != yes; then
REPLACE_MEMCHR=1
fi
- else
- HAVE_MEMCHR=0
fi
if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
AC_LIBOBJ([memchr])
diff --git a/m4/netinet_in_h.m4 b/m4/netinet_in_h.m4
index e2d022df7..87235b73b 100644
--- a/m4/netinet_in_h.m4
+++ b/m4/netinet_in_h.m4
@@ -1,4 +1,4 @@
-# netinet_in_h.m4 serial 4
+# netinet_in_h.m4 serial 5
dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -27,4 +27,5 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
AC_SUBST([HAVE_NETINET_IN_H])
fi
AC_SUBST([NETINET_IN_H])
+ AM_CONDITIONAL([GL_GENERATE_NETINET_IN_H], [test -n "$NETINET_IN_H"])
])
diff --git a/m4/read.m4 b/m4/read.m4
new file mode 100644
index 000000000..032761f1b
--- /dev/null
+++ b/m4/read.m4
@@ -0,0 +1,20 @@
+# read.m4 serial 1
+dnl Copyright (C) 2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_READ],
+[
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ dnl This ifdef is just an optimization, to avoid performing a configure
+ dnl check whose result is not used. It does not make the test of
+ dnl GNULIB_UNISTD_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
+ m4_ifdef([gl_NONBLOCKING_IO], [
+ gl_NONBLOCKING_IO
+ if test $gl_cv_have_nonblocking != yes; then
+ REPLACE_READ=1
+ AC_LIBOBJ([read])
+ fi
+ ])
+])
diff --git a/m4/socklen.m4 b/m4/socklen.m4
index 5e4c69ed7..447515444 100644
--- a/m4/socklen.m4
+++ b/m4/socklen.m4
@@ -1,4 +1,4 @@
-# socklen.m4 serial 8
+# socklen.m4 serial 10
dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,15 +9,11 @@ dnl From Albert Chin, Windows fixes from Simon Josefsson.
dnl Check for socklen_t: historically on BSD it is an int, and in
dnl POSIX 1g it is a type of its own, but some platforms use different
dnl types for the argument to getsockopt, getpeername, etc.:
-dnl HP-UX 10.20, IRIX 6.5, Interix 3.5, BeOS.
+dnl HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS.
dnl So we have to test to find something that will work.
-dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
-dnl it there first. That file is included by gnulib's sys_socket.in.h, which
-dnl all users of this module should include. Cygwin must not include
-dnl ws2tcpip.h.
AC_DEFUN([gl_TYPE_SOCKLEN_T],
- [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl
+ [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl
AC_CHECK_TYPE([socklen_t], ,
[AC_MSG_CHECKING([for socklen_t equivalent])
AC_CACHE_VAL([gl_cv_socklen_t_equiv],
@@ -45,9 +41,37 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
[type to use in place of socklen_t if not defined])],
- [#include
- #if HAVE_SYS_SOCKET_H
- # include
- #elif HAVE_WS2TCPIP_H
- # include
- #endif])])
+ [gl_SOCKET_HEADERS])])
+
+dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
+dnl it there too. But on Cygwin, wc2tcpip.h must not be included. Users
+dnl of this module should use the same include pattern as gl_SOCKET_HEADERS.
+dnl When you change this macro, keep also in sync:
+dnl - gl_CHECK_SOCKET_HEADERS,
+dnl - the Include section of modules/socklen.
+AC_DEFUN([gl_SOCKET_HEADERS],
+[
+/* is not needed according to POSIX, but the
+ in i386-unknown-freebsd4.10 and
+ powerpc-apple-darwin5.5 required it. */
+#include
+#if HAVE_SYS_SOCKET_H
+# include
+#elif HAVE_WS2TCPIP_H
+# include
+#endif
+])
+
+dnl Tests for the existence of the header for socket facilities.
+dnl Defines the C macros HAVE_SYS_SOCKET_H, HAVE_WS2TCPIP_H.
+dnl This macro must match gl_SOCKET_HEADERS.
+AC_DEFUN([gl_CHECK_SOCKET_HEADERS],
+ [AC_CHECK_HEADERS_ONCE([sys/socket.h])
+ if test $ac_cv_header_sys_socket_h = no; then
+ dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+ dnl the check for those headers unconditional; yet cygwin reports
+ dnl that the headers are present but cannot be compiled (since on
+ dnl cygwin, all socket information should come from sys/socket.h).
+ AC_CHECK_HEADERS([ws2tcpip.h])
+ fi
+ ])
diff --git a/m4/sockpfaf.m4 b/m4/sockpfaf.m4
index 27899aa59..c38daea5b 100644
--- a/m4/sockpfaf.m4
+++ b/m4/sockpfaf.m4
@@ -1,4 +1,4 @@
-# sockpfaf.m4 serial 7
+# sockpfaf.m4 serial 8
dnl Copyright (C) 2004, 2006, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -59,3 +59,29 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if defines AF_INET6.])
fi
])
+
+AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
+[
+ AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+ AC_CHECK_HEADERS_ONCE([sys/un.h])
+
+ AC_MSG_CHECKING([for UNIX domain sockets])
+ AC_CACHE_VAL([gl_cv_socket_unix],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include
+#ifdef HAVE_SYS_SOCKET_H
+#include
+#endif
+#ifdef HAVE_SYS_UN_H
+#include
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include
+#endif]],
+[[int x = AF_UNIX; struct sockaddr_un y;
+ if (&x && &y) return 0;]])],
+ gl_cv_socket_unix=yes, gl_cv_socket_unix=no)])
+ AC_MSG_RESULT([$gl_cv_socket_unix])
+ if test $gl_cv_socket_unix = yes; then
+ AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if defines AF_UNIX.])
+ fi
+])
diff --git a/m4/stdarg.m4 b/m4/stdarg.m4
deleted file mode 100644
index a1ef178c5..000000000
--- a/m4/stdarg.m4
+++ /dev/null
@@ -1,75 +0,0 @@
-# stdarg.m4 serial 5
-dnl Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-dnl From Bruno Haible.
-dnl Provide a working va_copy in combination with .
-
-AC_DEFUN([gl_STDARG_H],
-[
- STDARG_H=''; AC_SUBST([STDARG_H])
- NEXT_STDARG_H=''; AC_SUBST([NEXT_STDARG_H])
- AC_MSG_CHECKING([for va_copy])
- AC_CACHE_VAL([gl_cv_func_va_copy], [
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include ]],
- [[
-#ifndef va_copy
-void (*func) (va_list, va_list) = va_copy;
-#endif
- ]])],
- [gl_cv_func_va_copy=yes],
- [gl_cv_func_va_copy=no])])
- AC_MSG_RESULT([$gl_cv_func_va_copy])
- if test $gl_cv_func_va_copy = no; then
- dnl Provide a substitute.
- dnl Usually a simple definition in is enough. Not so on AIX 5
- dnl with some versions of the /usr/vac/bin/cc compiler. It has an
- dnl which does '#undef va_copy', leading to a missing va_copy symbol. For
- dnl this platform, we use an substitute. But we cannot use this
- dnl approach on other platforms, because often defines only
- dnl preprocessor macros and gl_ABSOLUTE_HEADER, gl_CHECK_NEXT_HEADERS do
- dnl not work in this situation.
- AC_EGREP_CPP([vaccine],
- [#if defined _AIX && !defined __GNUC__
- AIX vaccine
- #endif
- ], [gl_aixcc=yes], [gl_aixcc=no])
- if test $gl_aixcc = yes; then
- dnl Provide a substitute file.
- STDARG_H=stdarg.h
- gl_NEXT_HEADERS([stdarg.h])
- dnl Fallback for the case when contains only macro definitions.
- if test "$gl_cv_next_stdarg_h" = '""'; then
- gl_cv_next_stdarg_h='"///usr/include/stdarg.h"'
- NEXT_STDARG_H="$gl_cv_next_stdarg_h"
- fi
- else
- dnl Provide a substitute in , either __va_copy or as a simple
- dnl assignment.
- gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include ]],
- [[
-#ifndef __va_copy
-error, bail out
-#endif
- ]])],
- [gl_cv_func___va_copy=yes],
- [gl_cv_func___va_copy=no])])
- if test $gl_cv_func___va_copy = yes; then
- AC_DEFINE([va_copy], [__va_copy],
- [Define as a macro for copying va_list variables.])
- else
- AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed. */
-#define gl_va_copy(a,b) ((a) = (b))])
- AC_DEFINE([va_copy], [gl_va_copy],
- [Define as a macro for copying va_list variables.])
- fi
- fi
- fi
-])
diff --git a/m4/stdbool.m4 b/m4/stdbool.m4
index 838cf0f46..1ebf3e680 100644
--- a/m4/stdbool.m4
+++ b/m4/stdbool.m4
@@ -5,7 +5,7 @@ dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
-#serial 4
+#serial 5
# Prepare for substituting if it is not supported.
@@ -21,6 +21,7 @@ AC_DEFUN([AM_STDBOOL_H],
STDBOOL_H='stdbool.h'
fi
AC_SUBST([STDBOOL_H])
+ AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"])
if test "$ac_cv_type__Bool" = yes; then
HAVE__BOOL=1
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4
index 1942b6aa0..1ae234431 100644
--- a/m4/stddef_h.m4
+++ b/m4/stddef_h.m4
@@ -1,5 +1,5 @@
dnl A placeholder for POSIX 2008 , for platforms that have issues.
-# stddef_h.m4 serial 3
+# stddef_h.m4 serial 4
dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,6 +9,7 @@ AC_DEFUN([gl_STDDEF_H],
[
AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
AC_REQUIRE([gt_TYPE_WCHAR_T])
+ STDDEF_H=
if test $gt_cv_c_wchar_t = no; then
HAVE_WCHAR_T=0
STDDEF_H=stddef.h
@@ -24,6 +25,8 @@ AC_DEFUN([gl_STDDEF_H],
REPLACE_NULL=1
STDDEF_H=stddef.h
fi
+ AC_SUBST([STDDEF_H])
+ AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"])
if test -n "$STDDEF_H"; then
gl_NEXT_HEADERS([stddef.h])
fi
@@ -41,5 +44,4 @@ AC_DEFUN([gl_STDDEF_H_DEFAULTS],
dnl Assume proper GNU behavior unless another module says otherwise.
REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
- STDDEF_H=''; AC_SUBST([STDDEF_H])
])
diff --git a/m4/stdint.m4 b/m4/stdint.m4
index e7d0d0765..dff37fe1b 100644
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 39
+# stdint.m4 serial 40
dnl Copyright (C) 2001-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -305,6 +305,7 @@ static const char *macro_values[] =
STDINT_H=stdint.h
fi
AC_SUBST([STDINT_H])
+ AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"])
])
dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index 7f3ae5629..8b013c2f3 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 33
+# stdio_h.m4 serial 36
dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,6 +9,32 @@ AC_DEFUN([gl_STDIO_H],
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
AC_REQUIRE([AC_C_INLINE])
gl_NEXT_HEADERS([stdio.h])
+
+ dnl No need to create extra modules for these functions. Everyone who uses
+ dnl likely needs them.
+ GNULIB_FSCANF=1
+ GNULIB_SCANF=1
+ GNULIB_VFSCANF=1
+ GNULIB_VSCANF=1
+ GNULIB_FGETC=1
+ GNULIB_GETC=1
+ GNULIB_GETCHAR=1
+ GNULIB_FGETS=1
+ GNULIB_GETS=1
+ GNULIB_FREAD=1
+ dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c"
+ dnl "expected source file, required through AC_LIBSOURCES, not found". It is
+ dnl also an optimization, to avoid performing a configure check whose result
+ dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
+ dnl or GNULIB_NONBLOCKING redundant.
+ m4_ifdef([gl_NONBLOCKING_IO], [
+ gl_NONBLOCKING_IO
+ if test $gl_cv_have_nonblocking != yes; then
+ REPLACE_STDIO_READ_FUNCS=1
+ AC_LIBOBJ([stdio-read])
+ fi
+ ])
+
dnl No need to create extra modules for these functions. Everyone who uses
dnl likely needs them.
GNULIB_FPRINTF=1
@@ -21,9 +47,11 @@ AC_DEFUN([gl_STDIO_H],
GNULIB_FPUTS=1
GNULIB_PUTS=1
GNULIB_FWRITE=1
- dnl This ifdef is just an optimization, to avoid performing a configure
- dnl check whose result is not used. It does not make the test of
- dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant.
+ dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
+ dnl "expected source file, required through AC_LIBSOURCES, not found". It is
+ dnl also an optimization, to avoid performing a configure check whose result
+ dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
+ dnl GNULIB_SIGPIPE redundant.
m4_ifdef([gl_SIGNAL_SIGPIPE], [
gl_SIGNAL_SIGPIPE
if test $gl_cv_header_signal_h_SIGPIPE != yes; then
@@ -31,6 +59,18 @@ AC_DEFUN([gl_STDIO_H],
AC_LIBOBJ([stdio-write])
fi
])
+ dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
+ dnl "expected source file, required through AC_LIBSOURCES, not found". It is
+ dnl also an optimization, to avoid performing a configure check whose result
+ dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
+ dnl or GNULIB_NONBLOCKING redundant.
+ m4_ifdef([gl_NONBLOCKING_IO], [
+ gl_NONBLOCKING_IO
+ if test $gl_cv_have_nonblocking != yes; then
+ REPLACE_STDIO_WRITE_FUNCS=1
+ AC_LIBOBJ([stdio-write])
+ fi
+ ])
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use, and which is not
@@ -54,20 +94,27 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF])
GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE])
GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH])
+ GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC])
+ GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS])
GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF])
GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX])
GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE])
GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC])
GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS])
+ GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD])
GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
+ GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF])
GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO])
GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE])
+ GNULIB_GETC=0; AC_SUBST([GNULIB_GETC])
+ GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR])
GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM])
GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE])
+ GNULIB_GETS=0; AC_SUBST([GNULIB_GETS])
GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR])
@@ -80,11 +127,15 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE])
GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME])
GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT])
+ GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF])
GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
+ GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING])
GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE])
GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
+ GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF])
+ GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF])
GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF])
GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
@@ -129,6 +180,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
REPLACE_RENAMEAT=0; AC_SUBST([REPLACE_RENAMEAT])
REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
+ REPLACE_STDIO_READ_FUNCS=0; AC_SUBST([REPLACE_STDIO_READ_FUNCS])
REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE])
REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
diff --git a/m4/strcase.m4 b/m4/strcase.m4
deleted file mode 100644
index 1c553ff21..000000000
--- a/m4/strcase.m4
+++ /dev/null
@@ -1,44 +0,0 @@
-# strcase.m4 serial 10
-dnl Copyright (C) 2002, 2005-2011 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_STRCASE],
-[
- gl_FUNC_STRCASECMP
- gl_FUNC_STRNCASECMP
-])
-
-AC_DEFUN([gl_FUNC_STRCASECMP],
-[
- AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
- AC_REPLACE_FUNCS([strcasecmp])
- if test $ac_cv_func_strcasecmp = no; then
- HAVE_STRCASECMP=0
- gl_PREREQ_STRCASECMP
- fi
-])
-
-AC_DEFUN([gl_FUNC_STRNCASECMP],
-[
- AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
- AC_REPLACE_FUNCS([strncasecmp])
- if test $ac_cv_func_strncasecmp = no; then
- gl_PREREQ_STRNCASECMP
- fi
- AC_CHECK_DECLS([strncasecmp])
- if test $ac_cv_have_decl_strncasecmp = no; then
- HAVE_DECL_STRNCASECMP=0
- fi
-])
-
-# Prerequisites of lib/strcasecmp.c.
-AC_DEFUN([gl_PREREQ_STRCASECMP], [
- :
-])
-
-# Prerequisites of lib/strncasecmp.c.
-AC_DEFUN([gl_PREREQ_STRNCASECMP], [
- :
-])
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index 30ddfbc3a..df8c40353 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -5,7 +5,7 @@
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# serial 19
+# serial 20
# Written by Paul Eggert.
@@ -104,6 +104,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
+ REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
diff --git a/m4/strings_h.m4 b/m4/strings_h.m4
deleted file mode 100644
index 71d284b63..000000000
--- a/m4/strings_h.m4
+++ /dev/null
@@ -1,39 +0,0 @@
-# Configure a replacement for .
-# serial 3
-
-# Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_HEADER_STRINGS_H],
-[
- dnl Use AC_REQUIRE here, so that the default behavior below is expanded
- dnl once only, before all statements that occur in other macros.
- AC_REQUIRE([gl_HEADER_STRINGS_H_BODY])
-])
-
-AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
-[
- AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
- gl_CHECK_NEXT_HEADERS([strings.h])
-
- dnl Check for declarations of anything we want to poison if the
- dnl corresponding gnulib module is not in use.
- gl_WARN_ON_USE_PREPARE([[#include
- ]], [strcasecmp strncasecmp])
-])
-
-AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
-[
- dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
- AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
- gl_MODULE_INDICATOR_SET_VARIABLE([$1])
-])
-
-AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS],
-[
- dnl Assume proper GNU behavior unless another module says otherwise.
- HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP])
- HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP])
-])
diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4
index 12dc05d42..7da91a4a3 100644
--- a/m4/sys_socket_h.m4
+++ b/m4/sys_socket_h.m4
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 21
+# sys_socket_h.m4 serial 22
dnl Copyright (C) 2005-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -101,17 +101,13 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
[
dnl Check prerequisites of the replacement.
+ AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])
gl_CHECK_NEXT_HEADERS([sys/socket.h])
if test $ac_cv_header_sys_socket_h = yes; then
HAVE_SYS_SOCKET_H=1
HAVE_WS2TCPIP_H=0
else
HAVE_SYS_SOCKET_H=0
- dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
- dnl the check for those headers unconditional; yet cygwin reports
- dnl that the headers are present but cannot be compiled (since on
- dnl cygwin, all socket information should come from sys/socket.h).
- AC_CHECK_HEADERS([ws2tcpip.h])
if test $ac_cv_header_ws2tcpip_h = yes; then
HAVE_WS2TCPIP_H=1
else
diff --git a/m4/sys_uio_h.m4 b/m4/sys_uio_h.m4
new file mode 100644
index 000000000..bafa0ac45
--- /dev/null
+++ b/m4/sys_uio_h.m4
@@ -0,0 +1,31 @@
+# sys_uio_h.m4 serial 1
+dnl Copyright (C) 2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_HEADER_SYS_UIO],
+[
+ AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
+ dnl is always overridden, because of GNULIB_POSIXCHECK.
+ gl_CHECK_NEXT_HEADERS([sys/uio.h])
+ if test $ac_cv_header_sys_uio_h = yes; then
+ HAVE_SYS_UIO_H=1
+ else
+ HAVE_SYS_UIO_H=0
+ fi
+ AC_SUBST([HAVE_SYS_UIO_H])
+])
+
+AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
+ gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+ dnl Define it also as a C macro, for the benefit of the unit tests.
+ gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_SYS_UIO_H_DEFAULTS],
+[
+])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index c81a1138e..eeb3360b0 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 53
+# unistd_h.m4 serial 55
dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -52,47 +52,49 @@ AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
AC_DEFUN([gl_UNISTD_H_DEFAULTS],
[
- GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
- GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE])
- GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
- GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3])
- GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
- GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS])
- GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT])
- GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
- GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT])
- GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC])
- GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
- GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
- GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
- GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
- GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS])
- GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
- GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN])
- GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
- GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
- GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
- GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
- GNULIB_LINK=0; AC_SUBST([GNULIB_LINK])
- GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
- GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
- GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE])
- GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
- GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
- GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE])
- GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
- GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
- GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
- GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
- GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK])
- GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
- GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R])
- GNULIB_UNISTD_H_GETOPT=0; AC_SUBST([GNULIB_UNISTD_H_GETOPT])
- GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
- GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK])
- GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
- GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP])
- GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
+ GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
+ GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE])
+ GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
+ GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3])
+ GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
+ GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS])
+ GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT])
+ GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
+ GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT])
+ GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC])
+ GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
+ GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
+ GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
+ GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
+ GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS])
+ GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
+ GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN])
+ GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
+ GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
+ GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
+ GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
+ GNULIB_LINK=0; AC_SUBST([GNULIB_LINK])
+ GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
+ GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
+ GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE])
+ GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
+ GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
+ GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE])
+ GNULIB_READ=0; AC_SUBST([GNULIB_READ])
+ GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
+ GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
+ GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
+ GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
+ GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK])
+ GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
+ GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R])
+ GNULIB_UNISTD_H_GETOPT=0; AC_SUBST([GNULIB_UNISTD_H_GETOPT])
+ GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
+ GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
+ GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK])
+ GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
+ GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP])
+ GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN])
HAVE_DUP2=1; AC_SUBST([HAVE_DUP2])
@@ -147,6 +149,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
+ REPLACE_READ=0; AC_SUBST([REPLACE_READ])
REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
diff --git a/m4/version-etc.m4 b/m4/version-etc.m4
deleted file mode 100644
index 5032bf855..000000000
--- a/m4/version-etc.m4
+++ /dev/null
@@ -1,33 +0,0 @@
-# version-etc.m4 serial 1
-# Copyright (C) 2009-2011 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-dnl $1 - configure flag and define name
-dnl $2 - human readable description
-m4_define([gl_VERSION_ETC_FLAG],
-[dnl
- AC_ARG_WITH([$1], [AS_HELP_STRING([--with-$1], [$2])],
- [dnl
- case $withval in
- yes|no) ;;
- *) AC_DEFINE_UNQUOTED(AS_TR_CPP([PACKAGE_$1]), ["$withval"], [$2]) ;;
- esac
- ])
-])
-
-AC_DEFUN([gl_VERSION_ETC],
-[dnl
- gl_VERSION_ETC_FLAG([packager],
- [String identifying the packager of this software])
- gl_VERSION_ETC_FLAG([packager-version],
- [Packager-specific version information])
- gl_VERSION_ETC_FLAG([packager-bug-reports],
- [Packager info for bug reports (URL/e-mail/...)])
- if test "X$with_packager" = "X" && \
- test "X$with_packager_version$with_packager_bug_reports" != "X"
- then
- AC_MSG_ERROR([The --with-packager-{bug-reports,version} options require --with-packager])
- fi
-])
diff --git a/m4/write.m4 b/m4/write.m4
index 8695c8962..63ab5e4c0 100644
--- a/m4/write.m4
+++ b/m4/write.m4
@@ -1,4 +1,4 @@
-# write.m4 serial 1
+# write.m4 serial 2
dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,15 @@ AC_DEFUN([gl_FUNC_WRITE],
gl_SIGNAL_SIGPIPE
if test $gl_cv_header_signal_h_SIGPIPE != yes; then
REPLACE_WRITE=1
- AC_LIBOBJ([write])
fi
])
+ m4_ifdef([gl_NONBLOCKING_IO], [
+ gl_NONBLOCKING_IO
+ if test $gl_cv_have_nonblocking != yes; then
+ REPLACE_WRITE=1
+ fi
+ ])
+ if test $REPLACE_WRITE = 1; then
+ AC_LIBOBJ([write])
+ fi
])
diff --git a/maint.mk b/maint.mk
index 90c22cfed..47cb44ee2 100644
--- a/maint.mk
+++ b/maint.mk
@@ -33,7 +33,7 @@ GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
GIT = git
VC = $(GIT)
-VC-tag = git tag -s -m '$(VERSION)' -u '$(gpg_key_ID)'
+VC-tag = git tag -s -m '$(VERSION)' 'v$(VERSION)' -u '$(gpg_key_ID)'
VC_LIST = $(build_aux)/vc-list-files -C $(srcdir)
@@ -57,11 +57,13 @@ endif
# In order to be able to consistently filter "."-relative names,
# (i.e., with no $(srcdir) prefix), this definition is careful to
# remove any $(srcdir) prefix, and to restore what it removes.
+_sc_excl = \
+ $(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
VC_LIST_EXCEPT = \
$(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
- | grep -Ev -e '$(VC_LIST_ALWAYS_EXCLUDE_REGEX)' \
+ | grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
$(_prepend_srcdir_prefix)
ifeq ($(origin prev_version_file), undefined)
@@ -196,6 +198,16 @@ syntax-check: $(local-check)
# halt
#
# Message to display before to halting execution.
+#
+# Finally, you may exempt files based on an ERE matching file names.
+# For example, to exempt from the sc_space_tab check all files with the
+# .diff suffix, set this Make variable:
+#
+# exclude_file_name_regexp--sc_space_tab = \.diff$
+#
+# Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
+# when filtering by name via in_files, we explicitly filter out matching
+# names here as well.
# By default, _sc_search_regexp does not ignore case.
export ignore_case =
@@ -233,7 +245,8 @@ define _sc_search_regexp
\
: Filter by file name; \
if test -n "$$in_files"; then \
- files=$$(find $(srcdir) | grep -E "$$in_files"); \
+ files=$$(find $(srcdir) | grep -E "$$in_files" \
+ | grep -Ev '$(exclude_file_name_regexp--$@)'); \
else \
files=$$($(VC_LIST_EXCEPT)); \
if test -n "$$in_vc_files"; then \
@@ -659,7 +672,7 @@ sc_two_space_separator_in_usage:
sc_unmarked_diagnostics:
@grep -nE \
'\&2; \
exit 1; } || :
@@ -810,8 +823,8 @@ require_exactly_one_NL_at_EOF_ = \
END { exit defined $$fail }
sc_prohibit_empty_lines_at_EOF:
@perl -le '$(require_exactly_one_NL_at_EOF_)' $$($(VC_LIST_EXCEPT)) \
- || { echo '$(ME): empty line(s) or no newline at EOF' \
- 1>&2; exit 1; } || :; \
+ || { echo '$(ME): empty line(s) or no newline at EOF' \
+ 1>&2; exit 1; } || :
# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
# This is a bit of a kludge, since it prevents use of the string
@@ -828,6 +841,31 @@ sc_prohibit_S_IS_definition:
halt='do not define S_IS* macros; include ' \
$(_sc_search_regexp)
+prohibit_doubled_word_RE_ ?= \
+ /\b(then?|[iao]n|i[fst]|but|f?or|at|and|[dt]o)\s+\1\b/gims
+prohibit_doubled_word_ = \
+ -e 'while ($(prohibit_doubled_word_RE_))' \
+ -e ' {' \
+ -e ' $$n = ($$` =~ tr/\n/\n/ + 1);' \
+ -e ' ($$v = $$&) =~ s/\n/\\n/g;' \
+ -e ' print "$$ARGV:$$n:$$v\n";' \
+ -e ' }'
+
+# Define this to a regular expression that matches
+# any filename:dd:match lines you want to ignore.
+# The default is to ignore no matches.
+ignore_doubled_word_match_RE_ ?= ^$$
+
+sc_prohibit_doubled_word:
+ @perl -n -0777 $(prohibit_doubled_word_) $$($(VC_LIST_EXCEPT)) \
+ | grep -vE '$(ignore_doubled_word_match_RE_)' \
+ | grep . && { echo '$(ME): doubled words' 1>&2; exit 1; } || :
+
+sc_prohibit_can_not:
+ @prohibit='\' \
+ halt='use "cannot", not "can'' not"' \
+ $(_sc_search_regexp)
+
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
_ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
# Using test's -a and -o operators is not portable.
@@ -904,16 +942,23 @@ update-NEWS-hash: NEWS
# Ensure that we use only the standard $(VAR) notation,
# not @...@ in Makefile.am, now that we can rely on automake
# to emit a definition for each substituted variable.
-# We use perl rather than "grep -nE ..." to exempt a single
-# use of an @...@-delimited variable name in src/Makefile.am.
+# However, there is still one case in which @VAR@ use is not just
+# legitimate, but actually required: when augmenting an automake-defined
+# variable with a prefix. For example, gettext uses this:
+# MAKEINFO = env LANG= LC_MESSAGES= LC_ALL= LANGUAGE= @MAKEINFO@
+# otherwise, makeinfo would put German or French (current locale)
+# navigation hints in the otherwise-English documentation.
+#
# Allow the package to add exceptions via a hook in cfg.mk;
# for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by
# setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
_makefile_at_at_check_exceptions ?=
sc_makefile_at_at_check:
- @perl -ne '/\@[A-Z_0-9]+\@/'$(_makefile_at_at_check_exceptions) \
+ @perl -ne '/\@[A-Z_0-9]+\@/' \
+ -e ' && !/([A-Z_0-9]+)\s+=.*\@\1\@$$/' \
+ -e ''$(_makefile_at_at_check_exceptions) \
-e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
- $$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \
+ $$($(VC_LIST_EXCEPT) | grep -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
news-check: NEWS
@@ -942,13 +987,13 @@ fix_po_file_diag = \
apply the above patch\n'
# Verify that all source files using _() are listed in po/POTFILES.in.
-po_file = po/POTFILES.in
+po_file ?= $(srcdir)/po/POTFILES.in
sc_po_check:
@if test -f $(po_file); then \
grep -E -v '^(#|$$)' $(po_file) \
| grep -v '^src/false\.c$$' | sort > $@-1; \
files=; \
- for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \
+ for file in $$($(VC_LIST_EXCEPT)) $(srcdir)/lib/*.[ch]; do \
test -r $$file || continue; \
case $$file in \
*.m4|*.mk) continue ;; \
@@ -963,7 +1008,7 @@ sc_po_check:
files="$$files $$file"; \
done; \
grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
- | sort -u > $@-2; \
+ | sed 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2; \
diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
|| { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
rm -f $@-1 $@-2; \
From 7c86abd9ce9671c82a06d373ec8d1b847ec8d0bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Mon, 25 Apr 2011 23:59:12 +0200
Subject: [PATCH 35/48] Use `scm_with_guile' in `test-pthread-create'.
* test-suite/standalone/test-pthread-create.c (inner_main): New
function.
(main): Call it within `scm_with_guile', instead of using
`scm_init_guile'. This improves portability--e.g.,
`GC_get_stack_base', used by `scm_init_guile', failed on Darwin
up to BDW-GC 7.1alpha4 included (thanks, Mark, for the hint.)
---
test-suite/standalone/test-pthread-create.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/test-suite/standalone/test-pthread-create.c b/test-suite/standalone/test-pthread-create.c
index 8d9617b58..cf3771f07 100644
--- a/test-suite/standalone/test-pthread-create.c
+++ b/test-suite/standalone/test-pthread-create.c
@@ -42,15 +42,12 @@ thread (void *arg)
return NULL;
}
-
-int
-main (int argc, char *argv[])
+static void *
+inner_main (void *data)
{
int i;
pthread_t thr;
- scm_init_guile ();
-
do_something (NULL);
for (i = 0; i < 77; i++)
@@ -59,5 +56,14 @@ main (int argc, char *argv[])
pthread_join (thr, NULL);
}
+ return NULL;
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ scm_with_guile (inner_main, NULL);
+
return EXIT_SUCCESS;
}
From fb9cfa83a7fae2ba5afdb4d0666446f44593f1fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Tue, 26 Apr 2011 00:03:44 +0200
Subject: [PATCH 36/48] Remove the `sizeof (mpz_t)' check.
* libguile/numbers.c: Remove `sizeof (mpz_t)' check, which wasn't need
anymore since `make_bignum' doesn't make any such assumption.
---
libguile/numbers.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 742f4d1fe..fe510a195 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -70,9 +70,6 @@
#include "libguile/eq.h"
-/* GMP's `mpz_t' must fit into a double cell. */
-verify (sizeof (mpz_t) <= (2 * sizeof (scm_t_bits)));
-
/* values per glibc, if not already defined */
#ifndef M_LOG10E
#define M_LOG10E 0.43429448190325182765
From 94b55d3fa046523e13de9df1c2fb39280f4842e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 00:57:16 +0200
Subject: [PATCH 37/48] Gracefully handle `setlocale' errors at the REPL.
* module/ice-9/top-repl.scm (top-repl): Catch exceptions from
`setlocale'. Reported by CRLF0710 .
---
module/ice-9/top-repl.scm | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/module/ice-9/top-repl.scm b/module/ice-9/top-repl.scm
index 64c023997..d43436c4a 100644
--- a/module/ice-9/top-repl.scm
+++ b/module/ice-9/top-repl.scm
@@ -65,7 +65,14 @@
(call-with-sigint
(lambda ()
(and (defined? 'setlocale)
- (setlocale LC_ALL ""))
+ (catch 'system-error
+ (lambda ()
+ (setlocale LC_ALL ""))
+ (lambda (key subr fmt args errno)
+ (format (current-error-port)
+ "warning: failed to install locale: ~a~%"
+ (strerror (car errno))))))
+
(let ((status (start-repl 'scheme)))
(run-hook exit-hook)
status)))))
From 9a201881e67780f08fd398538100d4cdb4095321 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 16:28:29 +0200
Subject: [PATCH 38/48] Rewrite port decoding error tests using a mini DSL.
* test-suite/tests/ports.test ("string ports")[test-decoding-error]: New
macro.
["read-char, wrong encoding, error", "read-char, wrong encoding,
escape", "read-char, wrong encoding, substitute", "peek-char, wrong
encoding, error"]: Rewrite using `test-decoding-error'.
---
test-suite/tests/ports.test | 139 ++++++++++++++++++------------------
1 file changed, 71 insertions(+), 68 deletions(-)
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index 9d3000cc1..1f0e9b0cf 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -462,80 +462,79 @@
(= (port-line p) 0)
(= (port-column p) 0))))
- (pass-if "read-char, wrong encoding, error"
- (let ((p (open-bytevector-input-port #vu8(255 65 66 67))))
- (catch 'decoding-error
- (lambda ()
- (set-port-encoding! p "UTF-8")
- (set-port-conversion-strategy! p 'error)
- (read-char p)
- #f)
- (lambda (key subr message err port)
- (and (eq? port p)
+ ;; Mini DSL to test decoding error handling.
+ (letrec-syntax ((decoding-error?
+ (syntax-rules ()
+ ((_ port exp)
+ (catch 'decoding-error
+ (lambda ()
+ (pk 'exp exp)
+ #f)
+ (lambda (key subr message errno p)
+ (and (eq? p port)
+ (not (= 0 errno))))))))
+ (make-check
+ (syntax-rules (-> error eof)
+ ((_ port (proc -> error))
+ (decoding-error? port (proc port)))
+ ((_ port (proc -> eof))
+ (eof-object? (proc port)))
+ ((_ port (proc -> char))
+ (eq? (proc port) char))))
+ (make-checks
+ (syntax-rules ()
+ ((_ port check ...)
+ (and (make-check port check) ...))))
+ (test-decoding-error
+ (syntax-rules (tests)
+ ((_ sequence encoding strategy (tests checks ...))
+ (pass-if (format #f "test-decoding-error: ~s ~s ~s ~s"
+ (caar '(checks ...))
+ 'sequence encoding strategy)
+ (let ((p (open-bytevector-input-port
+ (u8-list->bytevector 'sequence))))
+ (set-port-encoding! p encoding)
+ (set-port-conversion-strategy! p strategy)
+ (make-checks p checks ...)))))))
- ;; PORT should point past the error.
- (equal? '(#\A #\B #\C)
- (list (read-char port)
- (read-char port)
- (read-char port)))
+ (test-decoding-error (255 65 66 67) "UTF-8" 'error
+ (tests
+ (read-char -> error)
+ (read-char -> #\A)
+ (read-char -> #\B)
+ (read-char -> #\C)
+ (read-char -> eof)))
- (eof-object? (read-char port)))))))
+ (test-decoding-error (255 65 66 67) "UTF-8" 'escape
+ ;; `escape' should behave exactly like `error'.
+ (tests
+ (read-char -> error)
+ (read-char -> #\A)
+ (read-char -> #\B)
+ (read-char -> #\C)
+ (read-char -> eof)))
- (pass-if "read-char, wrong encoding, escape"
- ;; `escape' should behave exactly like `error'.
- (let ((p (open-bytevector-input-port #vu8(255 65 66 67))))
- (catch 'decoding-error
- (lambda ()
- (set-port-encoding! p "UTF-8")
- (set-port-conversion-strategy! p 'escape)
- (read-char p)
- #f)
- (lambda (key subr message err port)
- (and (eq? port p)
+ (test-decoding-error (255 206 187 206 188) "UTF-8" 'substitute
+ (tests
+ (read-char -> #\?)
+ (read-char -> #\λ)
+ (read-char -> #\μ)
+ (read-char -> eof)))
- ;; PORT should point past the error.
- (equal? '(#\A #\B #\C)
- (list (read-char port)
- (read-char port)
- (read-char port)))
+ (test-decoding-error (255 65 66 67) "UTF-8" 'error
+ (tests
+ ;; `peek-char' should repeatedly raise an error.
+ (peek-char -> error)
+ (peek-char -> error)
+ (peek-char -> error)
- (eof-object? (read-char port)))))))
+ ;; Move past the error.
+ (read-char -> error)
- (pass-if "read-char, wrong encoding, substitute"
- (let ((p (open-bytevector-input-port #vu8(255 206 187 206 188))))
- (set-port-encoding! p "UTF-8")
- (set-port-conversion-strategy! p 'substitute)
- (equal? (list (read-char p) (read-char p) (read-char p))
- '(#\? #\λ #\μ))))
-
- (pass-if "peek-char, wrong encoding, error"
- (let-syntax ((decoding-error?
- (syntax-rules ()
- ((_ port exp)
- (catch 'decoding-error
- (lambda ()
- (pk 'exp exp)
- #f)
- (lambda (key subr message errno p)
- (eq? p port)))))))
- (let ((p (open-bytevector-input-port #vu8(255 65 66 67))))
- (set-port-encoding! p "UTF-8")
- (set-port-conversion-strategy! p 'error)
-
- ;; `peek-char' should repeatedly raise an error.
- (and (decoding-error? p (peek-char p))
- (decoding-error? p (peek-char p))
- (decoding-error? p (peek-char p))
-
- ;; Move past the error.
- (decoding-error? p (read-char p))
-
- ;; Finish happily.
- (equal? '(#\A #\B #\C)
- (list (read-char p)
- (read-char p)
- (read-char p)))
- (eof-object? (read-char p)))))))
+ (read-char -> #\A)
+ (read-char -> #\B)
+ (read-char -> #\C)
+ (read-char -> eof)))))
(with-test-prefix "call-with-output-string"
@@ -994,3 +993,7 @@
'("read" "read-char" "read-line")))
(delete-file (test-file))
+
+;;; Local Variables:
+;;; eval: (put 'test-decoding-error 'scheme-indent-function 3)
+;;; End:
From d84783a80c186b0b13e3aeb206384bb198bf41e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 16:26:26 +0200
Subject: [PATCH 39/48] Add a couple more Unicode I/O tests.
* test-suite/tests/ports.test ("string ports")["%default-port-encoding
is honored"]: Make sure `(port-encoding p)' is as expected.
["peek-char [utf-16]"]: New test.
---
test-suite/tests/ports.test | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index 1f0e9b0cf..c9337248a 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -391,7 +391,8 @@
(with-fluids ((%default-port-encoding e))
(call-with-output-string
(lambda (p)
- (display (port-encoding p) p)))))
+ (and (string=? e (port-encoding p))
+ (display (port-encoding p) p))))))
encodings)
encodings)))
@@ -462,6 +463,15 @@
(= (port-line p) 0)
(= (port-column p) 0))))
+ (pass-if "peek-char [utf-16]"
+ (let ((p (with-fluids ((%default-port-encoding "UTF-16BE"))
+ (open-input-string "안녕하세요"))))
+ (and (char=? (peek-char p) #\안)
+ (char=? (peek-char p) #\안)
+ (char=? (peek-char p) #\안)
+ (= (port-line p) 0)
+ (= (port-column p) 0))))
+
;; Mini DSL to test decoding error handling.
(letrec-syntax ((decoding-error?
(syntax-rules ()
From a42d79711b2366861cf4e6fa884eae709617121d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 20:34:08 +0200
Subject: [PATCH 40/48] Gracefully handle unterminated UTF-8 sequences instead
of hitting an `assert'.
* libguile/ports.c (get_codepoint): Return EILSEQ when OUTPUT_SIZE == 0.
* test-suite/tests/ports.test ("string ports"): Add 2 tests for
unterminated sequences.
---
libguile/ports.c | 14 +++++++++-----
test-suite/tests/ports.test | 14 ++++++++++++++
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/libguile/ports.c b/libguile/ports.c
index 6e0ae6c8b..b5ad95ec7 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -1174,6 +1174,10 @@ get_codepoint (SCM port, scm_t_wchar *codepoint,
output_size = sizeof (utf8_buf) - output_left;
}
+ if (SCM_UNLIKELY (output_size == 0))
+ /* An unterminated sequence. */
+ err = EILSEQ;
+
if (SCM_UNLIKELY (err != 0))
{
/* Reset the `iconv' state. */
@@ -1190,11 +1194,11 @@ get_codepoint (SCM port, scm_t_wchar *codepoint,
input encoding errors.) */
}
else
- /* Convert the UTF8_BUF sequence to a Unicode code point. */
- *codepoint = utf8_to_codepoint (utf8_buf, output_size);
-
- if (SCM_LIKELY (err == 0))
- update_port_lf (*codepoint, port);
+ {
+ /* Convert the UTF8_BUF sequence to a Unicode code point. */
+ *codepoint = utf8_to_codepoint (utf8_buf, output_size);
+ update_port_lf (*codepoint, port);
+ }
*len = bytes_consumed;
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index c9337248a..d4924fe01 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -531,6 +531,20 @@
(read-char -> #\μ)
(read-char -> eof)))
+ (test-decoding-error (206 187 206) "UTF-8" 'error
+ ;; Unterminated sequence.
+ (tests
+ (read-char -> #\λ)
+ (read-char -> error)
+ (read-char -> eof)))
+
+ (test-decoding-error (206 187 206) "UTF-8" 'substitute
+ ;; Unterminated sequence.
+ (tests
+ (read-char -> #\λ)
+ (read-char -> #\?)
+ (read-char -> eof)))
+
(test-decoding-error (255 65 66 67) "UTF-8" 'error
(tests
;; `peek-char' should repeatedly raise an error.
From 4cadf64f9af320e897240f4287fae91d211ef008 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 21:55:42 +0200
Subject: [PATCH 41/48] Add tests for UTF-8 ill-formed sequence handling.
* test-suite/tests/ports.test ("string ports"): Add for
`test-decoding-error' tests for ill-formed UTF-8 sequences. Thanks
to Mark H Weaver for pointing this out.
---
test-suite/tests/ports.test | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index d4924fe01..69e028f36 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -558,6 +558,33 @@
(read-char -> #\A)
(read-char -> #\B)
(read-char -> #\C)
+ (read-char -> eof)))
+
+ ;; Check how ill-formed UTF-8 sequences are handled (see Table 3-7
+ ;; of the "Conformance" chapter of Unicode 6.0.0.)
+
+ (test-decoding-error (#xc0 #x80 #x41) "UTF-8" 'error
+ (tests
+ (read-char -> error) ;; C0: should be in the C2..DF range
+ (read-char -> error) ;; 80: invalid
+ (read-char -> #\A)
+ (read-char -> eof)))
+
+ (test-decoding-error (#xc0 #x80 #x41) "UTF-8" 'error
+ (tests
+ (read-char -> error) ;; C0: should be in the C2..DF range
+ (read-char -> error) ;; 80: invalid
+ (read-char -> #\A)
+ (read-char -> eof)))
+
+ (test-decoding-error (#xe0 #x88 #x88) "UTF-8" 'error
+ (tests
+ (read-char -> error) ;; 2nd byte should be in the A0..BF range
+ (read-char -> eof)))
+
+ (test-decoding-error (#xf0 #x88 #x88 #x88) "UTF-8" 'error
+ (tests
+ (read-char -> error) ;; 2nd byte should be in the 90..BF range
(read-char -> eof)))))
(with-test-prefix "call-with-output-string"
From de424d959442e6be066fb8fa048253a4e5b2bb45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 22:14:31 +0200
Subject: [PATCH 42/48] Document `(ice-9 binary-ports)'.
* doc/ref/api-io.texi (R6RS I/O Ports): Mention `(ice-9 binary-ports)'.
* NEWS: Update.
---
NEWS | 1 +
doc/ref/api-io.texi | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/NEWS b/NEWS
index 4f0c22040..121cfd9b5 100644
--- a/NEWS
+++ b/NEWS
@@ -148,6 +148,7 @@ The humble `error' SRFI now has an entry in the manual.
* New modules
** `(ice-9 binary-ports)': XXX, in the manual
+** `(ice-9 binary-ports)': "R6RS I/O Ports", in the manual
** `(ice-9 eval-string)': "Fly Evaluation", in the manual
* Bugs fixed
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index 4786d79a4..e7e91edae 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -1164,6 +1164,10 @@ presented above (@pxref{Input and Output}).
* R6RS Binary Output:: Binary output.
@end menu
+A subset of the @code{(rnrs io ports)} module is provided by the
+@code{(ice-9 binary-ports)} module. It contains binary input/output
+procedures and does not rely on R6RS support.
+
@node R6RS End-of-File
@subsubsection The End-of-File Object
From 756b1dfa6e96684e839077d7f800ca227b88c33a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 22:26:05 +0200
Subject: [PATCH 43/48] Keep a 2.0.0-compatible `define-inlinable' macro in
(srfi srfi-9).
Partially reverts 165b10ddfaaa8ecc72d45a9be7d29e7537dc2379 and
531c9f1dc51c4801c4d031ee80a31f15285a6b85.
* module/srfi/srfi-9.scm (define-inlinable): New macro.
---
module/srfi/srfi-9.scm | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/module/srfi/srfi-9.scm b/module/srfi/srfi-9.scm
index ad9e95de1..6574a8da7 100644
--- a/module/srfi/srfi-9.scm
+++ b/module/srfi/srfi-9.scm
@@ -64,6 +64,37 @@
(cond-expand-provide (current-module) '(srfi-9))
+;; Roll our own instead of using the public `define-inlinable'. This is
+;; because the public one has a different `make-procedure-name', so
+;; using it would require users to recompile code that uses SRFI-9. See
+;; .
+
+(define-syntax define-inlinable
+ (lambda (x)
+ (define (make-procedure-name name)
+ (datum->syntax name
+ (symbol-append '% (syntax->datum name)
+ '-procedure)))
+
+ (syntax-case x ()
+ ((_ (name formals ...) body ...)
+ (identifier? #'name)
+ (with-syntax ((proc-name (make-procedure-name #'name))
+ ((args ...) (generate-temporaries #'(formals ...))))
+ #`(begin
+ (define (proc-name formals ...)
+ body ...)
+ (define-syntax name
+ (lambda (x)
+ (syntax-case x ()
+ ((_ args ...)
+ #'((lambda (formals ...)
+ body ...)
+ args ...))
+ (_
+ (identifier? x)
+ #'proc-name))))))))))
+
(define-syntax define-record-type
(lambda (x)
(define (field-identifiers field-specs)
From 2e6829d24d39bc3aad7f41a95e2ada4799a0e6c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 22:30:20 +0200
Subject: [PATCH 44/48] Update `NEWS'.
---
NEWS | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 121cfd9b5..cfbc65a3c 100644
--- a/NEWS
+++ b/NEWS
@@ -90,7 +90,7 @@ Guile 2.0.0 shipped with headers that, if configured with pthread
support, would re-define `pthread_create', `pthread_join', and other API
to redirect to the BDW-GC wrappers, `GC_pthread_create', etc. This was
unintended, and not necessary: because threads must enter Guile with
-scm_with_guile, Guile can handle thread registration itself, without
+`scm_with_guile', Guile can handle thread registration itself, without
needing to make the GC aware of all threads. This oversight has been
fixed.
@@ -147,13 +147,13 @@ The humble `error' SRFI now has an entry in the manual.
* New modules
-** `(ice-9 binary-ports)': XXX, in the manual
** `(ice-9 binary-ports)': "R6RS I/O Ports", in the manual
** `(ice-9 eval-string)': "Fly Evaluation", in the manual
+** `(ice-9 command-line)', not documented yet
* Bugs fixed
-** Fixed iconv_t memory leak on close-port
+** Fixed `iconv_t' memory leak on close-port
** Fixed some leaks with weak hash tables
** Export `vhash-delq' and `vhash-delv' from `(ice-9 vlist)'
** `after-gc-hook' works again
@@ -199,6 +199,10 @@ The humble `error' SRFI now has an entry in the manual.
** Fix optional second arg to R6RS log function
** Fix R6RS `assert' to return true value.
** Fix fencepost error when seeking in bytevector input ports
+** Gracefully handle `setlocale' errors when starting the REPL
+** Improve support of the `--disable-posix' configure option
+** Make sure R6RS binary ports pass `binary-port?' regardless of the locale
+** Gracefully handle unterminated UTF-8 sequences instead of hitting an `assert'
From 1aad6647393f3adfa42b1205977e77276fe9773c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 22:39:38 +0200
Subject: [PATCH 45/48] Bump version number for 2.0.1.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
(LIBGUILE_INTERFACE_CURRENT): Increment to account for new C functions
such as `scm_c_public_ref' and `scm_from_latin1_keyword'.
(LIBGUILE_INTERFACE_AGE): Increment.
---
GUILE-VERSION | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/GUILE-VERSION b/GUILE-VERSION
index 7da933738..cbbe90948 100644
--- a/GUILE-VERSION
+++ b/GUILE-VERSION
@@ -3,7 +3,7 @@
# Note: `GUILE_VERSION' is defined in `configure.ac' using `git-version-gen'.
GUILE_MAJOR_VERSION=2
GUILE_MINOR_VERSION=0
-GUILE_MICRO_VERSION=0
+GUILE_MICRO_VERSION=1
GUILE_EFFECTIVE_VERSION=2.0
@@ -18,7 +18,7 @@ GUILE_EFFECTIVE_VERSION=2.0
# See libtool info pages for more information on how and when to
# change these.
-LIBGUILE_INTERFACE_CURRENT=22
+LIBGUILE_INTERFACE_CURRENT=23
LIBGUILE_INTERFACE_REVISION=0
-LIBGUILE_INTERFACE_AGE=0
+LIBGUILE_INTERFACE_AGE=1
LIBGUILE_INTERFACE="${LIBGUILE_INTERFACE_CURRENT}:${LIBGUILE_INTERFACE_REVISION}:${LIBGUILE_INTERFACE_AGE}"
From 6b480ced9c31be3106e675b51afb2dfa4245bd03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?=
Date: Wed, 27 Apr 2011 22:48:20 +0200
Subject: [PATCH 46/48] Fix typo in `NEWS'.
---
NEWS | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index cfbc65a3c..df6de65cf 100644
--- a/NEWS
+++ b/NEWS
@@ -128,7 +128,7 @@ interpreted as starting an R6RS hex escape. This is backward compatible
because the symbol printer would never produce a "\x" before. The
printer also works better too.
-** Added --force-auto-compile option
+** Added `--fresh-auto-compile' option
This allows a user to invalidate the auto-compilation cache. It's
usually not needed. See "Compilation" in the manual, for a discussion.
From 18e444b40e88cf1969414a1e621adaed27d1dc43 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 28 Apr 2011 12:17:56 +0200
Subject: [PATCH 47/48] add reset and shift
* module/ice-9/control.scm (reset, shift): Add implementations of these
operators from Wolfgang J Moeller, derived from implementations by
Oleg Kiselyov.
(reset*, shift*): Procedural variants.
* test-suite/tests/control.test ("shift and reset"): Add tests,
originally from Oleg Kiselyov.
---
module/ice-9/control.scm | 30 +++++++++++++++++++++++++--
test-suite/tests/control.test | 38 +++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/module/ice-9/control.scm b/module/ice-9/control.scm
index dbee61e25..908e0e938 100644
--- a/module/ice-9/control.scm
+++ b/module/ice-9/control.scm
@@ -1,6 +1,6 @@
;;; Beyond call/cc
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2011 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
@@ -21,7 +21,7 @@
(define-module (ice-9 control)
#:re-export (call-with-prompt abort-to-prompt
default-prompt-tag make-prompt-tag)
- #:export (% abort))
+ #:export (% abort shift reset shift* reset*))
(define (abort . args)
(apply abort-to-prompt (default-prompt-tag) args))
@@ -54,3 +54,29 @@
(% (default-prompt-tag)
(proc k)
default-prompt-handler))
+
+;; Kindly provided by Wolfgang J Moeller , modelled
+;; after the ones by Oleg Kiselyov in
+;; http://okmij.org/ftp/Scheme/delim-control-n.scm, which are in the
+;; public domain, as noted at the top of http://okmij.org/ftp/.
+;;
+(define-syntax reset
+ (syntax-rules ()
+ ((_ . body)
+ (call-with-prompt (default-prompt-tag)
+ (lambda () . body)
+ (lambda (cont f) (f cont))))))
+
+(define-syntax shift
+ (syntax-rules ()
+ ((_ var . body)
+ (abort-to-prompt (default-prompt-tag)
+ (lambda (cont)
+ ((lambda (var) (reset . body))
+ (lambda vals (reset (apply cont vals)))))))))
+
+(define (reset* thunk)
+ (reset (thunk)))
+
+(define (shift* fc)
+ (shift c (fc c)))
diff --git a/test-suite/tests/control.test b/test-suite/tests/control.test
index 6f1804a3f..1c30b9c07 100644
--- a/test-suite/tests/control.test
+++ b/test-suite/tests/control.test
@@ -350,3 +350,41 @@
(and (eq? key 'foo)
(eq? vm new-vm)
(eq? (the-vm) prev-vm)))))))
+
+;; These tests from Oleg Kiselyov's delim-control-n.scm, available at
+;; http://okmij.org/ftp/Scheme/delim-control-n.scm. Public domain.
+;;
+(with-test-prefix "shift and reset"
+ (pass-if (equal?
+ 117
+ (+ 10 (reset (+ 2 (shift k (+ 100 (k (k 3)))))))))
+
+ (pass-if (equal?
+ 60
+ (* 10 (reset (* 2 (shift g (* 5 (shift f (+ (f 1) 1)))))))))
+
+ (pass-if (equal?
+ 121
+ (let ((f (lambda (x) (shift k (k (k x))))))
+ (+ 1 (reset (+ 10 (f 100)))))))
+
+ (pass-if (equal?
+ 'a
+ (car (reset
+ (let ((x (shift f
+ (shift f1 (f1 (cons 'a (f '())))))))
+ (shift g x))))))
+
+ ;; Example by Olivier Danvy
+ (pass-if (equal?
+ '(1 2 3 4 5)
+ (let ()
+ (define (traverse xs)
+ (define (visit xs)
+ (if (null? xs)
+ '()
+ (visit (shift*
+ (lambda (k)
+ (cons (car xs) (k (cdr xs))))))))
+ (reset* (lambda () (visit xs))))
+ (traverse '(1 2 3 4 5))))))
From 91956a94fe6363cf69d574b56397962ec6ef4468 Mon Sep 17 00:00:00 2001
From: Andy Wingo
Date: Thu, 28 Apr 2011 13:08:22 +0200
Subject: [PATCH 48/48] allow while as an expression
* module/ice-9/boot-9.scm (while): Specify the return value as #f under
normal conditions, #t under (break), and arg... under (break arg...).
* test-suite/tests/syntax.test ("while"): Test.
* doc/ref/api-control.texi (while do): Document.
---
doc/ref/api-control.texi | 18 +++++++++++++++---
module/ice-9/boot-9.scm | 18 +++++++++---------
test-suite/tests/syntax.test | 17 ++++++++++++-----
3 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/doc/ref/api-control.texi b/doc/ref/api-control.texi
index 1f33c43b5..1dde8ea9d 100644
--- a/doc/ref/api-control.texi
+++ b/doc/ref/api-control.texi
@@ -266,13 +266,12 @@ Concept of Closure}).
@deffn syntax while cond body @dots{}
Run a loop executing the @var{body} forms while @var{cond} is true.
@var{cond} is tested at the start of each iteration, so if it's
-@code{#f} the first time then @var{body} is not executed at all. The
-return value is unspecified.
+@code{#f} the first time then @var{body} is not executed at all.
Within @code{while}, two extra bindings are provided, they can be used
from both @var{cond} and @var{body}.
-@deffn {Scheme Procedure} break
+@deffn {Scheme Procedure} break break-arg...
Break out of the @code{while} form.
@end deffn
@@ -281,6 +280,19 @@ Abandon the current iteration, go back to the start and test
@var{cond} again, etc.
@end deffn
+If the loop terminates normally, by the @var{cond} evaluating to
+@code{#f}, then the @code{while} expression as a whole evaluates to
+@code{#f}. If it terminates by a call to @code{break} with some number
+of arguments, those arguments are returned from the @code{while}
+expression, as multiple values. Otherwise if it terminates by a call to
+@code{break} with no arguments, then return value is @code{#t}.
+
+@example
+(while #f (error "not reached")) @result{} #f
+(while #t (break)) @result{} #t
+(while #f (break 1 2 3)) @result{} 1 2 3
+@end example
+
Each @code{while} form gets its own @code{break} and @code{continue}
procedures, operating on that @code{while}. This means when loops are
nested the outer @code{break} can be used to escape all the way out.
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 84e76bded..401d90476 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -2785,13 +2785,11 @@ module '(ice-9 q) '(make-q q-length))}."
(define-syntax #,(datum->syntax #'while 'break)
(lambda (x)
(syntax-case x ()
- ((_)
- #'(abort-to-prompt break-tag))
- ((_ . args)
- (syntax-violation 'break "too many arguments" x))
+ ((_ arg (... ...))
+ #'(abort-to-prompt break-tag arg (... ...)))
(_
- #'(lambda ()
- (abort-to-prompt break-tag))))))
+ #'(lambda args
+ (apply abort-to-prompt break-tag args))))))
(let lp ()
(call-with-prompt
continue-tag
@@ -2806,10 +2804,12 @@ module '(ice-9 q) '(make-q q-length))}."
(_
#'(lambda ()
(abort-to-prompt continue-tag))))))
- (do () ((not cond)) body ...))
+ (do () ((not cond) #f) body ...))
(lambda (k) (lp)))))
- (lambda (k)
- #t)))))))
+ (lambda (k . args)
+ (if (null? args)
+ #t
+ (apply values args)))))))))
diff --git a/test-suite/tests/syntax.test b/test-suite/tests/syntax.test
index b33df7cb6..f6eb28a67 100644
--- a/test-suite/tests/syntax.test
+++ b/test-suite/tests/syntax.test
@@ -983,11 +983,18 @@
(with-test-prefix "break"
- (pass-if-syntax-error "too many args" exception:too-many-args
- (eval '(while #t
- (break 1))
- (interaction-environment)))
-
+ (pass-if "normal return"
+ (not (while #f (error "not reached"))))
+
+ (pass-if "no args"
+ (while #t (break)))
+
+ (pass-if "multiple values"
+ (equal? '(1 2 3)
+ (call-with-values
+ (lambda () (while #t (break 1 2 3)))
+ list)))
+
(with-test-prefix "from cond"
(pass-if "first"
(while (begin