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

Merge remote-tracking branch 'origin/stable-2.0'

Conflicts:
	GUILE-VERSION
This commit is contained in:
Andy Wingo 2011-04-28 15:53:35 +02:00
commit 1903eae4c9
117 changed files with 3447 additions and 2474 deletions

3
.gitignore vendored
View file

@ -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

View file

@ -18,7 +18,7 @@ GUILE_EFFECTIVE_VERSION=2.2
# 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}"

198
NEWS
View file

@ -7,17 +7,203 @@ Please send Guile bug reports to bug-guile@gnu.org.
Changes in 2.0.1 (since 2.0.0):
* New procedures (see the manual for details)
* Notable changes
** exact-integer-sqrt, imported into core from (rnrs base)
** guile.m4 supports linking with rpath
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.
** `begin' expands macros in its body before other expressions
This enables support for programs like the following:
(begin
(define even?
(lambda (x)
(or (= x 0) (odd? (- x 1)))))
(define-syntax odd?
(syntax-rules ()
((odd? x) (not (even? x)))))
(even? 10))
** REPL reader usability enhancements
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'
See "Fly Evaluation" in the manual.
** Added `scm_from_latin1_keyword', `scm_from_utf8_keyword'
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.
** 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)'
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.
** Added `heap-allocated-since-gc' to `(gc-stats)'
Also fixed the long-standing bug in the REPL `,stat' command.
** Add `on-error' REPL option
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.
** Enforce immutability of string literals
Attempting to mutate a string literal now causes a runtime error.
** Fix pthread redirection
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.
** `with-continuation-barrier' now unwinds on `quit'
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.
** `string->pointer' and `pointer->string' have optional encoding arg
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.
** R6RS fixnum arithmetic optimizations
R6RS fixnum operations are are still slower than generic arithmetic,
however.
** New procedure: `define-inlinable'
See "Inlinable Procedures" in the manual, for more.
** New procedure: `exact-integer-sqrt'
See "Integer Operations" in the manual, for more.
** "Extended read syntax" for symbols parses better
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.
** 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.
* 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)': "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
** 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 <prompt>
** Fix compilation of <prompt> in <fix> 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
** 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'
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):

View file

@ -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 <uniconv.h>
#include <unistring/iconveh.h>
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])])

View file

@ -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

View file

@ -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;

View file

@ -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
@ -644,12 +643,13 @@ AC_SUBST([SCM_I_GSC_HAVE_STRUCT_DIRENT64])
# this file instead of <fenv.h>
# 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
@ -874,6 +874,11 @@ if test "x$LTLIBUNISTRING" = "x"; then
AC_MSG_ERROR([GNU libunistring is required, please install it.])
fi
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.
PKG_CHECK_MODULES(LIBFFI, libffi)
@ -1238,7 +1243,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
@ -1514,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
## <http://thread.gmane.org/gmane.lisp.guile.bugs/5329>.)
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"

View file

@ -3,12 +3,6 @@
<!--#include virtual="/server/banner.html" -->
<h2>%%TITLE%%</h2>
<!-- This document is in XML, and xhtml 1.0 -->
<!-- Please make sure to properly nest your tags -->
<!-- and ensure that your final document validates -->
<!-- consistent with W3C xhtml 1.0 and CSS standards -->
<!-- See validator.w3.org -->
<address>Free Software Foundation</address>
<address>last updated %%DATE%%</address>
@ -66,29 +60,28 @@ this helps support FSF activities.</p>
<p>(This page generated by the <a href="%%SCRIPTURL%%">%%SCRIPTNAME%%
script</a>.)</p>
<!-- If needed, change the copyright block at the bottom. In general, -->
<!-- all pages on the GNU web server should have the section about -->
<!-- verbatim copying. Please do NOT remove this without talking -->
<!-- with the webmasters first. -->
<!-- Please make sure the copyright date is consistent with the document -->
<!-- and that it is like this "2001, 2002" not this "2001-2002." -->
<!-- If needed, change the copyright block at the bottom. In general,
all pages on the GNU web server should have the section about
verbatim copying. Please do NOT remove this without talking
with the webmasters first.
Please make sure the copyright date is consistent with the document
and that it is like this: "2001, 2002", not this: "2001-2002". -->
</div><!-- for id="content", starts in the include above -->
<!--#include virtual="/server/footer.html" -->
<div id="footer">
<p>
Please send FSF &amp; GNU inquiries to
<p>Please send general FSF &amp; GNU inquiries to
<a href="mailto:gnu@gnu.org">&lt;gnu@gnu.org&gt;</a>.
There are also <a href="/contact/">other ways to contact</a>
the FSF.<br />
Please send broken links and other corrections or suggestions to
<a href="mailto:%%EMAIL%%">&lt;%%EMAIL%%&gt;</a>.
</p>
<a href="mailto:%%EMAIL%%">&lt;%%EMAIL%%&gt;</a>.</p>
<p>Copyright &copy; 2010 Free Software Foundation, Inc.</p>
<p>Copyright &copy; 2011 Free Software Foundation, Inc.</p>
<p>Verbatim copying and distribution of this entire article is
permitted in any medium, provided this notice is preserved.</p>
<p>Verbatim copying and distribution of this entire article are
permitted worldwide, without royalty, in any medium, provided this
notice, and the copyright notice, are preserved.</p>
</div>
</div>

View file

@ -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.

View file

@ -4280,20 +4280,20 @@ 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
@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.
@ -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

View file

@ -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}.

View file

@ -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
@ -1229,6 +1233,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

View file

@ -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

View file

@ -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

View file

@ -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 <alloca.h> 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 <arpa/inet.h> 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 <byteswap.h> 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 <errno.h> 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 <float.h> 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 <iconv.h> 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 <locale.h> 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 <math.h> 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 <netdb.h> 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 <netinet/in.h> 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 <stdarg.h> 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 <stdbool.h> 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 <stddef.h> 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 <stdint.h> 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 <stdio.h> 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 <stdlib.h> 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 <string.h> 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 <strings.h> 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 <sys/file.h> 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 <sys/socket.h> 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 <sys/stat.h> 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 <sys/time.h> 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 <sys/uio.h> 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 <time.h> 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
# <unistd.h> 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 <wchar.h> 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' \

View file

@ -27,8 +27,8 @@
# include <features.h> /* 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 <sys/socket.h>

View file

@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _LIBC
# define _GL_USE_STDLIB_ALLOC 1
# include <config.h>
#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

View file

@ -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 <http://www.gnu.org/licenses/>. */
#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 */

View file

@ -19,7 +19,7 @@
/* Specification. */
#include <unistd.h>
#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

View file

@ -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 <bruno@clisp.org>, 2009.
@ -18,13 +18,9 @@
#include <config.h>
/* Specification. */
#include "close-hook.h"
#include "fd-hook.h"
#include <stdlib.h>
#include <unistd.h>
#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;
}
}

119
lib/fd-hook.h Normal file
View file

@ -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 <http://www.gnu.org/licenses/>. */
#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 */

View file

@ -18,6 +18,7 @@
/* written by Jim Meyering and Bruno Haible */
#define _GL_USE_STDLIB_ALLOC 1
#include <config.h>
/* 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 <stdlib.h>
#include <errno.h>
/* 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. */

View file

@ -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 <config.h>
/* 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

View file

@ -37,7 +37,8 @@
#ifndef _GL_NETDB_H
#define _GL_NETDB_H
/* Get netdb.h definitions such as struct hostent for MinGW. */
/* Get <netdb.h> definitions such as 'socklen_t' on IRIX 6.5 and OSF/1 4.0 and
'struct hostent' on MinGW. */
#include <sys/socket.h>
/* The definition of _GL_ARG_NONNULL is copied here. */

59
lib/read.c Normal file
View file

@ -0,0 +1,59 @@
/* POSIX compatible read() function.
Copyright (C) 2008-2011 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 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 <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
/* Replace this function only if module 'nonblocking' is requested. */
#if GNULIB_NONBLOCKING
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
# include <errno.h>
# include <io.h>
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
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

View file

@ -27,13 +27,15 @@
/* This includes winsock2.h on MinGW. */
# include <sys/socket.h>
# 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)

View file

@ -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;

View file

@ -67,8 +67,44 @@
#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 <unistd.h>, not in <stdio.h>. */
/* But in any case avoid namespace pollution on glibc systems. */
@ -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
<http://sources.redhat.com/bugzilla/show_bug.cgi?id=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)

View file

@ -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 - "

View file

@ -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 <config.h>
/* Specification. */
#include <string.h>
#include <ctype.h>
#include <limits.h>
#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);
}

View file

@ -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 \

View file

@ -277,6 +277,16 @@ _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 @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
@ -288,6 +298,7 @@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
_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));

View file

@ -1,94 +0,0 @@
/* A substitute <strings.h>.
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 */

View file

@ -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 <config.h>
/* Specification. */
#include <string.h>
#include <ctype.h>
#include <limits.h>
#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);
}

View file

@ -50,6 +50,10 @@
<sys/types.h>. */
# include <sys/types.h>
/* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL
is defined. */
# include <stddef.h>
/* 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 <winsock2.h>
# endif
@ -173,6 +176,19 @@ typedef int socklen_t;
# endif
/* For struct iovec */
# include <sys/uio.h>
/* 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@

View file

@ -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

View file

@ -1,5 +1,5 @@
/* Substitute for and wrapper around <stdarg.h>.
Copyright (C) 2008-2011 Free Software Foundation, Inc.
/* Substitute for <sys/uio.h>.
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 <sys/uio.h>. */
/* Get 'ssize_t'. */
# include <sys/types.h>
/* All known platforms that lack <sys/uio.h> 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 */

View file

@ -97,7 +97,8 @@
# include <netdb.h>
#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 <sys/types.h>
@ -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
<http://www.opengroup.org/susv3xsh/read.html>. */
# 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
<http://www.opengroup.org/susv3xsh/write.html>. */
# 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

View file

@ -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);

View file

@ -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 <int w>
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 <int w>
/* Verify requirement R at compile-time, as a declaration without a
trailing ';'. */
# 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

View file

@ -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 <http://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
#include <config.h>
/* 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.";

View file

@ -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 <http://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
#include <config.h>
/* Specification. */
#include "version-etc.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#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 <http://gnu.org/licenses/gpl.html>.\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: <http://www.gnu.org/software/%s/>\n"),
PACKAGE_NAME, PACKAGE);
#endif
fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"),
stdout);
}

View file

@ -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 <http://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
#ifndef VERSION_ETC_H
# define VERSION_ETC_H 1
# include <stdarg.h>
# include <stdio.h>
/* 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 */

View file

@ -61,9 +61,13 @@
<wchar.h>.
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
included before <wchar.h>.
In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
by <stddef.h>.
But avoid namespace pollution on glibc systems. */
#ifndef __GLIBC__
#if !(defined __GLIBC__ && !defined __UCLIBC__)
# include <stddef.h>
#endif
#ifndef __GLIBC__
# include <stdio.h>
# include <time.h>
#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 *,
/* 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 *,
/* 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

View file

@ -20,8 +20,9 @@
/* Specification. */
#include <unistd.h>
/* 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
{
for (;;)
{
ssize_t ret = write (fd, buf, count);
if (ret < 0)
{
# 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)
&& 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. */
/* If it is currently blocked or ignored, change errno from
EINVAL to EPIPE. */
errno = EPIPE;
}
# endif
}
}
return ret;
}
}
# endif

View file

@ -138,6 +138,7 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = \
expand.c \
extensions.c \
feature.c \
filesys.c \
fluids.c \
foreign.c \
fports.c \
@ -242,6 +243,7 @@ DOT_X_FILES = \
expand.x \
extensions.x \
feature.x \
filesys.x \
fluids.x \
foreign.x \
fports.x \
@ -342,6 +344,7 @@ DOT_DOC_FILES = \
expand.doc \
extensions.doc \
feature.doc \
filesys.doc \
fluids.doc \
foreign.doc \
fports.doc \
@ -425,7 +428,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

View file

@ -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}
*/
@ -652,7 +602,34 @@ 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
/* {Modifying Directories}
*/
@ -677,280 +654,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}
*/
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}
*/
@ -971,38 +674,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
@ -1427,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"
@ -1509,6 +1155,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 */
@ -1697,18 +1637,192 @@ 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;
}
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 +1884,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"
}

View file

@ -1,4 +1,5 @@
/* 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
@ -638,7 +639,7 @@ fport_print (SCM exp, SCM port, scm_print_state *pstate SCM_UNUSED)
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

View file

@ -57,6 +57,9 @@ extern unsigned long * __libc_ia64_register_backing_store_base;
#include "libguile/bdw-gc.h"
/* For GC_set_start_callback. */
#include <gc/gc_mark.h>
#ifdef GUILE_DEBUG_MALLOC
#include "libguile/debug-malloc.h"
#endif
@ -195,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;
@ -352,6 +362,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 ();
}
@ -544,23 +557,6 @@ scm_gc_unregister_roots (SCM *b, unsigned long n)
scm_gc_unregister_root (p);
}
static void
scm_c_register_gc_callback (void *key, void (*func) (void *, void *),
void *data)
{
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);
}
@ -616,8 +612,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,27 +640,29 @@ 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,
queue_after_gc_hook (void * hook_data SCM_UNUSED,
void *fn_data SCM_UNUSED,
void *data SCM_UNUSED)
{
@ -697,10 +693,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 +796,17 @@ 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);
#ifdef HAVE_GC_SET_START_CALLBACK
GC_set_start_callback (run_before_gc_c_hook);
#endif
#include "libguile/gc.x"
}

View file

@ -418,32 +418,54 @@ SCM_DEFINE (scm_make_hash_table, "make-hash-table", 0, 1, 0,
}
#undef FUNC_NAME
static void
weak_gc_callback (void *ptr, 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 = ptr;
void *val = *weak;
void *val = weak[0];
void (*callback) (SCM) = weak[1];
if (val)
{
void (*callback) (SCM) = data;
GC_REGISTER_FINALIZER_NO_ORDER (ptr, weak_gc_callback, data, NULL, NULL);
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))
{
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);
#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,

View file

@ -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;

View file

@ -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 */
@ -455,8 +448,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

View file

@ -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)))
{
@ -933,6 +938,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
}
@ -956,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);
@ -973,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;
}
}

View file

@ -45,6 +45,8 @@
# include <config.h>
#endif
#include <verify.h>
#include <math.h>
#include <string.h>
#include <unicase.h>

View file

@ -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);
}
*len = bytes_consumed;

View file

@ -27,6 +27,10 @@
#include <errno.h>
#include <uniconv.h>
#ifdef HAVE_SCHED_H
# include <sched.h>
#endif
#include "libguile/_scm.h"
#include "libguile/dynwind.h"
#include "libguile/fports.h"
@ -138,7 +142,6 @@ extern char *ttyname();
#endif
#include <sys/file.h> /* from Gnulib */
#include <nproc.h>
/* Some Unix systems don't define these. CPP hair is dangerous, but
this seems safe enough... */
@ -1325,54 +1328,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"
@ -1485,58 +1440,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.")
@ -1991,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,
@ -2218,12 +2091,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

View file

@ -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;

View file

@ -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;

View file

@ -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
@ -27,8 +27,6 @@
#include <errno.h>
#include <ctype.h>
#include <version-etc.h>
#include "libguile/_scm.h"
#include "libguile/eval.h"
#include "libguile/feature.h"
@ -357,464 +355,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")));
}

View file

@ -39,6 +39,7 @@
#endif
#include <assert.h>
#include <nproc.h>
#include "libguile/validate.h"
#include "libguile/root.h"
@ -613,6 +614,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;
@ -661,7 +666,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);
}
@ -685,10 +692,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);
@ -720,7 +723,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 +777,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 +792,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);
@ -2006,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;

View file

@ -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 */
/*

View file

@ -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.

View file

@ -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"])
])

View file

@ -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])

View file

@ -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"])
])

View file

@ -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 <sys/socket.h>])
AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [
#include <sys/types.h>
#include <sys/socket.h>
])
AC_CHECK_HEADERS_ONCE([netinet/in.h])

View file

@ -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

View file

@ -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

View file

@ -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:
@ -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

View file

@ -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"])
])

View file

@ -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])
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 = yes; then
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])

View file

@ -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"])
])

20
m4/read.m4 Normal file
View file

@ -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
])
])

View file

@ -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 <sys/types.h>
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#elif HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
#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],
[
/* <sys/types.h> is not needed according to POSIX, but the
<sys/socket.h> in i386-unknown-freebsd4.10 and
powerpc-apple-darwin5.5 required it. */
#include <sys/types.h>
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#elif HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
#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
])

View file

@ -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 <sys/socket.h> 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 <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#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 <sys/socket.h> defines AF_UNIX.])
fi
])

View file

@ -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 <stdarg.h>.
AC_DEFUN([gl_STDARG_H],
[
STDARG_H=''; AC_SUBST([STDARG_H])
NEXT_STDARG_H='<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 <stdarg.h>]],
[[
#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 <config.h> is enough. Not so on AIX 5
dnl with some versions of the /usr/vac/bin/cc compiler. It has an <stdarg.h>
dnl which does '#undef va_copy', leading to a missing va_copy symbol. For
dnl this platform, we use an <stdarg.h> substitute. But we cannot use this
dnl approach on other platforms, because <stdarg.h> 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 <stdarg.h> file.
STDARG_H=stdarg.h
gl_NEXT_HEADERS([stdarg.h])
dnl Fallback for the case when <stdarg.h> 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 <config.h>, 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 <stdarg.h>]],
[[
#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
])

View file

@ -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 <stdbool.h> 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

View file

@ -1,5 +1,5 @@
dnl A placeholder for POSIX 2008 <stddef.h>, 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])
])

View file

@ -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)

View file

@ -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 <stdio.h> 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 <stdio.h> 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])

View file

@ -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], [
:
])

View file

@ -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])

View file

@ -1,39 +0,0 @@
# Configure a replacement for <string.h>.
# 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 <strings.h>
]], [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])
])

View file

@ -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 <sys/socket.h> 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

31
m4/sys_uio_h.m4 Normal file
View file

@ -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 <sys/uio.h> 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],
[
])

View file

@ -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,
@ -80,6 +80,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
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])
@ -88,6 +89,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
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])
@ -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])

View file

@ -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
])

View file

@ -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
])

View file

@ -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 \
'\<error *\([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
| grep -v '_''(' && \
| grep -Ev '(_|ngettext ?)\(' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
@ -811,7 +824,7 @@ require_exactly_one_NL_at_EOF_ = \
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; } || :; \
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 <sys/stat.h>' \
$(_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='\<can[ ]not\>' \
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; \

View file

@ -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

View file

@ -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 \

View file

@ -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"))
@ -2784,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
@ -2805,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)))))))))
@ -3289,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))

View file

@ -0,0 +1,426 @@
;;; 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 <http://gnu.org/licenses/gpl.html>.
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 <http://gnu.org/licenses/lgpl.html>.
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: <http://www.gnu.org/gethelp/>\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
--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.
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)
(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))
((string=? arg "-q") ; don't load user init
(set! inhibit-user-init? #t)
(parse args out))
((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)
#:license *LGPLv3+*
#: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 '()))))

View file

@ -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 <wjm@heenes.com>, 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)))

View file

@ -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)

View file

@ -65,7 +65,14 @@
(call-with-sigint
(lambda ()
(and (defined? 'setlocale)
(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)))))

View file

@ -1343,6 +1343,25 @@ 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
((<const> exp)
exp)
((<application> proc args)
;; Gettexted literals, like `(_ "foo")'.
(and (record-case proc
((<toplevel-ref> name) (eq? name '_))
((<module-ref> name) (eq? name '_))
(else #f))
(pmatch args
((,fmt)
(record-case fmt
((<const> exp) exp)
(else #f)))
(else #f))))
(else #f)))
(define format-analysis
;; Report arity mismatches in the given tree.
(make-tree-analysis
@ -1355,11 +1374,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 +1394,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

View file

@ -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)

View file

@ -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
;; <http://lists.gnu.org/archive/html/guile-devel/2011-04/msg00111.html>.
(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)

View file

@ -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

Some files were not shown because too many files have changed in this diff Show more