mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-29 11:10:32 +02:00
Use Gnulib's `sys_stat' module; update Gnulib.
* .x-sc_prohibit_S_IS_definition: New file. * m4/gnulib-cache.m4: Add `sys_stat'. * libguile/filesys.c: Remove `S_IS*' macro definitions for Ultrix and MinGW.
This commit is contained in:
parent
20ccae8dbb
commit
1cd4fffcde
95 changed files with 9327 additions and 9148 deletions
1
.x-sc_prohibit_S_IS_definition
Normal file
1
.x-sc_prohibit_S_IS_definition
Normal file
|
@ -0,0 +1 @@
|
|||
lib/*
|
26
build-aux/arg-nonnull.h
Normal file
26
build-aux/arg-nonnull.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* A C macro for declaring that specific arguments must not be NULL.
|
||||
Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
by 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 General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
|
||||
that the values passed as arguments n, ..., m must be non-NULL pointers.
|
||||
n = 1 stands for the first argument, n = 2 for the second argument etc. */
|
||||
#ifndef _GL_ARG_NONNULL
|
||||
# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
|
||||
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
|
||||
# else
|
||||
# define _GL_ARG_NONNULL(params)
|
||||
# endif
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# Sign files and upload them.
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
scriptversion=2009-11-29.20; # UTC
|
||||
|
||||
# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
|
||||
#
|
||||
|
@ -73,34 +73,28 @@ actual command line options. Use this to keep your defaults. Comments
|
|||
(#) and empty lines in $conffile are allowed.
|
||||
|
||||
Examples:
|
||||
1. Upload automake-1.8.2b.tar.gz and automake-1.8.2b.tar.bz2 to two sites:
|
||||
gnupload --to sources.redhat.com:~ftp/pub/automake \\
|
||||
--to alpha.gnu.org:automake \\
|
||||
automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
|
||||
1. Upload foobar-1.0.tar.gz to ftp.gnu.org:
|
||||
gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz
|
||||
|
||||
2. Same as above, but also create symbolic links to automake-latest.tar.*:
|
||||
gnupload --to sources.redhat.com:~ftp/pub/automake \\
|
||||
--to alpha.gnu.org:automake \\
|
||||
2. Upload foobar-1.0.tar.gz and foobar-1.0.tar.xz to ftp.gnu.org:
|
||||
gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz foobar-1.0.tar.xz
|
||||
|
||||
3. Same as above, and also create symbolic links to foobar-latest.tar.*:
|
||||
gnupload --to ftp.gnu.org:foobar \\
|
||||
--symlink-regex \\
|
||||
automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
|
||||
foobar-1.0.tar.gz foobar-1.0.tar.xz
|
||||
|
||||
3. Symlink automake-1.8.2b.tar.gz to automake-latest.tar.gz and
|
||||
automake-1.8.2b.tar.bz2 to automake-latest.tar.bz2 on both sites:
|
||||
4. Upload foobar-0.9.90.tar.gz to two sites:
|
||||
gnupload --to alpha.gnu.org:foobar \\
|
||||
--to sources.redhat.com:~ftp/pub/foobar \\
|
||||
foobar-0.9.90.tar.gz
|
||||
|
||||
gnupload --to sources.redhat.com:~ftp/pub/automake \\
|
||||
--to alpha.gnu.org:automake \\
|
||||
--symlink automake-1.8.2b.tar.gz automake-latest.tar.gz \\
|
||||
automake-1.8.2b.tar.bz2 automake-latest.tar.bz2
|
||||
|
||||
4. Delete automake-1.8.2a.tar.gz and .bz2, remove symlink
|
||||
automake-latest.tar.gz and upload automake-1.8.2b.tar.gz:
|
||||
|
||||
gnupload --to sources.redhat.com:~ftp/pub/automake \\
|
||||
--to alpha.gnu.org:automake \\
|
||||
--delete automake-1.8.2a.tar.gz automake-1.8.2a.tar.bz2 \\
|
||||
--rmsymlink automake-latest.tar.gz \\
|
||||
-- \\
|
||||
automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
|
||||
5. Delete oopsbar-0.9.91.tar.gz and upload foobar-0.9.91.tar.gz
|
||||
(the -- terminates the list of files to delete):
|
||||
gnupload --to alpha.gnu.org:foobar \\
|
||||
--to sources.redhat.com:~ftp/pub/foobar \\
|
||||
--delete oopsbar-0.9.91.tar.gz \\
|
||||
-- foobar-0.9.91.tar.gz
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
Send patches to <automake-patches@gnu.org>."
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/* A C macro for emitting link time warnings.
|
||||
Copyright (C) 1995, 1997, 2000, 2002-2003, 2007, 2009 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
by 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 General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* GL_LINK_WARNING("literal string") arranges to emit the literal string as
|
||||
a linker warning on most glibc systems.
|
||||
We use a linker warning rather than a preprocessor warning, because
|
||||
|
@ -15,12 +32,12 @@
|
|||
# define GL_LINK_WARNING2(file, line, message) \
|
||||
GL_LINK_WARNING3 (file ":" #line ": warning: " message)
|
||||
# define GL_LINK_WARNING3(message) \
|
||||
({ static const char warning[sizeof (message)] \
|
||||
__attribute__ ((__unused__, \
|
||||
__section__ (".gnu.warning"), \
|
||||
__aligned__ (1))) \
|
||||
= message "\n"; \
|
||||
(void)0; \
|
||||
({ static const char warning[sizeof (message)] \
|
||||
__attribute__ ((__unused__, \
|
||||
__section__ (".gnu.warning"), \
|
||||
__aligned__ (1))) \
|
||||
= message "\n"; \
|
||||
(void)0; \
|
||||
})
|
||||
# else
|
||||
# define GL_LINK_WARNING(message) ((void) 0)
|
||||
|
|
|
@ -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 alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string verify version-etc-fsf vsnprintf warnings
|
||||
# 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 alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
|
||||
|
||||
|
@ -69,13 +69,32 @@ EXTRA_DIST += $(top_srcdir)/build-aux/announce-gen
|
|||
|
||||
## end gnulib module announce-gen
|
||||
|
||||
## begin gnulib module arg-nonnull
|
||||
|
||||
BUILT_SOURCES += arg-nonnull.h
|
||||
# The arg-nonnull.h that gets inserted into generated .h files is the same as
|
||||
# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
|
||||
arg-nonnull.h: $(top_srcdir)/build-aux/arg-nonnull.h
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
sed -n -e '/GL_ARG_NONNULL/,$$p' \
|
||||
< $(top_srcdir)/build-aux/arg-nonnull.h \
|
||||
> $@-t && \
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
|
||||
|
||||
ARG_NONNULL_H=arg-nonnull.h
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/build-aux/arg-nonnull.h
|
||||
|
||||
## end gnulib module arg-nonnull
|
||||
|
||||
## begin gnulib module arpa_inet
|
||||
|
||||
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
|
||||
arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_at)$(MKDIR_P) arpa
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
|
@ -88,6 +107,7 @@ arpa/inet.h: arpa_inet.in.h
|
|||
-e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
|
||||
-e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/arpa_inet.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -346,7 +366,7 @@ 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
|
||||
iconv.h: iconv.in.h $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
|
@ -356,6 +376,7 @@ iconv.h: iconv.in.h
|
|||
-e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \
|
||||
-e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \
|
||||
-e 's|@''REPLACE_ICONV_UTF''@|$(REPLACE_ICONV_UTF)|g' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/iconv.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -426,7 +447,18 @@ AM_CFLAGS += $(CFLAG_VISIBILITY)
|
|||
|
||||
## begin gnulib module link-warning
|
||||
|
||||
LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
|
||||
BUILT_SOURCES += link-warning.h
|
||||
# The link-warning.h that gets inserted into generated .h files is the same as
|
||||
# build-aux/link-warning.h, except that it has the copyright header cut off.
|
||||
link-warning.h: $(top_srcdir)/build-aux/link-warning.h
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
sed -n -e '/GL_LINK_WARNING/,$$p' \
|
||||
< $(top_srcdir)/build-aux/link-warning.h \
|
||||
> $@-t && \
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += link-warning.h link-warning.h-t
|
||||
|
||||
LINK_WARNING_H=link-warning.h
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h
|
||||
|
||||
|
@ -512,7 +544,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
|
||||
locale.h: locale.in.h $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
|
@ -521,6 +553,7 @@ locale.h: locale.in.h
|
|||
-e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \
|
||||
-e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
|
||||
-e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/locale.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -790,7 +823,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
|
||||
stdio.h: stdio.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
|
@ -875,6 +908,7 @@ stdio.h: stdio.in.h
|
|||
-e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
|
||||
-e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/stdio.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -892,7 +926,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
|
||||
stdlib.h: stdlib.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
|
@ -949,6 +983,7 @@ stdlib.h: stdlib.in.h
|
|||
-e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
|
||||
-e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/stdlib.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -1000,7 +1035,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
|
||||
string.h: string.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
|
@ -1067,6 +1102,7 @@ string.h: string.in.h
|
|||
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
|
||||
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/string.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -1082,7 +1118,7 @@ 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
|
||||
strings.h: strings.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
|
@ -1091,6 +1127,7 @@ strings.h: strings.in.h
|
|||
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
|
||||
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/strings.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -1132,7 +1169,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
|
||||
sys/socket.h: sys_socket.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_at)$(MKDIR_P) sys
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
|
@ -1162,6 +1199,7 @@ sys/socket.h: sys_socket.in.h
|
|||
-e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
|
||||
-e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/sys_socket.in.h; \
|
||||
} > $@-t && \
|
||||
mv -f $@-t $@
|
||||
|
@ -1178,7 +1216,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
|
||||
sys/stat.h: sys_stat.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_at)$(MKDIR_P) sys
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
|
@ -1218,6 +1256,7 @@ sys/stat.h: sys_stat.in.h
|
|||
-e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
|
||||
-e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/sys_stat.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -1234,7 +1273,7 @@ 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
|
||||
time.h: time.in.h $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
|
@ -1247,6 +1286,7 @@ time.h: time.in.h
|
|||
-e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
|
||||
-e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
|
||||
-e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/time.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -1271,7 +1311,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
|
||||
unistd.h: unistd.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
|
||||
|
@ -1302,6 +1342,7 @@ unistd.h: unistd.in.h
|
|||
-e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
|
||||
-e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
|
||||
-e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
|
||||
-e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
|
||||
-e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
|
||||
-e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
|
||||
-e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
|
||||
|
@ -1332,6 +1373,7 @@ unistd.h: unistd.in.h
|
|||
-e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
|
||||
-e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
|
||||
-e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
|
||||
-e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
|
||||
-e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
|
||||
-e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
|
||||
-e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
|
||||
|
@ -1356,6 +1398,7 @@ unistd.h: unistd.in.h
|
|||
-e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
|
||||
-e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
|
||||
-e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
|
||||
-e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
|
||||
-e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
|
||||
-e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
|
||||
-e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
|
||||
|
@ -1367,6 +1410,7 @@ unistd.h: unistd.in.h
|
|||
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
|
||||
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/unistd.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
@ -1476,7 +1520,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
|
||||
wchar.h: wchar.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||
|
@ -1519,6 +1563,7 @@ wchar.h: wchar.in.h
|
|||
-e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
|
||||
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||
< $(srcdir)/wchar.in.h; \
|
||||
} > $@-t && \
|
||||
mv $@-t $@
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* A GNU-like <arpa/inet.h>.
|
||||
|
||||
Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2006, 2008-2009 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
|
||||
|
@ -38,6 +38,8 @@
|
|||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -60,7 +62,8 @@ extern "C" {
|
|||
For more details, see the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
|
||||
extern const char *inet_ntop (int af, const void *restrict src,
|
||||
char *restrict dst, socklen_t cnt);
|
||||
char *restrict dst, socklen_t cnt)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef inet_ntop
|
||||
|
@ -72,13 +75,14 @@ extern const char *inet_ntop (int af, const void *restrict src,
|
|||
|
||||
#if @GNULIB_INET_PTON@
|
||||
# if !@HAVE_DECL_INET_PTON@
|
||||
extern int inet_pton (int af, const char *restrict src, void *restrict dst);
|
||||
extern int inet_pton (int af, const char *restrict src, void *restrict dst)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef inet_pton
|
||||
# define inet_pton(af,src,dst) \
|
||||
(GL_LINK_WARNING ("inet_pton is unportable - " \
|
||||
"use gnulib module inet_pton for portability"), \
|
||||
"use gnulib module inet_pton for portability"), \
|
||||
inet_pton (af, src, dst))
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,24 +21,24 @@
|
|||
/* Given an unsigned 16-bit argument X, return the value corresponding to
|
||||
X with reversed byte order. */
|
||||
#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
|
||||
(((x) & 0xFF00) >> 8))
|
||||
(((x) & 0xFF00) >> 8))
|
||||
|
||||
/* Given an unsigned 32-bit argument X, return the value corresponding to
|
||||
X with reversed byte order. */
|
||||
#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
|
||||
(((x) & 0x0000FF00) << 8) | \
|
||||
(((x) & 0x00FF0000) >> 8) | \
|
||||
(((x) & 0xFF000000) >> 24))
|
||||
(((x) & 0x0000FF00) << 8) | \
|
||||
(((x) & 0x00FF0000) >> 8) | \
|
||||
(((x) & 0xFF000000) >> 24))
|
||||
|
||||
/* Given an unsigned 64-bit argument X, return the value corresponding to
|
||||
X with reversed byte order. */
|
||||
#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
|
||||
(((x) & 0x000000000000FF00ULL) << 40) | \
|
||||
(((x) & 0x0000000000FF0000ULL) << 24) | \
|
||||
(((x) & 0x00000000FF000000ULL) << 8) | \
|
||||
(((x) & 0x000000FF00000000ULL) >> 8) | \
|
||||
(((x) & 0x0000FF0000000000ULL) >> 24) | \
|
||||
(((x) & 0x00FF000000000000ULL) >> 40) | \
|
||||
(((x) & 0xFF00000000000000ULL) >> 56))
|
||||
(((x) & 0x000000000000FF00ULL) << 40) | \
|
||||
(((x) & 0x0000000000FF0000ULL) << 24) | \
|
||||
(((x) & 0x00000000FF000000ULL) << 8) | \
|
||||
(((x) & 0x000000FF00000000ULL) >> 8) | \
|
||||
(((x) & 0x0000FF0000000000ULL) >> 24) | \
|
||||
(((x) & 0x00FF000000000000ULL) >> 40) | \
|
||||
(((x) & 0xFF00000000000000ULL) >> 56))
|
||||
|
||||
#endif /* _GL_BYTESWAP_H */
|
||||
|
|
|
@ -40,7 +40,7 @@ c_strcasecmp (const char *s1, const char *s2)
|
|||
c2 = c_tolower (*p2);
|
||||
|
||||
if (c1 == '\0')
|
||||
break;
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
|
|
|
@ -40,7 +40,7 @@ c_strncasecmp (const char *s1, const char *s2, size_t n)
|
|||
c2 = c_tolower (*p2);
|
||||
|
||||
if (--n == 0 || c1 == '\0')
|
||||
break;
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
|
||||
#if !HAVE_CANONICALIZE_FILE_NAME || !FUNC_REALPATH_WORKS || defined _LIBC
|
||||
|
||||
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
|
||||
optimizes away the name == NULL test below. */
|
||||
#define _GL_ARG_NONNULL(params)
|
||||
|
||||
/* Specification. */
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -94,9 +98,9 @@ __realpath (const char *name, char *resolved)
|
|||
if (name == NULL)
|
||||
{
|
||||
/* As per Single Unix Specification V2 we must return an error if
|
||||
either parameter is a null pointer. We extend this to allow
|
||||
the RESOLVED parameter to be NULL in case the we are expected to
|
||||
allocate the room for the return value. */
|
||||
either parameter is a null pointer. We extend this to allow
|
||||
the RESOLVED parameter to be NULL in case the we are expected to
|
||||
allocate the room for the return value. */
|
||||
__set_errno (EINVAL);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -104,7 +108,7 @@ __realpath (const char *name, char *resolved)
|
|||
if (name[0] == '\0')
|
||||
{
|
||||
/* As per Single Unix Specification V2 we must return an error if
|
||||
the name argument points to an empty string. */
|
||||
the name argument points to an empty string. */
|
||||
__set_errno (ENOENT);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -121,12 +125,12 @@ __realpath (const char *name, char *resolved)
|
|||
{
|
||||
rpath = malloc (path_max);
|
||||
if (rpath == NULL)
|
||||
{
|
||||
/* It's easier to set errno to ENOMEM than to rely on the
|
||||
'malloc-posix' gnulib module. */
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
/* It's easier to set errno to ENOMEM than to rely on the
|
||||
'malloc-posix' gnulib module. */
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
rpath = resolved;
|
||||
|
@ -135,10 +139,10 @@ __realpath (const char *name, char *resolved)
|
|||
if (name[0] != '/')
|
||||
{
|
||||
if (!__getcwd (rpath, path_max))
|
||||
{
|
||||
rpath[0] = '\0';
|
||||
goto error;
|
||||
}
|
||||
{
|
||||
rpath[0] = '\0';
|
||||
goto error;
|
||||
}
|
||||
dest = strchr (rpath, '\0');
|
||||
}
|
||||
else
|
||||
|
@ -146,7 +150,7 @@ __realpath (const char *name, char *resolved)
|
|||
rpath[0] = '/';
|
||||
dest = rpath + 1;
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && name[1] == '/')
|
||||
*dest++ = '/';
|
||||
*dest++ = '/';
|
||||
}
|
||||
|
||||
for (start = end = name; *start; start = end)
|
||||
|
@ -160,153 +164,153 @@ __realpath (const char *name, char *resolved)
|
|||
|
||||
/* Skip sequence of multiple path-separators. */
|
||||
while (*start == '/')
|
||||
++start;
|
||||
++start;
|
||||
|
||||
/* Find end of path component. */
|
||||
for (end = start; *end && *end != '/'; ++end)
|
||||
/* Nothing. */;
|
||||
/* Nothing. */;
|
||||
|
||||
if (end - start == 0)
|
||||
break;
|
||||
break;
|
||||
else if (end - start == 1 && start[0] == '.')
|
||||
/* nothing */;
|
||||
/* nothing */;
|
||||
else if (end - start == 2 && start[0] == '.' && start[1] == '.')
|
||||
{
|
||||
/* Back up to previous component, ignore if at root already. */
|
||||
if (dest > rpath + 1)
|
||||
while ((--dest)[-1] != '/');
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
|
||||
&& *dest == '/')
|
||||
dest++;
|
||||
}
|
||||
{
|
||||
/* Back up to previous component, ignore if at root already. */
|
||||
if (dest > rpath + 1)
|
||||
while ((--dest)[-1] != '/');
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
|
||||
&& *dest == '/')
|
||||
dest++;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t new_size;
|
||||
{
|
||||
size_t new_size;
|
||||
|
||||
if (dest[-1] != '/')
|
||||
*dest++ = '/';
|
||||
if (dest[-1] != '/')
|
||||
*dest++ = '/';
|
||||
|
||||
if (dest + (end - start) >= rpath_limit)
|
||||
{
|
||||
ptrdiff_t dest_offset = dest - rpath;
|
||||
char *new_rpath;
|
||||
if (dest + (end - start) >= rpath_limit)
|
||||
{
|
||||
ptrdiff_t dest_offset = dest - rpath;
|
||||
char *new_rpath;
|
||||
|
||||
if (resolved)
|
||||
{
|
||||
__set_errno (ENAMETOOLONG);
|
||||
if (dest > rpath + 1)
|
||||
dest--;
|
||||
*dest = '\0';
|
||||
goto error;
|
||||
}
|
||||
new_size = rpath_limit - rpath;
|
||||
if (end - start + 1 > path_max)
|
||||
new_size += end - start + 1;
|
||||
else
|
||||
new_size += path_max;
|
||||
new_rpath = (char *) realloc (rpath, new_size);
|
||||
if (new_rpath == NULL)
|
||||
{
|
||||
/* It's easier to set errno to ENOMEM than to rely on the
|
||||
'realloc-posix' gnulib module. */
|
||||
errno = ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
rpath = new_rpath;
|
||||
rpath_limit = rpath + new_size;
|
||||
if (resolved)
|
||||
{
|
||||
__set_errno (ENAMETOOLONG);
|
||||
if (dest > rpath + 1)
|
||||
dest--;
|
||||
*dest = '\0';
|
||||
goto error;
|
||||
}
|
||||
new_size = rpath_limit - rpath;
|
||||
if (end - start + 1 > path_max)
|
||||
new_size += end - start + 1;
|
||||
else
|
||||
new_size += path_max;
|
||||
new_rpath = (char *) realloc (rpath, new_size);
|
||||
if (new_rpath == NULL)
|
||||
{
|
||||
/* It's easier to set errno to ENOMEM than to rely on the
|
||||
'realloc-posix' gnulib module. */
|
||||
errno = ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
rpath = new_rpath;
|
||||
rpath_limit = rpath + new_size;
|
||||
|
||||
dest = rpath + dest_offset;
|
||||
}
|
||||
dest = rpath + dest_offset;
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
dest = __mempcpy (dest, start, end - start);
|
||||
dest = __mempcpy (dest, start, end - start);
|
||||
#else
|
||||
memcpy (dest, start, end - start);
|
||||
dest += end - start;
|
||||
memcpy (dest, start, end - start);
|
||||
dest += end - start;
|
||||
#endif
|
||||
*dest = '\0';
|
||||
*dest = '\0';
|
||||
|
||||
#ifdef _LIBC
|
||||
if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
|
||||
if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
|
||||
#else
|
||||
if (lstat (rpath, &st) < 0)
|
||||
if (lstat (rpath, &st) < 0)
|
||||
#endif
|
||||
goto error;
|
||||
goto error;
|
||||
|
||||
if (S_ISLNK (st.st_mode))
|
||||
{
|
||||
char *buf;
|
||||
size_t len;
|
||||
if (S_ISLNK (st.st_mode))
|
||||
{
|
||||
char *buf;
|
||||
size_t len;
|
||||
|
||||
if (++num_links > MAXSYMLINKS)
|
||||
{
|
||||
__set_errno (ELOOP);
|
||||
goto error;
|
||||
}
|
||||
if (++num_links > MAXSYMLINKS)
|
||||
{
|
||||
__set_errno (ELOOP);
|
||||
goto error;
|
||||
}
|
||||
|
||||
buf = malloca (path_max);
|
||||
if (!buf)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
buf = malloca (path_max);
|
||||
if (!buf)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
||||
n = __readlink (rpath, buf, path_max - 1);
|
||||
if (n < 0)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
freea (buf);
|
||||
errno = saved_errno;
|
||||
goto error;
|
||||
}
|
||||
buf[n] = '\0';
|
||||
n = __readlink (rpath, buf, path_max - 1);
|
||||
if (n < 0)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
freea (buf);
|
||||
errno = saved_errno;
|
||||
goto error;
|
||||
}
|
||||
buf[n] = '\0';
|
||||
|
||||
if (!extra_buf)
|
||||
{
|
||||
extra_buf = malloca (path_max);
|
||||
if (!extra_buf)
|
||||
{
|
||||
freea (buf);
|
||||
errno = ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (!extra_buf)
|
||||
{
|
||||
extra_buf = malloca (path_max);
|
||||
if (!extra_buf)
|
||||
{
|
||||
freea (buf);
|
||||
errno = ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
len = strlen (end);
|
||||
if ((long int) (n + len) >= path_max)
|
||||
{
|
||||
freea (buf);
|
||||
__set_errno (ENAMETOOLONG);
|
||||
goto error;
|
||||
}
|
||||
len = strlen (end);
|
||||
if ((long int) (n + len) >= path_max)
|
||||
{
|
||||
freea (buf);
|
||||
__set_errno (ENAMETOOLONG);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Careful here, end may be a pointer into extra_buf... */
|
||||
memmove (&extra_buf[n], end, len + 1);
|
||||
name = end = memcpy (extra_buf, buf, n);
|
||||
/* Careful here, end may be a pointer into extra_buf... */
|
||||
memmove (&extra_buf[n], end, len + 1);
|
||||
name = end = memcpy (extra_buf, buf, n);
|
||||
|
||||
if (buf[0] == '/')
|
||||
{
|
||||
dest = rpath + 1; /* It's an absolute symlink */
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/')
|
||||
*dest++ = '/';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Back up to previous component, ignore if at root
|
||||
already: */
|
||||
if (dest > rpath + 1)
|
||||
while ((--dest)[-1] != '/');
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
|
||||
&& *dest == '/')
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
else if (!S_ISDIR (st.st_mode) && *end != '\0')
|
||||
{
|
||||
__set_errno (ENOTDIR);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (buf[0] == '/')
|
||||
{
|
||||
dest = rpath + 1; /* It's an absolute symlink */
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && buf[1] == '/')
|
||||
*dest++ = '/';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Back up to previous component, ignore if at root
|
||||
already: */
|
||||
if (dest > rpath + 1)
|
||||
while ((--dest)[-1] != '/');
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
|
||||
&& *dest == '/')
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
else if (!S_ISDIR (st.st_mode) && *end != '\0')
|
||||
{
|
||||
__set_errno (ENOTDIR);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dest > rpath + 1 && dest[-1] == '/')
|
||||
--dest;
|
||||
|
|
1114
lib/config.charset
Executable file → Normal file
1114
lib/config.charset
Executable file → Normal file
File diff suppressed because it is too large
Load diff
|
@ -36,33 +36,33 @@ rpl_duplocale (locale_t locale)
|
|||
if (locale == LC_GLOBAL_LOCALE)
|
||||
{
|
||||
/* Create a copy of the locale by fetching the name of each locale
|
||||
category, starting with LC_CTYPE. */
|
||||
static struct { int cat; int mask; } categories[] =
|
||||
{
|
||||
{ LC_NUMERIC, LC_NUMERIC_MASK },
|
||||
{ LC_TIME, LC_TIME_MASK },
|
||||
{ LC_COLLATE, LC_COLLATE_MASK },
|
||||
{ LC_MONETARY, LC_MONETARY_MASK },
|
||||
{ LC_MESSAGES, LC_MESSAGES_MASK }
|
||||
category, starting with LC_CTYPE. */
|
||||
static struct { int cat; int mask; } const categories[] =
|
||||
{
|
||||
{ LC_NUMERIC, LC_NUMERIC_MASK },
|
||||
{ LC_TIME, LC_TIME_MASK },
|
||||
{ LC_COLLATE, LC_COLLATE_MASK },
|
||||
{ LC_MONETARY, LC_MONETARY_MASK },
|
||||
{ LC_MESSAGES, LC_MESSAGES_MASK }
|
||||
#ifdef LC_PAPER
|
||||
, { LC_PAPER, LC_PAPER_MASK }
|
||||
, { LC_PAPER, LC_PAPER_MASK }
|
||||
#endif
|
||||
#ifdef LC_NAME
|
||||
, { LC_NAME, LC_NAME_MASK }
|
||||
, { LC_NAME, LC_NAME_MASK }
|
||||
#endif
|
||||
#ifdef LC_ADDRESS
|
||||
, { LC_ADDRESS, LC_ADDRESS_MASK }
|
||||
, { LC_ADDRESS, LC_ADDRESS_MASK }
|
||||
#endif
|
||||
#ifdef LC_TELEPHONE
|
||||
, { LC_TELEPHONE, LC_TELEPHONE_MASK }
|
||||
, { LC_TELEPHONE, LC_TELEPHONE_MASK }
|
||||
#endif
|
||||
#ifdef LC_MEASUREMENT
|
||||
, { LC_MEASUREMENT, LC_MEASUREMENT_MASK }
|
||||
, { LC_MEASUREMENT, LC_MEASUREMENT_MASK }
|
||||
#endif
|
||||
#ifdef LC_IDENTIFICATION
|
||||
, { LC_IDENTIFICATION, LC_IDENTIFICATION_MASK }
|
||||
, { LC_IDENTIFICATION, LC_IDENTIFICATION_MASK }
|
||||
#endif
|
||||
};
|
||||
};
|
||||
const char *base_name;
|
||||
locale_t base_copy;
|
||||
unsigned int i;
|
||||
|
@ -70,28 +70,28 @@ rpl_duplocale (locale_t locale)
|
|||
base_name = setlocale (LC_CTYPE, NULL);
|
||||
base_copy = newlocale (LC_ALL_MASK, base_name, NULL);
|
||||
if (base_copy == NULL)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < SIZEOF (categories); i++)
|
||||
{
|
||||
int category = categories[i].cat;
|
||||
int category_mask = categories[i].mask;
|
||||
const char *name = setlocale (category, NULL);
|
||||
if (strcmp (name, base_name) != 0)
|
||||
{
|
||||
locale_t copy = newlocale (category_mask, name, base_copy);
|
||||
if (copy == NULL)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
freelocale (base_copy);
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
/* No need to call freelocale (base_copy) if copy != base_copy;
|
||||
the newlocale function already takes care of doing it. */
|
||||
base_copy = copy;
|
||||
}
|
||||
}
|
||||
{
|
||||
int category = categories[i].cat;
|
||||
int category_mask = categories[i].mask;
|
||||
const char *name = setlocale (category, NULL);
|
||||
if (strcmp (name, base_name) != 0)
|
||||
{
|
||||
locale_t copy = newlocale (category_mask, name, base_copy);
|
||||
if (copy == NULL)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
freelocale (base_copy);
|
||||
errno = saved_errno;
|
||||
return NULL;
|
||||
}
|
||||
/* No need to call freelocale (base_copy) if copy != base_copy;
|
||||
the newlocale function already takes care of doing it. */
|
||||
base_copy = copy;
|
||||
}
|
||||
}
|
||||
|
||||
return base_copy;
|
||||
}
|
||||
|
|
36
lib/flock.c
36
lib/flock.c
|
@ -130,27 +130,27 @@ flock (int fd, int operation)
|
|||
{
|
||||
DWORD err = GetLastError ();
|
||||
switch (err)
|
||||
{
|
||||
/* This means someone else is holding a lock. */
|
||||
case ERROR_LOCK_VIOLATION:
|
||||
errno = EAGAIN;
|
||||
break;
|
||||
{
|
||||
/* This means someone else is holding a lock. */
|
||||
case ERROR_LOCK_VIOLATION:
|
||||
errno = EAGAIN;
|
||||
break;
|
||||
|
||||
/* Out of memory. */
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
/* Out of memory. */
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
|
||||
case ERROR_BAD_COMMAND:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
case ERROR_BAD_COMMAND:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
|
||||
/* Unlikely to be other errors, but at least don't lose the
|
||||
* error code.
|
||||
*/
|
||||
default:
|
||||
errno = err;
|
||||
}
|
||||
/* Unlikely to be other errors, but at least don't lose the
|
||||
* error code.
|
||||
*/
|
||||
default:
|
||||
errno = err;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -65,12 +65,12 @@ full_rw (int fd, const void *buf, size_t count)
|
|||
{
|
||||
size_t n_rw = safe_rw (fd, ptr, count);
|
||||
if (n_rw == (size_t) -1)
|
||||
break;
|
||||
break;
|
||||
if (n_rw == 0)
|
||||
{
|
||||
errno = ZERO_BYTE_TRANSFER_ERRNO;
|
||||
break;
|
||||
}
|
||||
{
|
||||
errno = ZERO_BYTE_TRANSFER_ERRNO;
|
||||
break;
|
||||
}
|
||||
total += n_rw;
|
||||
ptr += n_rw;
|
||||
count -= n_rw;
|
||||
|
|
|
@ -140,8 +140,8 @@ inline
|
|||
#endif
|
||||
static const char *
|
||||
pgettext_aux (const char *domain,
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
int category)
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
int category)
|
||||
{
|
||||
const char *translation = dcgettext (domain, msg_ctxt_id, category);
|
||||
if (translation == msg_ctxt_id)
|
||||
|
@ -159,9 +159,9 @@ inline
|
|||
#endif
|
||||
static const char *
|
||||
npgettext_aux (const char *domain,
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
{
|
||||
const char *translation =
|
||||
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||
|
@ -199,8 +199,8 @@ inline
|
|||
#endif
|
||||
static const char *
|
||||
dcpgettext_expr (const char *domain,
|
||||
const char *msgctxt, const char *msgid,
|
||||
int category)
|
||||
const char *msgctxt, const char *msgid,
|
||||
int category)
|
||||
{
|
||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||
size_t msgid_len = strlen (msgid) + 1;
|
||||
|
@ -222,10 +222,10 @@ dcpgettext_expr (const char *domain,
|
|||
translation = dcgettext (domain, msg_ctxt_id, category);
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
if (msg_ctxt_id != buf)
|
||||
free (msg_ctxt_id);
|
||||
free (msg_ctxt_id);
|
||||
#endif
|
||||
if (translation != msg_ctxt_id)
|
||||
return translation;
|
||||
return translation;
|
||||
}
|
||||
return msgid;
|
||||
}
|
||||
|
@ -244,9 +244,9 @@ inline
|
|||
#endif
|
||||
static const char *
|
||||
dcnpgettext_expr (const char *domain,
|
||||
const char *msgctxt, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
const char *msgctxt, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
{
|
||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||
size_t msgid_len = strlen (msgid) + 1;
|
||||
|
@ -268,10 +268,10 @@ dcnpgettext_expr (const char *domain,
|
|||
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
if (msg_ctxt_id != buf)
|
||||
free (msg_ctxt_id);
|
||||
free (msg_ctxt_id);
|
||||
#endif
|
||||
if (!(translation == msg_ctxt_id || translation == msgid_plural))
|
||||
return translation;
|
||||
return translation;
|
||||
}
|
||||
return (n == 1 ? msgid : msgid_plural);
|
||||
}
|
||||
|
|
518
lib/iconv.c
518
lib/iconv.c
|
@ -59,25 +59,25 @@ utf16be_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n)
|
|||
{
|
||||
ucs4_t wc = (s[0] << 8) + s[1];
|
||||
if (wc >= 0xd800 && wc < 0xdc00)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
ucs4_t wc2 = (s[2] << 8) + s[3];
|
||||
if (!(wc2 >= 0xdc00 && wc2 < 0xe000))
|
||||
return RET_ILSEQ;
|
||||
*pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
ucs4_t wc2 = (s[2] << 8) + s[3];
|
||||
if (!(wc2 >= 0xdc00 && wc2 < 0xe000))
|
||||
return RET_ILSEQ;
|
||||
*pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
else if (wc >= 0xdc00 && wc < 0xe000)
|
||||
{
|
||||
return RET_ILSEQ;
|
||||
}
|
||||
{
|
||||
return RET_ILSEQ;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pwc = wc;
|
||||
return 2;
|
||||
}
|
||||
{
|
||||
*pwc = wc;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return RET_TOOFEW;
|
||||
}
|
||||
|
@ -88,31 +88,31 @@ utf16be_wctomb (unsigned char *r, ucs4_t wc, size_t n)
|
|||
if (!(wc >= 0xd800 && wc < 0xe000))
|
||||
{
|
||||
if (wc < 0x10000)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
r[0] = (unsigned char) (wc >> 8);
|
||||
r[1] = (unsigned char) wc;
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
r[0] = (unsigned char) (wc >> 8);
|
||||
r[1] = (unsigned char) wc;
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
else if (wc < 0x110000)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10);
|
||||
ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff);
|
||||
r[0] = (unsigned char) (wc1 >> 8);
|
||||
r[1] = (unsigned char) wc1;
|
||||
r[2] = (unsigned char) (wc2 >> 8);
|
||||
r[3] = (unsigned char) wc2;
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10);
|
||||
ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff);
|
||||
r[0] = (unsigned char) (wc1 >> 8);
|
||||
r[1] = (unsigned char) wc1;
|
||||
r[2] = (unsigned char) (wc2 >> 8);
|
||||
r[3] = (unsigned char) wc2;
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
}
|
||||
return RET_ILUNI;
|
||||
}
|
||||
|
@ -130,25 +130,25 @@ utf16le_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n)
|
|||
{
|
||||
ucs4_t wc = s[0] + (s[1] << 8);
|
||||
if (wc >= 0xd800 && wc < 0xdc00)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
ucs4_t wc2 = s[2] + (s[3] << 8);
|
||||
if (!(wc2 >= 0xdc00 && wc2 < 0xe000))
|
||||
return RET_ILSEQ;
|
||||
*pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
ucs4_t wc2 = s[2] + (s[3] << 8);
|
||||
if (!(wc2 >= 0xdc00 && wc2 < 0xe000))
|
||||
return RET_ILSEQ;
|
||||
*pwc = 0x10000 + ((wc - 0xd800) << 10) + (wc2 - 0xdc00);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
else if (wc >= 0xdc00 && wc < 0xe000)
|
||||
{
|
||||
return RET_ILSEQ;
|
||||
}
|
||||
{
|
||||
return RET_ILSEQ;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pwc = wc;
|
||||
return 2;
|
||||
}
|
||||
{
|
||||
*pwc = wc;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
return RET_TOOFEW;
|
||||
}
|
||||
|
@ -159,31 +159,31 @@ utf16le_wctomb (unsigned char *r, ucs4_t wc, size_t n)
|
|||
if (!(wc >= 0xd800 && wc < 0xe000))
|
||||
{
|
||||
if (wc < 0x10000)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
r[0] = (unsigned char) wc;
|
||||
r[1] = (unsigned char) (wc >> 8);
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
r[0] = (unsigned char) wc;
|
||||
r[1] = (unsigned char) (wc >> 8);
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
else if (wc < 0x110000)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10);
|
||||
ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff);
|
||||
r[0] = (unsigned char) wc1;
|
||||
r[1] = (unsigned char) (wc1 >> 8);
|
||||
r[2] = (unsigned char) wc2;
|
||||
r[3] = (unsigned char) (wc2 >> 8);
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
ucs4_t wc1 = 0xd800 + ((wc - 0x10000) >> 10);
|
||||
ucs4_t wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff);
|
||||
r[0] = (unsigned char) wc1;
|
||||
r[1] = (unsigned char) (wc1 >> 8);
|
||||
r[2] = (unsigned char) wc2;
|
||||
r[3] = (unsigned char) (wc2 >> 8);
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
}
|
||||
return RET_ILUNI;
|
||||
}
|
||||
|
@ -201,12 +201,12 @@ utf32be_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n)
|
|||
{
|
||||
ucs4_t wc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
|
||||
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
|
||||
{
|
||||
*pwc = wc;
|
||||
return 4;
|
||||
}
|
||||
{
|
||||
*pwc = wc;
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return RET_ILSEQ;
|
||||
return RET_ILSEQ;
|
||||
}
|
||||
return RET_TOOFEW;
|
||||
}
|
||||
|
@ -217,15 +217,15 @@ utf32be_wctomb (unsigned char *r, ucs4_t wc, size_t n)
|
|||
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
r[0] = 0;
|
||||
r[1] = (unsigned char) (wc >> 16);
|
||||
r[2] = (unsigned char) (wc >> 8);
|
||||
r[3] = (unsigned char) wc;
|
||||
return 4;
|
||||
}
|
||||
{
|
||||
r[0] = 0;
|
||||
r[1] = (unsigned char) (wc >> 16);
|
||||
r[2] = (unsigned char) (wc >> 8);
|
||||
r[3] = (unsigned char) wc;
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
return RET_ILUNI;
|
||||
}
|
||||
|
@ -243,12 +243,12 @@ utf32le_mbtowc (ucs4_t *pwc, const unsigned char *s, size_t n)
|
|||
{
|
||||
ucs4_t wc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24);
|
||||
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
|
||||
{
|
||||
*pwc = wc;
|
||||
return 4;
|
||||
}
|
||||
{
|
||||
*pwc = wc;
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return RET_ILSEQ;
|
||||
return RET_ILSEQ;
|
||||
}
|
||||
return RET_TOOFEW;
|
||||
}
|
||||
|
@ -259,15 +259,15 @@ utf32le_wctomb (unsigned char *r, ucs4_t wc, size_t n)
|
|||
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000))
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
r[0] = (unsigned char) wc;
|
||||
r[1] = (unsigned char) (wc >> 8);
|
||||
r[2] = (unsigned char) (wc >> 16);
|
||||
r[3] = 0;
|
||||
return 4;
|
||||
{
|
||||
r[0] = (unsigned char) wc;
|
||||
r[1] = (unsigned char) (wc >> 8);
|
||||
r[2] = (unsigned char) (wc >> 16);
|
||||
r[3] = 0;
|
||||
return 4;
|
||||
}
|
||||
else
|
||||
return RET_TOOSMALL;
|
||||
return RET_TOOSMALL;
|
||||
}
|
||||
return RET_ILUNI;
|
||||
}
|
||||
|
@ -276,173 +276,173 @@ utf32le_wctomb (unsigned char *r, ucs4_t wc, size_t n)
|
|||
|
||||
size_t
|
||||
rpl_iconv (iconv_t cd,
|
||||
ICONV_CONST char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft)
|
||||
ICONV_CONST char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft)
|
||||
#undef iconv
|
||||
{
|
||||
#if REPLACE_ICONV_UTF
|
||||
switch ((uintptr_t) cd)
|
||||
{
|
||||
{
|
||||
int (*xxx_wctomb) (unsigned char *, ucs4_t, size_t);
|
||||
int (*xxx_wctomb) (unsigned char *, ucs4_t, size_t);
|
||||
|
||||
case (uintptr_t) _ICONV_UTF8_UTF16BE:
|
||||
xxx_wctomb = utf16be_wctomb;
|
||||
goto loop_from_utf8;
|
||||
case (uintptr_t) _ICONV_UTF8_UTF16LE:
|
||||
xxx_wctomb = utf16le_wctomb;
|
||||
goto loop_from_utf8;
|
||||
case (uintptr_t) _ICONV_UTF8_UTF32BE:
|
||||
xxx_wctomb = utf32be_wctomb;
|
||||
goto loop_from_utf8;
|
||||
case (uintptr_t) _ICONV_UTF8_UTF32LE:
|
||||
xxx_wctomb = utf32le_wctomb;
|
||||
goto loop_from_utf8;
|
||||
case (uintptr_t) _ICONV_UTF8_UTF16BE:
|
||||
xxx_wctomb = utf16be_wctomb;
|
||||
goto loop_from_utf8;
|
||||
case (uintptr_t) _ICONV_UTF8_UTF16LE:
|
||||
xxx_wctomb = utf16le_wctomb;
|
||||
goto loop_from_utf8;
|
||||
case (uintptr_t) _ICONV_UTF8_UTF32BE:
|
||||
xxx_wctomb = utf32be_wctomb;
|
||||
goto loop_from_utf8;
|
||||
case (uintptr_t) _ICONV_UTF8_UTF32LE:
|
||||
xxx_wctomb = utf32le_wctomb;
|
||||
goto loop_from_utf8;
|
||||
|
||||
loop_from_utf8:
|
||||
if (inbuf == NULL || *inbuf == NULL)
|
||||
return 0;
|
||||
{
|
||||
ICONV_CONST char *inptr = *inbuf;
|
||||
size_t inleft = *inbytesleft;
|
||||
char *outptr = *outbuf;
|
||||
size_t outleft = *outbytesleft;
|
||||
size_t res = 0;
|
||||
while (inleft > 0)
|
||||
{
|
||||
ucs4_t uc;
|
||||
int m = u8_mbtoucr (&uc, (const uint8_t *) inptr, inleft);
|
||||
if (m <= 0)
|
||||
{
|
||||
if (m == -1)
|
||||
{
|
||||
errno = EILSEQ;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
if (m == -2)
|
||||
{
|
||||
errno = EINVAL;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = xxx_wctomb ((uint8_t *) outptr, uc, outleft);
|
||||
if (n < 0)
|
||||
{
|
||||
if (n == RET_ILUNI)
|
||||
{
|
||||
errno = EILSEQ;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
if (n == RET_TOOSMALL)
|
||||
{
|
||||
errno = E2BIG;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
inptr += m;
|
||||
inleft -= m;
|
||||
outptr += n;
|
||||
outleft -= n;
|
||||
}
|
||||
}
|
||||
}
|
||||
*inbuf = inptr;
|
||||
*inbytesleft = inleft;
|
||||
*outbuf = outptr;
|
||||
*outbytesleft = outleft;
|
||||
return res;
|
||||
}
|
||||
if (inbuf == NULL || *inbuf == NULL)
|
||||
return 0;
|
||||
{
|
||||
ICONV_CONST char *inptr = *inbuf;
|
||||
size_t inleft = *inbytesleft;
|
||||
char *outptr = *outbuf;
|
||||
size_t outleft = *outbytesleft;
|
||||
size_t res = 0;
|
||||
while (inleft > 0)
|
||||
{
|
||||
ucs4_t uc;
|
||||
int m = u8_mbtoucr (&uc, (const uint8_t *) inptr, inleft);
|
||||
if (m <= 0)
|
||||
{
|
||||
if (m == -1)
|
||||
{
|
||||
errno = EILSEQ;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
if (m == -2)
|
||||
{
|
||||
errno = EINVAL;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = xxx_wctomb ((uint8_t *) outptr, uc, outleft);
|
||||
if (n < 0)
|
||||
{
|
||||
if (n == RET_ILUNI)
|
||||
{
|
||||
errno = EILSEQ;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
if (n == RET_TOOSMALL)
|
||||
{
|
||||
errno = E2BIG;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
inptr += m;
|
||||
inleft -= m;
|
||||
outptr += n;
|
||||
outleft -= n;
|
||||
}
|
||||
}
|
||||
}
|
||||
*inbuf = inptr;
|
||||
*inbytesleft = inleft;
|
||||
*outbuf = outptr;
|
||||
*outbytesleft = outleft;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int (*xxx_mbtowc) (ucs4_t *, const unsigned char *, size_t);
|
||||
int (*xxx_mbtowc) (ucs4_t *, const unsigned char *, size_t);
|
||||
|
||||
case (uintptr_t) _ICONV_UTF16BE_UTF8:
|
||||
xxx_mbtowc = utf16be_mbtowc;
|
||||
goto loop_to_utf8;
|
||||
case (uintptr_t) _ICONV_UTF16LE_UTF8:
|
||||
xxx_mbtowc = utf16le_mbtowc;
|
||||
goto loop_to_utf8;
|
||||
case (uintptr_t) _ICONV_UTF32BE_UTF8:
|
||||
xxx_mbtowc = utf32be_mbtowc;
|
||||
goto loop_to_utf8;
|
||||
case (uintptr_t) _ICONV_UTF32LE_UTF8:
|
||||
xxx_mbtowc = utf32le_mbtowc;
|
||||
goto loop_to_utf8;
|
||||
case (uintptr_t) _ICONV_UTF16BE_UTF8:
|
||||
xxx_mbtowc = utf16be_mbtowc;
|
||||
goto loop_to_utf8;
|
||||
case (uintptr_t) _ICONV_UTF16LE_UTF8:
|
||||
xxx_mbtowc = utf16le_mbtowc;
|
||||
goto loop_to_utf8;
|
||||
case (uintptr_t) _ICONV_UTF32BE_UTF8:
|
||||
xxx_mbtowc = utf32be_mbtowc;
|
||||
goto loop_to_utf8;
|
||||
case (uintptr_t) _ICONV_UTF32LE_UTF8:
|
||||
xxx_mbtowc = utf32le_mbtowc;
|
||||
goto loop_to_utf8;
|
||||
|
||||
loop_to_utf8:
|
||||
if (inbuf == NULL || *inbuf == NULL)
|
||||
return 0;
|
||||
{
|
||||
ICONV_CONST char *inptr = *inbuf;
|
||||
size_t inleft = *inbytesleft;
|
||||
char *outptr = *outbuf;
|
||||
size_t outleft = *outbytesleft;
|
||||
size_t res = 0;
|
||||
while (inleft > 0)
|
||||
{
|
||||
ucs4_t uc;
|
||||
int m = xxx_mbtowc (&uc, (const uint8_t *) inptr, inleft);
|
||||
if (m <= 0)
|
||||
{
|
||||
if (m == RET_ILSEQ)
|
||||
{
|
||||
errno = EILSEQ;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
if (m == RET_TOOFEW)
|
||||
{
|
||||
errno = EINVAL;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = u8_uctomb ((uint8_t *) outptr, uc, outleft);
|
||||
if (n < 0)
|
||||
{
|
||||
if (n == -1)
|
||||
{
|
||||
errno = EILSEQ;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
if (n == -2)
|
||||
{
|
||||
errno = E2BIG;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
inptr += m;
|
||||
inleft -= m;
|
||||
outptr += n;
|
||||
outleft -= n;
|
||||
}
|
||||
}
|
||||
}
|
||||
*inbuf = inptr;
|
||||
*inbytesleft = inleft;
|
||||
*outbuf = outptr;
|
||||
*outbytesleft = outleft;
|
||||
return res;
|
||||
}
|
||||
if (inbuf == NULL || *inbuf == NULL)
|
||||
return 0;
|
||||
{
|
||||
ICONV_CONST char *inptr = *inbuf;
|
||||
size_t inleft = *inbytesleft;
|
||||
char *outptr = *outbuf;
|
||||
size_t outleft = *outbytesleft;
|
||||
size_t res = 0;
|
||||
while (inleft > 0)
|
||||
{
|
||||
ucs4_t uc;
|
||||
int m = xxx_mbtowc (&uc, (const uint8_t *) inptr, inleft);
|
||||
if (m <= 0)
|
||||
{
|
||||
if (m == RET_ILSEQ)
|
||||
{
|
||||
errno = EILSEQ;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
if (m == RET_TOOFEW)
|
||||
{
|
||||
errno = EINVAL;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
int n = u8_uctomb ((uint8_t *) outptr, uc, outleft);
|
||||
if (n < 0)
|
||||
{
|
||||
if (n == -1)
|
||||
{
|
||||
errno = EILSEQ;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
if (n == -2)
|
||||
{
|
||||
errno = E2BIG;
|
||||
res = (size_t)(-1);
|
||||
break;
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
else
|
||||
{
|
||||
inptr += m;
|
||||
inleft -= m;
|
||||
outptr += n;
|
||||
outleft -= n;
|
||||
}
|
||||
}
|
||||
}
|
||||
*inbuf = inptr;
|
||||
*inbytesleft = inleft;
|
||||
*outbuf = outptr;
|
||||
*outbytesleft = outleft;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* A GNU-like <iconv.h>.
|
||||
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2009 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
|
||||
|
@ -28,6 +28,8 @@
|
|||
#ifndef _GL_ICONV_H
|
||||
#define _GL_ICONV_H
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -37,7 +39,8 @@ extern "C" {
|
|||
/* An iconv_open wrapper that supports the IANA standardized encoding names
|
||||
("ISO-8859-1" etc.) as far as possible. */
|
||||
# define iconv_open rpl_iconv_open
|
||||
extern iconv_t iconv_open (const char *tocode, const char *fromcode);
|
||||
extern iconv_t iconv_open (const char *tocode, const char *fromcode)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @REPLACE_ICONV_UTF@
|
||||
|
@ -56,8 +59,8 @@ extern iconv_t iconv_open (const char *tocode, const char *fromcode);
|
|||
#if @REPLACE_ICONV@
|
||||
# define iconv rpl_iconv
|
||||
extern size_t iconv (iconv_t cd,
|
||||
@ICONV_CONST@ char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft);
|
||||
@ICONV_CONST@ char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft);
|
||||
# define iconv_close rpl_iconv_close
|
||||
extern int iconv_close (iconv_t cd);
|
||||
#endif
|
||||
|
|
|
@ -67,33 +67,33 @@ rpl_iconv_open (const char *tocode, const char *fromcode)
|
|||
&& fromcode[3] == '-')
|
||||
{
|
||||
if (c_toupper (tocode[0]) == 'U'
|
||||
&& c_toupper (tocode[1]) == 'T'
|
||||
&& c_toupper (tocode[2]) == 'F'
|
||||
&& tocode[3] == '-')
|
||||
{
|
||||
if (strcmp (fromcode + 4, "8") == 0)
|
||||
{
|
||||
if (c_strcasecmp (tocode + 4, "16BE") == 0)
|
||||
return _ICONV_UTF8_UTF16BE;
|
||||
if (c_strcasecmp (tocode + 4, "16LE") == 0)
|
||||
return _ICONV_UTF8_UTF16LE;
|
||||
if (c_strcasecmp (tocode + 4, "32BE") == 0)
|
||||
return _ICONV_UTF8_UTF32BE;
|
||||
if (c_strcasecmp (tocode + 4, "32LE") == 0)
|
||||
return _ICONV_UTF8_UTF32LE;
|
||||
}
|
||||
else if (strcmp (tocode + 4, "8") == 0)
|
||||
{
|
||||
if (c_strcasecmp (fromcode + 4, "16BE") == 0)
|
||||
return _ICONV_UTF16BE_UTF8;
|
||||
if (c_strcasecmp (fromcode + 4, "16LE") == 0)
|
||||
return _ICONV_UTF16LE_UTF8;
|
||||
if (c_strcasecmp (fromcode + 4, "32BE") == 0)
|
||||
return _ICONV_UTF32BE_UTF8;
|
||||
if (c_strcasecmp (fromcode + 4, "32LE") == 0)
|
||||
return _ICONV_UTF32LE_UTF8;
|
||||
}
|
||||
}
|
||||
&& c_toupper (tocode[1]) == 'T'
|
||||
&& c_toupper (tocode[2]) == 'F'
|
||||
&& tocode[3] == '-')
|
||||
{
|
||||
if (strcmp (fromcode + 4, "8") == 0)
|
||||
{
|
||||
if (c_strcasecmp (tocode + 4, "16BE") == 0)
|
||||
return _ICONV_UTF8_UTF16BE;
|
||||
if (c_strcasecmp (tocode + 4, "16LE") == 0)
|
||||
return _ICONV_UTF8_UTF16LE;
|
||||
if (c_strcasecmp (tocode + 4, "32BE") == 0)
|
||||
return _ICONV_UTF8_UTF32BE;
|
||||
if (c_strcasecmp (tocode + 4, "32LE") == 0)
|
||||
return _ICONV_UTF8_UTF32LE;
|
||||
}
|
||||
else if (strcmp (tocode + 4, "8") == 0)
|
||||
{
|
||||
if (c_strcasecmp (fromcode + 4, "16BE") == 0)
|
||||
return _ICONV_UTF16BE_UTF8;
|
||||
if (c_strcasecmp (fromcode + 4, "16LE") == 0)
|
||||
return _ICONV_UTF16LE_UTF8;
|
||||
if (c_strcasecmp (fromcode + 4, "32BE") == 0)
|
||||
return _ICONV_UTF32BE_UTF8;
|
||||
if (c_strcasecmp (fromcode + 4, "32LE") == 0)
|
||||
return _ICONV_UTF32LE_UTF8;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -116,20 +116,20 @@ rpl_iconv_open (const char *tocode, const char *fromcode)
|
|||
|
||||
/* Convert the encodings to upper case, because
|
||||
1. in the arguments of iconv_open() on AIX, HP-UX, and OSF/1 the case
|
||||
matters,
|
||||
matters,
|
||||
2. it makes searching in the table faster. */
|
||||
{
|
||||
const char *p = fromcode;
|
||||
char *q = fromcode_upper;
|
||||
while ((*q = c_toupper (*p)) != '\0')
|
||||
{
|
||||
p++;
|
||||
q++;
|
||||
if (q == &fromcode_upper[SIZEOF (fromcode_upper)])
|
||||
{
|
||||
errno = EINVAL;
|
||||
return (iconv_t)(-1);
|
||||
}
|
||||
p++;
|
||||
q++;
|
||||
if (q == &fromcode_upper[SIZEOF (fromcode_upper)])
|
||||
{
|
||||
errno = EINVAL;
|
||||
return (iconv_t)(-1);
|
||||
}
|
||||
}
|
||||
fromcode_upper_end = q;
|
||||
}
|
||||
|
@ -139,13 +139,13 @@ rpl_iconv_open (const char *tocode, const char *fromcode)
|
|||
char *q = tocode_upper;
|
||||
while ((*q = c_toupper (*p)) != '\0')
|
||||
{
|
||||
p++;
|
||||
q++;
|
||||
if (q == &tocode_upper[SIZEOF (tocode_upper)])
|
||||
{
|
||||
errno = EINVAL;
|
||||
return (iconv_t)(-1);
|
||||
}
|
||||
p++;
|
||||
q++;
|
||||
if (q == &tocode_upper[SIZEOF (tocode_upper)])
|
||||
{
|
||||
errno = EINVAL;
|
||||
return (iconv_t)(-1);
|
||||
}
|
||||
}
|
||||
tocode_upper_end = q;
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ extern "C" {
|
|||
/* Handling of unconvertible characters. */
|
||||
enum iconv_ilseq_handler
|
||||
{
|
||||
iconveh_error, /* return and set errno = EILSEQ */
|
||||
iconveh_question_mark, /* use one '?' per unconvertible character */
|
||||
iconveh_escape_sequence /* use escape sequence \uxxxx or \Uxxxxxxxx */
|
||||
iconveh_error, /* return and set errno = EILSEQ */
|
||||
iconveh_question_mark, /* use one '?' per unconvertible character */
|
||||
iconveh_escape_sequence /* use escape sequence \uxxxx or \Uxxxxxxxx */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -59,15 +59,15 @@ static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t si
|
|||
|
||||
/* char *
|
||||
* inet_ntop(af, src, dst, size)
|
||||
* convert a network format address to presentation format.
|
||||
* convert a network format address to presentation format.
|
||||
* return:
|
||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
const char *
|
||||
inet_ntop (int af, const void *restrict src,
|
||||
char *restrict dst, socklen_t cnt)
|
||||
char *restrict dst, socklen_t cnt)
|
||||
{
|
||||
switch (af)
|
||||
{
|
||||
|
@ -90,14 +90,14 @@ inet_ntop (int af, const void *restrict src,
|
|||
|
||||
/* const char *
|
||||
* inet_ntop4(src, dst, size)
|
||||
* format an IPv4 address
|
||||
* format an IPv4 address
|
||||
* return:
|
||||
* `dst' (as a const)
|
||||
* `dst' (as a const)
|
||||
* notes:
|
||||
* (1) uses no statics
|
||||
* (2) takes a u_char* not an in_addr as input
|
||||
* (1) uses no statics
|
||||
* (2) takes a u_char* not an in_addr as input
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
|
||||
|
@ -122,9 +122,9 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
|
|||
|
||||
/* const char *
|
||||
* inet_ntop6(src, dst, size)
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
|
||||
|
@ -157,26 +157,26 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
|
|||
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
|
||||
{
|
||||
if (words[i] == 0)
|
||||
{
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
}
|
||||
{
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
best = cur;
|
||||
}
|
||||
if (best.base != -1 && best.len < 2)
|
||||
best.base = -1;
|
||||
|
@ -189,28 +189,28 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
|
|||
{
|
||||
/* Are we inside the best run of 0x00's? */
|
||||
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
|
||||
{
|
||||
if (i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
{
|
||||
if (i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
/* Are we following an initial run of 0x00s or any real hex? */
|
||||
if (i != 0)
|
||||
*tp++ = ':';
|
||||
*tp++ = ':';
|
||||
/* Is this address an encapsulated IPv4? */
|
||||
if (i == 6 && best.base == 0 &&
|
||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||
{
|
||||
if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
|
||||
return (NULL);
|
||||
tp += strlen (tp);
|
||||
break;
|
||||
}
|
||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||
{
|
||||
if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
|
||||
return (NULL);
|
||||
tp += strlen (tp);
|
||||
break;
|
||||
}
|
||||
{
|
||||
int len = sprintf (tp, "%x", words[i]);
|
||||
if (len < 0)
|
||||
return NULL;
|
||||
tp += len;
|
||||
int len = sprintf (tp, "%x", words[i]);
|
||||
if (len < 0)
|
||||
return NULL;
|
||||
tp += len;
|
||||
}
|
||||
}
|
||||
/* Was it a trailing run of 0x00's? */
|
||||
|
|
158
lib/inet_pton.c
158
lib/inet_pton.c
|
@ -57,14 +57,14 @@ static int inet_pton6 (const char *src, unsigned char *dst);
|
|||
|
||||
/* int
|
||||
* inet_pton(af, src, dst)
|
||||
* convert from presentation format (which usually means ASCII printable)
|
||||
* to network format (which is usually some kind of binary format).
|
||||
* convert from presentation format (which usually means ASCII printable)
|
||||
* to network format (which is usually some kind of binary format).
|
||||
* return:
|
||||
* 1 if the address was valid for the specified address family
|
||||
* 0 if the address wasn't valid (`dst' is untouched in this case)
|
||||
* -1 if some other error occurred (`dst' is untouched in this case, too)
|
||||
* 1 if the address was valid for the specified address family
|
||||
* 0 if the address wasn't valid (`dst' is untouched in this case)
|
||||
* -1 if some other error occurred (`dst' is untouched in this case, too)
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
int
|
||||
inet_pton (int af, const char *restrict src, void *restrict dst)
|
||||
|
@ -88,14 +88,14 @@ inet_pton (int af, const char *restrict src, void *restrict dst)
|
|||
|
||||
/* int
|
||||
* inet_pton4(src, dst)
|
||||
* like inet_aton() but without all the hexadecimal, octal (with the
|
||||
* exception of 0) and shorthand.
|
||||
* like inet_aton() but without all the hexadecimal, octal (with the
|
||||
* exception of 0) and shorthand.
|
||||
* return:
|
||||
* 1 if `src' is a valid dotted quad, else 0.
|
||||
* 1 if `src' is a valid dotted quad, else 0.
|
||||
* notice:
|
||||
* does not touch `dst' unless it's returning 1.
|
||||
* does not touch `dst' unless it's returning 1.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static int
|
||||
inet_pton4 (const char *restrict src, unsigned char *restrict dst)
|
||||
|
@ -110,30 +110,30 @@ inet_pton4 (const char *restrict src, unsigned char *restrict dst)
|
|||
{
|
||||
|
||||
if (ch >= '0' && ch <= '9')
|
||||
{
|
||||
unsigned new = *tp * 10 + (ch - '0');
|
||||
{
|
||||
unsigned new = *tp * 10 + (ch - '0');
|
||||
|
||||
if (saw_digit && *tp == 0)
|
||||
return (0);
|
||||
if (new > 255)
|
||||
return (0);
|
||||
*tp = new;
|
||||
if (!saw_digit)
|
||||
{
|
||||
if (++octets > 4)
|
||||
return (0);
|
||||
saw_digit = 1;
|
||||
}
|
||||
}
|
||||
if (saw_digit && *tp == 0)
|
||||
return (0);
|
||||
if (new > 255)
|
||||
return (0);
|
||||
*tp = new;
|
||||
if (!saw_digit)
|
||||
{
|
||||
if (++octets > 4)
|
||||
return (0);
|
||||
saw_digit = 1;
|
||||
}
|
||||
}
|
||||
else if (ch == '.' && saw_digit)
|
||||
{
|
||||
if (octets == 4)
|
||||
return (0);
|
||||
*++tp = 0;
|
||||
saw_digit = 0;
|
||||
}
|
||||
{
|
||||
if (octets == 4)
|
||||
return (0);
|
||||
*++tp = 0;
|
||||
saw_digit = 0;
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
return (0);
|
||||
}
|
||||
if (octets < 4)
|
||||
return (0);
|
||||
|
@ -145,16 +145,16 @@ inet_pton4 (const char *restrict src, unsigned char *restrict dst)
|
|||
|
||||
/* int
|
||||
* inet_pton6(src, dst)
|
||||
* convert presentation level address to network order binary form.
|
||||
* convert presentation level address to network order binary form.
|
||||
* return:
|
||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
||||
* notice:
|
||||
* (1) does not touch `dst' unless it's returning 1.
|
||||
* (2) :: in a full address is silently ignored.
|
||||
* (1) does not touch `dst' unless it's returning 1.
|
||||
* (2) :: in a full address is silently ignored.
|
||||
* credit:
|
||||
* inspired by Mark Andrews.
|
||||
* inspired by Mark Andrews.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static int
|
||||
inet_pton6 (const char *restrict src, unsigned char *restrict dst)
|
||||
|
@ -181,49 +181,49 @@ inet_pton6 (const char *restrict src, unsigned char *restrict dst)
|
|||
|
||||
pch = strchr (xdigits, ch);
|
||||
if (pch != NULL)
|
||||
{
|
||||
val <<= 4;
|
||||
val |= (pch - xdigits);
|
||||
if (val > 0xffff)
|
||||
return (0);
|
||||
saw_xdigit = 1;
|
||||
continue;
|
||||
}
|
||||
{
|
||||
val <<= 4;
|
||||
val |= (pch - xdigits);
|
||||
if (val > 0xffff)
|
||||
return (0);
|
||||
saw_xdigit = 1;
|
||||
continue;
|
||||
}
|
||||
if (ch == ':')
|
||||
{
|
||||
curtok = src;
|
||||
if (!saw_xdigit)
|
||||
{
|
||||
if (colonp)
|
||||
return (0);
|
||||
colonp = tp;
|
||||
continue;
|
||||
}
|
||||
else if (*src == '\0')
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (u_char) (val >> 8) & 0xff;
|
||||
*tp++ = (u_char) val & 0xff;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
continue;
|
||||
}
|
||||
{
|
||||
curtok = src;
|
||||
if (!saw_xdigit)
|
||||
{
|
||||
if (colonp)
|
||||
return (0);
|
||||
colonp = tp;
|
||||
continue;
|
||||
}
|
||||
else if (*src == '\0')
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (u_char) (val >> 8) & 0xff;
|
||||
*tp++ = (u_char) val & 0xff;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
continue;
|
||||
}
|
||||
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
|
||||
inet_pton4 (curtok, tp) > 0)
|
||||
{
|
||||
tp += NS_INADDRSZ;
|
||||
saw_xdigit = 0;
|
||||
break; /* '\0' was seen by inet_pton4(). */
|
||||
}
|
||||
inet_pton4 (curtok, tp) > 0)
|
||||
{
|
||||
tp += NS_INADDRSZ;
|
||||
saw_xdigit = 0;
|
||||
break; /* '\0' was seen by inet_pton4(). */
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
if (saw_xdigit)
|
||||
{
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
return (0);
|
||||
*tp++ = (u_char) (val >> 8) & 0xff;
|
||||
*tp++ = (u_char) val & 0xff;
|
||||
}
|
||||
|
@ -237,12 +237,12 @@ inet_pton6 (const char *restrict src, unsigned char *restrict dst)
|
|||
int i;
|
||||
|
||||
if (tp == endp)
|
||||
return (0);
|
||||
return (0);
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
endp[-i] = colonp[n - i];
|
||||
colonp[n - i] = 0;
|
||||
}
|
||||
{
|
||||
endp[-i] = colonp[n - i];
|
||||
colonp[n - i] = 0;
|
||||
}
|
||||
tp = endp;
|
||||
}
|
||||
if (tp != endp)
|
||||
|
|
|
@ -129,214 +129,214 @@ get_charset_aliases (void)
|
|||
char *file_name;
|
||||
|
||||
/* Make it possible to override the charset.alias location. This is
|
||||
necessary for running the testsuite before "make install". */
|
||||
necessary for running the testsuite before "make install". */
|
||||
dir = getenv ("CHARSETALIASDIR");
|
||||
if (dir == NULL || dir[0] == '\0')
|
||||
dir = relocate (LIBDIR);
|
||||
dir = relocate (LIBDIR);
|
||||
|
||||
/* Concatenate dir and base into freshly allocated file_name. */
|
||||
{
|
||||
size_t dir_len = strlen (dir);
|
||||
size_t base_len = strlen (base);
|
||||
int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
|
||||
file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
|
||||
if (file_name != NULL)
|
||||
{
|
||||
memcpy (file_name, dir, dir_len);
|
||||
if (add_slash)
|
||||
file_name[dir_len] = DIRECTORY_SEPARATOR;
|
||||
memcpy (file_name + dir_len + add_slash, base, base_len + 1);
|
||||
}
|
||||
size_t dir_len = strlen (dir);
|
||||
size_t base_len = strlen (base);
|
||||
int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
|
||||
file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
|
||||
if (file_name != NULL)
|
||||
{
|
||||
memcpy (file_name, dir, dir_len);
|
||||
if (add_slash)
|
||||
file_name[dir_len] = DIRECTORY_SEPARATOR;
|
||||
memcpy (file_name + dir_len + add_slash, base, base_len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_name == NULL)
|
||||
/* Out of memory. Treat the file as empty. */
|
||||
cp = "";
|
||||
/* Out of memory. Treat the file as empty. */
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
int fd;
|
||||
{
|
||||
int fd;
|
||||
|
||||
/* Open the file. Reject symbolic links on platforms that support
|
||||
O_NOFOLLOW. This is a security feature. Without it, an attacker
|
||||
could retrieve parts of the contents (namely, the tail of the
|
||||
first line that starts with "* ") of an arbitrary file by placing
|
||||
a symbolic link to that file under the name "charset.alias" in
|
||||
some writable directory and defining the environment variable
|
||||
CHARSETALIASDIR to point to that directory. */
|
||||
fd = open (file_name,
|
||||
O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
|
||||
if (fd < 0)
|
||||
/* File not found. Treat it as empty. */
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
FILE *fp;
|
||||
/* Open the file. Reject symbolic links on platforms that support
|
||||
O_NOFOLLOW. This is a security feature. Without it, an attacker
|
||||
could retrieve parts of the contents (namely, the tail of the
|
||||
first line that starts with "* ") of an arbitrary file by placing
|
||||
a symbolic link to that file under the name "charset.alias" in
|
||||
some writable directory and defining the environment variable
|
||||
CHARSETALIASDIR to point to that directory. */
|
||||
fd = open (file_name,
|
||||
O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
|
||||
if (fd < 0)
|
||||
/* File not found. Treat it as empty. */
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fdopen (fd, "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
/* Out of memory. Treat the file as empty. */
|
||||
close (fd);
|
||||
cp = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Parse the file's contents. */
|
||||
char *res_ptr = NULL;
|
||||
size_t res_size = 0;
|
||||
fp = fdopen (fd, "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
/* Out of memory. Treat the file as empty. */
|
||||
close (fd);
|
||||
cp = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Parse the file's contents. */
|
||||
char *res_ptr = NULL;
|
||||
size_t res_size = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int c;
|
||||
char buf1[50+1];
|
||||
char buf2[50+1];
|
||||
size_t l1, l2;
|
||||
char *old_res_ptr;
|
||||
for (;;)
|
||||
{
|
||||
int c;
|
||||
char buf1[50+1];
|
||||
char buf2[50+1];
|
||||
size_t l1, l2;
|
||||
char *old_res_ptr;
|
||||
|
||||
c = getc (fp);
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (c == '\n' || c == ' ' || c == '\t')
|
||||
continue;
|
||||
if (c == '#')
|
||||
{
|
||||
/* Skip comment, to end of line. */
|
||||
do
|
||||
c = getc (fp);
|
||||
while (!(c == EOF || c == '\n'));
|
||||
if (c == EOF)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
ungetc (c, fp);
|
||||
if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
|
||||
break;
|
||||
l1 = strlen (buf1);
|
||||
l2 = strlen (buf2);
|
||||
old_res_ptr = res_ptr;
|
||||
if (res_size == 0)
|
||||
{
|
||||
res_size = l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) malloc (res_size + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
res_size += l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) realloc (res_ptr, res_size + 1);
|
||||
}
|
||||
if (res_ptr == NULL)
|
||||
{
|
||||
/* Out of memory. */
|
||||
res_size = 0;
|
||||
if (old_res_ptr != NULL)
|
||||
free (old_res_ptr);
|
||||
break;
|
||||
}
|
||||
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
|
||||
strcpy (res_ptr + res_size - (l2 + 1), buf2);
|
||||
}
|
||||
fclose (fp);
|
||||
if (res_size == 0)
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
*(res_ptr + res_size) = '\0';
|
||||
cp = res_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
c = getc (fp);
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (c == '\n' || c == ' ' || c == '\t')
|
||||
continue;
|
||||
if (c == '#')
|
||||
{
|
||||
/* Skip comment, to end of line. */
|
||||
do
|
||||
c = getc (fp);
|
||||
while (!(c == EOF || c == '\n'));
|
||||
if (c == EOF)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
ungetc (c, fp);
|
||||
if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
|
||||
break;
|
||||
l1 = strlen (buf1);
|
||||
l2 = strlen (buf2);
|
||||
old_res_ptr = res_ptr;
|
||||
if (res_size == 0)
|
||||
{
|
||||
res_size = l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) malloc (res_size + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
res_size += l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) realloc (res_ptr, res_size + 1);
|
||||
}
|
||||
if (res_ptr == NULL)
|
||||
{
|
||||
/* Out of memory. */
|
||||
res_size = 0;
|
||||
if (old_res_ptr != NULL)
|
||||
free (old_res_ptr);
|
||||
break;
|
||||
}
|
||||
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
|
||||
strcpy (res_ptr + res_size - (l2 + 1), buf2);
|
||||
}
|
||||
fclose (fp);
|
||||
if (res_size == 0)
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
*(res_ptr + res_size) = '\0';
|
||||
cp = res_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (file_name);
|
||||
}
|
||||
free (file_name);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
# if defined DARWIN7
|
||||
/* To avoid the trouble of installing a file that is shared by many
|
||||
GNU packages -- many packaging systems have problems with this --,
|
||||
simply inline the aliases here. */
|
||||
GNU packages -- many packaging systems have problems with this --,
|
||||
simply inline the aliases here. */
|
||||
cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
|
||||
"ISO8859-2" "\0" "ISO-8859-2" "\0"
|
||||
"ISO8859-4" "\0" "ISO-8859-4" "\0"
|
||||
"ISO8859-5" "\0" "ISO-8859-5" "\0"
|
||||
"ISO8859-7" "\0" "ISO-8859-7" "\0"
|
||||
"ISO8859-9" "\0" "ISO-8859-9" "\0"
|
||||
"ISO8859-13" "\0" "ISO-8859-13" "\0"
|
||||
"ISO8859-15" "\0" "ISO-8859-15" "\0"
|
||||
"KOI8-R" "\0" "KOI8-R" "\0"
|
||||
"KOI8-U" "\0" "KOI8-U" "\0"
|
||||
"CP866" "\0" "CP866" "\0"
|
||||
"CP949" "\0" "CP949" "\0"
|
||||
"CP1131" "\0" "CP1131" "\0"
|
||||
"CP1251" "\0" "CP1251" "\0"
|
||||
"eucCN" "\0" "GB2312" "\0"
|
||||
"GB2312" "\0" "GB2312" "\0"
|
||||
"eucJP" "\0" "EUC-JP" "\0"
|
||||
"eucKR" "\0" "EUC-KR" "\0"
|
||||
"Big5" "\0" "BIG5" "\0"
|
||||
"Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
|
||||
"GBK" "\0" "GBK" "\0"
|
||||
"GB18030" "\0" "GB18030" "\0"
|
||||
"SJIS" "\0" "SHIFT_JIS" "\0"
|
||||
"ARMSCII-8" "\0" "ARMSCII-8" "\0"
|
||||
"PT154" "\0" "PT154" "\0"
|
||||
/*"ISCII-DEV" "\0" "?" "\0"*/
|
||||
"*" "\0" "UTF-8" "\0";
|
||||
"ISO8859-2" "\0" "ISO-8859-2" "\0"
|
||||
"ISO8859-4" "\0" "ISO-8859-4" "\0"
|
||||
"ISO8859-5" "\0" "ISO-8859-5" "\0"
|
||||
"ISO8859-7" "\0" "ISO-8859-7" "\0"
|
||||
"ISO8859-9" "\0" "ISO-8859-9" "\0"
|
||||
"ISO8859-13" "\0" "ISO-8859-13" "\0"
|
||||
"ISO8859-15" "\0" "ISO-8859-15" "\0"
|
||||
"KOI8-R" "\0" "KOI8-R" "\0"
|
||||
"KOI8-U" "\0" "KOI8-U" "\0"
|
||||
"CP866" "\0" "CP866" "\0"
|
||||
"CP949" "\0" "CP949" "\0"
|
||||
"CP1131" "\0" "CP1131" "\0"
|
||||
"CP1251" "\0" "CP1251" "\0"
|
||||
"eucCN" "\0" "GB2312" "\0"
|
||||
"GB2312" "\0" "GB2312" "\0"
|
||||
"eucJP" "\0" "EUC-JP" "\0"
|
||||
"eucKR" "\0" "EUC-KR" "\0"
|
||||
"Big5" "\0" "BIG5" "\0"
|
||||
"Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
|
||||
"GBK" "\0" "GBK" "\0"
|
||||
"GB18030" "\0" "GB18030" "\0"
|
||||
"SJIS" "\0" "SHIFT_JIS" "\0"
|
||||
"ARMSCII-8" "\0" "ARMSCII-8" "\0"
|
||||
"PT154" "\0" "PT154" "\0"
|
||||
/*"ISCII-DEV" "\0" "?" "\0"*/
|
||||
"*" "\0" "UTF-8" "\0";
|
||||
# endif
|
||||
|
||||
# if defined VMS
|
||||
/* To avoid the troubles of an extra file charset.alias_vms in the
|
||||
sources of many GNU packages, simply inline the aliases here. */
|
||||
sources of many GNU packages, simply inline the aliases here. */
|
||||
/* The list of encodings is taken from the OpenVMS 7.3-1 documentation
|
||||
"Compaq C Run-Time Library Reference Manual for OpenVMS systems"
|
||||
section 10.7 "Handling Different Character Sets". */
|
||||
"Compaq C Run-Time Library Reference Manual for OpenVMS systems"
|
||||
section 10.7 "Handling Different Character Sets". */
|
||||
cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
|
||||
"ISO8859-2" "\0" "ISO-8859-2" "\0"
|
||||
"ISO8859-5" "\0" "ISO-8859-5" "\0"
|
||||
"ISO8859-7" "\0" "ISO-8859-7" "\0"
|
||||
"ISO8859-8" "\0" "ISO-8859-8" "\0"
|
||||
"ISO8859-9" "\0" "ISO-8859-9" "\0"
|
||||
/* Japanese */
|
||||
"eucJP" "\0" "EUC-JP" "\0"
|
||||
"SJIS" "\0" "SHIFT_JIS" "\0"
|
||||
"DECKANJI" "\0" "DEC-KANJI" "\0"
|
||||
"SDECKANJI" "\0" "EUC-JP" "\0"
|
||||
/* Chinese */
|
||||
"eucTW" "\0" "EUC-TW" "\0"
|
||||
"DECHANYU" "\0" "DEC-HANYU" "\0"
|
||||
"DECHANZI" "\0" "GB2312" "\0"
|
||||
/* Korean */
|
||||
"DECKOREAN" "\0" "EUC-KR" "\0";
|
||||
"ISO8859-2" "\0" "ISO-8859-2" "\0"
|
||||
"ISO8859-5" "\0" "ISO-8859-5" "\0"
|
||||
"ISO8859-7" "\0" "ISO-8859-7" "\0"
|
||||
"ISO8859-8" "\0" "ISO-8859-8" "\0"
|
||||
"ISO8859-9" "\0" "ISO-8859-9" "\0"
|
||||
/* Japanese */
|
||||
"eucJP" "\0" "EUC-JP" "\0"
|
||||
"SJIS" "\0" "SHIFT_JIS" "\0"
|
||||
"DECKANJI" "\0" "DEC-KANJI" "\0"
|
||||
"SDECKANJI" "\0" "EUC-JP" "\0"
|
||||
/* Chinese */
|
||||
"eucTW" "\0" "EUC-TW" "\0"
|
||||
"DECHANYU" "\0" "DEC-HANYU" "\0"
|
||||
"DECHANZI" "\0" "GB2312" "\0"
|
||||
/* Korean */
|
||||
"DECKOREAN" "\0" "EUC-KR" "\0";
|
||||
# endif
|
||||
|
||||
# if defined WIN32_NATIVE || defined __CYGWIN__
|
||||
/* To avoid the troubles of installing a separate file in the same
|
||||
directory as the DLL and of retrieving the DLL's directory at
|
||||
runtime, simply inline the aliases here. */
|
||||
directory as the DLL and of retrieving the DLL's directory at
|
||||
runtime, simply inline the aliases here. */
|
||||
|
||||
cp = "CP936" "\0" "GBK" "\0"
|
||||
"CP1361" "\0" "JOHAB" "\0"
|
||||
"CP20127" "\0" "ASCII" "\0"
|
||||
"CP20866" "\0" "KOI8-R" "\0"
|
||||
"CP20936" "\0" "GB2312" "\0"
|
||||
"CP21866" "\0" "KOI8-RU" "\0"
|
||||
"CP28591" "\0" "ISO-8859-1" "\0"
|
||||
"CP28592" "\0" "ISO-8859-2" "\0"
|
||||
"CP28593" "\0" "ISO-8859-3" "\0"
|
||||
"CP28594" "\0" "ISO-8859-4" "\0"
|
||||
"CP28595" "\0" "ISO-8859-5" "\0"
|
||||
"CP28596" "\0" "ISO-8859-6" "\0"
|
||||
"CP28597" "\0" "ISO-8859-7" "\0"
|
||||
"CP28598" "\0" "ISO-8859-8" "\0"
|
||||
"CP28599" "\0" "ISO-8859-9" "\0"
|
||||
"CP28605" "\0" "ISO-8859-15" "\0"
|
||||
"CP38598" "\0" "ISO-8859-8" "\0"
|
||||
"CP51932" "\0" "EUC-JP" "\0"
|
||||
"CP51936" "\0" "GB2312" "\0"
|
||||
"CP51949" "\0" "EUC-KR" "\0"
|
||||
"CP51950" "\0" "EUC-TW" "\0"
|
||||
"CP54936" "\0" "GB18030" "\0"
|
||||
"CP65001" "\0" "UTF-8" "\0";
|
||||
"CP1361" "\0" "JOHAB" "\0"
|
||||
"CP20127" "\0" "ASCII" "\0"
|
||||
"CP20866" "\0" "KOI8-R" "\0"
|
||||
"CP20936" "\0" "GB2312" "\0"
|
||||
"CP21866" "\0" "KOI8-RU" "\0"
|
||||
"CP28591" "\0" "ISO-8859-1" "\0"
|
||||
"CP28592" "\0" "ISO-8859-2" "\0"
|
||||
"CP28593" "\0" "ISO-8859-3" "\0"
|
||||
"CP28594" "\0" "ISO-8859-4" "\0"
|
||||
"CP28595" "\0" "ISO-8859-5" "\0"
|
||||
"CP28596" "\0" "ISO-8859-6" "\0"
|
||||
"CP28597" "\0" "ISO-8859-7" "\0"
|
||||
"CP28598" "\0" "ISO-8859-8" "\0"
|
||||
"CP28599" "\0" "ISO-8859-9" "\0"
|
||||
"CP28605" "\0" "ISO-8859-15" "\0"
|
||||
"CP38598" "\0" "ISO-8859-8" "\0"
|
||||
"CP51932" "\0" "EUC-JP" "\0"
|
||||
"CP51936" "\0" "GB2312" "\0"
|
||||
"CP51949" "\0" "EUC-KR" "\0"
|
||||
"CP51950" "\0" "EUC-TW" "\0"
|
||||
"CP54936" "\0" "GB18030" "\0"
|
||||
"CP65001" "\0" "UTF-8" "\0";
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -369,7 +369,7 @@ locale_charset (void)
|
|||
codeset = nl_langinfo (CODESET);
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
/* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always
|
||||
/* Cygwin 1.5.x does not have locales. nl_langinfo (CODESET) always
|
||||
returns "US-ASCII". As long as this is not fixed, return the suffix
|
||||
of the locale name from the environment variables (if present) or
|
||||
the codepage as a number. */
|
||||
|
@ -380,36 +380,46 @@ locale_charset (void)
|
|||
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
{
|
||||
/* If the locale name contains an encoding after the dot, return
|
||||
it. */
|
||||
const char *dot = strchr (locale, '.');
|
||||
{
|
||||
/* If the locale name contains an encoding after the dot, return
|
||||
it. */
|
||||
const char *dot = strchr (locale, '.');
|
||||
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Woe32 has a function returning the locale's codepage as a number. */
|
||||
/* Woe32 has a function returning the locale's codepage as a number:
|
||||
GetACP(). This encoding is used by Cygwin, unless the user has set
|
||||
the environment variable CYGWIN=codepage:oem (which very few people
|
||||
do).
|
||||
Output directed to console windows needs to be converted (to
|
||||
GetOEMCP() if the console is using a raster font, or to
|
||||
GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
|
||||
this conversion transparently (see winsup/cygwin/fhandler_console.cc),
|
||||
converting to GetConsoleOutputCP(). This leads to correct results,
|
||||
except when SetConsoleOutputCP has been called and a raster font is
|
||||
in use. */
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
codeset = buf;
|
||||
}
|
||||
|
@ -431,11 +441,11 @@ locale_charset (void)
|
|||
{
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
}
|
||||
|
||||
/* On some old systems, one used to set locale = "iso8859_1". On others,
|
||||
|
@ -449,7 +459,13 @@ locale_charset (void)
|
|||
|
||||
static char buf[2 + 10 + 1];
|
||||
|
||||
/* Woe32 has a function returning the locale's codepage as a number. */
|
||||
/* Woe32 has a function returning the locale's codepage as a number:
|
||||
GetACP().
|
||||
When the output goes to a console window, it needs to be provided in
|
||||
GetOEMCP() encoding if the console is using a raster font, or in
|
||||
GetConsoleOutputCP() encoding if it is using a TrueType font.
|
||||
But in GUI programs and for output sent to files and pipes, GetACP()
|
||||
encoding is the best bet. */
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
codeset = buf;
|
||||
|
||||
|
@ -467,7 +483,7 @@ locale_charset (void)
|
|||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
{
|
||||
|
@ -475,21 +491,21 @@ locale_charset (void)
|
|||
const char *dot = strchr (locale, '.');
|
||||
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
{
|
||||
const char *modifier;
|
||||
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Resolve through the charset.alias file. */
|
||||
codeset = locale;
|
||||
|
@ -498,12 +514,12 @@ locale_charset (void)
|
|||
{
|
||||
/* OS/2 has a function returning the locale's codepage as a number. */
|
||||
if (DosQueryCp (sizeof (cp), cp, &cplen))
|
||||
codeset = "";
|
||||
codeset = "";
|
||||
else
|
||||
{
|
||||
sprintf (buf, "CP%u", cp[0]);
|
||||
codeset = buf;
|
||||
}
|
||||
{
|
||||
sprintf (buf, "CP%u", cp[0]);
|
||||
codeset = buf;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -517,10 +533,10 @@ locale_charset (void)
|
|||
*aliases != '\0';
|
||||
aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
|
||||
if (strcmp (codeset, aliases) == 0
|
||||
|| (aliases[0] == '*' && aliases[1] == '\0'))
|
||||
|| (aliases[0] == '*' && aliases[1] == '\0'))
|
||||
{
|
||||
codeset = aliases + strlen (aliases) + 1;
|
||||
break;
|
||||
codeset = aliases + strlen (aliases) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Don't return an empty string. GNU libc and GNU libiconv interpret
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
# include <xlocale.h>
|
||||
#endif
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
|
||||
On systems that don't define it, use the same value as GNU libintl. */
|
||||
#if !defined LC_MESSAGES
|
||||
|
@ -44,7 +46,7 @@
|
|||
# if @REPLACE_DUPLOCALE@
|
||||
# undef duplocale
|
||||
# define duplocale rpl_duplocale
|
||||
extern locale_t duplocale (locale_t locale);
|
||||
extern locale_t duplocale (locale_t locale) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef duplocale
|
||||
|
|
|
@ -74,21 +74,21 @@ mmalloca (size_t n)
|
|||
char *p = (char *) malloc (nplus);
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
size_t slot;
|
||||
{
|
||||
size_t slot;
|
||||
|
||||
p += HEADER_SIZE;
|
||||
p += HEADER_SIZE;
|
||||
|
||||
/* Put a magic number into the indicator word. */
|
||||
((int *) p)[-1] = MAGIC_NUMBER;
|
||||
/* Put a magic number into the indicator word. */
|
||||
((int *) p)[-1] = MAGIC_NUMBER;
|
||||
|
||||
/* Enter p into the hash table. */
|
||||
slot = (unsigned long) p % HASH_TABLE_SIZE;
|
||||
((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
|
||||
mmalloca_results[slot] = p;
|
||||
/* Enter p into the hash table. */
|
||||
slot = (unsigned long) p % HASH_TABLE_SIZE;
|
||||
((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
|
||||
mmalloca_results[slot] = p;
|
||||
|
||||
return p;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
||||
/* Out of memory. */
|
||||
return NULL;
|
||||
|
@ -109,28 +109,28 @@ freea (void *p)
|
|||
if (p != NULL)
|
||||
{
|
||||
/* Attempt to quickly distinguish the mmalloca() result - which has
|
||||
a magic indicator word - and the alloca() result - which has an
|
||||
uninitialized indicator word. It is for this test that sa_increment
|
||||
additional bytes are allocated in the alloca() case. */
|
||||
a magic indicator word - and the alloca() result - which has an
|
||||
uninitialized indicator word. It is for this test that sa_increment
|
||||
additional bytes are allocated in the alloca() case. */
|
||||
if (((int *) p)[-1] == MAGIC_NUMBER)
|
||||
{
|
||||
/* Looks like a mmalloca() result. To see whether it really is one,
|
||||
perform a lookup in the hash table. */
|
||||
size_t slot = (unsigned long) p % HASH_TABLE_SIZE;
|
||||
void **chain = &mmalloca_results[slot];
|
||||
for (; *chain != NULL;)
|
||||
{
|
||||
if (*chain == p)
|
||||
{
|
||||
/* Found it. Remove it from the hash table and free it. */
|
||||
char *p_begin = (char *) p - HEADER_SIZE;
|
||||
*chain = ((struct header *) p_begin)->next;
|
||||
free (p_begin);
|
||||
return;
|
||||
}
|
||||
chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next;
|
||||
}
|
||||
}
|
||||
{
|
||||
/* Looks like a mmalloca() result. To see whether it really is one,
|
||||
perform a lookup in the hash table. */
|
||||
size_t slot = (unsigned long) p % HASH_TABLE_SIZE;
|
||||
void **chain = &mmalloca_results[slot];
|
||||
for (; *chain != NULL;)
|
||||
{
|
||||
if (*chain == p)
|
||||
{
|
||||
/* Found it. Remove it from the hash table and free it. */
|
||||
char *p_begin = (char *) p - HEADER_SIZE;
|
||||
*chain = ((struct header *) p_begin)->next;
|
||||
free (p_begin);
|
||||
return;
|
||||
}
|
||||
chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next;
|
||||
}
|
||||
}
|
||||
/* At this point, we know it was not a mmalloca() result. */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ extern "C" {
|
|||
the function returns. Upon failure, it returns NULL. */
|
||||
#if HAVE_ALLOCA
|
||||
# define malloca(N) \
|
||||
((N) < 4032 - sa_increment \
|
||||
((N) < 4032 - sa_increment \
|
||||
? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \
|
||||
: mmalloca (N))
|
||||
#else
|
||||
|
@ -122,10 +122,10 @@ enum
|
|||
sa_alignment_longdouble = sa_alignof (long double),
|
||||
sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
|
||||
#if HAVE_LONG_LONG_INT
|
||||
| (sa_alignment_longlong - 1)
|
||||
| (sa_alignment_longlong - 1)
|
||||
#endif
|
||||
| (sa_alignment_longdouble - 1)
|
||||
) + 1,
|
||||
| (sa_alignment_longdouble - 1)
|
||||
) + 1,
|
||||
/* The increment that guarantees room for a magic word must be >= sizeof (int)
|
||||
and a multiple of sa_alignment_max. */
|
||||
sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max
|
||||
|
|
432
lib/mbrtowc.c
432
lib/mbrtowc.c
|
@ -63,30 +63,30 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
|||
switch (nstate)
|
||||
{
|
||||
case 0:
|
||||
p = s;
|
||||
m = n;
|
||||
break;
|
||||
p = s;
|
||||
m = n;
|
||||
break;
|
||||
case 3:
|
||||
buf[2] = pstate[3];
|
||||
/*FALLTHROUGH*/
|
||||
buf[2] = pstate[3];
|
||||
/*FALLTHROUGH*/
|
||||
case 2:
|
||||
buf[1] = pstate[2];
|
||||
/*FALLTHROUGH*/
|
||||
buf[1] = pstate[2];
|
||||
/*FALLTHROUGH*/
|
||||
case 1:
|
||||
buf[0] = pstate[1];
|
||||
p = buf;
|
||||
m = nstate;
|
||||
buf[m++] = s[0];
|
||||
if (n >= 2 && m < 4)
|
||||
{
|
||||
buf[m++] = s[1];
|
||||
if (n >= 3 && m < 4)
|
||||
buf[m++] = s[2];
|
||||
}
|
||||
break;
|
||||
buf[0] = pstate[1];
|
||||
p = buf;
|
||||
m = nstate;
|
||||
buf[m++] = s[0];
|
||||
if (n >= 2 && m < 4)
|
||||
{
|
||||
buf[m++] = s[1];
|
||||
if (n >= 3 && m < 4)
|
||||
buf[m++] = s[2];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return (size_t)(-1);
|
||||
errno = EINVAL;
|
||||
return (size_t)(-1);
|
||||
}
|
||||
|
||||
/* Here m > 0. */
|
||||
|
@ -99,208 +99,208 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
|||
int res = mbtowc (pwc, p, m);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
if (pwc != NULL && ((*pwc == 0) != (res == 0)))
|
||||
abort ();
|
||||
if (nstate >= (res > 0 ? res : 1))
|
||||
abort ();
|
||||
res -= nstate;
|
||||
pstate[0] = 0;
|
||||
return res;
|
||||
}
|
||||
{
|
||||
if (pwc != NULL && ((*pwc == 0) != (res == 0)))
|
||||
abort ();
|
||||
if (nstate >= (res > 0 ? res : 1))
|
||||
abort ();
|
||||
res -= nstate;
|
||||
pstate[0] = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* mbtowc does not distinguish between invalid and incomplete multibyte
|
||||
sequences. But mbrtowc needs to make this distinction.
|
||||
There are two possible approaches:
|
||||
- Use iconv() and its return value.
|
||||
- Use built-in knowledge about the possible encodings.
|
||||
Given the low quality of implementation of iconv() on the systems that
|
||||
lack mbrtowc(), we use the second approach.
|
||||
The possible encodings are:
|
||||
- 8-bit encodings,
|
||||
- EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
|
||||
- UTF-8.
|
||||
Use specialized code for each. */
|
||||
sequences. But mbrtowc needs to make this distinction.
|
||||
There are two possible approaches:
|
||||
- Use iconv() and its return value.
|
||||
- Use built-in knowledge about the possible encodings.
|
||||
Given the low quality of implementation of iconv() on the systems that
|
||||
lack mbrtowc(), we use the second approach.
|
||||
The possible encodings are:
|
||||
- 8-bit encodings,
|
||||
- EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
|
||||
- UTF-8.
|
||||
Use specialized code for each. */
|
||||
if (m >= 4 || m >= MB_CUR_MAX)
|
||||
goto invalid;
|
||||
goto invalid;
|
||||
/* Here MB_CUR_MAX > 1 and 0 < m < 4. */
|
||||
{
|
||||
const char *encoding = locale_charset ();
|
||||
const char *encoding = locale_charset ();
|
||||
|
||||
if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
{
|
||||
/* Cf. unistr/u8-mblen.c. */
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
|
||||
{
|
||||
/* Cf. unistr/u8-mblen.c. */
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || c2 >= 0xa0)
|
||||
&& (c != 0xed || c2 < 0xa0))
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
else if (c <= 0xf4)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || c2 >= 0xa0)
|
||||
&& (c != 0xed || c2 < 0xa0))
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
else if (c <= 0xf4)
|
||||
{
|
||||
if (m == 1)
|
||||
goto incomplete;
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || c2 >= 0x90)
|
||||
&& (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
if ((c2 ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || c2 >= 0x90)
|
||||
&& (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if ((c3 ^ 0x80) < 0x40)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if ((c3 ^ 0x80) < 0x40)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* As a reference for this code, you can use the GNU libiconv
|
||||
implementation. Look for uses of the RET_TOOFEW macro. */
|
||||
/* As a reference for this code, you can use the GNU libiconv
|
||||
implementation. Look for uses of the RET_TOOFEW macro. */
|
||||
|
||||
if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
|
||||
goto incomplete;
|
||||
}
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
|
||||
goto incomplete;
|
||||
}
|
||||
if (m == 2)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8f)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
if (c == 0x8f)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0xa1 && c2 < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|
||||
|| STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|
||||
|| STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if (c2 >= 0xa1 && c2 < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
|
||||
|| STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
|
||||
|| STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0xa1 && c < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if (c >= 0xa1 && c < 0xff)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if (c == 0x8e)
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
|
||||
goto incomplete;
|
||||
}
|
||||
else /* m == 2 || m == 3 */
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if (c >= 0x90 && c <= 0xe3)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
if (c >= 0x90 && c <= 0xe3)
|
||||
{
|
||||
unsigned char c2 = (unsigned char) p[1];
|
||||
|
||||
if (c2 >= 0x30 && c2 <= 0x39)
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
if (c2 >= 0x30 && c2 <= 0x39)
|
||||
{
|
||||
if (m == 2)
|
||||
goto incomplete;
|
||||
else /* m == 3 */
|
||||
{
|
||||
unsigned char c3 = (unsigned char) p[2];
|
||||
|
||||
if (c3 >= 0x81 && c3 <= 0xfe)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
if (c3 >= 0x81 && c3 <= 0xfe)
|
||||
goto incomplete;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
|
||||
{
|
||||
if (m == 1)
|
||||
{
|
||||
unsigned char c = (unsigned char) p[0];
|
||||
|
||||
if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
|
||||
|| (c >= 0xf0 && c <= 0xf9))
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
|
||||
|| (c >= 0xf0 && c <= 0xf9))
|
||||
goto incomplete;
|
||||
}
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* An unknown multibyte encoding. */
|
||||
goto incomplete;
|
||||
/* An unknown multibyte encoding. */
|
||||
goto incomplete;
|
||||
}
|
||||
|
||||
incomplete:
|
||||
{
|
||||
size_t k = nstate;
|
||||
/* Here 0 <= k < m < 4. */
|
||||
pstate[++k] = s[0];
|
||||
if (k < m)
|
||||
{
|
||||
pstate[++k] = s[1];
|
||||
if (k < m)
|
||||
pstate[++k] = s[2];
|
||||
}
|
||||
if (k != m)
|
||||
abort ();
|
||||
size_t k = nstate;
|
||||
/* Here 0 <= k < m < 4. */
|
||||
pstate[++k] = s[0];
|
||||
if (k < m)
|
||||
{
|
||||
pstate[++k] = s[1];
|
||||
if (k < m)
|
||||
pstate[++k] = s[2];
|
||||
}
|
||||
if (k != m)
|
||||
abort ();
|
||||
}
|
||||
pstate[0] = m;
|
||||
return (size_t)(-2);
|
||||
|
@ -341,25 +341,25 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
|||
|
||||
if (!mbsinit (ps))
|
||||
{
|
||||
/* Parse the rest of the multibyte character byte for byte. */
|
||||
size_t count = 0;
|
||||
for (; n > 0; s++, n--)
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t ret = mbrtowc (&wc, s, 1, ps);
|
||||
/* Parse the rest of the multibyte character byte for byte. */
|
||||
size_t count = 0;
|
||||
for (; n > 0; s++, n--)
|
||||
{
|
||||
wchar_t wc;
|
||||
size_t ret = mbrtowc (&wc, s, 1, ps);
|
||||
|
||||
if (ret == (size_t)(-1))
|
||||
return (size_t)(-1);
|
||||
count++;
|
||||
if (ret != (size_t)(-2))
|
||||
{
|
||||
/* The multibyte character has been completed. */
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
return (wc == 0 ? 0 : count);
|
||||
}
|
||||
}
|
||||
return (size_t)(-2);
|
||||
if (ret == (size_t)(-1))
|
||||
return (size_t)(-1);
|
||||
count++;
|
||||
if (ret != (size_t)(-2))
|
||||
{
|
||||
/* The multibyte character has been completed. */
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
return (wc == 0 ? 0 : count);
|
||||
}
|
||||
}
|
||||
return (size_t)(-2);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
@ -371,10 +371,10 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
|||
|
||||
if (ret != (size_t)(-1) && ret != (size_t)(-2))
|
||||
{
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
if (wc == 0)
|
||||
ret = 0;
|
||||
if (pwc != NULL)
|
||||
*pwc = wc;
|
||||
if (wc == 0)
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
22
lib/memchr.c
22
lib/memchr.c
|
@ -97,15 +97,15 @@ __memchr (void const *s, int c_in, size_t n)
|
|||
repeated_one |= repeated_one << 31 << 1;
|
||||
repeated_c |= repeated_c << 31 << 1;
|
||||
if (8 < sizeof (longword))
|
||||
{
|
||||
size_t i;
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 64; i < sizeof (longword) * 8; i *= 2)
|
||||
{
|
||||
repeated_one |= repeated_one << i;
|
||||
repeated_c |= repeated_c << i;
|
||||
}
|
||||
}
|
||||
for (i = 64; i < sizeof (longword) * 8; i *= 2)
|
||||
{
|
||||
repeated_one |= repeated_one << i;
|
||||
repeated_c |= repeated_c << i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Instead of the traditional loop which tests each byte, we will test a
|
||||
|
@ -144,8 +144,8 @@ __memchr (void const *s, int c_in, size_t n)
|
|||
longword longword1 = *longword_ptr ^ repeated_c;
|
||||
|
||||
if ((((longword1 - repeated_one) & ~longword1)
|
||||
& (repeated_one << 7)) != 0)
|
||||
break;
|
||||
& (repeated_one << 7)) != 0)
|
||||
break;
|
||||
longword_ptr++;
|
||||
n -= sizeof (longword);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ __memchr (void const *s, int c_in, size_t n)
|
|||
for (; n > 0; --n, ++char_ptr)
|
||||
{
|
||||
if (*char_ptr == c)
|
||||
return (void *) char_ptr;
|
||||
return (void *) char_ptr;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
# if !defined PATH_MAX && defined _PC_PATH_MAX && defined HAVE_PATHCONF
|
||||
# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \
|
||||
: pathconf ("/", _PC_PATH_MAX))
|
||||
: pathconf ("/", _PC_PATH_MAX))
|
||||
# endif
|
||||
|
||||
/* Don't include sys/param.h if it already has been. */
|
||||
|
|
|
@ -43,146 +43,146 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
|
|||
switch (ap->type)
|
||||
{
|
||||
case TYPE_SCHAR:
|
||||
ap->a.a_schar = va_arg (args, /*signed char*/ int);
|
||||
break;
|
||||
ap->a.a_schar = va_arg (args, /*signed char*/ int);
|
||||
break;
|
||||
case TYPE_UCHAR:
|
||||
ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
|
||||
break;
|
||||
ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
|
||||
break;
|
||||
case TYPE_SHORT:
|
||||
ap->a.a_short = va_arg (args, /*short*/ int);
|
||||
break;
|
||||
ap->a.a_short = va_arg (args, /*short*/ int);
|
||||
break;
|
||||
case TYPE_USHORT:
|
||||
ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
|
||||
break;
|
||||
ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
|
||||
break;
|
||||
case TYPE_INT:
|
||||
ap->a.a_int = va_arg (args, int);
|
||||
break;
|
||||
ap->a.a_int = va_arg (args, int);
|
||||
break;
|
||||
case TYPE_UINT:
|
||||
ap->a.a_uint = va_arg (args, unsigned int);
|
||||
break;
|
||||
ap->a.a_uint = va_arg (args, unsigned int);
|
||||
break;
|
||||
case TYPE_LONGINT:
|
||||
ap->a.a_longint = va_arg (args, long int);
|
||||
break;
|
||||
ap->a.a_longint = va_arg (args, long int);
|
||||
break;
|
||||
case TYPE_ULONGINT:
|
||||
ap->a.a_ulongint = va_arg (args, unsigned long int);
|
||||
break;
|
||||
ap->a.a_ulongint = va_arg (args, unsigned long int);
|
||||
break;
|
||||
#if HAVE_LONG_LONG_INT
|
||||
case TYPE_LONGLONGINT:
|
||||
ap->a.a_longlongint = va_arg (args, long long int);
|
||||
break;
|
||||
ap->a.a_longlongint = va_arg (args, long long int);
|
||||
break;
|
||||
case TYPE_ULONGLONGINT:
|
||||
ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
|
||||
break;
|
||||
ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
|
||||
break;
|
||||
#endif
|
||||
case TYPE_DOUBLE:
|
||||
ap->a.a_double = va_arg (args, double);
|
||||
break;
|
||||
ap->a.a_double = va_arg (args, double);
|
||||
break;
|
||||
case TYPE_LONGDOUBLE:
|
||||
ap->a.a_longdouble = va_arg (args, long double);
|
||||
break;
|
||||
ap->a.a_longdouble = va_arg (args, long double);
|
||||
break;
|
||||
case TYPE_CHAR:
|
||||
ap->a.a_char = va_arg (args, int);
|
||||
break;
|
||||
ap->a.a_char = va_arg (args, int);
|
||||
break;
|
||||
#if HAVE_WINT_T
|
||||
case TYPE_WIDE_CHAR:
|
||||
/* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
|
||||
default argument promotions", this is not the case in mingw32,
|
||||
where wint_t is 'unsigned short'. */
|
||||
ap->a.a_wide_char =
|
||||
(sizeof (wint_t) < sizeof (int)
|
||||
? (wint_t) va_arg (args, int)
|
||||
: va_arg (args, wint_t));
|
||||
break;
|
||||
/* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
|
||||
default argument promotions", this is not the case in mingw32,
|
||||
where wint_t is 'unsigned short'. */
|
||||
ap->a.a_wide_char =
|
||||
(sizeof (wint_t) < sizeof (int)
|
||||
? (wint_t) va_arg (args, int)
|
||||
: va_arg (args, wint_t));
|
||||
break;
|
||||
#endif
|
||||
case TYPE_STRING:
|
||||
ap->a.a_string = va_arg (args, const char *);
|
||||
/* A null pointer is an invalid argument for "%s", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_string == NULL)
|
||||
ap->a.a_string = "(NULL)";
|
||||
break;
|
||||
ap->a.a_string = va_arg (args, const char *);
|
||||
/* A null pointer is an invalid argument for "%s", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_string == NULL)
|
||||
ap->a.a_string = "(NULL)";
|
||||
break;
|
||||
#if HAVE_WCHAR_T
|
||||
case TYPE_WIDE_STRING:
|
||||
ap->a.a_wide_string = va_arg (args, const wchar_t *);
|
||||
/* A null pointer is an invalid argument for "%ls", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_wide_string == NULL)
|
||||
{
|
||||
static const wchar_t wide_null_string[] =
|
||||
{
|
||||
(wchar_t)'(',
|
||||
(wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
|
||||
(wchar_t)')',
|
||||
(wchar_t)0
|
||||
};
|
||||
ap->a.a_wide_string = wide_null_string;
|
||||
}
|
||||
break;
|
||||
ap->a.a_wide_string = va_arg (args, const wchar_t *);
|
||||
/* A null pointer is an invalid argument for "%ls", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_wide_string == NULL)
|
||||
{
|
||||
static const wchar_t wide_null_string[] =
|
||||
{
|
||||
(wchar_t)'(',
|
||||
(wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
|
||||
(wchar_t)')',
|
||||
(wchar_t)0
|
||||
};
|
||||
ap->a.a_wide_string = wide_null_string;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case TYPE_POINTER:
|
||||
ap->a.a_pointer = va_arg (args, void *);
|
||||
break;
|
||||
ap->a.a_pointer = va_arg (args, void *);
|
||||
break;
|
||||
case TYPE_COUNT_SCHAR_POINTER:
|
||||
ap->a.a_count_schar_pointer = va_arg (args, signed char *);
|
||||
break;
|
||||
ap->a.a_count_schar_pointer = va_arg (args, signed char *);
|
||||
break;
|
||||
case TYPE_COUNT_SHORT_POINTER:
|
||||
ap->a.a_count_short_pointer = va_arg (args, short *);
|
||||
break;
|
||||
ap->a.a_count_short_pointer = va_arg (args, short *);
|
||||
break;
|
||||
case TYPE_COUNT_INT_POINTER:
|
||||
ap->a.a_count_int_pointer = va_arg (args, int *);
|
||||
break;
|
||||
ap->a.a_count_int_pointer = va_arg (args, int *);
|
||||
break;
|
||||
case TYPE_COUNT_LONGINT_POINTER:
|
||||
ap->a.a_count_longint_pointer = va_arg (args, long int *);
|
||||
break;
|
||||
ap->a.a_count_longint_pointer = va_arg (args, long int *);
|
||||
break;
|
||||
#if HAVE_LONG_LONG_INT
|
||||
case TYPE_COUNT_LONGLONGINT_POINTER:
|
||||
ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
|
||||
break;
|
||||
ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
|
||||
break;
|
||||
#endif
|
||||
#if ENABLE_UNISTDIO
|
||||
/* The unistdio extensions. */
|
||||
case TYPE_U8_STRING:
|
||||
ap->a.a_u8_string = va_arg (args, const uint8_t *);
|
||||
/* A null pointer is an invalid argument for "%U", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_u8_string == NULL)
|
||||
{
|
||||
static const uint8_t u8_null_string[] =
|
||||
{ '(', 'N', 'U', 'L', 'L', ')', 0 };
|
||||
ap->a.a_u8_string = u8_null_string;
|
||||
}
|
||||
break;
|
||||
ap->a.a_u8_string = va_arg (args, const uint8_t *);
|
||||
/* A null pointer is an invalid argument for "%U", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_u8_string == NULL)
|
||||
{
|
||||
static const uint8_t u8_null_string[] =
|
||||
{ '(', 'N', 'U', 'L', 'L', ')', 0 };
|
||||
ap->a.a_u8_string = u8_null_string;
|
||||
}
|
||||
break;
|
||||
case TYPE_U16_STRING:
|
||||
ap->a.a_u16_string = va_arg (args, const uint16_t *);
|
||||
/* A null pointer is an invalid argument for "%lU", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_u16_string == NULL)
|
||||
{
|
||||
static const uint16_t u16_null_string[] =
|
||||
{ '(', 'N', 'U', 'L', 'L', ')', 0 };
|
||||
ap->a.a_u16_string = u16_null_string;
|
||||
}
|
||||
break;
|
||||
ap->a.a_u16_string = va_arg (args, const uint16_t *);
|
||||
/* A null pointer is an invalid argument for "%lU", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_u16_string == NULL)
|
||||
{
|
||||
static const uint16_t u16_null_string[] =
|
||||
{ '(', 'N', 'U', 'L', 'L', ')', 0 };
|
||||
ap->a.a_u16_string = u16_null_string;
|
||||
}
|
||||
break;
|
||||
case TYPE_U32_STRING:
|
||||
ap->a.a_u32_string = va_arg (args, const uint32_t *);
|
||||
/* A null pointer is an invalid argument for "%llU", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_u32_string == NULL)
|
||||
{
|
||||
static const uint32_t u32_null_string[] =
|
||||
{ '(', 'N', 'U', 'L', 'L', ')', 0 };
|
||||
ap->a.a_u32_string = u32_null_string;
|
||||
}
|
||||
break;
|
||||
ap->a.a_u32_string = va_arg (args, const uint32_t *);
|
||||
/* A null pointer is an invalid argument for "%llU", but in practice
|
||||
it occurs quite frequently in printf statements that produce
|
||||
debug output. Use a fallback in this case. */
|
||||
if (ap->a.a_u32_string == NULL)
|
||||
{
|
||||
static const uint32_t u32_null_string[] =
|
||||
{ '(', 'N', 'U', 'L', 'L', ')', 0 };
|
||||
ap->a.a_u32_string = u32_null_string;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* Unknown type. */
|
||||
return -1;
|
||||
/* Unknown type. */
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -93,42 +93,42 @@ typedef struct
|
|||
arg_type type;
|
||||
union
|
||||
{
|
||||
signed char a_schar;
|
||||
unsigned char a_uchar;
|
||||
short a_short;
|
||||
unsigned short a_ushort;
|
||||
int a_int;
|
||||
unsigned int a_uint;
|
||||
long int a_longint;
|
||||
unsigned long int a_ulongint;
|
||||
signed char a_schar;
|
||||
unsigned char a_uchar;
|
||||
short a_short;
|
||||
unsigned short a_ushort;
|
||||
int a_int;
|
||||
unsigned int a_uint;
|
||||
long int a_longint;
|
||||
unsigned long int a_ulongint;
|
||||
#if HAVE_LONG_LONG_INT
|
||||
long long int a_longlongint;
|
||||
unsigned long long int a_ulonglongint;
|
||||
long long int a_longlongint;
|
||||
unsigned long long int a_ulonglongint;
|
||||
#endif
|
||||
float a_float;
|
||||
double a_double;
|
||||
long double a_longdouble;
|
||||
int a_char;
|
||||
float a_float;
|
||||
double a_double;
|
||||
long double a_longdouble;
|
||||
int a_char;
|
||||
#if HAVE_WINT_T
|
||||
wint_t a_wide_char;
|
||||
wint_t a_wide_char;
|
||||
#endif
|
||||
const char* a_string;
|
||||
const char* a_string;
|
||||
#if HAVE_WCHAR_T
|
||||
const wchar_t* a_wide_string;
|
||||
const wchar_t* a_wide_string;
|
||||
#endif
|
||||
void* a_pointer;
|
||||
signed char * a_count_schar_pointer;
|
||||
short * a_count_short_pointer;
|
||||
int * a_count_int_pointer;
|
||||
long int * a_count_longint_pointer;
|
||||
void* a_pointer;
|
||||
signed char * a_count_schar_pointer;
|
||||
short * a_count_short_pointer;
|
||||
int * a_count_int_pointer;
|
||||
long int * a_count_longint_pointer;
|
||||
#if HAVE_LONG_LONG_INT
|
||||
long long int * a_count_longlongint_pointer;
|
||||
long long int * a_count_longlongint_pointer;
|
||||
#endif
|
||||
#if ENABLE_UNISTDIO
|
||||
/* The unistdio extensions. */
|
||||
const uint8_t * a_u8_string;
|
||||
const uint16_t * a_u16_string;
|
||||
const uint32_t * a_u32_string;
|
||||
const uint8_t * a_u8_string;
|
||||
const uint16_t * a_u16_string;
|
||||
const uint32_t * a_u32_string;
|
||||
#endif
|
||||
}
|
||||
a;
|
||||
|
|
|
@ -80,10 +80,10 @@ STATIC
|
|||
int
|
||||
PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
||||
{
|
||||
const CHAR_T *cp = format; /* pointer into format */
|
||||
size_t arg_posn = 0; /* number of regular arguments consumed */
|
||||
size_t d_allocated; /* allocated elements of d->dir */
|
||||
size_t a_allocated; /* allocated elements of a->arg */
|
||||
const CHAR_T *cp = format; /* pointer into format */
|
||||
size_t arg_posn = 0; /* number of regular arguments consumed */
|
||||
size_t d_allocated; /* allocated elements of d->dir */
|
||||
size_t a_allocated; /* allocated elements of a->arg */
|
||||
size_t max_width_length = 0;
|
||||
size_t max_precision_length = 0;
|
||||
|
||||
|
@ -99,501 +99,501 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
|||
a->arg = NULL;
|
||||
|
||||
#define REGISTER_ARG(_index_,_type_) \
|
||||
{ \
|
||||
size_t n = (_index_); \
|
||||
if (n >= a_allocated) \
|
||||
{ \
|
||||
size_t memory_size; \
|
||||
argument *memory; \
|
||||
\
|
||||
a_allocated = xtimes (a_allocated, 2); \
|
||||
if (a_allocated <= n) \
|
||||
a_allocated = xsum (n, 1); \
|
||||
memory_size = xtimes (a_allocated, sizeof (argument)); \
|
||||
if (size_overflow_p (memory_size)) \
|
||||
/* Overflow, would lead to out of memory. */ \
|
||||
goto out_of_memory; \
|
||||
memory = (argument *) (a->arg \
|
||||
? realloc (a->arg, memory_size) \
|
||||
: malloc (memory_size)); \
|
||||
if (memory == NULL) \
|
||||
/* Out of memory. */ \
|
||||
goto out_of_memory; \
|
||||
a->arg = memory; \
|
||||
} \
|
||||
while (a->count <= n) \
|
||||
a->arg[a->count++].type = TYPE_NONE; \
|
||||
if (a->arg[n].type == TYPE_NONE) \
|
||||
a->arg[n].type = (_type_); \
|
||||
else if (a->arg[n].type != (_type_)) \
|
||||
/* Ambiguous type for positional argument. */ \
|
||||
goto error; \
|
||||
{ \
|
||||
size_t n = (_index_); \
|
||||
if (n >= a_allocated) \
|
||||
{ \
|
||||
size_t memory_size; \
|
||||
argument *memory; \
|
||||
\
|
||||
a_allocated = xtimes (a_allocated, 2); \
|
||||
if (a_allocated <= n) \
|
||||
a_allocated = xsum (n, 1); \
|
||||
memory_size = xtimes (a_allocated, sizeof (argument)); \
|
||||
if (size_overflow_p (memory_size)) \
|
||||
/* Overflow, would lead to out of memory. */ \
|
||||
goto out_of_memory; \
|
||||
memory = (argument *) (a->arg \
|
||||
? realloc (a->arg, memory_size) \
|
||||
: malloc (memory_size)); \
|
||||
if (memory == NULL) \
|
||||
/* Out of memory. */ \
|
||||
goto out_of_memory; \
|
||||
a->arg = memory; \
|
||||
} \
|
||||
while (a->count <= n) \
|
||||
a->arg[a->count++].type = TYPE_NONE; \
|
||||
if (a->arg[n].type == TYPE_NONE) \
|
||||
a->arg[n].type = (_type_); \
|
||||
else if (a->arg[n].type != (_type_)) \
|
||||
/* Ambiguous type for positional argument. */ \
|
||||
goto error; \
|
||||
}
|
||||
|
||||
while (*cp != '\0')
|
||||
{
|
||||
CHAR_T c = *cp++;
|
||||
if (c == '%')
|
||||
{
|
||||
size_t arg_index = ARG_NONE;
|
||||
DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
|
||||
{
|
||||
size_t arg_index = ARG_NONE;
|
||||
DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
|
||||
|
||||
/* Initialize the next directive. */
|
||||
dp->dir_start = cp - 1;
|
||||
dp->flags = 0;
|
||||
dp->width_start = NULL;
|
||||
dp->width_end = NULL;
|
||||
dp->width_arg_index = ARG_NONE;
|
||||
dp->precision_start = NULL;
|
||||
dp->precision_end = NULL;
|
||||
dp->precision_arg_index = ARG_NONE;
|
||||
dp->arg_index = ARG_NONE;
|
||||
/* Initialize the next directive. */
|
||||
dp->dir_start = cp - 1;
|
||||
dp->flags = 0;
|
||||
dp->width_start = NULL;
|
||||
dp->width_end = NULL;
|
||||
dp->width_arg_index = ARG_NONE;
|
||||
dp->precision_start = NULL;
|
||||
dp->precision_end = NULL;
|
||||
dp->precision_arg_index = ARG_NONE;
|
||||
dp->arg_index = ARG_NONE;
|
||||
|
||||
/* Test for positional argument. */
|
||||
if (*cp >= '0' && *cp <= '9')
|
||||
{
|
||||
const CHAR_T *np;
|
||||
/* Test for positional argument. */
|
||||
if (*cp >= '0' && *cp <= '9')
|
||||
{
|
||||
const CHAR_T *np;
|
||||
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
;
|
||||
if (*np == '$')
|
||||
{
|
||||
size_t n = 0;
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
;
|
||||
if (*np == '$')
|
||||
{
|
||||
size_t n = 0;
|
||||
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
n = xsum (xtimes (n, 10), *np - '0');
|
||||
if (n == 0)
|
||||
/* Positional argument 0. */
|
||||
goto error;
|
||||
if (size_overflow_p (n))
|
||||
/* n too large, would lead to out of memory later. */
|
||||
goto error;
|
||||
arg_index = n - 1;
|
||||
cp = np + 1;
|
||||
}
|
||||
}
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
n = xsum (xtimes (n, 10), *np - '0');
|
||||
if (n == 0)
|
||||
/* Positional argument 0. */
|
||||
goto error;
|
||||
if (size_overflow_p (n))
|
||||
/* n too large, would lead to out of memory later. */
|
||||
goto error;
|
||||
arg_index = n - 1;
|
||||
cp = np + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the flags. */
|
||||
for (;;)
|
||||
{
|
||||
if (*cp == '\'')
|
||||
{
|
||||
dp->flags |= FLAG_GROUP;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == '-')
|
||||
{
|
||||
dp->flags |= FLAG_LEFT;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == '+')
|
||||
{
|
||||
dp->flags |= FLAG_SHOWSIGN;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == ' ')
|
||||
{
|
||||
dp->flags |= FLAG_SPACE;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == '#')
|
||||
{
|
||||
dp->flags |= FLAG_ALT;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == '0')
|
||||
{
|
||||
dp->flags |= FLAG_ZERO;
|
||||
cp++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
/* Read the flags. */
|
||||
for (;;)
|
||||
{
|
||||
if (*cp == '\'')
|
||||
{
|
||||
dp->flags |= FLAG_GROUP;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == '-')
|
||||
{
|
||||
dp->flags |= FLAG_LEFT;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == '+')
|
||||
{
|
||||
dp->flags |= FLAG_SHOWSIGN;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == ' ')
|
||||
{
|
||||
dp->flags |= FLAG_SPACE;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == '#')
|
||||
{
|
||||
dp->flags |= FLAG_ALT;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == '0')
|
||||
{
|
||||
dp->flags |= FLAG_ZERO;
|
||||
cp++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/* Parse the field width. */
|
||||
if (*cp == '*')
|
||||
{
|
||||
dp->width_start = cp;
|
||||
cp++;
|
||||
dp->width_end = cp;
|
||||
if (max_width_length < 1)
|
||||
max_width_length = 1;
|
||||
/* Parse the field width. */
|
||||
if (*cp == '*')
|
||||
{
|
||||
dp->width_start = cp;
|
||||
cp++;
|
||||
dp->width_end = cp;
|
||||
if (max_width_length < 1)
|
||||
max_width_length = 1;
|
||||
|
||||
/* Test for positional argument. */
|
||||
if (*cp >= '0' && *cp <= '9')
|
||||
{
|
||||
const CHAR_T *np;
|
||||
/* Test for positional argument. */
|
||||
if (*cp >= '0' && *cp <= '9')
|
||||
{
|
||||
const CHAR_T *np;
|
||||
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
;
|
||||
if (*np == '$')
|
||||
{
|
||||
size_t n = 0;
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
;
|
||||
if (*np == '$')
|
||||
{
|
||||
size_t n = 0;
|
||||
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
n = xsum (xtimes (n, 10), *np - '0');
|
||||
if (n == 0)
|
||||
/* Positional argument 0. */
|
||||
goto error;
|
||||
if (size_overflow_p (n))
|
||||
/* n too large, would lead to out of memory later. */
|
||||
goto error;
|
||||
dp->width_arg_index = n - 1;
|
||||
cp = np + 1;
|
||||
}
|
||||
}
|
||||
if (dp->width_arg_index == ARG_NONE)
|
||||
{
|
||||
dp->width_arg_index = arg_posn++;
|
||||
if (dp->width_arg_index == ARG_NONE)
|
||||
/* arg_posn wrapped around. */
|
||||
goto error;
|
||||
}
|
||||
REGISTER_ARG (dp->width_arg_index, TYPE_INT);
|
||||
}
|
||||
else if (*cp >= '0' && *cp <= '9')
|
||||
{
|
||||
size_t width_length;
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
n = xsum (xtimes (n, 10), *np - '0');
|
||||
if (n == 0)
|
||||
/* Positional argument 0. */
|
||||
goto error;
|
||||
if (size_overflow_p (n))
|
||||
/* n too large, would lead to out of memory later. */
|
||||
goto error;
|
||||
dp->width_arg_index = n - 1;
|
||||
cp = np + 1;
|
||||
}
|
||||
}
|
||||
if (dp->width_arg_index == ARG_NONE)
|
||||
{
|
||||
dp->width_arg_index = arg_posn++;
|
||||
if (dp->width_arg_index == ARG_NONE)
|
||||
/* arg_posn wrapped around. */
|
||||
goto error;
|
||||
}
|
||||
REGISTER_ARG (dp->width_arg_index, TYPE_INT);
|
||||
}
|
||||
else if (*cp >= '0' && *cp <= '9')
|
||||
{
|
||||
size_t width_length;
|
||||
|
||||
dp->width_start = cp;
|
||||
for (; *cp >= '0' && *cp <= '9'; cp++)
|
||||
;
|
||||
dp->width_end = cp;
|
||||
width_length = dp->width_end - dp->width_start;
|
||||
if (max_width_length < width_length)
|
||||
max_width_length = width_length;
|
||||
}
|
||||
dp->width_start = cp;
|
||||
for (; *cp >= '0' && *cp <= '9'; cp++)
|
||||
;
|
||||
dp->width_end = cp;
|
||||
width_length = dp->width_end - dp->width_start;
|
||||
if (max_width_length < width_length)
|
||||
max_width_length = width_length;
|
||||
}
|
||||
|
||||
/* Parse the precision. */
|
||||
if (*cp == '.')
|
||||
{
|
||||
cp++;
|
||||
if (*cp == '*')
|
||||
{
|
||||
dp->precision_start = cp - 1;
|
||||
cp++;
|
||||
dp->precision_end = cp;
|
||||
if (max_precision_length < 2)
|
||||
max_precision_length = 2;
|
||||
/* Parse the precision. */
|
||||
if (*cp == '.')
|
||||
{
|
||||
cp++;
|
||||
if (*cp == '*')
|
||||
{
|
||||
dp->precision_start = cp - 1;
|
||||
cp++;
|
||||
dp->precision_end = cp;
|
||||
if (max_precision_length < 2)
|
||||
max_precision_length = 2;
|
||||
|
||||
/* Test for positional argument. */
|
||||
if (*cp >= '0' && *cp <= '9')
|
||||
{
|
||||
const CHAR_T *np;
|
||||
/* Test for positional argument. */
|
||||
if (*cp >= '0' && *cp <= '9')
|
||||
{
|
||||
const CHAR_T *np;
|
||||
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
;
|
||||
if (*np == '$')
|
||||
{
|
||||
size_t n = 0;
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
;
|
||||
if (*np == '$')
|
||||
{
|
||||
size_t n = 0;
|
||||
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
n = xsum (xtimes (n, 10), *np - '0');
|
||||
if (n == 0)
|
||||
/* Positional argument 0. */
|
||||
goto error;
|
||||
if (size_overflow_p (n))
|
||||
/* n too large, would lead to out of memory
|
||||
later. */
|
||||
goto error;
|
||||
dp->precision_arg_index = n - 1;
|
||||
cp = np + 1;
|
||||
}
|
||||
}
|
||||
if (dp->precision_arg_index == ARG_NONE)
|
||||
{
|
||||
dp->precision_arg_index = arg_posn++;
|
||||
if (dp->precision_arg_index == ARG_NONE)
|
||||
/* arg_posn wrapped around. */
|
||||
goto error;
|
||||
}
|
||||
REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t precision_length;
|
||||
for (np = cp; *np >= '0' && *np <= '9'; np++)
|
||||
n = xsum (xtimes (n, 10), *np - '0');
|
||||
if (n == 0)
|
||||
/* Positional argument 0. */
|
||||
goto error;
|
||||
if (size_overflow_p (n))
|
||||
/* n too large, would lead to out of memory
|
||||
later. */
|
||||
goto error;
|
||||
dp->precision_arg_index = n - 1;
|
||||
cp = np + 1;
|
||||
}
|
||||
}
|
||||
if (dp->precision_arg_index == ARG_NONE)
|
||||
{
|
||||
dp->precision_arg_index = arg_posn++;
|
||||
if (dp->precision_arg_index == ARG_NONE)
|
||||
/* arg_posn wrapped around. */
|
||||
goto error;
|
||||
}
|
||||
REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t precision_length;
|
||||
|
||||
dp->precision_start = cp - 1;
|
||||
for (; *cp >= '0' && *cp <= '9'; cp++)
|
||||
;
|
||||
dp->precision_end = cp;
|
||||
precision_length = dp->precision_end - dp->precision_start;
|
||||
if (max_precision_length < precision_length)
|
||||
max_precision_length = precision_length;
|
||||
}
|
||||
}
|
||||
dp->precision_start = cp - 1;
|
||||
for (; *cp >= '0' && *cp <= '9'; cp++)
|
||||
;
|
||||
dp->precision_end = cp;
|
||||
precision_length = dp->precision_end - dp->precision_start;
|
||||
if (max_precision_length < precision_length)
|
||||
max_precision_length = precision_length;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
arg_type type;
|
||||
{
|
||||
arg_type type;
|
||||
|
||||
/* Parse argument type/size specifiers. */
|
||||
{
|
||||
int flags = 0;
|
||||
/* Parse argument type/size specifiers. */
|
||||
{
|
||||
int flags = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (*cp == 'h')
|
||||
{
|
||||
flags |= (1 << (flags & 1));
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 'L')
|
||||
{
|
||||
flags |= 4;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 'l')
|
||||
{
|
||||
flags += 8;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 'j')
|
||||
{
|
||||
if (sizeof (intmax_t) > sizeof (long))
|
||||
{
|
||||
/* intmax_t = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else if (sizeof (intmax_t) > sizeof (int))
|
||||
{
|
||||
/* intmax_t = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 'z' || *cp == 'Z')
|
||||
{
|
||||
/* 'z' is standardized in ISO C 99, but glibc uses 'Z'
|
||||
because the warning facility in gcc-2.95.2 understands
|
||||
only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
|
||||
if (sizeof (size_t) > sizeof (long))
|
||||
{
|
||||
/* size_t = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else if (sizeof (size_t) > sizeof (int))
|
||||
{
|
||||
/* size_t = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 't')
|
||||
{
|
||||
if (sizeof (ptrdiff_t) > sizeof (long))
|
||||
{
|
||||
/* ptrdiff_t = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else if (sizeof (ptrdiff_t) > sizeof (int))
|
||||
{
|
||||
/* ptrdiff_t = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
if (*cp == 'h')
|
||||
{
|
||||
flags |= (1 << (flags & 1));
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 'L')
|
||||
{
|
||||
flags |= 4;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 'l')
|
||||
{
|
||||
flags += 8;
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 'j')
|
||||
{
|
||||
if (sizeof (intmax_t) > sizeof (long))
|
||||
{
|
||||
/* intmax_t = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else if (sizeof (intmax_t) > sizeof (int))
|
||||
{
|
||||
/* intmax_t = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 'z' || *cp == 'Z')
|
||||
{
|
||||
/* 'z' is standardized in ISO C 99, but glibc uses 'Z'
|
||||
because the warning facility in gcc-2.95.2 understands
|
||||
only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
|
||||
if (sizeof (size_t) > sizeof (long))
|
||||
{
|
||||
/* size_t = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else if (sizeof (size_t) > sizeof (int))
|
||||
{
|
||||
/* size_t = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
else if (*cp == 't')
|
||||
{
|
||||
if (sizeof (ptrdiff_t) > sizeof (long))
|
||||
{
|
||||
/* ptrdiff_t = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else if (sizeof (ptrdiff_t) > sizeof (int))
|
||||
{
|
||||
/* ptrdiff_t = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
#if defined __APPLE__ && defined __MACH__
|
||||
/* On MacOS X 10.3, PRIdMAX is defined as "qd".
|
||||
We cannot change it to "lld" because PRIdMAX must also
|
||||
be understood by the system's printf routines. */
|
||||
else if (*cp == 'q')
|
||||
{
|
||||
if (64 / 8 > sizeof (long))
|
||||
{
|
||||
/* int64_t = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* int64_t = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
/* On MacOS X 10.3, PRIdMAX is defined as "qd".
|
||||
We cannot change it to "lld" because PRIdMAX must also
|
||||
be understood by the system's printf routines. */
|
||||
else if (*cp == 'q')
|
||||
{
|
||||
if (64 / 8 > sizeof (long))
|
||||
{
|
||||
/* int64_t = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* int64_t = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
#endif
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* On native Win32, PRIdMAX is defined as "I64d".
|
||||
We cannot change it to "lld" because PRIdMAX must also
|
||||
be understood by the system's printf routines. */
|
||||
else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
|
||||
{
|
||||
if (64 / 8 > sizeof (long))
|
||||
{
|
||||
/* __int64 = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* __int64 = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp += 3;
|
||||
}
|
||||
/* On native Win32, PRIdMAX is defined as "I64d".
|
||||
We cannot change it to "lld" because PRIdMAX must also
|
||||
be understood by the system's printf routines. */
|
||||
else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
|
||||
{
|
||||
if (64 / 8 > sizeof (long))
|
||||
{
|
||||
/* __int64 = long long */
|
||||
flags += 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* __int64 = long */
|
||||
flags += 8;
|
||||
}
|
||||
cp += 3;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/* Read the conversion character. */
|
||||
c = *cp++;
|
||||
switch (c)
|
||||
{
|
||||
case 'd': case 'i':
|
||||
/* Read the conversion character. */
|
||||
c = *cp++;
|
||||
switch (c)
|
||||
{
|
||||
case 'd': case 'i':
|
||||
#if HAVE_LONG_LONG_INT
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_LONGLONGINT;
|
||||
else
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_LONGLONGINT;
|
||||
else
|
||||
#endif
|
||||
/* If 'long long' exists and is the same as 'long', we parse
|
||||
"lld" into TYPE_LONGINT. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_LONGINT;
|
||||
else if (flags & 2)
|
||||
type = TYPE_SCHAR;
|
||||
else if (flags & 1)
|
||||
type = TYPE_SHORT;
|
||||
else
|
||||
type = TYPE_INT;
|
||||
break;
|
||||
case 'o': case 'u': case 'x': case 'X':
|
||||
/* If 'long long' exists and is the same as 'long', we parse
|
||||
"lld" into TYPE_LONGINT. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_LONGINT;
|
||||
else if (flags & 2)
|
||||
type = TYPE_SCHAR;
|
||||
else if (flags & 1)
|
||||
type = TYPE_SHORT;
|
||||
else
|
||||
type = TYPE_INT;
|
||||
break;
|
||||
case 'o': case 'u': case 'x': case 'X':
|
||||
#if HAVE_LONG_LONG_INT
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_ULONGLONGINT;
|
||||
else
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_ULONGLONGINT;
|
||||
else
|
||||
#endif
|
||||
/* If 'unsigned long long' exists and is the same as
|
||||
'unsigned long', we parse "llu" into TYPE_ULONGINT. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_ULONGINT;
|
||||
else if (flags & 2)
|
||||
type = TYPE_UCHAR;
|
||||
else if (flags & 1)
|
||||
type = TYPE_USHORT;
|
||||
else
|
||||
type = TYPE_UINT;
|
||||
break;
|
||||
case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
|
||||
case 'a': case 'A':
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_LONGDOUBLE;
|
||||
else
|
||||
type = TYPE_DOUBLE;
|
||||
break;
|
||||
case 'c':
|
||||
if (flags >= 8)
|
||||
/* If 'unsigned long long' exists and is the same as
|
||||
'unsigned long', we parse "llu" into TYPE_ULONGINT. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_ULONGINT;
|
||||
else if (flags & 2)
|
||||
type = TYPE_UCHAR;
|
||||
else if (flags & 1)
|
||||
type = TYPE_USHORT;
|
||||
else
|
||||
type = TYPE_UINT;
|
||||
break;
|
||||
case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
|
||||
case 'a': case 'A':
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_LONGDOUBLE;
|
||||
else
|
||||
type = TYPE_DOUBLE;
|
||||
break;
|
||||
case 'c':
|
||||
if (flags >= 8)
|
||||
#if HAVE_WINT_T
|
||||
type = TYPE_WIDE_CHAR;
|
||||
type = TYPE_WIDE_CHAR;
|
||||
#else
|
||||
goto error;
|
||||
goto error;
|
||||
#endif
|
||||
else
|
||||
type = TYPE_CHAR;
|
||||
break;
|
||||
else
|
||||
type = TYPE_CHAR;
|
||||
break;
|
||||
#if HAVE_WINT_T
|
||||
case 'C':
|
||||
type = TYPE_WIDE_CHAR;
|
||||
c = 'c';
|
||||
break;
|
||||
case 'C':
|
||||
type = TYPE_WIDE_CHAR;
|
||||
c = 'c';
|
||||
break;
|
||||
#endif
|
||||
case 's':
|
||||
if (flags >= 8)
|
||||
case 's':
|
||||
if (flags >= 8)
|
||||
#if HAVE_WCHAR_T
|
||||
type = TYPE_WIDE_STRING;
|
||||
type = TYPE_WIDE_STRING;
|
||||
#else
|
||||
goto error;
|
||||
goto error;
|
||||
#endif
|
||||
else
|
||||
type = TYPE_STRING;
|
||||
break;
|
||||
else
|
||||
type = TYPE_STRING;
|
||||
break;
|
||||
#if HAVE_WCHAR_T
|
||||
case 'S':
|
||||
type = TYPE_WIDE_STRING;
|
||||
c = 's';
|
||||
break;
|
||||
case 'S':
|
||||
type = TYPE_WIDE_STRING;
|
||||
c = 's';
|
||||
break;
|
||||
#endif
|
||||
case 'p':
|
||||
type = TYPE_POINTER;
|
||||
break;
|
||||
case 'n':
|
||||
case 'p':
|
||||
type = TYPE_POINTER;
|
||||
break;
|
||||
case 'n':
|
||||
#if HAVE_LONG_LONG_INT
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_COUNT_LONGLONGINT_POINTER;
|
||||
else
|
||||
/* If 'long long' exists and is larger than 'long': */
|
||||
if (flags >= 16 || (flags & 4))
|
||||
type = TYPE_COUNT_LONGLONGINT_POINTER;
|
||||
else
|
||||
#endif
|
||||
/* If 'long long' exists and is the same as 'long', we parse
|
||||
"lln" into TYPE_COUNT_LONGINT_POINTER. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_COUNT_LONGINT_POINTER;
|
||||
else if (flags & 2)
|
||||
type = TYPE_COUNT_SCHAR_POINTER;
|
||||
else if (flags & 1)
|
||||
type = TYPE_COUNT_SHORT_POINTER;
|
||||
else
|
||||
type = TYPE_COUNT_INT_POINTER;
|
||||
break;
|
||||
/* If 'long long' exists and is the same as 'long', we parse
|
||||
"lln" into TYPE_COUNT_LONGINT_POINTER. */
|
||||
if (flags >= 8)
|
||||
type = TYPE_COUNT_LONGINT_POINTER;
|
||||
else if (flags & 2)
|
||||
type = TYPE_COUNT_SCHAR_POINTER;
|
||||
else if (flags & 1)
|
||||
type = TYPE_COUNT_SHORT_POINTER;
|
||||
else
|
||||
type = TYPE_COUNT_INT_POINTER;
|
||||
break;
|
||||
#if ENABLE_UNISTDIO
|
||||
/* The unistdio extensions. */
|
||||
case 'U':
|
||||
if (flags >= 16)
|
||||
type = TYPE_U32_STRING;
|
||||
else if (flags >= 8)
|
||||
type = TYPE_U16_STRING;
|
||||
else
|
||||
type = TYPE_U8_STRING;
|
||||
break;
|
||||
/* The unistdio extensions. */
|
||||
case 'U':
|
||||
if (flags >= 16)
|
||||
type = TYPE_U32_STRING;
|
||||
else if (flags >= 8)
|
||||
type = TYPE_U16_STRING;
|
||||
else
|
||||
type = TYPE_U8_STRING;
|
||||
break;
|
||||
#endif
|
||||
case '%':
|
||||
type = TYPE_NONE;
|
||||
break;
|
||||
default:
|
||||
/* Unknown conversion character. */
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
case '%':
|
||||
type = TYPE_NONE;
|
||||
break;
|
||||
default:
|
||||
/* Unknown conversion character. */
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != TYPE_NONE)
|
||||
{
|
||||
dp->arg_index = arg_index;
|
||||
if (dp->arg_index == ARG_NONE)
|
||||
{
|
||||
dp->arg_index = arg_posn++;
|
||||
if (dp->arg_index == ARG_NONE)
|
||||
/* arg_posn wrapped around. */
|
||||
goto error;
|
||||
}
|
||||
REGISTER_ARG (dp->arg_index, type);
|
||||
}
|
||||
dp->conversion = c;
|
||||
dp->dir_end = cp;
|
||||
}
|
||||
if (type != TYPE_NONE)
|
||||
{
|
||||
dp->arg_index = arg_index;
|
||||
if (dp->arg_index == ARG_NONE)
|
||||
{
|
||||
dp->arg_index = arg_posn++;
|
||||
if (dp->arg_index == ARG_NONE)
|
||||
/* arg_posn wrapped around. */
|
||||
goto error;
|
||||
}
|
||||
REGISTER_ARG (dp->arg_index, type);
|
||||
}
|
||||
dp->conversion = c;
|
||||
dp->dir_end = cp;
|
||||
}
|
||||
|
||||
d->count++;
|
||||
if (d->count >= d_allocated)
|
||||
{
|
||||
size_t memory_size;
|
||||
DIRECTIVE *memory;
|
||||
d->count++;
|
||||
if (d->count >= d_allocated)
|
||||
{
|
||||
size_t memory_size;
|
||||
DIRECTIVE *memory;
|
||||
|
||||
d_allocated = xtimes (d_allocated, 2);
|
||||
memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
|
||||
if (size_overflow_p (memory_size))
|
||||
/* Overflow, would lead to out of memory. */
|
||||
goto out_of_memory;
|
||||
memory = (DIRECTIVE *) realloc (d->dir, memory_size);
|
||||
if (memory == NULL)
|
||||
/* Out of memory. */
|
||||
goto out_of_memory;
|
||||
d->dir = memory;
|
||||
}
|
||||
}
|
||||
d_allocated = xtimes (d_allocated, 2);
|
||||
memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
|
||||
if (size_overflow_p (memory_size))
|
||||
/* Overflow, would lead to out of memory. */
|
||||
goto out_of_memory;
|
||||
memory = (DIRECTIVE *) realloc (d->dir, memory_size);
|
||||
if (memory == NULL)
|
||||
/* Out of memory. */
|
||||
goto out_of_memory;
|
||||
d->dir = memory;
|
||||
}
|
||||
}
|
||||
#if CHAR_T_ONLY_ASCII
|
||||
else if (!c_isascii (c))
|
||||
{
|
||||
/* Non-ASCII character. Not supported. */
|
||||
goto error;
|
||||
}
|
||||
{
|
||||
/* Non-ASCII character. Not supported. */
|
||||
goto error;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
d->dir[d->count].dir_start = cp;
|
||||
|
|
|
@ -26,15 +26,15 @@
|
|||
|
||||
|
||||
/* Flags */
|
||||
#define FLAG_GROUP 1 /* ' flag */
|
||||
#define FLAG_LEFT 2 /* - flag */
|
||||
#define FLAG_SHOWSIGN 4 /* + flag */
|
||||
#define FLAG_SPACE 8 /* space flag */
|
||||
#define FLAG_ALT 16 /* # flag */
|
||||
#define FLAG_ZERO 32
|
||||
#define FLAG_GROUP 1 /* ' flag */
|
||||
#define FLAG_LEFT 2 /* - flag */
|
||||
#define FLAG_SHOWSIGN 4 /* + flag */
|
||||
#define FLAG_SPACE 8 /* space flag */
|
||||
#define FLAG_ALT 16 /* # flag */
|
||||
#define FLAG_ZERO 32
|
||||
|
||||
/* arg_index value indicating that no argument is consumed. */
|
||||
#define ARG_NONE (~(size_t)0)
|
||||
#define ARG_NONE (~(size_t)0)
|
||||
|
||||
/* xxx_directive: A parsed directive.
|
||||
xxx_directives: A parsed format string. */
|
||||
|
@ -163,10 +163,10 @@ extern int
|
|||
u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
|
||||
extern int
|
||||
u16_printf_parse (const uint16_t *format, u16_directives *d,
|
||||
arguments *a);
|
||||
arguments *a);
|
||||
extern int
|
||||
u32_printf_parse (const uint32_t *format, u32_directives *d,
|
||||
arguments *a);
|
||||
arguments *a);
|
||||
#else
|
||||
# ifdef STATIC
|
||||
STATIC
|
||||
|
|
22
lib/putenv.c
22
lib/putenv.c
|
@ -44,8 +44,8 @@ extern char **environ;
|
|||
/* This lock protects against simultaneous modifications of `environ'. */
|
||||
# include <bits/libc-lock.h>
|
||||
__libc_lock_define_initialized (static, envlock)
|
||||
# define LOCK __libc_lock_lock (envlock)
|
||||
# define UNLOCK __libc_lock_unlock (envlock)
|
||||
# define LOCK __libc_lock_lock (envlock)
|
||||
# define UNLOCK __libc_lock_unlock (envlock)
|
||||
#else
|
||||
# define LOCK
|
||||
# define UNLOCK
|
||||
|
@ -71,13 +71,13 @@ _unsetenv (const char *name)
|
|||
while (*ep != NULL)
|
||||
if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
|
||||
{
|
||||
/* Found it. Remove this pointer by moving later ones back. */
|
||||
char **dp = ep;
|
||||
/* Found it. Remove this pointer by moving later ones back. */
|
||||
char **dp = ep;
|
||||
|
||||
do
|
||||
dp[0] = dp[1];
|
||||
while (*dp++);
|
||||
/* Continue the loop in case NAME appears again. */
|
||||
do
|
||||
dp[0] = dp[1];
|
||||
while (*dp++);
|
||||
/* Continue the loop in case NAME appears again. */
|
||||
}
|
||||
else
|
||||
++ep;
|
||||
|
@ -106,7 +106,7 @@ putenv (char *string)
|
|||
size = 0;
|
||||
for (ep = environ; *ep != NULL; ++ep)
|
||||
if (!strncmp (*ep, string, name_end - string) &&
|
||||
(*ep)[name_end - string] == '=')
|
||||
(*ep)[name_end - string] == '=')
|
||||
break;
|
||||
else
|
||||
++size;
|
||||
|
@ -116,9 +116,9 @@ putenv (char *string)
|
|||
static char **last_environ = NULL;
|
||||
char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
|
||||
if (new_environ == NULL)
|
||||
return -1;
|
||||
return -1;
|
||||
(void) memcpy ((void *) new_environ, (void *) environ,
|
||||
size * sizeof (char *));
|
||||
size * sizeof (char *));
|
||||
new_environ[size] = (char *) string;
|
||||
new_environ[size + 1] = NULL;
|
||||
free (last_environ);
|
||||
|
|
|
@ -66,12 +66,12 @@ safe_rw (int fd, void const *buf, size_t count)
|
|||
ssize_t result = rw (fd, buf, count);
|
||||
|
||||
if (0 <= result)
|
||||
return result;
|
||||
return result;
|
||||
else if (IS_EINTR (errno))
|
||||
continue;
|
||||
continue;
|
||||
else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
|
||||
count = BUGGY_READ_MAXIMUM;
|
||||
count = BUGGY_READ_MAXIMUM;
|
||||
else
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,10 +55,10 @@ rpl_stat (char const *name, struct stat *st)
|
|||
{
|
||||
size_t len = strlen (name);
|
||||
if (ISSLASH (name[len - 1]))
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
errno = ENOTDIR;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
#endif /* REPLACE_FUNC_STAT_FILE */
|
||||
#if REPLACE_FUNC_STAT_DIR
|
||||
|
|
|
@ -102,8 +102,8 @@
|
|||
((signed) \
|
||||
? ~ _STDINT_MIN (signed, bits, zero) \
|
||||
: /* The expression for the unsigned case. The subtraction of (signed) \
|
||||
is a nop in the unsigned case and avoids "signed integer overflow" \
|
||||
warnings in the signed case. */ \
|
||||
is a nop in the unsigned case and avoids "signed integer overflow" \
|
||||
warnings in the signed case. */ \
|
||||
((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
|
||||
|
||||
/* 7.18.1.1. Exact-width integer types */
|
||||
|
@ -454,10 +454,10 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
|
|||
#undef SIG_ATOMIC_MAX
|
||||
#define SIG_ATOMIC_MIN \
|
||||
_STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
|
||||
0@SIG_ATOMIC_T_SUFFIX@)
|
||||
0@SIG_ATOMIC_T_SUFFIX@)
|
||||
#define SIG_ATOMIC_MAX \
|
||||
_STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
|
||||
0@SIG_ATOMIC_T_SUFFIX@)
|
||||
0@SIG_ATOMIC_T_SUFFIX@)
|
||||
|
||||
|
||||
/* size_t limit */
|
||||
|
|
|
@ -39,27 +39,27 @@
|
|||
# include <windows.h>
|
||||
|
||||
# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
|
||||
if (ferror (stream)) \
|
||||
return (EXPRESSION); \
|
||||
else \
|
||||
{ \
|
||||
RETTYPE ret; \
|
||||
SetLastError (0); \
|
||||
ret = (EXPRESSION); \
|
||||
if (ferror (stream)) \
|
||||
return (EXPRESSION); \
|
||||
else \
|
||||
{ \
|
||||
RETTYPE ret; \
|
||||
SetLastError (0); \
|
||||
ret = (EXPRESSION); \
|
||||
if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \
|
||||
{ \
|
||||
int fd = fileno (stream); \
|
||||
if (fd >= 0 \
|
||||
&& GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
|
||||
{ \
|
||||
/* Try to raise signal SIGPIPE. */ \
|
||||
raise (SIGPIPE); \
|
||||
/* If it is currently blocked or ignored, change errno from \
|
||||
EINVAL to EPIPE. */ \
|
||||
errno = EPIPE; \
|
||||
} \
|
||||
} \
|
||||
return ret; \
|
||||
{ \
|
||||
int fd = fileno (stream); \
|
||||
if (fd >= 0 \
|
||||
&& GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
|
||||
{ \
|
||||
/* Try to raise signal SIGPIPE. */ \
|
||||
raise (SIGPIPE); \
|
||||
/* If it is currently blocked or ignored, change errno from \
|
||||
EINVAL to EPIPE. */ \
|
||||
errno = EPIPE; \
|
||||
} \
|
||||
} \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
|
||||
|
|
112
lib/stdio.in.h
112
lib/stdio.in.h
|
@ -63,6 +63,8 @@
|
|||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -74,7 +76,7 @@ extern "C" {
|
|||
# endif
|
||||
# if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
|
||||
extern int dprintf (int fd, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef dprintf
|
||||
|
@ -88,7 +90,7 @@ extern int dprintf (int fd, const char *format, ...)
|
|||
# if @REPLACE_FCLOSE@
|
||||
# define fclose rpl_fclose
|
||||
/* Close STREAM and its underlying file descriptor. */
|
||||
extern int fclose (FILE *stream);
|
||||
extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fclose
|
||||
|
@ -123,7 +125,8 @@ extern int fclose (FILE *stream);
|
|||
# if @REPLACE_FOPEN@
|
||||
# undef fopen
|
||||
# define fopen rpl_fopen
|
||||
extern FILE * fopen (const char *filename, const char *mode);
|
||||
extern FILE * fopen (const char *filename, const char *mode)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fopen
|
||||
|
@ -137,12 +140,14 @@ extern FILE * fopen (const char *filename, const char *mode);
|
|||
# if @REPLACE_FPRINTF@
|
||||
# define fprintf rpl_fprintf
|
||||
extern int fprintf (FILE *fp, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)))
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
# define fprintf rpl_fprintf
|
||||
extern int fprintf (FILE *fp, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)))
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fprintf
|
||||
# define fprintf \
|
||||
|
@ -163,7 +168,7 @@ extern int fprintf (FILE *fp, const char *format, ...)
|
|||
was before the write calls. When discarding pending input, the file
|
||||
position is advanced to match the end of the previously read input.
|
||||
Return 0 if successful. Upon error, return -1 and set errno. */
|
||||
extern int fpurge (FILE *gl_stream);
|
||||
extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fpurge
|
||||
|
@ -176,20 +181,21 @@ extern int fprintf (FILE *fp, const char *format, ...)
|
|||
#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
# undef fputc
|
||||
# define fputc rpl_fputc
|
||||
extern int fputc (int c, FILE *stream);
|
||||
extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
# undef fputs
|
||||
# define fputs rpl_fputs
|
||||
extern int fputs (const char *string, FILE *stream);
|
||||
extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FREOPEN@
|
||||
# if @REPLACE_FREOPEN@
|
||||
# undef freopen
|
||||
# define freopen rpl_freopen
|
||||
extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
|
||||
extern FILE * freopen (const char *filename, const char *mode, FILE *stream)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef freopen
|
||||
|
@ -200,7 +206,7 @@ extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
|
|||
#endif
|
||||
|
||||
#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
|
||||
extern int rpl_fseek (FILE *fp, long offset, int whence);
|
||||
extern int rpl_fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
|
||||
# undef fseek
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# define fseek(f,o,w) \
|
||||
|
@ -226,7 +232,7 @@ extern int rpl_fseek (FILE *fp, long offset, int whence);
|
|||
/* Provide fseek, fseeko functions that are aware of a preceding
|
||||
fflush(), and which detect pipes. */
|
||||
# define fseeko rpl_fseeko
|
||||
extern int fseeko (FILE *fp, off_t offset, int whence);
|
||||
extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1));
|
||||
# if !@GNULIB_FSEEK@
|
||||
# undef fseek
|
||||
# define fseek(f,o,w) \
|
||||
|
@ -245,7 +251,7 @@ extern int fseeko (FILE *fp, off_t offset, int whence);
|
|||
#endif
|
||||
|
||||
#if @GNULIB_FTELL@ && @REPLACE_FTELL@
|
||||
extern long rpl_ftell (FILE *fp);
|
||||
extern long rpl_ftell (FILE *fp) _GL_ARG_NONNULL ((1));
|
||||
# undef ftell
|
||||
# if GNULIB_POSIXCHECK
|
||||
# define ftell(f) \
|
||||
|
@ -269,7 +275,7 @@ extern long rpl_ftell (FILE *fp);
|
|||
#if @GNULIB_FTELLO@
|
||||
# if @REPLACE_FTELLO@
|
||||
# define ftello rpl_ftello
|
||||
extern off_t ftello (FILE *fp);
|
||||
extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
|
||||
# if !@GNULIB_FTELL@
|
||||
# undef ftell
|
||||
# define ftell(f) \
|
||||
|
@ -290,7 +296,8 @@ extern off_t ftello (FILE *fp);
|
|||
#if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
# undef fwrite
|
||||
# define fwrite rpl_fwrite
|
||||
extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
|
||||
extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
|
||||
_GL_ARG_NONNULL ((1, 4));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_GETDELIM@
|
||||
|
@ -302,13 +309,14 @@ extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
|
|||
Return the number of bytes read and stored at *LINEPTR (not including the
|
||||
NUL terminator), or -1 on error or EOF. */
|
||||
extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
|
||||
FILE *stream);
|
||||
FILE *stream)
|
||||
_GL_ARG_NONNULL ((1, 2, 4));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getdelim
|
||||
# define getdelim(l, s, d, f) \
|
||||
(GL_LINK_WARNING ("getdelim is unportable - " \
|
||||
"use gnulib module getdelim for portability"), \
|
||||
# define getdelim(l, s, d, f) \
|
||||
(GL_LINK_WARNING ("getdelim is unportable - " \
|
||||
"use gnulib module getdelim for portability"), \
|
||||
getdelim (l, s, d, f))
|
||||
#endif
|
||||
|
||||
|
@ -324,13 +332,14 @@ extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
|
|||
bytes of space. It is realloc'd as necessary.
|
||||
Return the number of bytes read and stored at *LINEPTR (not including the
|
||||
NUL terminator), or -1 on error or EOF. */
|
||||
extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
|
||||
extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream)
|
||||
_GL_ARG_NONNULL ((1, 2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getline
|
||||
# define getline(l, s, f) \
|
||||
(GL_LINK_WARNING ("getline is unportable - " \
|
||||
"use gnulib module getline for portability"), \
|
||||
# define getline(l, s, f) \
|
||||
(GL_LINK_WARNING ("getline is unportable - " \
|
||||
"use gnulib module getline for portability"), \
|
||||
getline (l, s, f))
|
||||
#endif
|
||||
|
||||
|
@ -347,10 +356,10 @@ extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
|
|||
memory allocation error, call obstack_alloc_failed_handler. Upon
|
||||
other error, return -1. */
|
||||
extern int obstack_printf (struct obstack *obs, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
|
||||
extern int obstack_vprintf (struct obstack *obs, const char *format,
|
||||
va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -374,7 +383,8 @@ extern void perror (const char *string);
|
|||
# if @REPLACE_POPEN@
|
||||
# undef popen
|
||||
# define popen rpl_popen
|
||||
extern FILE *popen (const char *cmd, const char *mode);
|
||||
extern FILE *popen (const char *cmd, const char *mode)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef popen
|
||||
|
@ -389,13 +399,13 @@ extern FILE *popen (const char *cmd, const char *mode);
|
|||
/* Don't break __attribute__((format(printf,M,N))). */
|
||||
# define printf __printf__
|
||||
extern int printf (const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
__attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
/* Don't break __attribute__((format(printf,M,N))). */
|
||||
# define printf __printf__
|
||||
extern int printf (const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
__attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef printf
|
||||
# define printf \
|
||||
|
@ -415,7 +425,7 @@ extern int printf (const char *format, ...)
|
|||
#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
# undef putc
|
||||
# define putc rpl_fputc
|
||||
extern int putc (int c, FILE *stream);
|
||||
extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
|
@ -427,18 +437,18 @@ extern int putchar (int c);
|
|||
#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
# undef puts
|
||||
# define puts rpl_puts
|
||||
extern int puts (const char *string);
|
||||
extern int puts (const char *string) _GL_ARG_NONNULL ((1));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_REMOVE@
|
||||
# if @REPLACE_REMOVE@
|
||||
# undef remove
|
||||
# define remove rpl_remove
|
||||
extern int remove (const char *name);
|
||||
extern int remove (const char *name) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef remove
|
||||
# define remove(n) \
|
||||
# define remove(n) \
|
||||
(GL_LINK_WARNING ("remove cannot handle directories on some platforms - " \
|
||||
"use gnulib module remove for more portability"), \
|
||||
remove (n))
|
||||
|
@ -448,11 +458,12 @@ extern int remove (const char *name);
|
|||
# if @REPLACE_RENAME@
|
||||
# undef rename
|
||||
# define rename rpl_rename
|
||||
extern int rename (const char *old, const char *new);
|
||||
extern int rename (const char *old_filename, const char *new_filename)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef rename
|
||||
# define rename(o,n) \
|
||||
# define rename(o,n) \
|
||||
(GL_LINK_WARNING ("rename is buggy on some platforms - " \
|
||||
"use gnulib module rename for more portability"), \
|
||||
rename (o, n))
|
||||
|
@ -464,11 +475,12 @@ extern int rename (const char *old, const char *new);
|
|||
# define renameat rpl_renameat
|
||||
# endif
|
||||
# if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@
|
||||
extern int renameat (int fd1, char const *file1, int fd2, char const *file2);
|
||||
extern int renameat (int fd1, char const *file1, int fd2, char const *file2)
|
||||
_GL_ARG_NONNULL ((2, 4));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef renameat
|
||||
# define renameat(d1,f1,d2,f2) \
|
||||
# define renameat(d1,f1,d2,f2) \
|
||||
(GL_LINK_WARNING ("renameat is not portable - " \
|
||||
"use gnulib module renameat for portability"), \
|
||||
renameat (d1, f1, d2, f2))
|
||||
|
@ -480,7 +492,8 @@ extern int renameat (int fd1, char const *file1, int fd2, char const *file2);
|
|||
# endif
|
||||
# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
|
||||
extern int snprintf (char *str, size_t size, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)))
|
||||
_GL_ARG_NONNULL ((3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef snprintf
|
||||
|
@ -494,7 +507,8 @@ extern int snprintf (char *str, size_t size, const char *format, ...)
|
|||
# if @REPLACE_SPRINTF@
|
||||
# define sprintf rpl_sprintf
|
||||
extern int sprintf (char *str, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)))
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef sprintf
|
||||
|
@ -516,9 +530,9 @@ extern int sprintf (char *str, const char *format, ...)
|
|||
*RESULT and return the number of resulting bytes, excluding the trailing
|
||||
NUL. Upon memory allocation error, or some other error, return -1. */
|
||||
extern int asprintf (char **result, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
|
||||
extern int vasprintf (char **result, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -528,7 +542,7 @@ extern int sprintf (char *str, const char *format, ...)
|
|||
# endif
|
||||
# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
|
||||
extern int vdprintf (int fd, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vdprintf
|
||||
|
@ -542,12 +556,14 @@ extern int vdprintf (int fd, const char *format, va_list args)
|
|||
# if @REPLACE_VFPRINTF@
|
||||
# define vfprintf rpl_vfprintf
|
||||
extern int vfprintf (FILE *fp, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)))
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
# define vfprintf rpl_vfprintf
|
||||
extern int vfprintf (FILE *fp, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)))
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vfprintf
|
||||
# define vfprintf(s,f,a) \
|
||||
|
@ -561,12 +577,12 @@ extern int vfprintf (FILE *fp, const char *format, va_list args)
|
|||
# if @REPLACE_VPRINTF@
|
||||
# define vprintf rpl_vprintf
|
||||
extern int vprintf (const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 1, 0)));
|
||||
__attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
|
||||
# define vprintf rpl_vprintf
|
||||
extern int vprintf (const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 1, 0)));
|
||||
__attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vprintf
|
||||
# define vprintf(f,a) \
|
||||
|
@ -582,7 +598,8 @@ extern int vprintf (const char *format, va_list args)
|
|||
# endif
|
||||
# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
|
||||
extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 3, 0)));
|
||||
__attribute__ ((__format__ (__printf__, 3, 0)))
|
||||
_GL_ARG_NONNULL ((3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vsnprintf
|
||||
|
@ -596,7 +613,8 @@ extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
|
|||
# if @REPLACE_VSPRINTF@
|
||||
# define vsprintf rpl_vsprintf
|
||||
extern int vsprintf (char *str, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)))
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vsprintf
|
||||
|
|
|
@ -56,18 +56,20 @@
|
|||
#if !@HAVE_STRUCT_RANDOM_DATA@
|
||||
struct random_data
|
||||
{
|
||||
int32_t *fptr; /* Front pointer. */
|
||||
int32_t *rptr; /* Rear pointer. */
|
||||
int32_t *state; /* Array of state values. */
|
||||
int rand_type; /* Type of random number generator. */
|
||||
int rand_deg; /* Degree of random number generator. */
|
||||
int rand_sep; /* Distance between front and rear. */
|
||||
int32_t *end_ptr; /* Pointer behind state table. */
|
||||
int32_t *fptr; /* Front pointer. */
|
||||
int32_t *rptr; /* Rear pointer. */
|
||||
int32_t *state; /* Array of state values. */
|
||||
int rand_type; /* Type of random number generator. */
|
||||
int rand_deg; /* Degree of random number generator. */
|
||||
int rand_sep; /* Distance between front and rear. */
|
||||
int32_t *end_ptr; /* Pointer behind state table. */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
|
||||
/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
|
||||
#ifndef EXIT_SUCCESS
|
||||
|
@ -91,7 +93,7 @@ extern "C" {
|
|||
# if !@HAVE_ATOLL@
|
||||
/* Parse a signed decimal integer.
|
||||
Returns the value of the integer. Errors are not detected. */
|
||||
extern long long atoll (const char *string);
|
||||
extern long long atoll (const char *string) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef atoll
|
||||
|
@ -120,7 +122,7 @@ extern void * calloc (size_t nmemb, size_t size);
|
|||
# define canonicalize_file_name rpl_canonicalize_file_name
|
||||
# endif
|
||||
# if !@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@
|
||||
extern char *canonicalize_file_name (const char *name);
|
||||
extern char *canonicalize_file_name (const char *name) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef canonicalize_file_name
|
||||
|
@ -136,7 +138,7 @@ extern char *canonicalize_file_name (const char *name);
|
|||
The three numbers are the load average of the last 1 minute, the last 5
|
||||
minutes, and the last 15 minutes, respectively.
|
||||
LOADAVG is an array of NELEM numbers. */
|
||||
extern int getloadavg (double loadavg[], int nelem);
|
||||
extern int getloadavg (double loadavg[], int nelem) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getloadavg
|
||||
|
@ -159,7 +161,8 @@ extern int getloadavg (double loadavg[], int nelem);
|
|||
For more details see the POSIX:2001 specification.
|
||||
http://www.opengroup.org/susv3xsh/getsubopt.html */
|
||||
# if !@HAVE_GETSUBOPT@
|
||||
extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
|
||||
extern int getsubopt (char **optionp, char *const *tokens, char **valuep)
|
||||
_GL_ARG_NONNULL ((1, 2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getsubopt
|
||||
|
@ -190,7 +193,7 @@ extern void * malloc (size_t size);
|
|||
they are replaced with a string that makes the directory name unique.
|
||||
Returns TEMPLATE, or a null pointer if it cannot get a unique name.
|
||||
The directory is created mode 700. */
|
||||
extern char * mkdtemp (char * /*template*/);
|
||||
extern char * mkdtemp (char * /*template*/) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkdtemp
|
||||
|
@ -214,7 +217,7 @@ extern char * mkdtemp (char * /*template*/);
|
|||
implementation.
|
||||
Returns the open file descriptor if successful, otherwise -1 and errno
|
||||
set. */
|
||||
extern int mkostemp (char * /*template*/, int /*flags*/);
|
||||
extern int mkostemp (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkostemp
|
||||
|
@ -239,7 +242,8 @@ extern int mkostemp (char * /*template*/, int /*flags*/);
|
|||
implementation.
|
||||
Returns the open file descriptor if successful, otherwise -1 and errno
|
||||
set. */
|
||||
extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
|
||||
extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkostemps
|
||||
|
@ -261,7 +265,7 @@ extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
|
|||
Returns the open file descriptor if successful, otherwise -1 and errno
|
||||
set. */
|
||||
# define mkstemp rpl_mkstemp
|
||||
extern int mkstemp (char * /*template*/);
|
||||
extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1));
|
||||
# else
|
||||
/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
|
||||
# include <unistd.h>
|
||||
|
@ -286,7 +290,8 @@ extern int mkstemp (char * /*template*/);
|
|||
implementation.
|
||||
Returns the open file descriptor if successful, otherwise -1 and errno
|
||||
set. */
|
||||
extern int mkstemps (char * /*template*/, int /*suffixlen*/);
|
||||
extern int mkstemps (char * /*template*/, int /*suffixlen*/)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkstemps
|
||||
|
@ -300,7 +305,7 @@ extern int mkstemps (char * /*template*/, int /*suffixlen*/);
|
|||
# if @REPLACE_PUTENV@
|
||||
# undef putenv
|
||||
# define putenv rpl_putenv
|
||||
extern int putenv (char *string);
|
||||
extern int putenv (char *string) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -311,30 +316,34 @@ extern int putenv (char *string);
|
|||
# define RAND_MAX 2147483647
|
||||
# endif
|
||||
|
||||
int srandom_r (unsigned int seed, struct random_data *rand_state);
|
||||
int srandom_r (unsigned int seed, struct random_data *rand_state)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
int initstate_r (unsigned int seed, char *buf, size_t buf_size,
|
||||
struct random_data *rand_state);
|
||||
int setstate_r (char *arg_state, struct random_data *rand_state);
|
||||
int random_r (struct random_data *buf, int32_t *result);
|
||||
struct random_data *rand_state)
|
||||
_GL_ARG_NONNULL ((2, 4));
|
||||
int setstate_r (char *arg_state, struct random_data *rand_state)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
int random_r (struct random_data *buf, int32_t *result)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef random_r
|
||||
# define random_r(b,r) \
|
||||
# define random_r(b,r) \
|
||||
(GL_LINK_WARNING ("random_r is unportable - " \
|
||||
"use gnulib module random_r for portability"), \
|
||||
random_r (b,r))
|
||||
# undef initstate_r
|
||||
# define initstate_r(s,b,sz,r) \
|
||||
# define initstate_r(s,b,sz,r) \
|
||||
(GL_LINK_WARNING ("initstate_r is unportable - " \
|
||||
"use gnulib module random_r for portability"), \
|
||||
initstate_r (s,b,sz,r))
|
||||
# undef srandom_r
|
||||
# define srandom_r(s,r) \
|
||||
# define srandom_r(s,r) \
|
||||
(GL_LINK_WARNING ("srandom_r is unportable - " \
|
||||
"use gnulib module random_r for portability"), \
|
||||
srandom_r (s,r))
|
||||
# undef setstate_r
|
||||
# define setstate_r(a,r) \
|
||||
# define setstate_r(a,r) \
|
||||
(GL_LINK_WARNING ("setstate_r is unportable - " \
|
||||
"use gnulib module random_r for portability"), \
|
||||
setstate_r (a,r))
|
||||
|
@ -359,7 +368,7 @@ extern void * realloc (void *ptr, size_t size);
|
|||
# define realpath rpl_realpath
|
||||
# endif
|
||||
# if !@HAVE_REALPATH@ || @REPLACE_REALPATH@
|
||||
extern char *realpath (const char *name, char *resolved);
|
||||
extern char *realpath (const char *name, char *resolved) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef realpath
|
||||
|
@ -373,7 +382,7 @@ extern char *realpath (const char *name, char *resolved);
|
|||
# if !@HAVE_RPMATCH@
|
||||
/* Test a user response to a question.
|
||||
Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
|
||||
extern int rpmatch (const char *response);
|
||||
extern int rpmatch (const char *response) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef rpmatch
|
||||
|
@ -391,7 +400,8 @@ extern int rpmatch (const char *response);
|
|||
# if !@HAVE_SETENV@ || @REPLACE_SETENV@
|
||||
/* Set NAME to VALUE in the environment.
|
||||
If REPLACE is nonzero, overwrite an existing value. */
|
||||
extern int setenv (const char *name, const char *value, int replace);
|
||||
extern int setenv (const char *name, const char *value, int replace)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef setenv
|
||||
|
@ -407,7 +417,7 @@ extern int setenv (const char *name, const char *value, int replace);
|
|||
# endif
|
||||
# if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
|
||||
/* Parse a double from STRING, updating ENDP if appropriate. */
|
||||
extern double strtod (const char *str, char **endp);
|
||||
extern double strtod (const char *str, char **endp) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strtod
|
||||
|
@ -427,7 +437,8 @@ extern double strtod (const char *str, char **endp);
|
|||
stored in *ENDPTR.
|
||||
Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
|
||||
to ERANGE. */
|
||||
extern long long strtoll (const char *string, char **endptr, int base);
|
||||
extern long long strtoll (const char *string, char **endptr, int base)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strtoll
|
||||
|
@ -447,7 +458,8 @@ extern long long strtoll (const char *string, char **endptr, int base);
|
|||
stored in *ENDPTR.
|
||||
Upon overflow, the return value is ULLONG_MAX, and errno is set to
|
||||
ERANGE. */
|
||||
extern unsigned long long strtoull (const char *string, char **endptr, int base);
|
||||
extern unsigned long long strtoull (const char *string, char **endptr, int base)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strtoull
|
||||
|
@ -464,7 +476,7 @@ extern unsigned long long strtoull (const char *string, char **endptr, int base)
|
|||
# endif
|
||||
# if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@
|
||||
/* Remove the variable NAME from the environment. */
|
||||
extern int unsetenv (const char *name);
|
||||
extern int unsetenv (const char *name) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef unsetenv
|
||||
|
|
|
@ -46,7 +46,7 @@ strcasecmp (const char *s1, const char *s2)
|
|||
c2 = TOLOWER (*p2);
|
||||
|
||||
if (c1 == '\0')
|
||||
break;
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
|
|
1566
lib/strftime.c
1566
lib/strftime.c
File diff suppressed because it is too large
Load diff
|
@ -27,7 +27,7 @@ extern "C" {
|
|||
use UTC instead. Use __NS as the number of nanoseconds in the
|
||||
%N directive. */
|
||||
size_t nstrftime (char *, size_t, char const *, struct tm const *,
|
||||
int __utc, int __ns);
|
||||
int __utc, int __ns);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
1294
lib/striconveh.c
1294
lib/striconveh.c
File diff suppressed because it is too large
Load diff
|
@ -54,7 +54,7 @@ typedef struct
|
|||
set. */
|
||||
extern int
|
||||
iconveh_open (const char *to_codeset, const char *from_codeset,
|
||||
iconveh_t *cdp);
|
||||
iconveh_t *cdp);
|
||||
|
||||
/* Close a conversion descriptor created by iconveh_open().
|
||||
Return value: 0 if successful, otherwise -1 and errno set. */
|
||||
|
@ -78,10 +78,10 @@ extern int
|
|||
unchanged if no dynamic memory allocation was necessary. */
|
||||
extern int
|
||||
mem_cd_iconveh (const char *src, size_t srclen,
|
||||
const iconveh_t *cd,
|
||||
enum iconv_ilseq_handler handler,
|
||||
size_t *offsets,
|
||||
char **resultp, size_t *lengthp);
|
||||
const iconveh_t *cd,
|
||||
enum iconv_ilseq_handler handler,
|
||||
size_t *offsets,
|
||||
char **resultp, size_t *lengthp);
|
||||
|
||||
/* Convert an entire string from one encoding to another, using iconv.
|
||||
The original string is the NUL-terminated string starting at SRC.
|
||||
|
@ -94,8 +94,8 @@ extern int
|
|||
successful, otherwise NULL and errno set. */
|
||||
extern char *
|
||||
str_cd_iconveh (const char *src,
|
||||
const iconveh_t *cd,
|
||||
enum iconv_ilseq_handler handler);
|
||||
const iconveh_t *cd,
|
||||
enum iconv_ilseq_handler handler);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -114,10 +114,10 @@ extern char *
|
|||
unchanged if no dynamic memory allocation was necessary. */
|
||||
extern int
|
||||
mem_iconveh (const char *src, size_t srclen,
|
||||
const char *from_codeset, const char *to_codeset,
|
||||
enum iconv_ilseq_handler handler,
|
||||
size_t *offsets,
|
||||
char **resultp, size_t *lengthp);
|
||||
const char *from_codeset, const char *to_codeset,
|
||||
enum iconv_ilseq_handler handler,
|
||||
size_t *offsets,
|
||||
char **resultp, size_t *lengthp);
|
||||
|
||||
/* Convert an entire string from one encoding to another, using iconv.
|
||||
The original string is the NUL-terminated string starting at SRC.
|
||||
|
@ -128,8 +128,8 @@ extern int
|
|||
successful, otherwise NULL and errno set. */
|
||||
extern char *
|
||||
str_iconveh (const char *src,
|
||||
const char *from_codeset, const char *to_codeset,
|
||||
enum iconv_ilseq_handler handler);
|
||||
const char *from_codeset, const char *to_codeset,
|
||||
enum iconv_ilseq_handler handler);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
107
lib/string.in.h
107
lib/string.in.h
|
@ -45,6 +45,8 @@
|
|||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -56,7 +58,7 @@ extern "C" {
|
|||
# if @REPLACE_MEMCHR@
|
||||
# define memchr rpl_memchr
|
||||
extern void *memchr (void const *__s, int __c, size_t __n)
|
||||
__attribute__ ((__pure__));
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef memchr
|
||||
|
@ -73,8 +75,8 @@ extern void *memchr (void const *__s, int __c, size_t __n)
|
|||
# endif
|
||||
# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
|
||||
extern void *memmem (void const *__haystack, size_t __haystack_len,
|
||||
void const *__needle, size_t __needle_len)
|
||||
__attribute__ ((__pure__));
|
||||
void const *__needle, size_t __needle_len)
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef memmem
|
||||
|
@ -90,7 +92,8 @@ extern void *memmem (void const *__haystack, size_t __haystack_len,
|
|||
#if @GNULIB_MEMPCPY@
|
||||
# if ! @HAVE_MEMPCPY@
|
||||
extern void *mempcpy (void *restrict __dest, void const *restrict __src,
|
||||
size_t __n);
|
||||
size_t __n)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mempcpy
|
||||
|
@ -104,7 +107,7 @@ extern void *mempcpy (void *restrict __dest, void const *restrict __src,
|
|||
#if @GNULIB_MEMRCHR@
|
||||
# if ! @HAVE_DECL_MEMRCHR@
|
||||
extern void *memrchr (void const *, int, size_t)
|
||||
__attribute__ ((__pure__));
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef memrchr
|
||||
|
@ -120,7 +123,7 @@ extern void *memrchr (void const *, int, size_t)
|
|||
#if @GNULIB_RAWMEMCHR@
|
||||
# if ! @HAVE_RAWMEMCHR@
|
||||
extern void *rawmemchr (void const *__s, int __c_in)
|
||||
__attribute__ ((__pure__));
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef rawmemchr
|
||||
|
@ -133,7 +136,8 @@ extern void *rawmemchr (void const *__s, int __c_in)
|
|||
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
|
||||
#if @GNULIB_STPCPY@
|
||||
# if ! @HAVE_STPCPY@
|
||||
extern char *stpcpy (char *restrict __dst, char const *restrict __src);
|
||||
extern char *stpcpy (char *restrict __dst, char const *restrict __src)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef stpcpy
|
||||
|
@ -149,7 +153,8 @@ extern char *stpcpy (char *restrict __dst, char const *restrict __src);
|
|||
# if ! @HAVE_STPNCPY@
|
||||
# define stpncpy gnu_stpncpy
|
||||
extern char *stpncpy (char *restrict __dst, char const *restrict __src,
|
||||
size_t __n);
|
||||
size_t __n)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef stpncpy
|
||||
|
@ -174,7 +179,7 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src,
|
|||
#if @GNULIB_STRCHRNUL@
|
||||
# if ! @HAVE_STRCHRNUL@
|
||||
extern char *strchrnul (char const *__s, int __c_in)
|
||||
__attribute__ ((__pure__));
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strchrnul
|
||||
|
@ -191,7 +196,7 @@ extern char *strchrnul (char const *__s, int __c_in)
|
|||
# define strdup rpl_strdup
|
||||
# endif
|
||||
# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
|
||||
extern char *strdup (char const *__s);
|
||||
extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strdup
|
||||
|
@ -208,7 +213,7 @@ extern char *strdup (char const *__s);
|
|||
# define strndup rpl_strndup
|
||||
# endif
|
||||
# if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
|
||||
extern char *strndup (char const *__string, size_t __n);
|
||||
extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strndup
|
||||
|
@ -224,7 +229,7 @@ extern char *strndup (char const *__string, size_t __n);
|
|||
#if @GNULIB_STRNLEN@
|
||||
# if ! @HAVE_DECL_STRNLEN@
|
||||
extern size_t strnlen (char const *__string, size_t __maxlen)
|
||||
__attribute__ ((__pure__));
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strnlen
|
||||
|
@ -251,7 +256,7 @@ extern size_t strnlen (char const *__string, size_t __maxlen)
|
|||
#if @GNULIB_STRPBRK@
|
||||
# if ! @HAVE_STRPBRK@
|
||||
extern char *strpbrk (char const *__s, char const *__accept)
|
||||
__attribute__ ((__pure__));
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
/* strpbrk() assumes the second argument is a list of single-byte characters.
|
||||
|
@ -313,7 +318,8 @@ extern char *strpbrk (char const *__s, char const *__accept)
|
|||
See also strtok_r(). */
|
||||
#if @GNULIB_STRSEP@
|
||||
# if ! @HAVE_STRSEP@
|
||||
extern char *strsep (char **restrict __stringp, char const *restrict __delim);
|
||||
extern char *strsep (char **restrict __stringp, char const *restrict __delim)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# undef strsep
|
||||
|
@ -334,8 +340,8 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim);
|
|||
#if @GNULIB_STRSTR@
|
||||
# if @REPLACE_STRSTR@
|
||||
# define strstr rpl_strstr
|
||||
char *strstr (const char *haystack, const char *needle)
|
||||
__attribute__ ((__pure__));
|
||||
extern char *strstr (const char *haystack, const char *needle)
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
/* strstr() does not work with multibyte strings if the locale encoding is
|
||||
|
@ -360,7 +366,7 @@ char *strstr (const char *haystack, const char *needle)
|
|||
# endif
|
||||
# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
|
||||
extern char *strcasestr (const char *haystack, const char *needle)
|
||||
__attribute__ ((__pure__));
|
||||
__attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
/* strcasestr() does not work with multibyte strings:
|
||||
|
@ -379,12 +385,12 @@ extern char *strcasestr (const char *haystack, const char *needle)
|
|||
/* Parse S into tokens separated by characters in DELIM.
|
||||
If S is NULL, the saved pointer in SAVE_PTR is used as
|
||||
the next starting point. For example:
|
||||
char s[] = "-abc-=-def";
|
||||
char *sp;
|
||||
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
|
||||
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
|
||||
x = strtok_r(NULL, "=", &sp); // x = NULL
|
||||
// s = "abc\0-def\0"
|
||||
char s[] = "-abc-=-def";
|
||||
char *sp;
|
||||
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
|
||||
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
|
||||
x = strtok_r(NULL, "=", &sp); // x = NULL
|
||||
// s = "abc\0-def\0"
|
||||
|
||||
This is a variant of strtok() that is multithread-safe.
|
||||
|
||||
|
@ -407,7 +413,8 @@ extern char *strcasestr (const char *haystack, const char *needle)
|
|||
# endif
|
||||
# if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
|
||||
extern char *strtok_r (char *restrict s, char const *restrict delim,
|
||||
char **restrict save_ptr);
|
||||
char **restrict save_ptr)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# undef strtok_r
|
||||
|
@ -432,13 +439,13 @@ extern char *strtok_r (char *restrict s, char const *restrict delim,
|
|||
#if @GNULIB_MBSLEN@
|
||||
/* Return the number of multibyte characters in the character string STRING.
|
||||
This considers multibyte characters, unlike strlen, which counts bytes. */
|
||||
extern size_t mbslen (const char *string);
|
||||
extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSNLEN@
|
||||
/* Return the number of multibyte characters in the character string starting
|
||||
at STRING and ending at STRING + LEN. */
|
||||
extern size_t mbsnlen (const char *string, size_t len);
|
||||
extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSCHR@
|
||||
|
@ -447,7 +454,7 @@ extern size_t mbsnlen (const char *string, size_t len);
|
|||
Unlike strchr(), this function works correctly in multibyte locales with
|
||||
encodings such as GB18030. */
|
||||
# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
|
||||
extern char * mbschr (const char *string, int c);
|
||||
extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSRCHR@
|
||||
|
@ -456,7 +463,7 @@ extern char * mbschr (const char *string, int c);
|
|||
Unlike strrchr(), this function works correctly in multibyte locales with
|
||||
encodings such as GB18030. */
|
||||
# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
|
||||
extern char * mbsrchr (const char *string, int c);
|
||||
extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSSTR@
|
||||
|
@ -464,7 +471,8 @@ extern char * mbsrchr (const char *string, int c);
|
|||
string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
|
||||
Unlike strstr(), this function works correctly in multibyte locales with
|
||||
encodings different from UTF-8. */
|
||||
extern char * mbsstr (const char *haystack, const char *needle);
|
||||
extern char * mbsstr (const char *haystack, const char *needle)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSCASECMP@
|
||||
|
@ -474,7 +482,8 @@ extern char * mbsstr (const char *haystack, const char *needle);
|
|||
Note: This function may, in multibyte locales, return 0 for strings of
|
||||
different lengths!
|
||||
Unlike strcasecmp(), this function works correctly in multibyte locales. */
|
||||
extern int mbscasecmp (const char *s1, const char *s2);
|
||||
extern int mbscasecmp (const char *s1, const char *s2)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSNCASECMP@
|
||||
|
@ -487,7 +496,8 @@ extern int mbscasecmp (const char *s1, const char *s2);
|
|||
of different lengths!
|
||||
Unlike strncasecmp(), this function works correctly in multibyte locales.
|
||||
But beware that N is not a byte count but a character count! */
|
||||
extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
|
||||
extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSPCASECMP@
|
||||
|
@ -500,7 +510,8 @@ extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
|
|||
smaller length than PREFIX!
|
||||
Unlike strncasecmp(), this function works correctly in multibyte
|
||||
locales. */
|
||||
extern char * mbspcasecmp (const char *string, const char *prefix);
|
||||
extern char * mbspcasecmp (const char *string, const char *prefix)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSCASESTR@
|
||||
|
@ -509,7 +520,8 @@ extern char * mbspcasecmp (const char *string, const char *prefix);
|
|||
Note: This function may, in multibyte locales, return success even if
|
||||
strlen (haystack) < strlen (needle) !
|
||||
Unlike strcasestr(), this function works correctly in multibyte locales. */
|
||||
extern char * mbscasestr (const char *haystack, const char *needle);
|
||||
extern char * mbscasestr (const char *haystack, const char *needle)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSCSPN@
|
||||
|
@ -518,7 +530,8 @@ extern char * mbscasestr (const char *haystack, const char *needle);
|
|||
beginning of the string to this occurrence, or to the end of the string
|
||||
if none exists.
|
||||
Unlike strcspn(), this function works correctly in multibyte locales. */
|
||||
extern size_t mbscspn (const char *string, const char *accept);
|
||||
extern size_t mbscspn (const char *string, const char *accept)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSPBRK@
|
||||
|
@ -527,7 +540,8 @@ extern size_t mbscspn (const char *string, const char *accept);
|
|||
exists.
|
||||
Unlike strpbrk(), this function works correctly in multibyte locales. */
|
||||
# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
|
||||
extern char * mbspbrk (const char *string, const char *accept);
|
||||
extern char * mbspbrk (const char *string, const char *accept)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSSPN@
|
||||
|
@ -536,7 +550,8 @@ extern char * mbspbrk (const char *string, const char *accept);
|
|||
beginning of the string to this occurrence, or to the end of the string
|
||||
if none exists.
|
||||
Unlike strspn(), this function works correctly in multibyte locales. */
|
||||
extern size_t mbsspn (const char *string, const char *reject);
|
||||
extern size_t mbsspn (const char *string, const char *reject)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSSEP@
|
||||
|
@ -554,7 +569,8 @@ extern size_t mbsspn (const char *string, const char *reject);
|
|||
Caveat: The identity of the delimiting character is lost.
|
||||
|
||||
See also mbstok_r(). */
|
||||
extern char * mbssep (char **stringp, const char *delim);
|
||||
extern char * mbssep (char **stringp, const char *delim)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSTOK_R@
|
||||
|
@ -562,19 +578,20 @@ extern char * mbssep (char **stringp, const char *delim);
|
|||
the character string DELIM.
|
||||
If STRING is NULL, the saved pointer in SAVE_PTR is used as
|
||||
the next starting point. For example:
|
||||
char s[] = "-abc-=-def";
|
||||
char *sp;
|
||||
x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
|
||||
x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
|
||||
x = mbstok_r(NULL, "=", &sp); // x = NULL
|
||||
// s = "abc\0-def\0"
|
||||
char s[] = "-abc-=-def";
|
||||
char *sp;
|
||||
x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
|
||||
x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
|
||||
x = mbstok_r(NULL, "=", &sp); // x = NULL
|
||||
// s = "abc\0-def\0"
|
||||
|
||||
Caveat: It modifies the original string.
|
||||
Caveat: These functions cannot be used on constant strings.
|
||||
Caveat: The identity of the delimiting character is lost.
|
||||
|
||||
See also mbssep(). */
|
||||
extern char * mbstok_r (char *string, const char *delim, char **save_ptr);
|
||||
extern char * mbstok_r (char *string, const char *delim, char **save_ptr)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
#endif
|
||||
|
||||
/* Map any int, typically from errno, into an error message. */
|
||||
|
@ -609,7 +626,7 @@ extern char *strsignal (int __sig);
|
|||
|
||||
#if @GNULIB_STRVERSCMP@
|
||||
# if !@HAVE_STRVERSCMP@
|
||||
extern int strverscmp (const char *, const char *);
|
||||
extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strverscmp
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* A substitute <strings.h>.
|
||||
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2009 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
|
||||
|
@ -31,6 +31,8 @@
|
|||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -42,7 +44,8 @@ extern "C" {
|
|||
than S2.
|
||||
Note: This function does not work in multibyte locales. */
|
||||
#if ! @HAVE_STRCASECMP@
|
||||
extern int strcasecmp (char const *s1, char const *s2);
|
||||
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:
|
||||
|
@ -64,7 +67,8 @@ extern int strcasecmp (char const *s1, char const *s2);
|
|||
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);
|
||||
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:
|
||||
|
|
|
@ -46,7 +46,7 @@ strncasecmp (const char *s1, const char *s2, size_t n)
|
|||
c2 = TOLOWER (*p2);
|
||||
|
||||
if (--n == 0 || c1 == '\0')
|
||||
break;
|
||||
break;
|
||||
|
||||
++p1;
|
||||
++p2;
|
||||
|
|
|
@ -49,7 +49,7 @@ extern int flock (int fd, int operation);
|
|||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef flock
|
||||
# define flock(fd,op) \
|
||||
# define flock(fd,op) \
|
||||
(GL_LINK_WARNING ("flock is unportable - " \
|
||||
"use gnulib module flock for portability"), \
|
||||
flock ((fd), (op)))
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#ifndef _GL_SYS_SOCKET_H
|
||||
#define _GL_SYS_SOCKET_H
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
#if !@HAVE_SA_FAMILY_T@
|
||||
typedef unsigned short sa_family_t;
|
||||
#endif
|
||||
|
@ -54,10 +56,10 @@ typedef unsigned short sa_family_t;
|
|||
# define __ss_aligntype unsigned long int
|
||||
# define _SS_SIZE 256
|
||||
# define _SS_PADSIZE \
|
||||
(_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
|
||||
? sizeof (sa_family_t) \
|
||||
: alignof (__ss_aligntype)) \
|
||||
+ sizeof (__ss_aligntype)))
|
||||
(_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
|
||||
? sizeof (sa_family_t) \
|
||||
: alignof (__ss_aligntype)) \
|
||||
+ sizeof (__ss_aligntype)))
|
||||
|
||||
struct sockaddr_storage
|
||||
{
|
||||
|
@ -177,7 +179,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
|
|||
# if @GNULIB_SOCKET@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef socket
|
||||
# define socket rpl_socket
|
||||
# define socket rpl_socket
|
||||
extern int rpl_socket (int, int, int protocol);
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
|
@ -194,8 +196,8 @@ extern int rpl_socket (int, int, int protocol);
|
|||
# if @GNULIB_CONNECT@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef connect
|
||||
# define connect rpl_connect
|
||||
extern int rpl_connect (int, struct sockaddr *, int);
|
||||
# define connect rpl_connect
|
||||
extern int rpl_connect (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef connect
|
||||
|
@ -211,7 +213,7 @@ extern int rpl_connect (int, struct sockaddr *, int);
|
|||
# if @GNULIB_ACCEPT@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef accept
|
||||
# define accept rpl_accept
|
||||
# define accept rpl_accept
|
||||
extern int rpl_accept (int, struct sockaddr *, int *);
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
|
@ -228,8 +230,8 @@ extern int rpl_accept (int, struct sockaddr *, int *);
|
|||
# if @GNULIB_BIND@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef bind
|
||||
# define bind rpl_bind
|
||||
extern int rpl_bind (int, struct sockaddr *, int);
|
||||
# define bind rpl_bind
|
||||
extern int rpl_bind (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef bind
|
||||
|
@ -245,8 +247,9 @@ extern int rpl_bind (int, struct sockaddr *, int);
|
|||
# if @GNULIB_GETPEERNAME@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef getpeername
|
||||
# define getpeername rpl_getpeername
|
||||
extern int rpl_getpeername (int, struct sockaddr *, int *);
|
||||
# define getpeername rpl_getpeername
|
||||
extern int rpl_getpeername (int, struct sockaddr *, int *)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef getpeername
|
||||
|
@ -262,8 +265,9 @@ extern int rpl_getpeername (int, struct sockaddr *, int *);
|
|||
# if @GNULIB_GETSOCKNAME@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef getsockname
|
||||
# define getsockname rpl_getsockname
|
||||
extern int rpl_getsockname (int, struct sockaddr *, int *);
|
||||
# define getsockname rpl_getsockname
|
||||
extern int rpl_getsockname (int, struct sockaddr *, int *)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef getsockname
|
||||
|
@ -279,8 +283,9 @@ extern int rpl_getsockname (int, struct sockaddr *, int *);
|
|||
# if @GNULIB_GETSOCKOPT@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef getsockopt
|
||||
# define getsockopt rpl_getsockopt
|
||||
extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
|
||||
# define getsockopt rpl_getsockopt
|
||||
extern int rpl_getsockopt (int, int, int, void *, socklen_t *)
|
||||
_GL_ARG_NONNULL ((4, 5));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef getsockopt
|
||||
|
@ -296,7 +301,7 @@ extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
|
|||
# if @GNULIB_LISTEN@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef listen
|
||||
# define listen rpl_listen
|
||||
# define listen rpl_listen
|
||||
extern int rpl_listen (int, int);
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
|
@ -313,8 +318,8 @@ extern int rpl_listen (int, int);
|
|||
# if @GNULIB_RECV@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef recv
|
||||
# define recv rpl_recv
|
||||
extern int rpl_recv (int, void *, int, int);
|
||||
# define recv rpl_recv
|
||||
extern int rpl_recv (int, void *, int, int) _GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef recv
|
||||
|
@ -330,8 +335,8 @@ extern int rpl_recv (int, void *, int, int);
|
|||
# if @GNULIB_SEND@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef send
|
||||
# define send rpl_send
|
||||
extern int rpl_send (int, const void *, int, int);
|
||||
# define send rpl_send
|
||||
extern int rpl_send (int, const void *, int, int) _GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef send
|
||||
|
@ -347,8 +352,9 @@ extern int rpl_send (int, const void *, int, int);
|
|||
# if @GNULIB_RECVFROM@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef recvfrom
|
||||
# define recvfrom rpl_recvfrom
|
||||
extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
|
||||
# define recvfrom rpl_recvfrom
|
||||
extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef recvfrom
|
||||
|
@ -364,8 +370,9 @@ extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
|
|||
# if @GNULIB_SENDTO@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef sendto
|
||||
# define sendto rpl_sendto
|
||||
extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
|
||||
# define sendto rpl_sendto
|
||||
extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef sendto
|
||||
|
@ -381,8 +388,9 @@ extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
|
|||
# if @GNULIB_SETSOCKOPT@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef setsockopt
|
||||
# define setsockopt rpl_setsockopt
|
||||
extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
|
||||
# define setsockopt rpl_setsockopt
|
||||
extern int rpl_setsockopt (int, int, int, const void *, socklen_t)
|
||||
_GL_ARG_NONNULL ((4));
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
# undef setsockopt
|
||||
|
@ -398,7 +406,7 @@ extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
|
|||
# if @GNULIB_SHUTDOWN@
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef shutdown
|
||||
# define shutdown rpl_shutdown
|
||||
# define shutdown rpl_shutdown
|
||||
extern int rpl_shutdown (int, int);
|
||||
# endif
|
||||
# elif @HAVE_WINSOCK2_H@
|
||||
|
@ -414,7 +422,7 @@ extern int rpl_shutdown (int, int);
|
|||
|
||||
# if @HAVE_WINSOCK2_H@
|
||||
# undef select
|
||||
# define select select_used_without_including_sys_select_h
|
||||
# define select select_used_without_including_sys_select_h
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
|
@ -437,7 +445,7 @@ extern "C" {
|
|||
# define accept4 rpl_accept4
|
||||
# endif
|
||||
extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
|
||||
int flags);
|
||||
int flags);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef accept4
|
||||
# define accept4(s,a,l,f) \
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
|
||||
headers that may declare mkdir(). */
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
|
@ -295,7 +297,8 @@ extern "C" {
|
|||
|
||||
#if @GNULIB_FCHMODAT@
|
||||
# if !@HAVE_FCHMODAT@
|
||||
extern int fchmodat (int fd, char const *file, mode_t mode, int flag);
|
||||
extern int fchmodat (int fd, char const *file, mode_t mode, int flag)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fchmodat
|
||||
|
@ -308,7 +311,7 @@ extern int fchmodat (int fd, char const *file, mode_t mode, int flag);
|
|||
|
||||
#if @REPLACE_FSTAT@
|
||||
# define fstat rpl_fstat
|
||||
extern int fstat (int fd, struct stat *buf);
|
||||
extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2));
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -318,7 +321,8 @@ extern int fstat (int fd, struct stat *buf);
|
|||
# define fstatat rpl_fstatat
|
||||
# endif
|
||||
# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@
|
||||
extern int fstatat (int fd, char const *name, struct stat *st, int flags);
|
||||
extern int fstatat (int fd, char const *name, struct stat *st, int flags)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fstatat
|
||||
|
@ -360,7 +364,7 @@ extern int futimens (int fd, struct timespec const times[2]);
|
|||
# define lchmod chmod
|
||||
# endif
|
||||
# if 0 /* assume already declared */
|
||||
extern int lchmod (const char *filename, mode_t mode);
|
||||
extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef lchmod
|
||||
|
@ -379,13 +383,14 @@ extern int lchmod (const char *filename, mode_t mode);
|
|||
# elif @REPLACE_LSTAT@
|
||||
# undef lstat
|
||||
# define lstat rpl_lstat
|
||||
extern int rpl_lstat (const char *name, struct stat *buf);
|
||||
extern int rpl_lstat (const char *name, struct stat *buf)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef lstat
|
||||
# define lstat(p,b) \
|
||||
(GL_LINK_WARNING ("lstat is unportable - " \
|
||||
"use gnulib module lstat for portability"), \
|
||||
# define lstat(p,b) \
|
||||
(GL_LINK_WARNING ("lstat is unportable - " \
|
||||
"use gnulib module lstat for portability"), \
|
||||
lstat (p, b))
|
||||
#endif
|
||||
|
||||
|
@ -393,7 +398,7 @@ extern int rpl_lstat (const char *name, struct stat *buf);
|
|||
#if @REPLACE_MKDIR@
|
||||
# undef mkdir
|
||||
# define mkdir rpl_mkdir
|
||||
extern int mkdir (char const *name, mode_t mode);
|
||||
extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1));
|
||||
#else
|
||||
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
|
||||
Additionally, it declares _mkdir (and depending on compile flags, an
|
||||
|
@ -413,7 +418,8 @@ rpl_mkdir (char const *name, mode_t mode)
|
|||
|
||||
#if @GNULIB_MKDIRAT@
|
||||
# if !@HAVE_MKDIRAT@
|
||||
extern int mkdirat (int fd, char const *file, mode_t mode);
|
||||
extern int mkdirat (int fd, char const *file, mode_t mode)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkdirat
|
||||
|
@ -430,7 +436,7 @@ extern int mkdirat (int fd, char const *file, mode_t mode);
|
|||
# define mkfifo rpl_mkfifo
|
||||
# endif
|
||||
# if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@
|
||||
int mkfifo (char const *file, mode_t mode);
|
||||
extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkfifo
|
||||
|
@ -443,11 +449,12 @@ int mkfifo (char const *file, mode_t mode);
|
|||
|
||||
#if @GNULIB_MKFIFOAT@
|
||||
# if !@HAVE_MKFIFOAT@
|
||||
int mkfifoat (int fd, char const *file, mode_t mode);
|
||||
extern int mkfifoat (int fd, char const *file, mode_t mode)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkfifoat
|
||||
# define mkfifoat(d,n,m) \
|
||||
# define mkfifoat(d,n,m) \
|
||||
(GL_LINK_WARNING ("mkfifoat is not portable - " \
|
||||
"use gnulib module mkfifoat for portability"), \
|
||||
mkfifoat (d, n, m))
|
||||
|
@ -460,7 +467,8 @@ int mkfifoat (int fd, char const *file, mode_t mode);
|
|||
# define mknod rpl_mknod
|
||||
# endif
|
||||
# if !@HAVE_MKNOD@ || @REPLACE_MKNOD@
|
||||
int mknod (char const *file, mode_t mode, dev_t dev);
|
||||
extern int mknod (char const *file, mode_t mode, dev_t dev)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mknod
|
||||
|
@ -473,11 +481,12 @@ int mknod (char const *file, mode_t mode, dev_t dev);
|
|||
|
||||
#if @GNULIB_MKNODAT@
|
||||
# if !@HAVE_MKNODAT@
|
||||
int mknodat (int fd, char const *file, mode_t mode, dev_t dev);
|
||||
extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mknodat
|
||||
# define mknodat(f,n,m,d) \
|
||||
# define mknodat(f,n,m,d) \
|
||||
(GL_LINK_WARNING ("mknodat is not portable - " \
|
||||
"use gnulib module mkfifoat for portability"), \
|
||||
mknodat (f, n, m, d))
|
||||
|
@ -499,13 +508,13 @@ int mknodat (int fd, char const *file, mode_t mode, dev_t dev);
|
|||
# else /* !_LARGE_FILES */
|
||||
# define stat(name, st) rpl_stat (name, st)
|
||||
# endif /* !_LARGE_FILES */
|
||||
extern int stat (const char *name, struct stat *buf);
|
||||
extern int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef stat
|
||||
# define stat(p,b) \
|
||||
(GL_LINK_WARNING ("stat is unportable - " \
|
||||
"use gnulib module stat for portability"), \
|
||||
# define stat(p,b) \
|
||||
(GL_LINK_WARNING ("stat is unportable - " \
|
||||
"use gnulib module stat for portability"), \
|
||||
stat (p, b))
|
||||
#endif
|
||||
|
||||
|
@ -517,7 +526,8 @@ extern int stat (const char *name, struct stat *buf);
|
|||
# endif
|
||||
# if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@
|
||||
extern int utimensat (int fd, char const *name,
|
||||
struct timespec const times[2], int flag);
|
||||
struct timespec const times[2], int flag)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef utimensat
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
/* NetBSD 5.0 mis-defines NULL. */
|
||||
#include <stddef.h>
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
@ -66,13 +68,14 @@ struct timespec
|
|||
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */
|
||||
# if @REPLACE_NANOSLEEP@
|
||||
# define nanosleep rpl_nanosleep
|
||||
int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
|
||||
extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
|
||||
/* Return the 'time_t' representation of TP and normalize TP. */
|
||||
# if @REPLACE_MKTIME@
|
||||
# define mktime rpl_mktime
|
||||
extern time_t mktime (struct tm *__tp);
|
||||
extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
|
||||
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
|
||||
|
@ -83,10 +86,12 @@ extern time_t mktime (struct tm *__tp);
|
|||
# define localtime_r rpl_localtime_r
|
||||
# undef gmtime_r
|
||||
# define gmtime_r rpl_gmtime_r
|
||||
struct tm *localtime_r (time_t const *restrict __timer,
|
||||
struct tm *restrict __result);
|
||||
struct tm *gmtime_r (time_t const *restrict __timer,
|
||||
struct tm *restrict __result);
|
||||
extern struct tm *localtime_r (time_t const *restrict __timer,
|
||||
struct tm *restrict __result)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
extern struct tm *gmtime_r (time_t const *restrict __timer,
|
||||
struct tm *restrict __result)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
|
||||
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
|
||||
|
@ -95,15 +100,17 @@ struct tm *gmtime_r (time_t const *restrict __timer,
|
|||
# if @REPLACE_STRPTIME@
|
||||
# undef strptime
|
||||
# define strptime rpl_strptime
|
||||
char *strptime (char const *restrict __buf, char const *restrict __format,
|
||||
struct tm *restrict __tm);
|
||||
extern char *strptime (char const *restrict __buf,
|
||||
char const *restrict __format,
|
||||
struct tm *restrict __tm)
|
||||
_GL_ARG_NONNULL ((1, 2, 3));
|
||||
# endif
|
||||
|
||||
/* Convert TM to a time_t value, assuming UTC. */
|
||||
# if @REPLACE_TIMEGM@
|
||||
# undef timegm
|
||||
# define timegm rpl_timegm
|
||||
time_t timegm (struct tm *__tm);
|
||||
extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
|
||||
/* Encourage applications to avoid unsafe functions that can overrun
|
||||
|
|
117
lib/unistd.in.h
117
lib/unistd.in.h
|
@ -59,43 +59,45 @@
|
|||
# include <winsock2.h>
|
||||
# if !defined _GL_SYS_SOCKET_H
|
||||
# undef socket
|
||||
# define socket socket_used_without_including_sys_socket_h
|
||||
# define socket socket_used_without_including_sys_socket_h
|
||||
# undef connect
|
||||
# define connect connect_used_without_including_sys_socket_h
|
||||
# define connect connect_used_without_including_sys_socket_h
|
||||
# undef accept
|
||||
# define accept accept_used_without_including_sys_socket_h
|
||||
# define accept accept_used_without_including_sys_socket_h
|
||||
# undef bind
|
||||
# define bind bind_used_without_including_sys_socket_h
|
||||
# define bind bind_used_without_including_sys_socket_h
|
||||
# undef getpeername
|
||||
# define getpeername getpeername_used_without_including_sys_socket_h
|
||||
# define getpeername getpeername_used_without_including_sys_socket_h
|
||||
# undef getsockname
|
||||
# define getsockname getsockname_used_without_including_sys_socket_h
|
||||
# define getsockname getsockname_used_without_including_sys_socket_h
|
||||
# undef getsockopt
|
||||
# define getsockopt getsockopt_used_without_including_sys_socket_h
|
||||
# define getsockopt getsockopt_used_without_including_sys_socket_h
|
||||
# undef listen
|
||||
# define listen listen_used_without_including_sys_socket_h
|
||||
# define listen listen_used_without_including_sys_socket_h
|
||||
# undef recv
|
||||
# define recv recv_used_without_including_sys_socket_h
|
||||
# define recv recv_used_without_including_sys_socket_h
|
||||
# undef send
|
||||
# define send send_used_without_including_sys_socket_h
|
||||
# define send send_used_without_including_sys_socket_h
|
||||
# undef recvfrom
|
||||
# define recvfrom recvfrom_used_without_including_sys_socket_h
|
||||
# define recvfrom recvfrom_used_without_including_sys_socket_h
|
||||
# undef sendto
|
||||
# define sendto sendto_used_without_including_sys_socket_h
|
||||
# define sendto sendto_used_without_including_sys_socket_h
|
||||
# undef setsockopt
|
||||
# define setsockopt setsockopt_used_without_including_sys_socket_h
|
||||
# define setsockopt setsockopt_used_without_including_sys_socket_h
|
||||
# undef shutdown
|
||||
# define shutdown shutdown_used_without_including_sys_socket_h
|
||||
# define shutdown shutdown_used_without_including_sys_socket_h
|
||||
# endif
|
||||
# if !defined _GL_SYS_SELECT_H
|
||||
# undef select
|
||||
# define select select_used_without_including_sys_select_h
|
||||
# define select select_used_without_including_sys_select_h
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
|
||||
/* OS/2 EMX lacks these macros. */
|
||||
#ifndef STDIN_FILENO
|
||||
|
@ -135,7 +137,8 @@ extern "C" {
|
|||
Return 0 if successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/chown.html>. */
|
||||
extern int chown (const char *file, uid_t uid, gid_t gid);
|
||||
extern int chown (const char *file, uid_t uid, gid_t gid)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef chown
|
||||
|
@ -239,7 +242,7 @@ extern char **environ;
|
|||
# if !@HAVE_EUIDACCESS@
|
||||
/* Like access(), except that it uses the effective user id and group id of
|
||||
the current process. */
|
||||
extern int euidaccess (const char *filename, int mode);
|
||||
extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef euidaccess
|
||||
|
@ -252,11 +255,12 @@ extern int euidaccess (const char *filename, int mode);
|
|||
|
||||
#if @GNULIB_FACCESSAT@
|
||||
# if !@HAVE_FACCESSAT@
|
||||
int faccessat (int fd, char const *file, int mode, int flag);
|
||||
extern int faccessat (int fd, char const *file, int mode, int flag)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef faccessat
|
||||
# define faccessat(d,n,m,f) \
|
||||
# define faccessat(d,n,m,f) \
|
||||
(GL_LINK_WARNING ("faccessat is not portable - " \
|
||||
"use gnulib module faccessat for portability"), \
|
||||
faccessat (d, n, m, f))
|
||||
|
@ -273,7 +277,8 @@ int faccessat (int fd, char const *file, int mode, int flag);
|
|||
extern int fchdir (int /*fd*/);
|
||||
|
||||
/* Gnulib internal hooks needed to maintain the fchdir metadata. */
|
||||
extern int _gl_register_fd (int fd, const char *filename);
|
||||
extern int _gl_register_fd (int fd, const char *filename)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
extern void _gl_unregister_fd (int fd);
|
||||
extern int _gl_register_dup (int oldfd, int newfd);
|
||||
extern const char *_gl_directory_name (int fd);
|
||||
|
@ -294,11 +299,12 @@ extern const char *_gl_directory_name (int fd);
|
|||
# define fchownat rpl_fchownat
|
||||
# endif
|
||||
# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
|
||||
extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);
|
||||
extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fchownat
|
||||
# define fchownat(d,n,o,g,f) \
|
||||
# define fchownat(d,n,o,g,f) \
|
||||
(GL_LINK_WARNING ("fchownat is not portable - " \
|
||||
"use gnulib module openat for portability"), \
|
||||
fchownat (d, n, o, g, f))
|
||||
|
@ -378,7 +384,7 @@ extern char * getcwd (char *buf, size_t size);
|
|||
If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
|
||||
Return 0 if successful, otherwise set errno and return -1. */
|
||||
# if !@HAVE_GETDOMAINNAME@
|
||||
extern int getdomainname(char *name, size_t len);
|
||||
extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getdomainname
|
||||
|
@ -439,7 +445,7 @@ int getgroups (int n, gid_t *groups);
|
|||
# define gethostname rpl_gethostname
|
||||
# endif
|
||||
# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
|
||||
extern int gethostname(char *name, size_t len);
|
||||
extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif @UNISTD_H_HAVE_WINSOCK2_H@
|
||||
# undef gethostname
|
||||
|
@ -464,7 +470,7 @@ extern int gethostname(char *name, size_t len);
|
|||
See <http://www.opengroup.org/susv3xsh/getlogin.html>.
|
||||
*/
|
||||
# if !@HAVE_DECL_GETLOGIN_R@
|
||||
extern int getlogin_r (char *name, size_t size);
|
||||
extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getlogin_r
|
||||
|
@ -574,7 +580,8 @@ extern void endusershell (void);
|
|||
Return 0 if successful, otherwise -1 and errno set.
|
||||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/lchown.html>. */
|
||||
extern int lchown (char const *file, uid_t owner, gid_t group);
|
||||
extern int lchown (char const *file, uid_t owner, gid_t group)
|
||||
_GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef lchown
|
||||
|
@ -594,7 +601,8 @@ extern int lchown (char const *file, uid_t owner, gid_t group);
|
|||
See POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/link.html>. */
|
||||
# if !@HAVE_LINK@ || @REPLACE_LINK@
|
||||
extern int link (const char *path1, const char *path2);
|
||||
extern int link (const char *path1, const char *path2)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef link
|
||||
|
@ -614,11 +622,12 @@ extern int link (const char *path1, const char *path2);
|
|||
Return 0 if successful, otherwise -1 and errno set. */
|
||||
# if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
|
||||
extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
|
||||
int flag);
|
||||
int flag)
|
||||
_GL_ARG_NONNULL ((2, 4));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef linkat
|
||||
# define link(f1,path1,f2,path2,f) \
|
||||
# define link(f1,path1,f2,path2,f) \
|
||||
(GL_LINK_WARNING ("linkat is unportable - " \
|
||||
"use gnulib module linkat for portability"), \
|
||||
linkat (f1, path1, f2, path2,f))
|
||||
|
@ -654,7 +663,7 @@ extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
|
|||
# if @HAVE_PIPE2@
|
||||
# define pipe2 rpl_pipe2
|
||||
# endif
|
||||
extern int pipe2 (int fd[2], int flags);
|
||||
extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef pipe2
|
||||
# define pipe2(f,o) \
|
||||
|
@ -664,6 +673,27 @@ extern int pipe2 (int fd[2], int flags);
|
|||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_PREAD@
|
||||
# if @REPLACE_PREAD@
|
||||
# define pread rpl_pread
|
||||
# endif
|
||||
/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
|
||||
Return the number of bytes placed into BUF if successful, otherwise
|
||||
set errno and return -1. 0 indicates EOF. See the POSIX:2001
|
||||
specification <http://www.opengroup.org/susv3xsh/pread.html>. */
|
||||
# if !@HAVE_PREAD@ || @REPLACE_PREAD@
|
||||
extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef pread
|
||||
# define pread(f,b,s,o) \
|
||||
(GL_LINK_WARNING ("pread is unportable - " \
|
||||
"use gnulib module pread for portability"), \
|
||||
pread (f, b, s, o))
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_READLINK@
|
||||
# if @REPLACE_READLINK@
|
||||
# define readlink rpl_readlink
|
||||
|
@ -674,7 +704,8 @@ extern int pipe2 (int fd[2], int flags);
|
|||
See the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/readlink.html>. */
|
||||
# if !@HAVE_READLINK@ || @REPLACE_READLINK@
|
||||
extern ssize_t readlink (const char *file, char *buf, size_t bufsize);
|
||||
extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef readlink
|
||||
|
@ -687,11 +718,12 @@ extern ssize_t readlink (const char *file, char *buf, size_t bufsize);
|
|||
|
||||
#if @GNULIB_READLINKAT@
|
||||
# if !@HAVE_READLINKAT@
|
||||
ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
|
||||
extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef readlinkat
|
||||
# define readlinkat(d,n,b,l) \
|
||||
# define readlinkat(d,n,b,l) \
|
||||
(GL_LINK_WARNING ("readlinkat is not portable - " \
|
||||
"use gnulib module symlinkat for portability"), \
|
||||
readlinkat (d, n, b, l))
|
||||
|
@ -702,7 +734,7 @@ ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
|
|||
# if @REPLACE_RMDIR@
|
||||
# define rmdir rpl_rmdir
|
||||
/* Remove the directory DIR. */
|
||||
extern int rmdir (char const *name);
|
||||
extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef rmdir
|
||||
|
@ -740,11 +772,12 @@ extern unsigned int sleep (unsigned int n);
|
|||
# define symlink rpl_symlink
|
||||
# endif
|
||||
# if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
|
||||
int symlink (char const *contents, char const *file);
|
||||
extern int symlink (char const *contents, char const *file)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef symlink
|
||||
# define symlink(c,n) \
|
||||
# define symlink(c,n) \
|
||||
(GL_LINK_WARNING ("symlink is not portable - " \
|
||||
"use gnulib module symlink for portability"), \
|
||||
symlink (c, n))
|
||||
|
@ -753,11 +786,12 @@ int symlink (char const *contents, char const *file);
|
|||
|
||||
#if @GNULIB_SYMLINKAT@
|
||||
# if !@HAVE_SYMLINKAT@
|
||||
int symlinkat (char const *contents, int fd, char const *file);
|
||||
extern int symlinkat (char const *contents, int fd, char const *file)
|
||||
_GL_ARG_NONNULL ((1, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef symlinkat
|
||||
# define symlinkat(c,d,n) \
|
||||
# define symlinkat(c,d,n) \
|
||||
(GL_LINK_WARNING ("symlinkat is not portable - " \
|
||||
"use gnulib module symlinkat for portability"), \
|
||||
symlinkat (c, d, n))
|
||||
|
@ -768,7 +802,7 @@ int symlinkat (char const *contents, int fd, char const *file);
|
|||
# if @REPLACE_UNLINK@
|
||||
# undef unlink
|
||||
# define unlink rpl_unlink
|
||||
extern int unlink (char const *file);
|
||||
extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef unlink
|
||||
|
@ -785,7 +819,7 @@ extern int unlink (char const *file);
|
|||
# define unlinkat rpl_unlinkat
|
||||
# endif
|
||||
# if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
|
||||
extern int unlinkat (int fd, char const *file, int flag);
|
||||
extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef unlinkat
|
||||
|
@ -823,7 +857,8 @@ extern int usleep (useconds_t n);
|
|||
<http://www.opengroup.org/susv3xsh/write.html>. */
|
||||
# undef write
|
||||
# define write rpl_write
|
||||
extern ssize_t write (int fd, const void *buf, size_t count);
|
||||
extern ssize_t write (int fd, const void *buf, size_t count)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
#endif
|
||||
|
||||
|
||||
|
|
22
lib/unistr.h
22
lib/unistr.h
|
@ -81,32 +81,32 @@ extern const uint32_t *
|
|||
/* Convert an UTF-8 string to an UTF-16 string. */
|
||||
extern uint16_t *
|
||||
u8_to_u16 (const uint8_t *s, size_t n, uint16_t *resultbuf,
|
||||
size_t *lengthp);
|
||||
size_t *lengthp);
|
||||
|
||||
/* Convert an UTF-8 string to an UCS-4 string. */
|
||||
extern uint32_t *
|
||||
u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf,
|
||||
size_t *lengthp);
|
||||
size_t *lengthp);
|
||||
|
||||
/* Convert an UTF-16 string to an UTF-8 string. */
|
||||
extern uint8_t *
|
||||
u16_to_u8 (const uint16_t *s, size_t n, uint8_t *resultbuf,
|
||||
size_t *lengthp);
|
||||
size_t *lengthp);
|
||||
|
||||
/* Convert an UTF-16 string to an UCS-4 string. */
|
||||
extern uint32_t *
|
||||
u16_to_u32 (const uint16_t *s, size_t n, uint32_t *resultbuf,
|
||||
size_t *lengthp);
|
||||
size_t *lengthp);
|
||||
|
||||
/* Convert an UCS-4 string to an UTF-8 string. */
|
||||
extern uint8_t *
|
||||
u32_to_u8 (const uint32_t *s, size_t n, uint8_t *resultbuf,
|
||||
size_t *lengthp);
|
||||
size_t *lengthp);
|
||||
|
||||
/* Convert an UCS-4 string to an UTF-16 string. */
|
||||
extern uint16_t *
|
||||
u32_to_u16 (const uint32_t *s, size_t n, uint16_t *resultbuf,
|
||||
size_t *lengthp);
|
||||
size_t *lengthp);
|
||||
|
||||
|
||||
/* Elementary string functions. */
|
||||
|
@ -351,12 +351,12 @@ u32_uctomb (uint32_t *s, ucs4_t uc, int n)
|
|||
if (uc < 0xd800 || (uc >= 0xe000 && uc < 0x110000))
|
||||
{
|
||||
if (n > 0)
|
||||
{
|
||||
*s = uc;
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
*s = uc;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return -2;
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
|
|
@ -30,124 +30,124 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (c < 0xfc)
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xfe)
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
|
|
|
@ -30,134 +30,134 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (c < 0xfc)
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xfe)
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
|
|
|
@ -41,134 +41,134 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
else if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (c < 0xfc)
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xfe)
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
|
|
|
@ -40,124 +40,124 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
else if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (c < 0xfc)
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
else if (c < 0xfe)
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
|
|
|
@ -33,250 +33,250 @@ u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
else if (c >= 0xc2)
|
||||
{
|
||||
if (c < 0xe0)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x1f) << 6)
|
||||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if (c < 0xfc)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else if (c < 0xfe)
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
if ((s[5] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (n >= 2)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
if ((s[5] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
|
|
|
@ -29,65 +29,65 @@ u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start)
|
|||
uint8_t c_1 = s[-1];
|
||||
|
||||
if (c_1 < 0x80)
|
||||
{
|
||||
*puc = c_1;
|
||||
return s - 1;
|
||||
}
|
||||
{
|
||||
*puc = c_1;
|
||||
return s - 1;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((c_1 ^ 0x80) < 0x40)
|
||||
#endif
|
||||
if (s - 1 != start)
|
||||
{
|
||||
uint8_t c_2 = s[-2];
|
||||
if (s - 1 != start)
|
||||
{
|
||||
uint8_t c_2 = s[-2];
|
||||
|
||||
if (c_2 >= 0xc2 && c_2 < 0xe0)
|
||||
{
|
||||
*puc = ((unsigned int) (c_2 & 0x1f) << 6)
|
||||
| (unsigned int) (c_1 ^ 0x80);
|
||||
return s - 2;
|
||||
}
|
||||
if (c_2 >= 0xc2 && c_2 < 0xe0)
|
||||
{
|
||||
*puc = ((unsigned int) (c_2 & 0x1f) << 6)
|
||||
| (unsigned int) (c_1 ^ 0x80);
|
||||
return s - 2;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((c_2 ^ 0x80) < 0x40)
|
||||
if ((c_2 ^ 0x80) < 0x40)
|
||||
#endif
|
||||
if (s - 2 != start)
|
||||
{
|
||||
uint8_t c_3 = s[-3];
|
||||
if (s - 2 != start)
|
||||
{
|
||||
uint8_t c_3 = s[-3];
|
||||
|
||||
if (c_3 >= 0xe0 && c_3 < 0xf0
|
||||
if (c_3 >= 0xe0 && c_3 < 0xf0
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
&& (c_3 >= 0xe1 || c_2 >= 0xa0)
|
||||
&& (c_3 != 0xed || c_2 < 0xa0)
|
||||
&& (c_3 >= 0xe1 || c_2 >= 0xa0)
|
||||
&& (c_3 != 0xed || c_2 < 0xa0)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c_3 & 0x0f) << 12)
|
||||
| ((unsigned int) (c_2 ^ 0x80) << 6)
|
||||
| (unsigned int) (c_1 ^ 0x80);
|
||||
return s - 3;
|
||||
}
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c_3 & 0x0f) << 12)
|
||||
| ((unsigned int) (c_2 ^ 0x80) << 6)
|
||||
| (unsigned int) (c_1 ^ 0x80);
|
||||
return s - 3;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((c_3 ^ 0x80) < 0x40)
|
||||
if ((c_3 ^ 0x80) < 0x40)
|
||||
#endif
|
||||
if (s - 3 != start)
|
||||
{
|
||||
uint8_t c_4 = s[-4];
|
||||
if (s - 3 != start)
|
||||
{
|
||||
uint8_t c_4 = s[-4];
|
||||
|
||||
if (c_4 >= 0xf0 && c_4 < 0xf8
|
||||
if (c_4 >= 0xf0 && c_4 < 0xf8
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
&& (c_4 >= 0xf1 || c_3 >= 0x90)
|
||||
&& (c_4 < 0xf4 || (c_4 == 0xf4 && c_3 < 0x90))
|
||||
&& (c_4 >= 0xf1 || c_3 >= 0x90)
|
||||
&& (c_4 < 0xf4 || (c_4 == 0xf4 && c_3 < 0x90))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c_4 & 0x07) << 18)
|
||||
| ((unsigned int) (c_3 ^ 0x80) << 12)
|
||||
| ((unsigned int) (c_2 ^ 0x80) << 6)
|
||||
| (unsigned int) (c_1 ^ 0x80);
|
||||
return s - 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c_4 & 0x07) << 18)
|
||||
| ((unsigned int) (c_3 ^ 0x80) << 12)
|
||||
| ((unsigned int) (c_2 ^ 0x80) << 6)
|
||||
| (unsigned int) (c_1 ^ 0x80);
|
||||
return s - 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n)
|
|||
else if (uc < 0x10000)
|
||||
{
|
||||
if (uc < 0xd800 || uc >= 0xe000)
|
||||
count = 3;
|
||||
count = 3;
|
||||
else
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
#if 0
|
||||
else if (uc < 0x200000)
|
||||
|
|
|
@ -33,10 +33,10 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
|
|||
if (uc < 0x80)
|
||||
{
|
||||
if (n > 0)
|
||||
{
|
||||
s[0] = uc;
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
s[0] = uc;
|
||||
return 1;
|
||||
}
|
||||
/* else return -2, below. */
|
||||
}
|
||||
else
|
||||
|
@ -44,43 +44,43 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
|
|||
int count;
|
||||
|
||||
if (uc < 0x800)
|
||||
count = 2;
|
||||
count = 2;
|
||||
else if (uc < 0x10000)
|
||||
{
|
||||
if (uc < 0xd800 || uc >= 0xe000)
|
||||
count = 3;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
if (uc < 0xd800 || uc >= 0xe000)
|
||||
count = 3;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#if 0
|
||||
else if (uc < 0x200000)
|
||||
count = 4;
|
||||
count = 4;
|
||||
else if (uc < 0x4000000)
|
||||
count = 5;
|
||||
count = 5;
|
||||
else if (uc <= 0x7fffffff)
|
||||
count = 6;
|
||||
count = 6;
|
||||
#else
|
||||
else if (uc < 0x110000)
|
||||
count = 4;
|
||||
count = 4;
|
||||
#endif
|
||||
else
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
if (n >= count)
|
||||
{
|
||||
switch (count) /* note: code falls through cases! */
|
||||
{
|
||||
{
|
||||
switch (count) /* note: code falls through cases! */
|
||||
{
|
||||
#if 0
|
||||
case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000;
|
||||
case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000;
|
||||
case 6: s[5] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x4000000;
|
||||
case 5: s[4] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x200000;
|
||||
#endif
|
||||
case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
|
||||
case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
|
||||
case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
|
||||
/*case 1:*/ s[0] = uc;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
|
||||
case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
|
||||
case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
|
||||
/*case 1:*/ s[0] = uc;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
|
|
7694
lib/vasnprintf.c
7694
lib/vasnprintf.c
File diff suppressed because it is too large
Load diff
|
@ -110,8 +110,8 @@
|
|||
|
||||
#if 4 <= __GNUC__
|
||||
# define verify(R) \
|
||||
extern int (* verify_function__ (void)) \
|
||||
[__builtin_constant_p (R) && (R) ? 1 : -1]
|
||||
extern int (* verify_function__ (void)) \
|
||||
[__builtin_constant_p (R) && (R) ? 1 : -1]
|
||||
#endif
|
||||
|
||||
* In C++, any struct definition inside sizeof is invalid.
|
||||
|
|
|
@ -32,6 +32,12 @@
|
|||
#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 = 2009 };
|
||||
|
||||
/* The three functions below display the --version information the
|
||||
|
@ -54,9 +60,9 @@ enum { COPYRIGHT_YEAR = 2009 };
|
|||
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)
|
||||
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);
|
||||
|
@ -66,7 +72,7 @@ version_etc_arn (FILE *stream,
|
|||
#ifdef PACKAGE_PACKAGER
|
||||
# ifdef PACKAGE_PACKAGER_VERSION
|
||||
fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER,
|
||||
PACKAGE_PACKAGER_VERSION);
|
||||
PACKAGE_PACKAGER_VERSION);
|
||||
# else
|
||||
fprintf (stream, _("Packaged by %s\n"), PACKAGE_PACKAGER);
|
||||
# endif
|
||||
|
@ -84,7 +90,7 @@ 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);
|
||||
stream);
|
||||
|
||||
switch (n_authors)
|
||||
{
|
||||
|
@ -102,66 +108,66 @@ There is NO WARRANTY, to the extent permitted by law.\n\
|
|||
case 3:
|
||||
/* TRANSLATORS: Each %s denotes an author name. */
|
||||
fprintf (stream, _("Written by %s, %s, and %s.\n"),
|
||||
authors[0], authors[1], authors[2]);
|
||||
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. */
|
||||
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]);
|
||||
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. */
|
||||
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]);
|
||||
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. */
|
||||
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]);
|
||||
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. */
|
||||
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]);
|
||||
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. */
|
||||
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]);
|
||||
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. */
|
||||
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]);
|
||||
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. */
|
||||
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. */
|
||||
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]);
|
||||
authors[0], authors[1], authors[2], authors[3], authors[4],
|
||||
authors[5], authors[6], authors[7], authors[8]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -172,8 +178,8 @@ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
|
|||
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)
|
||||
const char *command_name, const char *package,
|
||||
const char *version, const char * const * authors)
|
||||
{
|
||||
size_t n_authors;
|
||||
|
||||
|
@ -188,19 +194,19 @@ version_etc_ar (FILE *stream,
|
|||
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)
|
||||
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;
|
||||
&& (authtab[n_authors] = va_arg (authors, const char *)) != NULL;
|
||||
n_authors++)
|
||||
;
|
||||
version_etc_arn (stream, command_name, package, version,
|
||||
authtab, n_authors);
|
||||
authtab, n_authors);
|
||||
}
|
||||
|
||||
|
||||
|
@ -219,8 +225,8 @@ version_etc_va (FILE *stream,
|
|||
NULL argument at the end. */
|
||||
void
|
||||
version_etc (FILE *stream,
|
||||
const char *command_name, const char *package,
|
||||
const char *version, /* const char *author1, ...*/ ...)
|
||||
const char *command_name, const char *package,
|
||||
const char *version, /* const char *author1, ...*/ ...)
|
||||
{
|
||||
va_list authors;
|
||||
|
||||
|
@ -239,14 +245,14 @@ emit_bug_reporting_address (void)
|
|||
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);
|
||||
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_TARNAME);
|
||||
PACKAGE_NAME, PACKAGE);
|
||||
#endif
|
||||
fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"),
|
||||
stdout);
|
||||
stdout);
|
||||
}
|
||||
|
|
|
@ -50,26 +50,26 @@ extern const char version_etc_copyright[];
|
|||
|
||||
/* 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);
|
||||
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);
|
||||
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);
|
||||
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 */ ...)
|
||||
const char *command_name, const char *package,
|
||||
const char *version,
|
||||
/* const char *author1, ..., NULL */ ...)
|
||||
ATTRIBUTE_SENTINEL;
|
||||
|
||||
/* Display the usual `Report bugs to' stanza */
|
||||
|
|
|
@ -52,11 +52,11 @@ vsnprintf (char *str, size_t size, const char *format, va_list args)
|
|||
if (output != str)
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
size_t pruned_len = (len < size ? len : size - 1);
|
||||
memcpy (str, output, pruned_len);
|
||||
str[pruned_len] = '\0';
|
||||
}
|
||||
{
|
||||
size_t pruned_len = (len < size ? len : size - 1);
|
||||
memcpy (str, output, pruned_len);
|
||||
str[pruned_len] = '\0';
|
||||
}
|
||||
|
||||
free (output);
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -197,7 +199,8 @@ extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
|
|||
# define mbsrtowcs rpl_mbsrtowcs
|
||||
# endif
|
||||
# if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@
|
||||
extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps);
|
||||
extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mbsrtowcs
|
||||
|
@ -215,7 +218,8 @@ extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t
|
|||
# define mbsnrtowcs rpl_mbsnrtowcs
|
||||
# endif
|
||||
# if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@
|
||||
extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps);
|
||||
extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mbsnrtowcs
|
||||
|
@ -251,7 +255,8 @@ extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
|
|||
# define wcsrtombs rpl_wcsrtombs
|
||||
# endif
|
||||
# if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@
|
||||
extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps);
|
||||
extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef wcsrtombs
|
||||
|
@ -269,7 +274,8 @@ extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t
|
|||
# define wcsnrtombs rpl_wcsnrtombs
|
||||
# endif
|
||||
# if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@
|
||||
extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps);
|
||||
extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)
|
||||
_GL_ARG_NONNULL ((2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef wcsnrtombs
|
||||
|
|
16
lib/write.c
16
lib/write.c
|
@ -46,14 +46,14 @@ rpl_write (int fd, const void *buf, size_t count)
|
|||
if (ret < 0)
|
||||
{
|
||||
if (GetLastError () == ERROR_NO_DATA
|
||||
&& GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)
|
||||
{
|
||||
/* Try to raise signal SIGPIPE. */
|
||||
raise (SIGPIPE);
|
||||
/* If it is currently blocked or ignored, change errno from EINVAL
|
||||
to EPIPE. */
|
||||
errno = EPIPE;
|
||||
}
|
||||
&& GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)
|
||||
{
|
||||
/* Try to raise signal SIGPIPE. */
|
||||
raise (SIGPIPE);
|
||||
/* If it is currently blocked or ignored, change errno from EINVAL
|
||||
to EPIPE. */
|
||||
errno = EPIPE;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -115,69 +115,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* Ultrix has S_IFSOCK, but no S_ISSOCK. Ipe! */
|
||||
#if defined (S_IFSOCK) && ! defined (S_ISSOCK)
|
||||
#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
|
||||
#endif
|
||||
|
||||
/* The MinGW gcc does not define the S_ISSOCK macro. Any other native Windows
|
||||
compiler like BorlandC or MSVC has none of these macros defined. */
|
||||
#ifdef __MINGW32__
|
||||
|
||||
# ifdef _S_IFIFO
|
||||
# undef _S_IFIFO
|
||||
# endif
|
||||
# ifdef _S_IFCHR
|
||||
# undef _S_IFCHR
|
||||
# endif
|
||||
# ifdef _S_IFBLK
|
||||
# undef _S_IFBLK
|
||||
# endif
|
||||
# ifdef _S_IFDIR
|
||||
# undef _S_IFDIR
|
||||
# endif
|
||||
# ifdef _S_IFREG
|
||||
# undef _S_IFREG
|
||||
# endif
|
||||
# ifdef _S_IFSOCK
|
||||
# undef _S_IFSOCK
|
||||
# endif
|
||||
|
||||
# define _S_IFIFO 0x1000 /* FIFO */
|
||||
# define _S_IFCHR 0x2000 /* Character */
|
||||
# define _S_IFBLK 0x3000 /* Block */
|
||||
# define _S_IFDIR 0x4000 /* Directory */
|
||||
# define _S_IFREG 0x8000 /* Regular */
|
||||
# define _S_IFSOCK 0xC000 /* Socket */
|
||||
|
||||
# ifdef S_ISBLK
|
||||
# undef S_ISBLK
|
||||
# endif
|
||||
# ifdef S_ISFIFO
|
||||
# undef S_ISFIFO
|
||||
# endif
|
||||
# ifdef S_ISCHR
|
||||
# undef S_ISCHR
|
||||
# endif
|
||||
# ifdef S_ISDIR
|
||||
# undef S_ISDIR
|
||||
# endif
|
||||
# ifdef S_ISREG
|
||||
# undef S_ISREG
|
||||
# endif
|
||||
# ifdef S_ISSOCK
|
||||
# undef S_ISSOCK
|
||||
# endif
|
||||
|
||||
# define S_ISBLK(mode) (((mode) & _S_IFMT) == _S_IFBLK)
|
||||
# define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO)
|
||||
# define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR)
|
||||
# define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR)
|
||||
# define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG)
|
||||
# define S_ISSOCK(mode) (((mode) & _S_IFMT) == _S_IFSOCK)
|
||||
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
/* Some more definitions for the native Windows port. */
|
||||
#ifdef __MINGW32__
|
||||
# define mkdir(path, mode) mkdir (path)
|
||||
|
|
22
m4/dos.m4
22
m4/dos.m4
|
@ -14,31 +14,31 @@ AC_DEFUN([gl_AC_DOS],
|
|||
[
|
||||
AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
|
||||
[
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
|
||||
#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
|
||||
neither MSDOS nor Windows
|
||||
#endif]])],
|
||||
[ac_cv_win_or_dos=yes],
|
||||
[ac_cv_win_or_dos=no])
|
||||
[ac_cv_win_or_dos=yes],
|
||||
[ac_cv_win_or_dos=no])
|
||||
])
|
||||
|
||||
if test x"$ac_cv_win_or_dos" = xyes; then
|
||||
ac_fs_accepts_drive_letter_prefix=1
|
||||
ac_fs_backslash_is_file_name_separator=1
|
||||
AC_CACHE_CHECK([whether drive letter can start relative path],
|
||||
[ac_cv_drive_letter_can_be_relative],
|
||||
[
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
|
||||
[ac_cv_drive_letter_can_be_relative],
|
||||
[
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
|
||||
#if defined __CYGWIN__
|
||||
drive letters are always absolute
|
||||
#endif]])],
|
||||
[ac_cv_drive_letter_can_be_relative=yes],
|
||||
[ac_cv_drive_letter_can_be_relative=no])
|
||||
])
|
||||
[ac_cv_drive_letter_can_be_relative=yes],
|
||||
[ac_cv_drive_letter_can_be_relative=no])
|
||||
])
|
||||
if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
|
||||
ac_fs_drive_letter_can_be_relative=1
|
||||
ac_fs_drive_letter_can_be_relative=1
|
||||
else
|
||||
ac_fs_drive_letter_can_be_relative=0
|
||||
ac_fs_drive_letter_can_be_relative=0
|
||||
fi
|
||||
else
|
||||
ac_fs_accepts_drive_letter_prefix=0
|
||||
|
|
|
@ -9,27 +9,27 @@ AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
|
|||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root],
|
||||
[ if test x"$cross_compiling" = xyes ; then
|
||||
# When cross-compiling, there is no way to tell whether // is special
|
||||
# short of a list of hosts. However, the only known hosts to date
|
||||
# that have a distinct // are Apollo DomainOS (too old to port to),
|
||||
# Cygwin, and z/OS. If anyone knows of another system for which // has
|
||||
# special semantics and is distinct from /, please report it to
|
||||
# <bug-gnulib@gnu.org>.
|
||||
case $host in
|
||||
*-cygwin | i370-ibm-openedition)
|
||||
gl_cv_double_slash_root=yes ;;
|
||||
*)
|
||||
# Be optimistic and assume that / and // are the same when we
|
||||
# don't know.
|
||||
gl_cv_double_slash_root='unknown, assuming no' ;;
|
||||
esac
|
||||
# When cross-compiling, there is no way to tell whether // is special
|
||||
# short of a list of hosts. However, the only known hosts to date
|
||||
# that have a distinct // are Apollo DomainOS (too old to port to),
|
||||
# Cygwin, and z/OS. If anyone knows of another system for which // has
|
||||
# special semantics and is distinct from /, please report it to
|
||||
# <bug-gnulib@gnu.org>.
|
||||
case $host in
|
||||
*-cygwin | i370-ibm-openedition)
|
||||
gl_cv_double_slash_root=yes ;;
|
||||
*)
|
||||
# Be optimistic and assume that / and // are the same when we
|
||||
# don't know.
|
||||
gl_cv_double_slash_root='unknown, assuming no' ;;
|
||||
esac
|
||||
else
|
||||
set x `ls -di / // 2>/dev/null`
|
||||
if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
|
||||
gl_cv_double_slash_root=no
|
||||
else
|
||||
gl_cv_double_slash_root=yes
|
||||
fi
|
||||
set x `ls -di / // 2>/dev/null`
|
||||
if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
|
||||
gl_cv_double_slash_root=no
|
||||
else
|
||||
gl_cv_double_slash_root=yes
|
||||
fi
|
||||
fi])
|
||||
if test "$gl_cv_double_slash_root" = yes; then
|
||||
AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1],
|
||||
|
|
|
@ -74,8 +74,8 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
|
|||
[ac_cv_safe_to_define___extensions__],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
# define __EXTENSIONS__ 1
|
||||
]AC_INCLUDES_DEFAULT])],
|
||||
# define __EXTENSIONS__ 1
|
||||
]AC_INCLUDES_DEFAULT])],
|
||||
[ac_cv_safe_to_define___extensions__=yes],
|
||||
[ac_cv_safe_to_define___extensions__=no])])
|
||||
test $ac_cv_safe_to_define___extensions__ = yes &&
|
||||
|
|
|
@ -26,53 +26,53 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
|
|||
AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef O_NOATIME
|
||||
#define O_NOATIME 0
|
||||
#endif
|
||||
#ifndef O_NOFOLLOW
|
||||
#define O_NOFOLLOW 0
|
||||
#endif
|
||||
static int const constants[] =
|
||||
{
|
||||
O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
|
||||
O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
|
||||
};
|
||||
]],
|
||||
[[
|
||||
int status = !constants;
|
||||
{
|
||||
static char const sym[] = "conftest.sym";
|
||||
if (symlink (".", sym) != 0
|
||||
|| close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
|
||||
status |= 32;
|
||||
unlink (sym);
|
||||
}
|
||||
{
|
||||
static char const file[] = "confdefs.h";
|
||||
int fd = open (file, O_RDONLY | O_NOATIME);
|
||||
char c;
|
||||
struct stat st0, st1;
|
||||
if (fd < 0
|
||||
|| fstat (fd, &st0) != 0
|
||||
|| sleep (1) != 0
|
||||
|| read (fd, &c, 1) != 1
|
||||
|| close (fd) != 0
|
||||
|| stat (file, &st1) != 0
|
||||
|| st0.st_atime != st1.st_atime)
|
||||
status |= 64;
|
||||
}
|
||||
return status;]])],
|
||||
[[#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef O_NOATIME
|
||||
#define O_NOATIME 0
|
||||
#endif
|
||||
#ifndef O_NOFOLLOW
|
||||
#define O_NOFOLLOW 0
|
||||
#endif
|
||||
static int const constants[] =
|
||||
{
|
||||
O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
|
||||
O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
|
||||
};
|
||||
]],
|
||||
[[
|
||||
int status = !constants;
|
||||
{
|
||||
static char const sym[] = "conftest.sym";
|
||||
if (symlink (".", sym) != 0
|
||||
|| close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
|
||||
status |= 32;
|
||||
unlink (sym);
|
||||
}
|
||||
{
|
||||
static char const file[] = "confdefs.h";
|
||||
int fd = open (file, O_RDONLY | O_NOATIME);
|
||||
char c;
|
||||
struct stat st0, st1;
|
||||
if (fd < 0
|
||||
|| fstat (fd, &st0) != 0
|
||||
|| sleep (1) != 0
|
||||
|| read (fd, &c, 1) != 1
|
||||
|| close (fd) != 0
|
||||
|| stat (file, &st1) != 0
|
||||
|| st0.st_atime != st1.st_atime)
|
||||
status |= 64;
|
||||
}
|
||||
return status;]])],
|
||||
[gl_cv_header_working_fcntl_h=yes],
|
||||
[case $? in #(
|
||||
32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
|
||||
64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
|
||||
96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
|
||||
*) gl_cv_header_working_fcntl_h='no';;
|
||||
esac],
|
||||
32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
|
||||
64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
|
||||
96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
|
||||
*) gl_cv_header_working_fcntl_h='no';;
|
||||
esac],
|
||||
[gl_cv_header_working_fcntl_h=cross-compiling])])
|
||||
|
||||
case $gl_cv_header_working_fcntl_h in #(
|
||||
|
|
|
@ -12,16 +12,16 @@ AC_DEFUN([gl_GLIBC21],
|
|||
AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
|
||||
[ac_cv_gnu_library_2_1],
|
||||
[AC_EGREP_CPP([Lucky GNU user],
|
||||
[
|
||||
[
|
||||
#include <features.h>
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
|
||||
Lucky GNU user
|
||||
#endif
|
||||
#endif
|
||||
],
|
||||
[ac_cv_gnu_library_2_1=yes],
|
||||
[ac_cv_gnu_library_2_1=no])
|
||||
],
|
||||
[ac_cv_gnu_library_2_1=yes],
|
||||
[ac_cv_gnu_library_2_1=no])
|
||||
]
|
||||
)
|
||||
AC_SUBST([GLIBC21])
|
||||
|
|
|
@ -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 alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string verify version-etc-fsf vsnprintf warnings
|
||||
# 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 alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
|
||||
|
||||
# Specification in the form of a few gnulib-tool.m4 macro invocations:
|
||||
gl_LOCAL_DIR([])
|
||||
|
@ -52,6 +52,7 @@ gl_MODULES([
|
|||
strftime
|
||||
striconveh
|
||||
string
|
||||
sys_stat
|
||||
verify
|
||||
version-etc-fsf
|
||||
vsnprintf
|
||||
|
|
|
@ -70,13 +70,13 @@ AC_DEFUN([AC_C_RESTRICT],
|
|||
for ac_kw in __restrict __restrict__ _Restrict restrict; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||
[[typedef int * int_ptr;
|
||||
int foo (int_ptr $ac_kw ip) {
|
||||
return ip[0];
|
||||
int foo (int_ptr $ac_kw ip) {
|
||||
return ip[0];
|
||||
}]],
|
||||
[[int s[1];
|
||||
int * $ac_kw t = s;
|
||||
t[0] = 0;
|
||||
return foo(t)]])],
|
||||
int * $ac_kw t = s;
|
||||
t[0] = 0;
|
||||
return foo(t)]])],
|
||||
[ac_cv_c_restrict=$ac_kw])
|
||||
test "$ac_cv_c_restrict" != no && break
|
||||
done
|
||||
|
|
|
@ -179,7 +179,7 @@ AC_DEFUN([gl_INIT],
|
|||
if test -n "$gl_LIBOBJS"; then
|
||||
# Remove the extension.
|
||||
sed_drop_objext='s/\.o$//;s/\.obj$//'
|
||||
for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
|
||||
for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
|
||||
gl_libobjs="$gl_libobjs $i.$ac_objext"
|
||||
gl_ltlibobjs="$gl_ltlibobjs $i.lo"
|
||||
done
|
||||
|
@ -218,7 +218,7 @@ AC_DEFUN([gl_INIT],
|
|||
if test -n "$gltests_LIBOBJS"; then
|
||||
# Remove the extension.
|
||||
sed_drop_objext='s/\.o$//;s/\.obj$//'
|
||||
for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
|
||||
for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
|
||||
gltests_libobjs="$gltests_libobjs $i.$ac_objext"
|
||||
gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
|
||||
done
|
||||
|
@ -286,6 +286,7 @@ AC_DEFUN([gltests_LIBSOURCES], [
|
|||
# gnulib-tool and may be removed by future gnulib-tool invocations.
|
||||
AC_DEFUN([gl_FILE_LIST], [
|
||||
build-aux/announce-gen
|
||||
build-aux/arg-nonnull.h
|
||||
build-aux/config.rpath
|
||||
build-aux/gendocs.sh
|
||||
build-aux/gitlog-to-changelog
|
||||
|
|
|
@ -90,8 +90,8 @@ int main ()
|
|||
outptr = buf;
|
||||
outbytesleft = sizeof (buf);
|
||||
res = iconv (cd,
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
ASSERT (res == 0 && inbytesleft == 0);
|
||||
ASSERT (outptr == buf + (sizeof (expected) - 1));
|
||||
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
|
||||
|
@ -117,8 +117,8 @@ int main ()
|
|||
outptr = buf;
|
||||
outbytesleft = sizeof (buf);
|
||||
res = iconv (cd,
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
ASSERT (res == 0 && inbytesleft == 0);
|
||||
ASSERT (outptr == buf + (sizeof (expected) - 1));
|
||||
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
|
||||
|
@ -144,8 +144,8 @@ int main ()
|
|||
outptr = buf;
|
||||
outbytesleft = sizeof (buf);
|
||||
res = iconv (cd,
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
ASSERT (res == 0 && inbytesleft == 0);
|
||||
ASSERT (outptr == buf + (sizeof (expected) - 1));
|
||||
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
|
||||
|
@ -171,8 +171,8 @@ int main ()
|
|||
outptr = buf;
|
||||
outbytesleft = sizeof (buf);
|
||||
res = iconv (cd,
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
ASSERT (res == 0 && inbytesleft == 0);
|
||||
ASSERT (outptr == buf + (sizeof (expected) - 1));
|
||||
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
|
||||
|
@ -199,8 +199,8 @@ int main ()
|
|||
outptr = buf;
|
||||
outbytesleft = sizeof (buf);
|
||||
res = iconv (cd,
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
(ICONV_CONST char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
ASSERT (res == 0 && inbytesleft == 0);
|
||||
ASSERT (outptr == buf + (sizeof (expected) - 1));
|
||||
ASSERT (memcmp (buf, expected, sizeof (expected) - 1) == 0);
|
||||
|
|
|
@ -109,11 +109,11 @@ EOF
|
|||
# be
|
||||
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
|
||||
# That way, a header file with the following line:
|
||||
# #@INCLUDE_NEXT@ @NEXT_FOO_H@
|
||||
# #@INCLUDE_NEXT@ @NEXT_FOO_H@
|
||||
# or
|
||||
# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
|
||||
# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
|
||||
# behaves (after sed substitution) as if it contained
|
||||
# #include_next <foo.h>
|
||||
# #include_next <foo.h>
|
||||
# even if the compiler does not support include_next.
|
||||
# The three "///" are to pacify Sun C 5.8, which otherwise would say
|
||||
# "warning: #include of /usr/include/... may be non-portable".
|
||||
|
@ -129,46 +129,46 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
|
|||
|
||||
m4_foreach_w([gl_HEADER_NAME], [$1],
|
||||
[AS_VAR_PUSHDEF([gl_next_header],
|
||||
[gl_cv_next_]m4_defn([gl_HEADER_NAME]))
|
||||
[gl_cv_next_]m4_defn([gl_HEADER_NAME]))
|
||||
if test $gl_cv_have_include_next = yes; then
|
||||
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
|
||||
else
|
||||
AC_CACHE_CHECK(
|
||||
[absolute name of <]m4_defn([gl_HEADER_NAME])[>],
|
||||
m4_defn([gl_next_header]),
|
||||
[AS_VAR_PUSHDEF([gl_header_exists],
|
||||
[ac_cv_header_]m4_defn([gl_HEADER_NAME]))
|
||||
if test AS_VAR_GET(gl_header_exists) = yes; then
|
||||
AC_LANG_CONFTEST(
|
||||
[AC_LANG_SOURCE(
|
||||
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
|
||||
)])
|
||||
dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
|
||||
dnl that contain only a #include of other header files and no
|
||||
dnl non-comment tokens of their own. This leads to a failure to
|
||||
dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
|
||||
dnl and others. The workaround is to force preservation of comments
|
||||
dnl through option -C. This ensures all necessary #line directives
|
||||
dnl are present. GCC supports option -C as well.
|
||||
case "$host_os" in
|
||||
aix*) gl_absname_cpp="$ac_cpp -C" ;;
|
||||
*) gl_absname_cpp="$ac_cpp" ;;
|
||||
esac
|
||||
dnl eval is necessary to expand gl_absname_cpp.
|
||||
dnl Ultrix and Pyramid sh refuse to redirect output of eval,
|
||||
dnl so use subshell.
|
||||
AS_VAR_SET([gl_next_header],
|
||||
['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
|
||||
sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
|
||||
s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
|
||||
s#^/[^/]#//&#
|
||||
p
|
||||
q
|
||||
}'`'"'])
|
||||
else
|
||||
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
|
||||
fi
|
||||
AS_VAR_POPDEF([gl_header_exists])])
|
||||
[absolute name of <]m4_defn([gl_HEADER_NAME])[>],
|
||||
m4_defn([gl_next_header]),
|
||||
[AS_VAR_PUSHDEF([gl_header_exists],
|
||||
[ac_cv_header_]m4_defn([gl_HEADER_NAME]))
|
||||
if test AS_VAR_GET(gl_header_exists) = yes; then
|
||||
AC_LANG_CONFTEST(
|
||||
[AC_LANG_SOURCE(
|
||||
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
|
||||
)])
|
||||
dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
|
||||
dnl that contain only a #include of other header files and no
|
||||
dnl non-comment tokens of their own. This leads to a failure to
|
||||
dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
|
||||
dnl and others. The workaround is to force preservation of comments
|
||||
dnl through option -C. This ensures all necessary #line directives
|
||||
dnl are present. GCC supports option -C as well.
|
||||
case "$host_os" in
|
||||
aix*) gl_absname_cpp="$ac_cpp -C" ;;
|
||||
*) gl_absname_cpp="$ac_cpp" ;;
|
||||
esac
|
||||
dnl eval is necessary to expand gl_absname_cpp.
|
||||
dnl Ultrix and Pyramid sh refuse to redirect output of eval,
|
||||
dnl so use subshell.
|
||||
AS_VAR_SET([gl_next_header],
|
||||
['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
|
||||
sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
|
||||
s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
|
||||
s#^/[^/]#//&#
|
||||
p
|
||||
q
|
||||
}'`'"'])
|
||||
else
|
||||
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
|
||||
fi
|
||||
AS_VAR_POPDEF([gl_header_exists])])
|
||||
fi
|
||||
AC_SUBST(
|
||||
AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
|
||||
|
|
|
@ -27,7 +27,7 @@ AC_DEFUN([gl_LD_VERSION_SCRIPT],
|
|||
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
|
||||
cat > conftest.map <<EOF
|
||||
VERS_1 {
|
||||
global: sym;
|
||||
global: sym;
|
||||
};
|
||||
|
||||
VERS_2 {
|
||||
|
|
|
@ -59,7 +59,7 @@ if test "$GCC" = yes; then
|
|||
# Canonicalize the path of ld
|
||||
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
|
||||
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
|
||||
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
|
||||
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
|
||||
done
|
||||
test -z "$LD" && LD="$ac_prog"
|
||||
;;
|
||||
|
@ -89,9 +89,9 @@ AC_CACHE_VAL([acl_cv_path_LD],
|
|||
# Break only if it was the GNU/non-GNU ld that we prefer.
|
||||
case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
|
||||
*GNU* | *'with BFD'*)
|
||||
test "$with_gnu_ld" != no && break ;;
|
||||
test "$with_gnu_ld" != no && break ;;
|
||||
*)
|
||||
test "$with_gnu_ld" != yes && break ;;
|
||||
test "$with_gnu_ld" != yes && break ;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -20,30 +20,30 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
|
|||
[AC_LINK_IFELSE(
|
||||
[_AC_TYPE_LONG_LONG_SNIPPET],
|
||||
[dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
|
||||
dnl If cross compiling, assume the bug isn't important, since
|
||||
dnl nobody cross compiles for this platform as far as we know.
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[@%:@include <limits.h>
|
||||
@%:@ifndef LLONG_MAX
|
||||
@%:@ define HALF \
|
||||
(1LL << (sizeof (long long int) * CHAR_BIT - 2))
|
||||
@%:@ define LLONG_MAX (HALF - 1 + HALF)
|
||||
@%:@endif]],
|
||||
[[long long int n = 1;
|
||||
int i;
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
long long int m = n << i;
|
||||
if (m >> i != n)
|
||||
return 1;
|
||||
if (LLONG_MAX / 2 < m)
|
||||
break;
|
||||
}
|
||||
return 0;]])],
|
||||
[ac_cv_type_long_long_int=yes],
|
||||
[ac_cv_type_long_long_int=no],
|
||||
[ac_cv_type_long_long_int=yes])],
|
||||
dnl If cross compiling, assume the bug isn't important, since
|
||||
dnl nobody cross compiles for this platform as far as we know.
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[@%:@include <limits.h>
|
||||
@%:@ifndef LLONG_MAX
|
||||
@%:@ define HALF \
|
||||
(1LL << (sizeof (long long int) * CHAR_BIT - 2))
|
||||
@%:@ define LLONG_MAX (HALF - 1 + HALF)
|
||||
@%:@endif]],
|
||||
[[long long int n = 1;
|
||||
int i;
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
long long int m = n << i;
|
||||
if (m >> i != n)
|
||||
return 1;
|
||||
if (LLONG_MAX / 2 < m)
|
||||
break;
|
||||
}
|
||||
return 0;]])],
|
||||
[ac_cv_type_long_long_int=yes],
|
||||
[ac_cv_type_long_long_int=no],
|
||||
[ac_cv_type_long_long_int=yes])],
|
||||
[ac_cv_type_long_long_int=no])])
|
||||
if test $ac_cv_type_long_long_int = yes; then
|
||||
AC_DEFINE([HAVE_LONG_LONG_INT], [1],
|
||||
|
@ -83,24 +83,24 @@ AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
|
|||
[
|
||||
AC_LANG_PROGRAM(
|
||||
[[/* For now, do not test the preprocessor; as of 2007 there are too many
|
||||
implementations with broken preprocessors. Perhaps this can
|
||||
be revisited in 2012. In the meantime, code should not expect
|
||||
#if to work with literals wider than 32 bits. */
|
||||
implementations with broken preprocessors. Perhaps this can
|
||||
be revisited in 2012. In the meantime, code should not expect
|
||||
#if to work with literals wider than 32 bits. */
|
||||
/* Test literals. */
|
||||
long long int ll = 9223372036854775807ll;
|
||||
long long int nll = -9223372036854775807LL;
|
||||
unsigned long long int ull = 18446744073709551615ULL;
|
||||
/* Test constant expressions. */
|
||||
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
|
||||
? 1 : -1)];
|
||||
? 1 : -1)];
|
||||
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
|
||||
? 1 : -1)];
|
||||
? 1 : -1)];
|
||||
int i = 63;]],
|
||||
[[/* Test availability of runtime routines for shift and division. */
|
||||
long long int llmax = 9223372036854775807ll;
|
||||
unsigned long long int ullmax = 18446744073709551615ull;
|
||||
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
|
||||
| (llmax / ll) | (llmax % ll)
|
||||
| (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
|
||||
| (ullmax / ull) | (ullmax % ull));]])
|
||||
| (llmax / ll) | (llmax % ll)
|
||||
| (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
|
||||
| (ullmax / ull) | (ullmax % ull));]])
|
||||
])
|
||||
|
|
|
@ -18,17 +18,17 @@ AC_DEFUN([AC_TYPE_MBSTATE_T],
|
|||
|
||||
AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[AC_INCLUDES_DEFAULT[
|
||||
# include <wchar.h>]],
|
||||
[[mbstate_t x; return sizeof x;]])],
|
||||
[ac_cv_type_mbstate_t=yes],
|
||||
[ac_cv_type_mbstate_t=no])])
|
||||
[AC_LANG_PROGRAM(
|
||||
[AC_INCLUDES_DEFAULT[
|
||||
# include <wchar.h>]],
|
||||
[[mbstate_t x; return sizeof x;]])],
|
||||
[ac_cv_type_mbstate_t=yes],
|
||||
[ac_cv_type_mbstate_t=no])])
|
||||
if test $ac_cv_type_mbstate_t = yes; then
|
||||
AC_DEFINE([HAVE_MBSTATE_T], [1],
|
||||
[Define to 1 if <wchar.h> declares mbstate_t.])
|
||||
[Define to 1 if <wchar.h> declares mbstate_t.])
|
||||
else
|
||||
AC_DEFINE([mbstate_t], [int],
|
||||
[Define to a type if <wchar.h> does not define.])
|
||||
[Define to a type if <wchar.h> does not define.])
|
||||
fi
|
||||
])
|
||||
|
|
|
@ -53,11 +53,11 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
|
|||
{
|
||||
int pagesize = getpagesize ();
|
||||
char *two_pages =
|
||||
(char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
|
||||
flags, fd, 0);
|
||||
(char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
|
||||
flags, fd, 0);
|
||||
if (two_pages != (char *)(-1)
|
||||
&& mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
|
||||
fence = two_pages + pagesize;
|
||||
&& mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
|
||||
fence = two_pages + pagesize;
|
||||
}
|
||||
#endif
|
||||
if (fence)
|
||||
|
|
10
m4/putenv.m4
10
m4/putenv.m4
|
@ -28,11 +28,11 @@ AC_DEFUN([gl_FUNC_PUTENV],
|
|||
return 1;
|
||||
|
||||
return 0;
|
||||
]])],
|
||||
gl_cv_func_svid_putenv=yes,
|
||||
gl_cv_func_svid_putenv=no,
|
||||
dnl When crosscompiling, assume putenv is broken.
|
||||
gl_cv_func_svid_putenv=no)
|
||||
]])],
|
||||
gl_cv_func_svid_putenv=yes,
|
||||
gl_cv_func_svid_putenv=no,
|
||||
dnl When crosscompiling, assume putenv is broken.
|
||||
gl_cv_func_svid_putenv=no)
|
||||
])
|
||||
if test $gl_cv_func_svid_putenv = no; then
|
||||
REPLACE_PUTENV=1
|
||||
|
|
|
@ -20,30 +20,30 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
|
|||
AC_CHECK_TYPE([socklen_t], ,
|
||||
[AC_MSG_CHECKING([for socklen_t equivalent])
|
||||
AC_CACHE_VAL([gl_cv_socklen_t_equiv],
|
||||
[# Systems have either "struct sockaddr *" or
|
||||
# "void *" as the second argument to getpeername
|
||||
gl_cv_socklen_t_equiv=
|
||||
for arg2 in "struct sockaddr" void; do
|
||||
for t in int size_t "unsigned int" "long int" "unsigned long int"; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||
[# Systems have either "struct sockaddr *" or
|
||||
# "void *" as the second argument to getpeername
|
||||
gl_cv_socklen_t_equiv=
|
||||
for arg2 in "struct sockaddr" void; do
|
||||
for t in int size_t "unsigned int" "long int" "unsigned long int"; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||
[[#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
int getpeername (int, $arg2 *, $t *);]],
|
||||
[[$t len;
|
||||
getpeername (0, 0, &len);]])],
|
||||
[gl_cv_socklen_t_equiv="$t"])
|
||||
test "$gl_cv_socklen_t_equiv" != "" && break
|
||||
done
|
||||
test "$gl_cv_socklen_t_equiv" != "" && break
|
||||
done
|
||||
[gl_cv_socklen_t_equiv="$t"])
|
||||
test "$gl_cv_socklen_t_equiv" != "" && break
|
||||
done
|
||||
test "$gl_cv_socklen_t_equiv" != "" && break
|
||||
done
|
||||
])
|
||||
if test "$gl_cv_socklen_t_equiv" = ""; then
|
||||
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
|
||||
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
|
||||
fi
|
||||
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])],
|
||||
[type to use in place of socklen_t if not defined])],
|
||||
[#include <sys/types.h>
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
|
|
138
m4/stdbool.m4
138
m4/stdbool.m4
|
@ -38,77 +38,77 @@ AC_DEFUN([AC_HEADER_STDBOOL],
|
|||
[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
|
||||
[ac_cv_header_stdbool_h],
|
||||
[AC_TRY_COMPILE(
|
||||
[
|
||||
#include <stdbool.h>
|
||||
#ifndef bool
|
||||
"error: bool is not defined"
|
||||
#endif
|
||||
#ifndef false
|
||||
"error: false is not defined"
|
||||
#endif
|
||||
#if false
|
||||
"error: false is not 0"
|
||||
#endif
|
||||
#ifndef true
|
||||
"error: true is not defined"
|
||||
#endif
|
||||
#if true != 1
|
||||
"error: true is not 1"
|
||||
#endif
|
||||
#ifndef __bool_true_false_are_defined
|
||||
"error: __bool_true_false_are_defined is not defined"
|
||||
#endif
|
||||
[
|
||||
#include <stdbool.h>
|
||||
#ifndef bool
|
||||
"error: bool is not defined"
|
||||
#endif
|
||||
#ifndef false
|
||||
"error: false is not defined"
|
||||
#endif
|
||||
#if false
|
||||
"error: false is not 0"
|
||||
#endif
|
||||
#ifndef true
|
||||
"error: true is not defined"
|
||||
#endif
|
||||
#if true != 1
|
||||
"error: true is not 1"
|
||||
#endif
|
||||
#ifndef __bool_true_false_are_defined
|
||||
"error: __bool_true_false_are_defined is not defined"
|
||||
#endif
|
||||
|
||||
struct s { _Bool s: 1; _Bool t; } s;
|
||||
struct s { _Bool s: 1; _Bool t; } s;
|
||||
|
||||
char a[true == 1 ? 1 : -1];
|
||||
char b[false == 0 ? 1 : -1];
|
||||
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
|
||||
char d[(bool) 0.5 == true ? 1 : -1];
|
||||
bool e = &s;
|
||||
char f[(_Bool) 0.0 == false ? 1 : -1];
|
||||
char g[true];
|
||||
char h[sizeof (_Bool)];
|
||||
char i[sizeof s.t];
|
||||
enum { j = false, k = true, l = false * true, m = true * 256 };
|
||||
_Bool n[m];
|
||||
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
|
||||
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
|
||||
#if defined __xlc__ || defined __GNUC__
|
||||
/* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
|
||||
reported by James Lemley on 2005-10-05; see
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
|
||||
This test is not quite right, since xlc is allowed to
|
||||
reject this program, as the initializer for xlcbug is
|
||||
not one of the forms that C requires support for.
|
||||
However, doing the test right would require a run-time
|
||||
test, and that would make cross-compilation harder.
|
||||
Let us hope that IBM fixes the xlc bug, and also adds
|
||||
support for this kind of constant expression. In the
|
||||
meantime, this test will reject xlc, which is OK, since
|
||||
our stdbool.h substitute should suffice. We also test
|
||||
this with GCC, where it should work, to detect more
|
||||
quickly whether someone messes up the test in the
|
||||
future. */
|
||||
char digs[] = "0123456789";
|
||||
int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
|
||||
#endif
|
||||
/* Catch a bug in an HP-UX C compiler. See
|
||||
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
|
||||
*/
|
||||
_Bool q = true;
|
||||
_Bool *pq = &q;
|
||||
],
|
||||
[
|
||||
*pq |= q;
|
||||
*pq |= ! q;
|
||||
/* Refer to every declared value, to avoid compiler optimizations. */
|
||||
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
|
||||
+ !m + !n + !o + !p + !q + !pq);
|
||||
],
|
||||
[ac_cv_header_stdbool_h=yes],
|
||||
[ac_cv_header_stdbool_h=no])])
|
||||
char a[true == 1 ? 1 : -1];
|
||||
char b[false == 0 ? 1 : -1];
|
||||
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
|
||||
char d[(bool) 0.5 == true ? 1 : -1];
|
||||
bool e = &s;
|
||||
char f[(_Bool) 0.0 == false ? 1 : -1];
|
||||
char g[true];
|
||||
char h[sizeof (_Bool)];
|
||||
char i[sizeof s.t];
|
||||
enum { j = false, k = true, l = false * true, m = true * 256 };
|
||||
_Bool n[m];
|
||||
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
|
||||
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
|
||||
#if defined __xlc__ || defined __GNUC__
|
||||
/* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
|
||||
reported by James Lemley on 2005-10-05; see
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
|
||||
This test is not quite right, since xlc is allowed to
|
||||
reject this program, as the initializer for xlcbug is
|
||||
not one of the forms that C requires support for.
|
||||
However, doing the test right would require a run-time
|
||||
test, and that would make cross-compilation harder.
|
||||
Let us hope that IBM fixes the xlc bug, and also adds
|
||||
support for this kind of constant expression. In the
|
||||
meantime, this test will reject xlc, which is OK, since
|
||||
our stdbool.h substitute should suffice. We also test
|
||||
this with GCC, where it should work, to detect more
|
||||
quickly whether someone messes up the test in the
|
||||
future. */
|
||||
char digs[] = "0123456789";
|
||||
int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
|
||||
#endif
|
||||
/* Catch a bug in an HP-UX C compiler. See
|
||||
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
|
||||
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
|
||||
*/
|
||||
_Bool q = true;
|
||||
_Bool *pq = &q;
|
||||
],
|
||||
[
|
||||
*pq |= q;
|
||||
*pq |= ! q;
|
||||
/* Refer to every declared value, to avoid compiler optimizations. */
|
||||
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
|
||||
+ !m + !n + !o + !p + !q + !pq);
|
||||
],
|
||||
[ac_cv_header_stdbool_h=yes],
|
||||
[ac_cv_header_stdbool_h=no])])
|
||||
AC_CHECK_TYPES([_Bool])
|
||||
if test $ac_cv_header_stdbool_h = yes; then
|
||||
AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
|
||||
|
|
12
m4/stdint.m4
12
m4/stdint.m4
|
@ -396,12 +396,12 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
|
|||
for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
|
||||
case $glsuf in
|
||||
'') gltype1='int';;
|
||||
l) gltype1='long int';;
|
||||
ll) gltype1='long long int';;
|
||||
i64) gltype1='__int64';;
|
||||
u) gltype1='unsigned int';;
|
||||
ul) gltype1='unsigned long int';;
|
||||
ull) gltype1='unsigned long long int';;
|
||||
l) gltype1='long int';;
|
||||
ll) gltype1='long long int';;
|
||||
i64) gltype1='__int64';;
|
||||
u) gltype1='unsigned int';;
|
||||
ul) gltype1='unsigned long int';;
|
||||
ull) gltype1='unsigned long long int';;
|
||||
ui64)gltype1='unsigned __int64';;
|
||||
esac
|
||||
AC_COMPILE_IFELSE(
|
||||
|
|
|
@ -140,6 +140,6 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
|
|||
choke me
|
||||
# endif
|
||||
#endif]])],
|
||||
[gl_cv_var_stdin_large_offset=yes],
|
||||
[gl_cv_var_stdin_large_offset=no])])
|
||||
[gl_cv_var_stdin_large_offset=yes],
|
||||
[gl_cv_var_stdin_large_offset=no])])
|
||||
])
|
||||
|
|
|
@ -66,31 +66,31 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
|
|||
GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
|
||||
GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
|
||||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
|
||||
HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
|
||||
HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
|
||||
HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
|
||||
HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
|
||||
HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
|
||||
HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
|
||||
HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
|
||||
HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
|
||||
HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
|
||||
HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
|
||||
HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
|
||||
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
|
||||
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
|
||||
HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
|
||||
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
|
||||
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
|
||||
REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
|
||||
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
|
||||
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
|
||||
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
|
||||
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
|
||||
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
|
||||
REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
|
||||
REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
|
||||
REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
|
||||
UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
|
||||
HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
|
||||
HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
|
||||
HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
|
||||
HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
|
||||
HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
|
||||
HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
|
||||
HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
|
||||
HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
|
||||
HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
|
||||
HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
|
||||
HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
|
||||
HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
|
||||
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
|
||||
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
|
||||
HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
|
||||
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
|
||||
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
|
||||
REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
|
||||
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
|
||||
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
|
||||
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
|
||||
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
|
||||
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
|
||||
REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
|
||||
REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
|
||||
REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
|
||||
UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
|
||||
])
|
||||
|
|
18
m4/time_h.m4
18
m4/time_h.m4
|
@ -45,9 +45,9 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
|
|||
[gl_cv_sys_struct_timespec_in_time_h],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <time.h>
|
||||
]],
|
||||
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
|
||||
[[#include <time.h>
|
||||
]],
|
||||
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
|
||||
[gl_cv_sys_struct_timespec_in_time_h=yes],
|
||||
[gl_cv_sys_struct_timespec_in_time_h=no])])
|
||||
|
||||
|
@ -59,12 +59,12 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
|
|||
AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
|
||||
[gl_cv_sys_struct_timespec_in_sys_time_h],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <sys/time.h>
|
||||
]],
|
||||
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
|
||||
[gl_cv_sys_struct_timespec_in_sys_time_h=yes],
|
||||
[gl_cv_sys_struct_timespec_in_sys_time_h=no])])
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <sys/time.h>
|
||||
]],
|
||||
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
|
||||
[gl_cv_sys_struct_timespec_in_sys_time_h=yes],
|
||||
[gl_cv_sys_struct_timespec_in_sys_time_h=no])])
|
||||
if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
|
||||
SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
|
||||
fi
|
||||
|
|
|
@ -56,6 +56,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
|
|||
GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
|
||||
GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
|
||||
GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
|
||||
GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
|
||||
GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
|
||||
GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
|
||||
GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
|
||||
|
@ -87,6 +88,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
|
|||
HAVE_LINK=1; AC_SUBST([HAVE_LINK])
|
||||
HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
|
||||
HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
|
||||
HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
|
||||
HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
|
||||
HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
|
||||
HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
|
||||
|
@ -111,6 +113,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
|
|||
REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
|
||||
REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
|
||||
REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
|
||||
REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
|
||||
REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
|
||||
REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
|
||||
REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
|
||||
|
|
|
@ -11,8 +11,8 @@ m4_define([gl_VERSION_ETC_FLAG],
|
|||
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]) ;;
|
||||
yes|no) ;;
|
||||
*) AC_DEFINE_UNQUOTED(AS_TR_CPP([PACKAGE_$1]), ["$withval"], [$2]) ;;
|
||||
esac
|
||||
])
|
||||
])
|
||||
|
@ -20,11 +20,11 @@ m4_define([gl_VERSION_ETC_FLAG],
|
|||
AC_DEFUN([gl_VERSION_ETC],
|
||||
[dnl
|
||||
gl_VERSION_ETC_FLAG([packager],
|
||||
[String identifying the packager of this software])
|
||||
[String identifying the packager of this software])
|
||||
gl_VERSION_ETC_FLAG([packager-version],
|
||||
[Packager-specific version information])
|
||||
[Packager-specific version information])
|
||||
gl_VERSION_ETC_FLAG([packager-bug-reports],
|
||||
[Packager info for bug reports (URL/e-mail/...)])
|
||||
[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
|
||||
|
|
|
@ -33,7 +33,7 @@ AC_CACHE_CHECK([whether compiler handles $1], [gl_Warn], [
|
|||
CPPFLAGS="${CPPFLAGS} $1"
|
||||
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
|
||||
[AS_VAR_SET([gl_Warn], [yes])],
|
||||
[AS_VAR_SET([gl_Warn], [no])])
|
||||
[AS_VAR_SET([gl_Warn], [no])])
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
])
|
||||
AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl
|
||||
|
|
38
maint.mk
38
maint.mk
|
@ -77,6 +77,11 @@ else
|
|||
url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
|
||||
endif
|
||||
|
||||
# Override this in cfg.mk if you are using a different format in your
|
||||
# NEWS file.
|
||||
today = $(shell date +%Y-%m-%d)
|
||||
news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)'
|
||||
|
||||
# Prevent programs like 'sort' from considering distinct strings to be equal.
|
||||
# Doing it here saves us from having to set LC_ALL elsewhere in this file.
|
||||
export LC_ALL = C
|
||||
|
@ -568,13 +573,12 @@ sc_makefile_check:
|
|||
$$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \
|
||||
&& { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
|
||||
|
||||
news-date-check: NEWS
|
||||
today=`date +%Y-%m-%d`; \
|
||||
if head $(srcdir)/NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
|
||||
news-check: NEWS
|
||||
if head $(srcdir)/NEWS | grep -E $(news-check-regexp) \
|
||||
>/dev/null; then \
|
||||
:; \
|
||||
else \
|
||||
echo "version or today's date is not in NEWS" 1>&2; \
|
||||
echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
|
@ -678,17 +682,6 @@ vc-diff-check:
|
|||
rm vc-diffs; \
|
||||
fi
|
||||
|
||||
# Use this to make sure we don't run these programs when building
|
||||
# from a virgin tgz file, below.
|
||||
null_AM_MAKEFLAGS = \
|
||||
ACLOCAL=false \
|
||||
AUTOCONF=false \
|
||||
AUTOMAKE=false \
|
||||
AUTOHEADER=false \
|
||||
MAKEINFO=false
|
||||
|
||||
built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
|
||||
|
||||
rel-files = $(DIST_ARCHIVES)
|
||||
|
||||
gnulib_dir ?= $(srcdir)/gnulib
|
||||
|
@ -754,15 +747,24 @@ alpha beta stable: $(local-check) writable-files no-submodule-changes
|
|||
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
|
||||
|| :
|
||||
$(MAKE) vc-diff-check
|
||||
$(MAKE) news-date-check
|
||||
$(MAKE) news-check
|
||||
$(MAKE) distcheck
|
||||
$(MAKE) dist XZ_OPT=-9ev
|
||||
$(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
|
||||
$(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
|
||||
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
|
||||
|
||||
# Override this in cfg.mk if you follow different procedures.
|
||||
release-prep-hook ?= release-prep
|
||||
|
||||
.PHONY: release-prep
|
||||
release-prep:
|
||||
case $$RELEASE_TYPE in alpha|beta|stable) ;; \
|
||||
*) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac
|
||||
$(MAKE) -s announcement > /tmp/announce-$(my_distdir)
|
||||
if test -d $(release_archive_dir); then \
|
||||
ln $(rel-files) $(release_archive_dir); \
|
||||
chmod a-w $(rel-files); \
|
||||
fi
|
||||
$(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
|
||||
echo $(VERSION) > $(prev_version_file)
|
||||
$(MAKE) update-NEWS-hash
|
||||
perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue