Use gnulib-tool to create gnulib source files.
* Add gnulib files generated by gnulib-tool in build-aux, m4 and
    grub-core/gnulib directories
    * .bzignore: Add **/.deps and autogenerated gnulib files
    * configure.ac: Assign auxiliary directory to build-aux, add invocation
    of gnulib macros, add grub-core/gnulib/Makefile
    * Makefile.am: Add gnulib directory in SUBDIRS (removing unnecessary .),
    include m4 directory to aclocal.
    * Makefile.util.def: Remove direct compilation of gnulib source files
    and use the new grub-core/gnulib/libgnu.a.
    * build-aux/config.rpath: move config.rpath from top directory to
    build-aux
    * conf/Makefile.common: Remove the macro _GL_UNUSED already defined
    in gnulib headers
    * conf/Makefile.extra-dist: Add m4/gnulib-cache.m4
    * grub-core/Makefile.core.def: Remove unnecessary extra_dist
    * grub-core/lib/posix_wrap/localcharset.h (locale_charset): Update
    header.
    * grub-core/lib/posix_wrap/langinfo.h (nl_langinfo): Return static
    string.
			
			
This commit is contained in:
		
							parent
							
								
									e511c9f591
								
							
						
					
					
						commit
						15c6926126
					
				
					 164 changed files with 28462 additions and 276 deletions
				
			
		
							
								
								
									
										18
									
								
								.bzrignore
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								.bzrignore
									
										
									
									
									
								
							|  | @ -99,6 +99,7 @@ depcomp | |||
| mdate-sh | ||||
| texinfo.tex | ||||
| grub-core/lib/libgcrypt-grub | ||||
| **/.deps | ||||
| **/.deps-util | ||||
| **/.deps-core | ||||
| **/.dirstamp | ||||
|  | @ -111,3 +112,20 @@ grub-core/gensyminfo.sh | |||
| grub-core/*.module | ||||
| grub-core/*.pp | ||||
| util/bash-completion.d/grub | ||||
| grub-core/gnulib/alloca.h | ||||
| grub-core/gnulib/arg-nonnull.h | ||||
| grub-core/gnulib/c++defs.h | ||||
| grub-core/gnulib/charset.alias | ||||
| grub-core/gnulib/configmake.h | ||||
| grub-core/gnulib/getopt.h | ||||
| grub-core/gnulib/langinfo.h | ||||
| grub-core/gnulib/ref-add.sed | ||||
| grub-core/gnulib/ref-del.sed | ||||
| grub-core/gnulib/stdio.h | ||||
| grub-core/gnulib/stdlib.h | ||||
| grub-core/gnulib/string.h | ||||
| grub-core/gnulib/strings.h | ||||
| grub-core/gnulib/unistd.h | ||||
| grub-core/gnulib/warn-on-use.h | ||||
| grub-core/gnulib/wchar.h | ||||
| grub-core/gnulib/wctype.h | ||||
|  |  | |||
							
								
								
									
										24
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								ChangeLog
									
										
									
									
									
								
							|  | @ -1,3 +1,27 @@ | |||
| 2010-09-20  Yves Blusseau  <blusseau@zetam.org> | ||||
| 
 | ||||
| 	Use gnulib-tool to create gnulib source files. | ||||
| 
 | ||||
| 	* Add gnulib files generated by gnulib-tool in build-aux, m4 and | ||||
| 	grub-core/gnulib directories | ||||
| 	* .bzignore: Add **/.deps and autogenerated gnulib files | ||||
| 	* configure.ac: Assign auxiliary directory to build-aux, add invocation | ||||
| 	of gnulib macros, add grub-core/gnulib/Makefile | ||||
| 	* Makefile.am: Add gnulib directory in SUBDIRS (removing unnecessary .), | ||||
| 	include m4 directory to aclocal. | ||||
| 	* Makefile.util.def: Remove direct compilation of gnulib source files | ||||
| 	and use the new grub-core/gnulib/libgnu.a. | ||||
| 	* build-aux/config.rpath: move config.rpath from top directory to | ||||
| 	build-aux | ||||
| 	* conf/Makefile.common: Remove the macro _GL_UNUSED already defined | ||||
| 	in gnulib headers | ||||
| 	* conf/Makefile.extra-dist: Add m4/gnulib-cache.m4 | ||||
| 	* grub-core/Makefile.core.def: Remove unnecessary extra_dist | ||||
| 	* grub-core/lib/posix_wrap/localcharset.h (locale_charset): Update | ||||
| 	header. | ||||
| 	* grub-core/lib/posix_wrap/langinfo.h (nl_langinfo): Return static | ||||
| 	string. | ||||
| 
 | ||||
| 2010-09-20  Yves Blusseau  <blusseau@zetam.org> | ||||
| 
 | ||||
| 	* .bzrignore: Add grub-kbdcomp, grub-menulst2cfg, *.marker, | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| AUTOMAKE_OPTIONS = subdir-objects | ||||
| 
 | ||||
| DEPDIR = .deps-util | ||||
| SUBDIRS = . grub-core po docs util/bash-completion.d | ||||
| SUBDIRS = grub-core/gnulib grub-core po docs util/bash-completion.d | ||||
| 
 | ||||
| include $(top_srcdir)/conf/Makefile.common | ||||
| include $(top_srcdir)/conf/Makefile.extra-dist | ||||
|  | @ -11,6 +11,8 @@ AM_LDFLAGS = $(HOST_LDFLAGS) | |||
| AM_CPPFLAGS = $(HOST_CPPFLAGS) $(CPPFLAGS_DEFAULT) | ||||
| AM_CCASFLAGS = $(HOST_CCASFLAGS) $(CCASFLAGS_DEFAULT) | ||||
| 
 | ||||
| ACLOCAL_AMFLAGS = -I m4 | ||||
| 
 | ||||
| CFLAGS_PROGRAM += $(CFLAGS_GNULIB) | ||||
| LDFLAGS_PROGRAM += $(LDFLAGS_GNULIB) | ||||
| CPPFLAGS_PROGRAM += $(CPPFLAGS_GNULIB) | ||||
|  |  | |||
|  | @ -11,14 +11,6 @@ library = { | |||
|   common_nodist = grub_script.yy.h; | ||||
|   common_nodist = grub_script.tab.h; | ||||
| 
 | ||||
|   common = grub-core/gnulib/error.c; | ||||
|   common = grub-core/gnulib/fnmatch.c; | ||||
|   common = grub-core/gnulib/getdelim.c; | ||||
|   common = grub-core/gnulib/getline.c; | ||||
|   common = grub-core/gnulib/getopt1.c; | ||||
|   common = grub-core/gnulib/getopt.c; | ||||
|   common = grub-core/gnulib/progname.c; | ||||
| 
 | ||||
|   common = util/misc.c; | ||||
|   common = grub-core/kern/misc.c; | ||||
|   common = grub-core/kern/emu/mm.c; | ||||
|  | @ -101,6 +93,7 @@ program = { | |||
|   common = util/bin2h.c; | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
|   mansection = 1; | ||||
| }; | ||||
| 
 | ||||
|  | @ -114,6 +107,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
|   cppflags = '-DGRUB_PKGLIBROOTDIR=\"$(pkglibrootdir)\"'; | ||||
| }; | ||||
| 
 | ||||
|  | @ -125,6 +119,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| }; | ||||
| 
 | ||||
| program = { | ||||
|  | @ -135,6 +130,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| }; | ||||
| 
 | ||||
| program = { | ||||
|  | @ -145,6 +141,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| }; | ||||
| 
 | ||||
| program = { | ||||
|  | @ -155,6 +152,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
|   cflags = '$(CFLAGS_GCRY)'; | ||||
|   cppflags = '$(CPPFLAGS_GCRY)'; | ||||
| }; | ||||
|  | @ -173,6 +171,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
|   condition = COND_GRUB_PE2ELF; | ||||
| }; | ||||
| 
 | ||||
|  | @ -184,10 +183,12 @@ program = { | |||
|   common = grub-core/kern/emu/hostfs.c; | ||||
|   common = grub-core/disk/host.c; | ||||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   cflags = '$(CFLAGS_GCRY)'; | ||||
|   cppflags = '$(CPPFLAGS_GCRY)'; | ||||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| }; | ||||
| 
 | ||||
| program = { | ||||
|  | @ -200,6 +201,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
|   ldadd = '$(freetype_libs)'; | ||||
|   condition = COND_GRUB_MKFONT; | ||||
| }; | ||||
|  | @ -218,6 +220,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| }; | ||||
| 
 | ||||
| program = { | ||||
|  | @ -228,6 +231,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| }; | ||||
| 
 | ||||
| program = { | ||||
|  | @ -242,6 +246,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| 
 | ||||
|   enable = i386_pc; | ||||
|   enable = sparc64_ieee1275; | ||||
|  | @ -255,6 +260,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
|   enable = sparc64_ieee1275; | ||||
| }; | ||||
| 
 | ||||
|  | @ -266,6 +272,7 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldadd = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| }; | ||||
| 
 | ||||
| data = { | ||||
|  | @ -585,4 +592,5 @@ program = { | |||
| 
 | ||||
|   ldadd = libgrub.a; | ||||
|   ldflags = '$(LIBINTL) $(LIBDEVMAPPER)'; | ||||
|   ldadd = grub-core/gnulib/libgnu.a; | ||||
| }; | ||||
|  |  | |||
							
								
								
									
										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, 2010 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 | ||||
							
								
								
									
										271
									
								
								build-aux/c++defs.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										271
									
								
								build-aux/c++defs.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,271 @@ | |||
| /* C++ compatible function declaration macros.
 | ||||
|    Copyright (C) 2010 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/>.  */
 | ||||
| 
 | ||||
| #ifndef _GL_CXXDEFS_H | ||||
| #define _GL_CXXDEFS_H | ||||
| 
 | ||||
| /* The three most frequent use cases of these macros are:
 | ||||
| 
 | ||||
|    * For providing a substitute for a function that is missing on some | ||||
|      platforms, but is declared and works fine on the platforms on which | ||||
|      it exists: | ||||
| 
 | ||||
|        #if @GNULIB_FOO@ | ||||
|        # if !@HAVE_FOO@ | ||||
|        _GL_FUNCDECL_SYS (foo, ...); | ||||
|        # endif | ||||
|        _GL_CXXALIAS_SYS (foo, ...); | ||||
|        _GL_CXXALIASWARN (foo); | ||||
|        #elif defined GNULIB_POSIXCHECK | ||||
|        ... | ||||
|        #endif | ||||
| 
 | ||||
|    * For providing a replacement for a function that exists on all platforms, | ||||
|      but is broken/insufficient and needs to be replaced on some platforms: | ||||
| 
 | ||||
|        #if @GNULIB_FOO@ | ||||
|        # if @REPLACE_FOO@ | ||||
|        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
|        #   undef foo | ||||
|        #   define foo rpl_foo | ||||
|        #  endif | ||||
|        _GL_FUNCDECL_RPL (foo, ...); | ||||
|        _GL_CXXALIAS_RPL (foo, ...); | ||||
|        # else | ||||
|        _GL_CXXALIAS_SYS (foo, ...); | ||||
|        # endif | ||||
|        _GL_CXXALIASWARN (foo); | ||||
|        #elif defined GNULIB_POSIXCHECK | ||||
|        ... | ||||
|        #endif | ||||
| 
 | ||||
|    * For providing a replacement for a function that exists on some platforms | ||||
|      but is broken/insufficient and needs to be replaced on some of them and | ||||
|      is additionally either missing or undeclared on some other platforms: | ||||
| 
 | ||||
|        #if @GNULIB_FOO@ | ||||
|        # if @REPLACE_FOO@ | ||||
|        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
|        #   undef foo | ||||
|        #   define foo rpl_foo | ||||
|        #  endif | ||||
|        _GL_FUNCDECL_RPL (foo, ...); | ||||
|        _GL_CXXALIAS_RPL (foo, ...); | ||||
|        # else | ||||
|        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@ | ||||
|        _GL_FUNCDECL_SYS (foo, ...); | ||||
|        #  endif | ||||
|        _GL_CXXALIAS_SYS (foo, ...); | ||||
|        # endif | ||||
|        _GL_CXXALIASWARN (foo); | ||||
|        #elif defined GNULIB_POSIXCHECK | ||||
|        ... | ||||
|        #endif | ||||
| */ | ||||
| 
 | ||||
| /* _GL_EXTERN_C declaration;
 | ||||
|    performs the declaration with C linkage.  */ | ||||
| #if defined __cplusplus | ||||
| # define _GL_EXTERN_C extern "C" | ||||
| #else | ||||
| # define _GL_EXTERN_C extern | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
 | ||||
|    declares a replacement function, named rpl_func, with the given prototype, | ||||
|    consisting of return type, parameters, and attributes. | ||||
|    Example: | ||||
|      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) | ||||
|                                   _GL_ARG_NONNULL ((1))); | ||||
|  */ | ||||
| #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ | ||||
|   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) | ||||
| #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ | ||||
|   _GL_EXTERN_C rettype rpl_func parameters_and_attributes | ||||
| 
 | ||||
| /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
 | ||||
|    declares the system function, named func, with the given prototype, | ||||
|    consisting of return type, parameters, and attributes. | ||||
|    Example: | ||||
|      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) | ||||
|                                   _GL_ARG_NONNULL ((1))); | ||||
|  */ | ||||
| #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ | ||||
|   _GL_EXTERN_C rettype func parameters_and_attributes | ||||
| 
 | ||||
| /* _GL_CXXALIAS_RPL (func, rettype, parameters);
 | ||||
|    declares a C++ alias called GNULIB_NAMESPACE::func | ||||
|    that redirects to rpl_func, if GNULIB_NAMESPACE is defined. | ||||
|    Example: | ||||
|      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); | ||||
|  */ | ||||
| #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ | ||||
|   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) | ||||
| #if defined __cplusplus && defined GNULIB_NAMESPACE | ||||
| # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||||
|     namespace GNULIB_NAMESPACE                                \ | ||||
|     {                                                         \ | ||||
|       rettype (*const func) parameters = ::rpl_func;          \ | ||||
|     }                                                         \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #else | ||||
| # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
 | ||||
|    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); | ||||
|    except that the C function rpl_func may have a slightly different | ||||
|    declaration.  A cast is used to silence the "invalid conversion" error | ||||
|    that would otherwise occur.  */ | ||||
| #if defined __cplusplus && defined GNULIB_NAMESPACE | ||||
| # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||||
|     namespace GNULIB_NAMESPACE                                     \ | ||||
|     {                                                              \ | ||||
|       rettype (*const func) parameters =                           \ | ||||
|         reinterpret_cast<rettype(*)parameters>(::rpl_func);        \ | ||||
|     }                                                              \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #else | ||||
| # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_CXXALIAS_SYS (func, rettype, parameters);
 | ||||
|    declares a C++ alias called GNULIB_NAMESPACE::func | ||||
|    that redirects to the system provided function func, if GNULIB_NAMESPACE | ||||
|    is defined. | ||||
|    Example: | ||||
|      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); | ||||
|  */ | ||||
| #if defined __cplusplus && defined GNULIB_NAMESPACE | ||||
|   /* If we were to write
 | ||||
|        rettype (*const func) parameters = ::func; | ||||
|      like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls | ||||
|      better (remove an indirection through a 'static' pointer variable), | ||||
|      but then the _GL_CXXALIASWARN macro below would cause a warning not only | ||||
|      for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */ | ||||
| # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||||
|     namespace GNULIB_NAMESPACE                     \ | ||||
|     {                                              \ | ||||
|       static rettype (*func) parameters = ::func;  \ | ||||
|     }                                              \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #else | ||||
| # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
 | ||||
|    is like  _GL_CXXALIAS_SYS (func, rettype, parameters); | ||||
|    except that the C function func may have a slightly different declaration. | ||||
|    A cast is used to silence the "invalid conversion" error that would | ||||
|    otherwise occur.  */ | ||||
| #if defined __cplusplus && defined GNULIB_NAMESPACE | ||||
| # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||||
|     namespace GNULIB_NAMESPACE                          \ | ||||
|     {                                                   \ | ||||
|       static rettype (*func) parameters =               \ | ||||
|         reinterpret_cast<rettype(*)parameters>(::func); \ | ||||
|     }                                                   \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #else | ||||
| # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
 | ||||
|    is like  _GL_CXXALIAS_SYS (func, rettype, parameters); | ||||
|    except that the C function is picked among a set of overloaded functions, | ||||
|    namely the one with rettype2 and parameters2.  Two consecutive casts | ||||
|    are used to silence the "cannot find a match" and "invalid conversion" | ||||
|    errors that would otherwise occur.  */ | ||||
| #if defined __cplusplus && defined GNULIB_NAMESPACE | ||||
|   /* The outer cast must be a reinterpret_cast.
 | ||||
|      The inner cast: When the function is defined as a set of overloaded | ||||
|      functions, it works as a static_cast<>, choosing the designated variant. | ||||
|      When the function is defined as a single variant, it works as a | ||||
|      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */ | ||||
| # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||||
|     namespace GNULIB_NAMESPACE                                                \ | ||||
|     {                                                                         \ | ||||
|       static rettype (*func) parameters =                                     \ | ||||
|         reinterpret_cast<rettype(*)parameters>(                               \ | ||||
|           (rettype2(*)parameters2)(::func));                                  \ | ||||
|     }                                                                         \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #else | ||||
| # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_CXXALIASWARN (func);
 | ||||
|    causes a warning to be emitted when ::func is used but not when | ||||
|    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded | ||||
|    variants.  */ | ||||
| #if defined __cplusplus && defined GNULIB_NAMESPACE | ||||
| # define _GL_CXXALIASWARN(func) \ | ||||
|    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) | ||||
| # define _GL_CXXALIASWARN_1(func,namespace) \ | ||||
|    _GL_CXXALIASWARN_2 (func, namespace) | ||||
| /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
 | ||||
|    we enable the warning only when not optimizing.  */ | ||||
| # if !__OPTIMIZE__ | ||||
| #  define _GL_CXXALIASWARN_2(func,namespace) \ | ||||
|     _GL_WARN_ON_USE (func, \ | ||||
|                      "The symbol ::" #func " refers to the system function. " \ | ||||
|                      "Use " #namespace "::" #func " instead.") | ||||
| # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||||
| #  define _GL_CXXALIASWARN_2(func,namespace) \ | ||||
|      extern __typeof__ (func) func | ||||
| # else | ||||
| #  define _GL_CXXALIASWARN_2(func,namespace) \ | ||||
|      _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| # endif | ||||
| #else | ||||
| # define _GL_CXXALIASWARN(func) \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
 | ||||
|    causes a warning to be emitted when the given overloaded variant of ::func | ||||
|    is used but not when GNULIB_NAMESPACE::func is used.  */ | ||||
| #if defined __cplusplus && defined GNULIB_NAMESPACE | ||||
| # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||||
|    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ | ||||
|                         GNULIB_NAMESPACE) | ||||
| # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ | ||||
|    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) | ||||
| /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
 | ||||
|    we enable the warning only when not optimizing.  */ | ||||
| # if !__OPTIMIZE__ | ||||
| #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||||
|     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ | ||||
|                          "The symbol ::" #func " refers to the system function. " \ | ||||
|                          "Use " #namespace "::" #func " instead.") | ||||
| # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||||
| #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||||
|      extern __typeof__ (func) func | ||||
| # else | ||||
| #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ | ||||
|      _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| # endif | ||||
| #else | ||||
| # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ | ||||
|     _GL_EXTERN_C int _gl_cxxalias_dummy | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _GL_CXXDEFS_H */ | ||||
|  | @ -2,7 +2,7 @@ | |||
| # Output a system dependent set of variables, describing how to set the | ||||
| # run time search path of shared libraries in an executable. | ||||
| # | ||||
| #   Copyright 1996-2008 Free Software Foundation, Inc. | ||||
| #   Copyright 1996-2006 Free Software Foundation, Inc. | ||||
| #   Taken from GNU libtool, 2001 | ||||
| #   Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 | ||||
| # | ||||
|  | @ -47,7 +47,7 @@ for cc_temp in $CC""; do | |||
| done | ||||
| cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` | ||||
| 
 | ||||
| # Code taken from libtool.m4's _LT_COMPILER_PIC. | ||||
| # Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. | ||||
| 
 | ||||
| wl= | ||||
| if test "$GCC" = yes; then | ||||
|  | @ -64,7 +64,7 @@ else | |||
|           ;; | ||||
|       esac | ||||
|       ;; | ||||
|     mingw* | cygwin* | pw32* | os2* | cegcc*) | ||||
|     mingw* | pw32* | os2*) | ||||
|       ;; | ||||
|     hpux9* | hpux10* | hpux11*) | ||||
|       wl='-Wl,' | ||||
|  | @ -74,15 +74,9 @@ else | |||
|       ;; | ||||
|     newsos6) | ||||
|       ;; | ||||
|     linux* | k*bsd*-gnu) | ||||
|     linux*) | ||||
|       case $cc_basename in | ||||
|         ecc*) | ||||
|           wl='-Wl,' | ||||
|           ;; | ||||
|         icc* | ifort*) | ||||
|           wl='-Wl,' | ||||
|           ;; | ||||
|         lf95*) | ||||
|         icc* | ecc*) | ||||
|           wl='-Wl,' | ||||
|           ;; | ||||
|         pgcc | pgf77 | pgf90) | ||||
|  | @ -106,7 +100,7 @@ else | |||
|     osf3* | osf4* | osf5*) | ||||
|       wl='-Wl,' | ||||
|       ;; | ||||
|     rdos*) | ||||
|     sco3.2v5*) | ||||
|       ;; | ||||
|     solaris*) | ||||
|       wl='-Wl,' | ||||
|  | @ -114,14 +108,11 @@ else | |||
|     sunos4*) | ||||
|       wl='-Qoption ld ' | ||||
|       ;; | ||||
|     sysv4 | sysv4.2uw2* | sysv4.3*) | ||||
|     sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) | ||||
|       wl='-Wl,' | ||||
|       ;; | ||||
|     sysv4*MP*) | ||||
|       ;; | ||||
|     sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) | ||||
|       wl='-Wl,' | ||||
|       ;; | ||||
|     unicos*) | ||||
|       wl='-Wl,' | ||||
|       ;; | ||||
|  | @ -130,7 +121,7 @@ else | |||
|   esac | ||||
| fi | ||||
| 
 | ||||
| # Code taken from libtool.m4's _LT_LINKER_SHLIBS. | ||||
| # Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. | ||||
| 
 | ||||
| hardcode_libdir_flag_spec= | ||||
| hardcode_libdir_separator= | ||||
|  | @ -138,7 +129,7 @@ hardcode_direct=no | |||
| hardcode_minus_L=no | ||||
| 
 | ||||
| case "$host_os" in | ||||
|   cygwin* | mingw* | pw32* | cegcc*) | ||||
|   cygwin* | mingw* | pw32*) | ||||
|     # FIXME: the MSVC++ port hasn't been tested in a loooong time | ||||
|     # When not using gcc, we currently assume that we are using | ||||
|     # Microsoft Visual C++. | ||||
|  | @ -164,7 +155,7 @@ if test "$with_gnu_ld" = yes; then | |||
|   # option of GNU ld is called -rpath, not --rpath. | ||||
|   hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' | ||||
|   case "$host_os" in | ||||
|     aix[3-9]*) | ||||
|     aix3* | aix4* | aix5*) | ||||
|       # On AIX/PPC, the GNU linker is very broken | ||||
|       if test "$host_cpu" != ia64; then | ||||
|         ld_shlibs=no | ||||
|  | @ -188,7 +179,7 @@ if test "$with_gnu_ld" = yes; then | |||
|         ld_shlibs=no | ||||
|       fi | ||||
|       ;; | ||||
|     cygwin* | mingw* | pw32* | cegcc*) | ||||
|     cygwin* | mingw* | pw32*) | ||||
|       # hardcode_libdir_flag_spec is actually meaningless, as there is | ||||
|       # no search path for DLLs. | ||||
|       hardcode_libdir_flag_spec='-L$libdir' | ||||
|  | @ -198,11 +189,11 @@ if test "$with_gnu_ld" = yes; then | |||
|         ld_shlibs=no | ||||
|       fi | ||||
|       ;; | ||||
|     interix[3-9]*) | ||||
|     interix3*) | ||||
|       hardcode_direct=no | ||||
|       hardcode_libdir_flag_spec='${wl}-rpath,$libdir' | ||||
|       ;; | ||||
|     gnu* | linux* | k*bsd*-gnu) | ||||
|     linux*) | ||||
|       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then | ||||
|         : | ||||
|       else | ||||
|  | @ -260,7 +251,7 @@ else | |||
|         hardcode_direct=unsupported | ||||
|       fi | ||||
|       ;; | ||||
|     aix[4-9]*) | ||||
|     aix4* | aix5*) | ||||
|       if test "$host_cpu" = ia64; then | ||||
|         # On IA64, the linker does run time linking by default, so we don't | ||||
|         # have to do anything special. | ||||
|  | @ -270,7 +261,7 @@ else | |||
|         # Test if we are trying to use run time linking or normal | ||||
|         # AIX style linking. If -brtl is somewhere in LDFLAGS, we | ||||
|         # need to do runtime linking. | ||||
|         case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) | ||||
|         case $host_os in aix4.[23]|aix4.[23].*|aix5*) | ||||
|           for ld_flag in $LDFLAGS; do | ||||
|             if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then | ||||
|               aix_use_runtimelinking=yes | ||||
|  | @ -289,7 +280,7 @@ else | |||
|             strings "$collect2name" | grep resolve_lib_name >/dev/null | ||||
|           then | ||||
|             # We have reworked collect2 | ||||
|             : | ||||
|             hardcode_direct=yes | ||||
|           else | ||||
|             # We have old collect2 | ||||
|             hardcode_direct=unsupported | ||||
|  | @ -332,7 +323,7 @@ else | |||
|       ;; | ||||
|     bsdi[45]*) | ||||
|       ;; | ||||
|     cygwin* | mingw* | pw32* | cegcc*) | ||||
|     cygwin* | mingw* | pw32*) | ||||
|       # When not using gcc, we currently assume that we are using | ||||
|       # Microsoft Visual C++. | ||||
|       # hardcode_libdir_flag_spec is actually meaningless, as there is | ||||
|  | @ -368,7 +359,7 @@ else | |||
|       hardcode_direct=yes | ||||
|       hardcode_minus_L=yes | ||||
|       ;; | ||||
|     freebsd* | dragonfly*) | ||||
|     freebsd* | kfreebsd*-gnu | dragonfly*) | ||||
|       hardcode_libdir_flag_spec='-R$libdir' | ||||
|       hardcode_direct=yes | ||||
|       ;; | ||||
|  | @ -421,7 +412,6 @@ else | |||
|       hardcode_libdir_separator=: | ||||
|       ;; | ||||
|     openbsd*) | ||||
|       if test -f /usr/libexec/ld.so; then | ||||
|       hardcode_direct=yes | ||||
|       if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then | ||||
|         hardcode_libdir_flag_spec='${wl}-rpath,$libdir' | ||||
|  | @ -435,9 +425,6 @@ else | |||
|             ;; | ||||
|         esac | ||||
|       fi | ||||
|       else | ||||
|         ld_shlibs=no | ||||
|       fi | ||||
|       ;; | ||||
|     os2*) | ||||
|       hardcode_libdir_flag_spec='-L$libdir' | ||||
|  | @ -484,7 +471,7 @@ else | |||
|         ld_shlibs=yes | ||||
|       fi | ||||
|       ;; | ||||
|     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) | ||||
|     sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*) | ||||
|       ;; | ||||
|     sysv5* | sco3.2v5* | sco5v6*) | ||||
|       hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' | ||||
|  | @ -500,52 +487,34 @@ else | |||
| fi | ||||
| 
 | ||||
| # Check dynamic linker characteristics | ||||
| # Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. | ||||
| # Unlike libtool.m4, here we don't care about _all_ names of the library, but | ||||
| # only about the one the linker finds when passed -lNAME. This is the last | ||||
| # element of library_names_spec in libtool.m4, or possibly two of them if the | ||||
| # linker has special search rules. | ||||
| library_names_spec=      # the last element of library_names_spec in libtool.m4 | ||||
| # Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. | ||||
| libname_spec='lib$name' | ||||
| case "$host_os" in | ||||
|   aix3*) | ||||
|     library_names_spec='$libname.a' | ||||
|     ;; | ||||
|   aix[4-9]*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|   aix4* | aix5*) | ||||
|     ;; | ||||
|   amigaos*) | ||||
|     library_names_spec='$libname.a' | ||||
|     ;; | ||||
|   beos*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   bsdi[45]*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   cygwin* | mingw* | pw32* | cegcc*) | ||||
|   cygwin* | mingw* | pw32*) | ||||
|     shrext=.dll | ||||
|     library_names_spec='$libname.dll.a $libname.lib' | ||||
|     ;; | ||||
|   darwin* | rhapsody*) | ||||
|     shrext=.dylib | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   dgux*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   freebsd1*) | ||||
|     ;; | ||||
|   kfreebsd*-gnu) | ||||
|     ;; | ||||
|   freebsd* | dragonfly*) | ||||
|     case "$host_os" in | ||||
|       freebsd[123]*) | ||||
|         library_names_spec='$libname$shrext$versuffix' ;; | ||||
|       *) | ||||
|         library_names_spec='$libname$shrext' ;; | ||||
|     esac | ||||
|     ;; | ||||
|   gnu*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   hpux9* | hpux10* | hpux11*) | ||||
|     case $host_cpu in | ||||
|  | @ -559,13 +528,10 @@ case "$host_os" in | |||
|         shrext=.sl | ||||
|         ;; | ||||
|     esac | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   interix[3-9]*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|   interix3*) | ||||
|     ;; | ||||
|   irix5* | irix6* | nonstopux*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     case "$host_os" in | ||||
|       irix5* | nonstopux*) | ||||
|         libsuff= shlibsuff= | ||||
|  | @ -582,59 +548,41 @@ case "$host_os" in | |||
|     ;; | ||||
|   linux*oldld* | linux*aout* | linux*coff*) | ||||
|     ;; | ||||
|   linux* | k*bsd*-gnu) | ||||
|     library_names_spec='$libname$shrext' | ||||
|   linux*) | ||||
|     ;; | ||||
|   knetbsd*-gnu) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   netbsd*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   newsos6) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   nto-qnx*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   openbsd*) | ||||
|     library_names_spec='$libname$shrext$versuffix' | ||||
|     ;; | ||||
|   os2*) | ||||
|     libname_spec='$name' | ||||
|     shrext=.dll | ||||
|     library_names_spec='$libname.a' | ||||
|     ;; | ||||
|   osf3* | osf4* | osf5*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   rdos*) | ||||
|     ;; | ||||
|   solaris*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   sunos4*) | ||||
|     library_names_spec='$libname$shrext$versuffix' | ||||
|     ;; | ||||
|   sysv4 | sysv4.3*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   sysv4*MP*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
|   uts4*) | ||||
|     library_names_spec='$libname$shrext' | ||||
|     ;; | ||||
| esac | ||||
| 
 | ||||
| sed_quote_subst='s/\(["`$\\]\)/\\\1/g' | ||||
| escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` | ||||
| shlibext=`echo "$shrext" | sed -e 's,^\.,,'` | ||||
| escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` | ||||
| escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` | ||||
| escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` | ||||
| 
 | ||||
| LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF | ||||
|  | @ -648,12 +596,6 @@ libext="$libext" | |||
| # Shared library suffix (normally "so"). | ||||
| shlibext="$shlibext" | ||||
| 
 | ||||
| # Format of library name prefix. | ||||
| libname_spec="$escaped_libname_spec" | ||||
| 
 | ||||
| # Library names that the linker finds when passed -lNAME. | ||||
| library_names_spec="$escaped_library_names_spec" | ||||
| 
 | ||||
| # Flag to hardcode \$libdir into a binary during linking. | ||||
| # This must work even if \$libdir does not exist. | ||||
| hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec" | ||||
							
								
								
									
										109
									
								
								build-aux/warn-on-use.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								build-aux/warn-on-use.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,109 @@ | |||
| /* A C macro for emitting warnings if a function is used.
 | ||||
|    Copyright (C) 2010 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_WARN_ON_USE (function, "literal string") issues a declaration
 | ||||
|    for FUNCTION which will then trigger a compiler warning containing | ||||
|    the text of "literal string" anywhere that function is called, if | ||||
|    supported by the compiler.  If the compiler does not support this | ||||
|    feature, the macro expands to an unused extern declaration. | ||||
| 
 | ||||
|    This macro is useful for marking a function as a potential | ||||
|    portability trap, with the intent that "literal string" include | ||||
|    instructions on the replacement function that should be used | ||||
|    instead.  However, one of the reasons that a function is a | ||||
|    portability trap is if it has the wrong signature.  Declaring | ||||
|    FUNCTION with a different signature in C is a compilation error, so | ||||
|    this macro must use the same type as any existing declaration so | ||||
|    that programs that avoid the problematic FUNCTION do not fail to | ||||
|    compile merely because they included a header that poisoned the | ||||
|    function.  But this implies that _GL_WARN_ON_USE is only safe to | ||||
|    use if FUNCTION is known to already have a declaration.  Use of | ||||
|    this macro implies that there must not be any other macro hiding | ||||
|    the declaration of FUNCTION; but undefining FUNCTION first is part | ||||
|    of the poisoning process anyway (although for symbols that are | ||||
|    provided only via a macro, the result is a compilation error rather | ||||
|    than a warning containing "literal string").  Also note that in | ||||
|    C++, it is only safe to use if FUNCTION has no overloads. | ||||
| 
 | ||||
|    For an example, it is possible to poison 'getline' by: | ||||
|    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], | ||||
|      [getline]) in configure.ac, which potentially defines | ||||
|      HAVE_RAW_DECL_GETLINE | ||||
|    - adding this code to a header that wraps the system <stdio.h>: | ||||
|      #undef getline | ||||
|      #if HAVE_RAW_DECL_GETLINE | ||||
|      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" | ||||
|        "not universally present; use the gnulib module getline"); | ||||
|      #endif | ||||
| 
 | ||||
|    It is not possible to directly poison global variables.  But it is | ||||
|    possible to write a wrapper accessor function, and poison that | ||||
|    (less common usage, like &environ, will cause a compilation error | ||||
|    rather than issue the nice warning, but the end result of informing | ||||
|    the developer about their portability problem is still achieved): | ||||
|    #if HAVE_RAW_DECL_ENVIRON | ||||
|    static inline char ***rpl_environ (void) { return &environ; } | ||||
|    _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); | ||||
|    # undef environ | ||||
|    # define environ (*rpl_environ ()) | ||||
|    #endif | ||||
|    */ | ||||
| #ifndef _GL_WARN_ON_USE | ||||
| 
 | ||||
| # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||||
| /* A compiler attribute is available in gcc versions 4.3.0 and later.  */ | ||||
| #  define _GL_WARN_ON_USE(function, message) \ | ||||
| extern __typeof__ (function) function __attribute__ ((__warning__ (message))) | ||||
| # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||||
| /* Verify the existence of the function.  */ | ||||
| #  define _GL_WARN_ON_USE(function, message) \ | ||||
| extern __typeof__ (function) function | ||||
| # else /* Unsupported.  */ | ||||
| #  define _GL_WARN_ON_USE(function, message) \ | ||||
| _GL_WARN_EXTERN_C int _gl_warn_on_use | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
 | ||||
|    is like _GL_WARN_ON_USE (function, "string"), except that the function is | ||||
|    declared with the given prototype, consisting of return type, parameters, | ||||
|    and attributes. | ||||
|    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does | ||||
|    not work in this case.  */ | ||||
| #ifndef _GL_WARN_ON_USE_CXX | ||||
| # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) | ||||
| #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||||
| extern rettype function parameters_and_attributes \ | ||||
|      __attribute__ ((__warning__ (msg))) | ||||
| # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | ||||
| /* Verify the existence of the function.  */ | ||||
| #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||||
| extern rettype function parameters_and_attributes | ||||
| # else /* Unsupported.  */ | ||||
| #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ | ||||
| _GL_WARN_EXTERN_C int _gl_warn_on_use | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* _GL_WARN_EXTERN_C declaration;
 | ||||
|    performs the declaration with C linkage.  */ | ||||
| #ifndef _GL_WARN_EXTERN_C | ||||
| # if defined __cplusplus | ||||
| #  define _GL_WARN_EXTERN_C extern "C" | ||||
| # else | ||||
| #  define _GL_WARN_EXTERN_C extern | ||||
| # endif | ||||
| #endif | ||||
|  | @ -80,7 +80,7 @@ platformdir = $(pkglibrootdir)/$(target_cpu)-$(platform) | |||
| CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers | ||||
| CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap | ||||
| 
 | ||||
| CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -D_GL_UNUSED="__attribute__ ((unused))" | ||||
| CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused | ||||
| CPPFLAGS_GNULIB = -I$(top_srcdir)/grub-core/gnulib | ||||
| 
 | ||||
| CFLAGS_POSIX = -fno-builtin | ||||
|  |  | |||
|  | @ -30,3 +30,5 @@ EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h') | |||
| EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib -name '*.h') | ||||
| EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/gnulib -name '*.h') | ||||
| EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/efiemu -name '*.h') | ||||
| 
 | ||||
| EXTRA_DIST += m4/gnulib-cache.m4 | ||||
|  |  | |||
|  | @ -34,6 +34,8 @@ dnl type. | |||
| 
 | ||||
| AC_INIT([GRUB],[1.98],[bug-grub@gnu.org]) | ||||
| 
 | ||||
| AC_CONFIG_AUX_DIR([build-aux]) | ||||
| 
 | ||||
| # We don't want -g -O2 by default in CFLAGS | ||||
| : ${CFLAGS=""} | ||||
| 
 | ||||
|  | @ -249,6 +251,7 @@ AC_PATH_PROG(MAKEINFO, makeinfo) | |||
| # | ||||
| 
 | ||||
| AC_PROG_CC | ||||
| gl_EARLY | ||||
| AM_PROG_CC_C_O | ||||
| AM_PROG_AS | ||||
| 
 | ||||
|  | @ -309,6 +312,9 @@ HOST_CC=$CC | |||
| AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc], | ||||
|                  [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])]) | ||||
| 
 | ||||
| # For gnulib. | ||||
| gl_INIT | ||||
| 
 | ||||
| # | ||||
| # Check for target programs. | ||||
| # | ||||
|  | @ -927,6 +933,7 @@ fi | |||
| 
 | ||||
| AC_CONFIG_FILES([Makefile]) | ||||
| AC_CONFIG_FILES([grub-core/Makefile]) | ||||
| AC_CONFIG_FILES([grub-core/gnulib/Makefile]) | ||||
| AC_CONFIG_FILES([po/Makefile]) | ||||
| AC_CONFIG_FILES([docs/Makefile]) | ||||
| AC_CONFIG_FILES([util/bash-completion.d/Makefile]) | ||||
|  |  | |||
|  | @ -380,12 +380,6 @@ module = { | |||
| library = { | ||||
|   name = libgnulib.a; | ||||
|   common = gnulib/regex.c; | ||||
| 
 | ||||
|   extra_dist = gnulib/regcomp.c; | ||||
|   extra_dist = gnulib/regexec.c; | ||||
|   extra_dist = gnulib/fnmatch_loop.c; | ||||
|   extra_dist = gnulib/regex_internal.c; | ||||
| 
 | ||||
|   cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)'; | ||||
|   cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)'; | ||||
| }; | ||||
|  |  | |||
							
								
								
									
										1336
									
								
								grub-core/gnulib/Makefile.am
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1336
									
								
								grub-core/gnulib/Makefile.am
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										489
									
								
								grub-core/gnulib/alloca.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										489
									
								
								grub-core/gnulib/alloca.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,489 @@ | |||
| /* alloca.c -- allocate automatically reclaimed memory
 | ||||
|    (Mostly) portable public-domain implementation -- D A Gwyn | ||||
| 
 | ||||
|    This implementation of the PWB library alloca function, | ||||
|    which is used to allocate space off the run-time stack so | ||||
|    that it is automatically reclaimed upon procedure exit, | ||||
|    was inspired by discussions with J. Q. Johnson of Cornell. | ||||
|    J.Otto Tennant <jot@cray.com> contributed the Cray support. | ||||
| 
 | ||||
|    There are some preprocessor constants that can | ||||
|    be defined when compiling for your specific system, for | ||||
|    improved efficiency; however, the defaults should be okay. | ||||
| 
 | ||||
|    The general concept of this implementation is to keep | ||||
|    track of all alloca-allocated blocks, and reclaim any | ||||
|    that are found to be deeper in the stack than the current | ||||
|    invocation.  This heuristic does not reclaim storage as | ||||
|    soon as it becomes invalid, but it will do so eventually. | ||||
| 
 | ||||
|    As a special case, alloca(0) reclaims storage without | ||||
|    allocating any.  It is a good idea to use alloca(0) in | ||||
|    your main control loop, etc. to force garbage collection.  */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| #include <alloca.h> | ||||
| 
 | ||||
| #include <string.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| #ifdef emacs | ||||
| # include "lisp.h" | ||||
| # include "blockinput.h" | ||||
| # ifdef EMACS_FREE | ||||
| #  undef free | ||||
| #  define free EMACS_FREE | ||||
| # endif | ||||
| #else | ||||
| # define memory_full() abort () | ||||
| #endif | ||||
| 
 | ||||
| /* If compiling with GCC 2, this file's not needed.  */ | ||||
| #if !defined (__GNUC__) || __GNUC__ < 2 | ||||
| 
 | ||||
| /* If someone has defined alloca as a macro,
 | ||||
|    there must be some other way alloca is supposed to work.  */ | ||||
| # ifndef alloca | ||||
| 
 | ||||
| #  ifdef emacs | ||||
| #   ifdef static | ||||
| /* actually, only want this if static is defined as ""
 | ||||
|    -- this is for usg, in which emacs must undefine static | ||||
|    in order to make unexec workable | ||||
|    */ | ||||
| #    ifndef STACK_DIRECTION | ||||
| you | ||||
| lose | ||||
| -- must know STACK_DIRECTION at compile-time | ||||
| /* Using #error here is not wise since this file should work for
 | ||||
|    old and obscure compilers.  */ | ||||
| #    endif /* STACK_DIRECTION undefined */ | ||||
| #   endif /* static */ | ||||
| #  endif /* emacs */ | ||||
| 
 | ||||
| /* If your stack is a linked list of frames, you have to
 | ||||
|    provide an "address metric" ADDRESS_FUNCTION macro.  */ | ||||
| 
 | ||||
| #  if defined (CRAY) && defined (CRAY_STACKSEG_END) | ||||
| long i00afunc (); | ||||
| #   define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) | ||||
| #  else | ||||
| #   define ADDRESS_FUNCTION(arg) &(arg) | ||||
| #  endif | ||||
| 
 | ||||
| /* Define STACK_DIRECTION if you know the direction of stack
 | ||||
|    growth for your system; otherwise it will be automatically | ||||
|    deduced at run-time. | ||||
| 
 | ||||
|    STACK_DIRECTION > 0 => grows toward higher addresses | ||||
|    STACK_DIRECTION < 0 => grows toward lower addresses | ||||
|    STACK_DIRECTION = 0 => direction of growth unknown  */ | ||||
| 
 | ||||
| #  ifndef STACK_DIRECTION | ||||
| #   define STACK_DIRECTION      0       /* Direction unknown.  */ | ||||
| #  endif | ||||
| 
 | ||||
| #  if STACK_DIRECTION != 0 | ||||
| 
 | ||||
| #   define STACK_DIR    STACK_DIRECTION /* Known at compile-time.  */ | ||||
| 
 | ||||
| #  else /* STACK_DIRECTION == 0; need run-time code.  */ | ||||
| 
 | ||||
| static int stack_dir;           /* 1 or -1 once known.  */ | ||||
| #   define STACK_DIR    stack_dir | ||||
| 
 | ||||
| static void | ||||
| find_stack_direction (void) | ||||
| { | ||||
|   static char *addr = NULL;     /* Address of first `dummy', once known.  */ | ||||
|   auto char dummy;              /* To get stack address.  */ | ||||
| 
 | ||||
|   if (addr == NULL) | ||||
|     {                           /* Initial entry.  */ | ||||
|       addr = ADDRESS_FUNCTION (dummy); | ||||
| 
 | ||||
|       find_stack_direction ();  /* Recurse once.  */ | ||||
|     } | ||||
|   else | ||||
|     { | ||||
|       /* Second entry.  */ | ||||
|       if (ADDRESS_FUNCTION (dummy) > addr) | ||||
|         stack_dir = 1;          /* Stack grew upward.  */ | ||||
|       else | ||||
|         stack_dir = -1;         /* Stack grew downward.  */ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #  endif /* STACK_DIRECTION == 0 */ | ||||
| 
 | ||||
| /* An "alloca header" is used to:
 | ||||
|    (a) chain together all alloca'ed blocks; | ||||
|    (b) keep track of stack depth. | ||||
| 
 | ||||
|    It is very important that sizeof(header) agree with malloc | ||||
|    alignment chunk size.  The following default should work okay.  */ | ||||
| 
 | ||||
| #  ifndef       ALIGN_SIZE | ||||
| #   define ALIGN_SIZE   sizeof(double) | ||||
| #  endif | ||||
| 
 | ||||
| typedef union hdr | ||||
| { | ||||
|   char align[ALIGN_SIZE];       /* To force sizeof(header).  */ | ||||
|   struct | ||||
|     { | ||||
|       union hdr *next;          /* For chaining headers.  */ | ||||
|       char *deep;               /* For stack depth measure.  */ | ||||
|     } h; | ||||
| } header; | ||||
| 
 | ||||
| static header *last_alloca_header = NULL;       /* -> last alloca header.  */ | ||||
| 
 | ||||
| /* Return a pointer to at least SIZE bytes of storage,
 | ||||
|    which will be automatically reclaimed upon exit from | ||||
|    the procedure that called alloca.  Originally, this space | ||||
|    was supposed to be taken from the current stack frame of the | ||||
|    caller, but that method cannot be made to work for some | ||||
|    implementations of C, for example under Gould's UTX/32.  */ | ||||
| 
 | ||||
| void * | ||||
| alloca (size_t size) | ||||
| { | ||||
|   auto char probe;              /* Probes stack depth: */ | ||||
|   register char *depth = ADDRESS_FUNCTION (probe); | ||||
| 
 | ||||
| #  if STACK_DIRECTION == 0 | ||||
|   if (STACK_DIR == 0)           /* Unknown growth direction.  */ | ||||
|     find_stack_direction (); | ||||
| #  endif | ||||
| 
 | ||||
|   /* Reclaim garbage, defined as all alloca'd storage that
 | ||||
|      was allocated from deeper in the stack than currently.  */ | ||||
| 
 | ||||
|   { | ||||
|     register header *hp;        /* Traverses linked list.  */ | ||||
| 
 | ||||
| #  ifdef emacs | ||||
|     BLOCK_INPUT; | ||||
| #  endif | ||||
| 
 | ||||
|     for (hp = last_alloca_header; hp != NULL;) | ||||
|       if ((STACK_DIR > 0 && hp->h.deep > depth) | ||||
|           || (STACK_DIR < 0 && hp->h.deep < depth)) | ||||
|         { | ||||
|           register header *np = hp->h.next; | ||||
| 
 | ||||
|           free (hp);            /* Collect garbage.  */ | ||||
| 
 | ||||
|           hp = np;              /* -> next header.  */ | ||||
|         } | ||||
|       else | ||||
|         break;                  /* Rest are not deeper.  */ | ||||
| 
 | ||||
|     last_alloca_header = hp;    /* -> last valid storage.  */ | ||||
| 
 | ||||
| #  ifdef emacs | ||||
|     UNBLOCK_INPUT; | ||||
| #  endif | ||||
|   } | ||||
| 
 | ||||
|   if (size == 0) | ||||
|     return NULL;                /* No allocation required.  */ | ||||
| 
 | ||||
|   /* Allocate combined header + user data storage.  */ | ||||
| 
 | ||||
|   { | ||||
|     /* Address of header.  */ | ||||
|     register header *new; | ||||
| 
 | ||||
|     size_t combined_size = sizeof (header) + size; | ||||
|     if (combined_size < sizeof (header)) | ||||
|       memory_full (); | ||||
| 
 | ||||
|     new = malloc (combined_size); | ||||
| 
 | ||||
|     if (! new) | ||||
|       memory_full (); | ||||
| 
 | ||||
|     new->h.next = last_alloca_header; | ||||
|     new->h.deep = depth; | ||||
| 
 | ||||
|     last_alloca_header = new; | ||||
| 
 | ||||
|     /* User storage begins just after header.  */ | ||||
| 
 | ||||
|     return (void *) (new + 1); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| #  if defined (CRAY) && defined (CRAY_STACKSEG_END) | ||||
| 
 | ||||
| #   ifdef DEBUG_I00AFUNC | ||||
| #    include <stdio.h> | ||||
| #   endif | ||||
| 
 | ||||
| #   ifndef CRAY_STACK | ||||
| #    define CRAY_STACK | ||||
| #    ifndef CRAY2 | ||||
| /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ | ||||
| struct stack_control_header | ||||
|   { | ||||
|     long shgrow:32;             /* Number of times stack has grown.  */ | ||||
|     long shaseg:32;             /* Size of increments to stack.  */ | ||||
|     long shhwm:32;              /* High water mark of stack.  */ | ||||
|     long shsize:32;             /* Current size of stack (all segments).  */ | ||||
|   }; | ||||
| 
 | ||||
| /* The stack segment linkage control information occurs at
 | ||||
|    the high-address end of a stack segment.  (The stack | ||||
|    grows from low addresses to high addresses.)  The initial | ||||
|    part of the stack segment linkage control information is | ||||
|    0200 (octal) words.  This provides for register storage | ||||
|    for the routine which overflows the stack.  */ | ||||
| 
 | ||||
| struct stack_segment_linkage | ||||
|   { | ||||
|     long ss[0200];              /* 0200 overflow words.  */ | ||||
|     long sssize:32;             /* Number of words in this segment.  */ | ||||
|     long ssbase:32;             /* Offset to stack base.  */ | ||||
|     long:32; | ||||
|     long sspseg:32;             /* Offset to linkage control of previous
 | ||||
|                                    segment of stack.  */ | ||||
|     long:32; | ||||
|     long sstcpt:32;             /* Pointer to task common address block.  */ | ||||
|     long sscsnm;                /* Private control structure number for
 | ||||
|                                    microtasking.  */ | ||||
|     long ssusr1;                /* Reserved for user.  */ | ||||
|     long ssusr2;                /* Reserved for user.  */ | ||||
|     long sstpid;                /* Process ID for pid based multi-tasking.  */ | ||||
|     long ssgvup;                /* Pointer to multitasking thread giveup.  */ | ||||
|     long sscray[7];             /* Reserved for Cray Research.  */ | ||||
|     long ssa0; | ||||
|     long ssa1; | ||||
|     long ssa2; | ||||
|     long ssa3; | ||||
|     long ssa4; | ||||
|     long ssa5; | ||||
|     long ssa6; | ||||
|     long ssa7; | ||||
|     long sss0; | ||||
|     long sss1; | ||||
|     long sss2; | ||||
|     long sss3; | ||||
|     long sss4; | ||||
|     long sss5; | ||||
|     long sss6; | ||||
|     long sss7; | ||||
|   }; | ||||
| 
 | ||||
| #    else /* CRAY2 */ | ||||
| /* The following structure defines the vector of words
 | ||||
|    returned by the STKSTAT library routine.  */ | ||||
| struct stk_stat | ||||
|   { | ||||
|     long now;                   /* Current total stack size.  */ | ||||
|     long maxc;                  /* Amount of contiguous space which would
 | ||||
|                                    be required to satisfy the maximum | ||||
|                                    stack demand to date.  */ | ||||
|     long high_water;            /* Stack high-water mark.  */ | ||||
|     long overflows;             /* Number of stack overflow ($STKOFEN) calls.  */ | ||||
|     long hits;                  /* Number of internal buffer hits.  */ | ||||
|     long extends;               /* Number of block extensions.  */ | ||||
|     long stko_mallocs;          /* Block allocations by $STKOFEN.  */ | ||||
|     long underflows;            /* Number of stack underflow calls ($STKRETN).  */ | ||||
|     long stko_free;             /* Number of deallocations by $STKRETN.  */ | ||||
|     long stkm_free;             /* Number of deallocations by $STKMRET.  */ | ||||
|     long segments;              /* Current number of stack segments.  */ | ||||
|     long maxs;                  /* Maximum number of stack segments so far.  */ | ||||
|     long pad_size;              /* Stack pad size.  */ | ||||
|     long current_address;       /* Current stack segment address.  */ | ||||
|     long current_size;          /* Current stack segment size.  This
 | ||||
|                                    number is actually corrupted by STKSTAT to | ||||
|                                    include the fifteen word trailer area.  */ | ||||
|     long initial_address;       /* Address of initial segment.  */ | ||||
|     long initial_size;          /* Size of initial segment.  */ | ||||
|   }; | ||||
| 
 | ||||
| /* The following structure describes the data structure which trails
 | ||||
|    any stack segment.  I think that the description in 'asdef' is | ||||
|    out of date.  I only describe the parts that I am sure about.  */ | ||||
| 
 | ||||
| struct stk_trailer | ||||
|   { | ||||
|     long this_address;          /* Address of this block.  */ | ||||
|     long this_size;             /* Size of this block (does not include
 | ||||
|                                    this trailer).  */ | ||||
|     long unknown2; | ||||
|     long unknown3; | ||||
|     long link;                  /* Address of trailer block of previous
 | ||||
|                                    segment.  */ | ||||
|     long unknown5; | ||||
|     long unknown6; | ||||
|     long unknown7; | ||||
|     long unknown8; | ||||
|     long unknown9; | ||||
|     long unknown10; | ||||
|     long unknown11; | ||||
|     long unknown12; | ||||
|     long unknown13; | ||||
|     long unknown14; | ||||
|   }; | ||||
| 
 | ||||
| #    endif /* CRAY2 */ | ||||
| #   endif /* not CRAY_STACK */ | ||||
| 
 | ||||
| #   ifdef CRAY2 | ||||
| /* Determine a "stack measure" for an arbitrary ADDRESS.
 | ||||
|    I doubt that "lint" will like this much.  */ | ||||
| 
 | ||||
| static long | ||||
| i00afunc (long *address) | ||||
| { | ||||
|   struct stk_stat status; | ||||
|   struct stk_trailer *trailer; | ||||
|   long *block, size; | ||||
|   long result = 0; | ||||
| 
 | ||||
|   /* We want to iterate through all of the segments.  The first
 | ||||
|      step is to get the stack status structure.  We could do this | ||||
|      more quickly and more directly, perhaps, by referencing the | ||||
|      $LM00 common block, but I know that this works.  */ | ||||
| 
 | ||||
|   STKSTAT (&status); | ||||
| 
 | ||||
|   /* Set up the iteration.  */ | ||||
| 
 | ||||
|   trailer = (struct stk_trailer *) (status.current_address | ||||
|                                     + status.current_size | ||||
|                                     - 15); | ||||
| 
 | ||||
|   /* There must be at least one stack segment.  Therefore it is
 | ||||
|      a fatal error if "trailer" is null.  */ | ||||
| 
 | ||||
|   if (trailer == 0) | ||||
|     abort (); | ||||
| 
 | ||||
|   /* Discard segments that do not contain our argument address.  */ | ||||
| 
 | ||||
|   while (trailer != 0) | ||||
|     { | ||||
|       block = (long *) trailer->this_address; | ||||
|       size = trailer->this_size; | ||||
|       if (block == 0 || size == 0) | ||||
|         abort (); | ||||
|       trailer = (struct stk_trailer *) trailer->link; | ||||
|       if ((block <= address) && (address < (block + size))) | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|   /* Set the result to the offset in this segment and add the sizes
 | ||||
|      of all predecessor segments.  */ | ||||
| 
 | ||||
|   result = address - block; | ||||
| 
 | ||||
|   if (trailer == 0) | ||||
|     { | ||||
|       return result; | ||||
|     } | ||||
| 
 | ||||
|   do | ||||
|     { | ||||
|       if (trailer->this_size <= 0) | ||||
|         abort (); | ||||
|       result += trailer->this_size; | ||||
|       trailer = (struct stk_trailer *) trailer->link; | ||||
|     } | ||||
|   while (trailer != 0); | ||||
| 
 | ||||
|   /* We are done.  Note that if you present a bogus address (one
 | ||||
|      not in any segment), you will get a different number back, formed | ||||
|      from subtracting the address of the first block.  This is probably | ||||
|      not what you want.  */ | ||||
| 
 | ||||
|   return (result); | ||||
| } | ||||
| 
 | ||||
| #   else /* not CRAY2 */ | ||||
| /* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
 | ||||
|    Determine the number of the cell within the stack, | ||||
|    given the address of the cell.  The purpose of this | ||||
|    routine is to linearize, in some sense, stack addresses | ||||
|    for alloca.  */ | ||||
| 
 | ||||
| static long | ||||
| i00afunc (long address) | ||||
| { | ||||
|   long stkl = 0; | ||||
| 
 | ||||
|   long size, pseg, this_segment, stack; | ||||
|   long result = 0; | ||||
| 
 | ||||
|   struct stack_segment_linkage *ssptr; | ||||
| 
 | ||||
|   /* Register B67 contains the address of the end of the
 | ||||
|      current stack segment.  If you (as a subprogram) store | ||||
|      your registers on the stack and find that you are past | ||||
|      the contents of B67, you have overflowed the segment. | ||||
| 
 | ||||
|      B67 also points to the stack segment linkage control | ||||
|      area, which is what we are really interested in.  */ | ||||
| 
 | ||||
|   stkl = CRAY_STACKSEG_END (); | ||||
|   ssptr = (struct stack_segment_linkage *) stkl; | ||||
| 
 | ||||
|   /* If one subtracts 'size' from the end of the segment,
 | ||||
|      one has the address of the first word of the segment. | ||||
| 
 | ||||
|      If this is not the first segment, 'pseg' will be | ||||
|      nonzero.  */ | ||||
| 
 | ||||
|   pseg = ssptr->sspseg; | ||||
|   size = ssptr->sssize; | ||||
| 
 | ||||
|   this_segment = stkl - size; | ||||
| 
 | ||||
|   /* It is possible that calling this routine itself caused
 | ||||
|      a stack overflow.  Discard stack segments which do not | ||||
|      contain the target address.  */ | ||||
| 
 | ||||
|   while (!(this_segment <= address && address <= stkl)) | ||||
|     { | ||||
| #    ifdef DEBUG_I00AFUNC | ||||
|       fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); | ||||
| #    endif | ||||
|       if (pseg == 0) | ||||
|         break; | ||||
|       stkl = stkl - pseg; | ||||
|       ssptr = (struct stack_segment_linkage *) stkl; | ||||
|       size = ssptr->sssize; | ||||
|       pseg = ssptr->sspseg; | ||||
|       this_segment = stkl - size; | ||||
|     } | ||||
| 
 | ||||
|   result = address - this_segment; | ||||
| 
 | ||||
|   /* If you subtract pseg from the current end of the stack,
 | ||||
|      you get the address of the previous stack segment's end. | ||||
|      This seems a little convoluted to me, but I'll bet you save | ||||
|      a cycle somewhere.  */ | ||||
| 
 | ||||
|   while (pseg != 0) | ||||
|     { | ||||
| #    ifdef DEBUG_I00AFUNC | ||||
|       fprintf (stderr, "%011o %011o\n", pseg, size); | ||||
| #    endif | ||||
|       stkl = stkl - pseg; | ||||
|       ssptr = (struct stack_segment_linkage *) stkl; | ||||
|       size = ssptr->sssize; | ||||
|       pseg = ssptr->sspseg; | ||||
|       result += size; | ||||
|     } | ||||
|   return (result); | ||||
| } | ||||
| 
 | ||||
| #   endif /* not CRAY2 */ | ||||
| #  endif /* CRAY */ | ||||
| 
 | ||||
| # endif /* no alloca */ | ||||
| #endif /* not GCC version 3 */ | ||||
|  | @ -5,7 +5,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    by the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
							
								
								
									
										35
									
								
								grub-core/gnulib/asnprintf.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								grub-core/gnulib/asnprintf.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| /* Formatted output to strings.
 | ||||
|    Copyright (C) 1999, 2002, 2006, 2009, 2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include "vasnprintf.h" | ||||
| 
 | ||||
| #include <stdarg.h> | ||||
| 
 | ||||
| char * | ||||
| asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) | ||||
| { | ||||
|   va_list args; | ||||
|   char *result; | ||||
| 
 | ||||
|   va_start (args, format); | ||||
|   result = vasnprintf (resultbuf, lengthp, format, args); | ||||
|   va_end (args); | ||||
|   return result; | ||||
| } | ||||
|  | @ -1,58 +0,0 @@ | |||
| /* basename.c -- return the last element in a file name
 | ||||
| 
 | ||||
|    Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| #include "dirname.h" | ||||
| 
 | ||||
| #include <string.h> | ||||
| #include "xalloc.h" | ||||
| #include "xstrndup.h" | ||||
| 
 | ||||
| char * | ||||
| base_name (char const *name) | ||||
| { | ||||
|   char const *base = last_component (name); | ||||
|   size_t length; | ||||
| 
 | ||||
|   /* If there is no last component, then name is a file system root or the
 | ||||
|      empty string.  */ | ||||
|   if (! *base) | ||||
|     return xstrndup (name, base_len (name)); | ||||
| 
 | ||||
|   /* Collapse a sequence of trailing slashes into one.  */ | ||||
|   length = base_len (base); | ||||
|   if (ISSLASH (base[length])) | ||||
|     length++; | ||||
| 
 | ||||
|   /* On systems with drive letters, `a/b:c' must return `./b:c' rather
 | ||||
|      than `b:c' to avoid confusion with a drive letter.  On systems | ||||
|      with pure POSIX semantics, this is not an issue.  */ | ||||
|   if (FILE_SYSTEM_PREFIX_LEN (base)) | ||||
|     { | ||||
|       char *p = xmalloc (length + 3); | ||||
|       p[0] = '.'; | ||||
|       p[1] = '/'; | ||||
|       memcpy (p + 2, base, length); | ||||
|       p[length + 2] = '\0'; | ||||
|       return p; | ||||
|     } | ||||
| 
 | ||||
|   /* Finally, copy the basename.  */ | ||||
|   return xstrndup (base, length); | ||||
| } | ||||
|  | @ -1,7 +1,6 @@ | |||
| /* dirname.c -- return all but the last element in a file name
 | ||||
| 
 | ||||
|    Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software | ||||
|    Foundation, Inc. | ||||
| /* Convert unibyte character to wide character.
 | ||||
|    Copyright (C) 2008, 2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2008. | ||||
| 
 | ||||
|    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 | ||||
|  | @ -18,21 +17,23 @@ | |||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| #include "dirname.h" | ||||
| /* Specification.  */ | ||||
| #include <wchar.h> | ||||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include "xalloc.h" | ||||
| 
 | ||||
| /* Just like mdir_name (dirname-lgpl.c), except, rather than
 | ||||
|    returning NULL upon malloc failure, here, we report the | ||||
|    "memory exhausted" condition and exit.  */ | ||||
| 
 | ||||
| char * | ||||
| dir_name (char const *file) | ||||
| wint_t | ||||
| btowc (int c) | ||||
| { | ||||
|   char *result = mdir_name (file); | ||||
|   if (!result) | ||||
|     xalloc_die (); | ||||
|   return result; | ||||
|   if (c != EOF) | ||||
|     { | ||||
|       char buf[1]; | ||||
|       wchar_t wc; | ||||
| 
 | ||||
|       buf[0] = c; | ||||
|       if (mbtowc (&wc, buf, 1) >= 0) | ||||
|         return wc; | ||||
|     } | ||||
|   return WEOF; | ||||
| } | ||||
							
								
								
									
										683
									
								
								grub-core/gnulib/config.charset
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										683
									
								
								grub-core/gnulib/config.charset
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,683 @@ | |||
| #! /bin/sh | ||||
| # Output a system dependent table of character encoding aliases. | ||||
| # | ||||
| #   Copyright (C) 2000-2004, 2006-2010 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, 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 General Public License for more details. | ||||
| # | ||||
| #   You should have received a copy of the GNU General Public License along | ||||
| #   with this program; if not, write to the Free Software Foundation, | ||||
| #   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| # | ||||
| # The table consists of lines of the form | ||||
| #    ALIAS  CANONICAL | ||||
| # | ||||
| # ALIAS is the (system dependent) result of "nl_langinfo (CODESET)". | ||||
| # ALIAS is compared in a case sensitive way. | ||||
| # | ||||
| # CANONICAL is the GNU canonical name for this character encoding. | ||||
| # It must be an encoding supported by libiconv. Support by GNU libc is | ||||
| # also desirable. CANONICAL is case insensitive. Usually an upper case | ||||
| # MIME charset name is preferred. | ||||
| # The current list of GNU canonical charset names is as follows. | ||||
| # | ||||
| #       name              MIME?             used by which systems | ||||
| #   ASCII, ANSI_X3.4-1968       glibc solaris freebsd netbsd darwin cygwin | ||||
| #   ISO-8859-1              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin | ||||
| #   ISO-8859-2              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin | ||||
| #   ISO-8859-3              Y   glibc solaris cygwin | ||||
| #   ISO-8859-4              Y   osf solaris freebsd netbsd openbsd darwin | ||||
| #   ISO-8859-5              Y   glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin | ||||
| #   ISO-8859-6              Y   glibc aix hpux solaris cygwin | ||||
| #   ISO-8859-7              Y   glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin | ||||
| #   ISO-8859-8              Y   glibc aix hpux osf solaris cygwin | ||||
| #   ISO-8859-9              Y   glibc aix hpux irix osf solaris darwin cygwin | ||||
| #   ISO-8859-13                 glibc netbsd openbsd darwin cygwin | ||||
| #   ISO-8859-14                 glibc cygwin | ||||
| #   ISO-8859-15                 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin | ||||
| #   KOI8-R                  Y   glibc solaris freebsd netbsd openbsd darwin | ||||
| #   KOI8-U                  Y   glibc freebsd netbsd openbsd darwin cygwin | ||||
| #   KOI8-T                      glibc | ||||
| #   CP437                       dos | ||||
| #   CP775                       dos | ||||
| #   CP850                       aix osf dos | ||||
| #   CP852                       dos | ||||
| #   CP855                       dos | ||||
| #   CP856                       aix | ||||
| #   CP857                       dos | ||||
| #   CP861                       dos | ||||
| #   CP862                       dos | ||||
| #   CP864                       dos | ||||
| #   CP865                       dos | ||||
| #   CP866                       freebsd netbsd openbsd darwin dos | ||||
| #   CP869                       dos | ||||
| #   CP874                       woe32 dos | ||||
| #   CP922                       aix | ||||
| #   CP932                       aix cygwin woe32 dos | ||||
| #   CP943                       aix | ||||
| #   CP949                       osf darwin woe32 dos | ||||
| #   CP950                       woe32 dos | ||||
| #   CP1046                      aix | ||||
| #   CP1124                      aix | ||||
| #   CP1125                      dos | ||||
| #   CP1129                      aix | ||||
| #   CP1131                      darwin | ||||
| #   CP1250                      woe32 | ||||
| #   CP1251                      glibc solaris netbsd openbsd darwin cygwin woe32 | ||||
| #   CP1252                      aix woe32 | ||||
| #   CP1253                      woe32 | ||||
| #   CP1254                      woe32 | ||||
| #   CP1255                      glibc woe32 | ||||
| #   CP1256                      woe32 | ||||
| #   CP1257                      woe32 | ||||
| #   GB2312                  Y   glibc aix hpux irix solaris freebsd netbsd darwin | ||||
| #   EUC-JP                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin | ||||
| #   EUC-KR                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin | ||||
| #   EUC-TW                      glibc aix hpux irix osf solaris netbsd | ||||
| #   BIG5                    Y   glibc aix hpux osf solaris freebsd netbsd darwin cygwin | ||||
| #   BIG5-HKSCS                  glibc solaris darwin | ||||
| #   GBK                         glibc aix osf solaris darwin cygwin woe32 dos | ||||
| #   GB18030                     glibc solaris netbsd darwin | ||||
| #   SHIFT_JIS               Y   hpux osf solaris freebsd netbsd darwin | ||||
| #   JOHAB                       glibc solaris woe32 | ||||
| #   TIS-620                     glibc aix hpux osf solaris cygwin | ||||
| #   VISCII                  Y   glibc | ||||
| #   TCVN5712-1                  glibc | ||||
| #   ARMSCII-8                   glibc darwin | ||||
| #   GEORGIAN-PS                 glibc cygwin | ||||
| #   PT154                       glibc | ||||
| #   HP-ROMAN8                   hpux | ||||
| #   HP-ARABIC8                  hpux | ||||
| #   HP-GREEK8                   hpux | ||||
| #   HP-HEBREW8                  hpux | ||||
| #   HP-TURKISH8                 hpux | ||||
| #   HP-KANA8                    hpux | ||||
| #   DEC-KANJI                   osf | ||||
| #   DEC-HANYU                   osf | ||||
| #   UTF-8                   Y   glibc aix hpux osf solaris netbsd darwin cygwin | ||||
| # | ||||
| # Note: Names which are not marked as being a MIME name should not be used in | ||||
| # Internet protocols for information interchange (mail, news, etc.). | ||||
| # | ||||
| # Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications | ||||
| # must understand both names and treat them as equivalent. | ||||
| # | ||||
| # The first argument passed to this file is the canonical host specification, | ||||
| #    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM | ||||
| # or | ||||
| #    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM | ||||
| 
 | ||||
| host="$1" | ||||
| os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'` | ||||
| echo "# This file contains a table of character encoding aliases," | ||||
| echo "# suitable for operating system '${os}'." | ||||
| echo "# It was automatically generated from config.charset." | ||||
| # List of references, updated during installation: | ||||
| echo "# Packages using this file: " | ||||
| case "$os" in | ||||
|   linux-gnulibc1*) | ||||
|     # Linux libc5 doesn't have nl_langinfo(CODESET); therefore | ||||
|     # localcharset.c falls back to using the full locale name | ||||
|     # from the environment variables. | ||||
|     echo "C ASCII" | ||||
|     echo "POSIX ASCII" | ||||
|     for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \ | ||||
|              en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \ | ||||
|              en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \ | ||||
|              es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \ | ||||
|              et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \ | ||||
|              fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \ | ||||
|              it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \ | ||||
|              sv_FI sv_SE; do | ||||
|       echo "$l ISO-8859-1" | ||||
|       echo "$l.iso-8859-1 ISO-8859-1" | ||||
|       echo "$l.iso-8859-15 ISO-8859-15" | ||||
|       echo "$l.iso-8859-15@euro ISO-8859-15" | ||||
|       echo "$l@euro ISO-8859-15" | ||||
|       echo "$l.cp-437 CP437" | ||||
|       echo "$l.cp-850 CP850" | ||||
|       echo "$l.cp-1252 CP1252" | ||||
|       echo "$l.cp-1252@euro CP1252" | ||||
|       #echo "$l.atari-st ATARI-ST" # not a commonly used encoding | ||||
|       echo "$l.utf-8 UTF-8" | ||||
|       echo "$l.utf-8@euro UTF-8" | ||||
|     done | ||||
|     for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \ | ||||
|              sl_SI sr sr_CS sr_YU; do | ||||
|       echo "$l ISO-8859-2" | ||||
|       echo "$l.iso-8859-2 ISO-8859-2" | ||||
|       echo "$l.cp-852 CP852" | ||||
|       echo "$l.cp-1250 CP1250" | ||||
|       echo "$l.utf-8 UTF-8" | ||||
|     done | ||||
|     for l in mk mk_MK ru ru_RU; do | ||||
|       echo "$l ISO-8859-5" | ||||
|       echo "$l.iso-8859-5 ISO-8859-5" | ||||
|       echo "$l.koi8-r KOI8-R" | ||||
|       echo "$l.cp-866 CP866" | ||||
|       echo "$l.cp-1251 CP1251" | ||||
|       echo "$l.utf-8 UTF-8" | ||||
|     done | ||||
|     for l in ar ar_SA; do | ||||
|       echo "$l ISO-8859-6" | ||||
|       echo "$l.iso-8859-6 ISO-8859-6" | ||||
|       echo "$l.cp-864 CP864" | ||||
|       #echo "$l.cp-868 CP868" # not a commonly used encoding | ||||
|       echo "$l.cp-1256 CP1256" | ||||
|       echo "$l.utf-8 UTF-8" | ||||
|     done | ||||
|     for l in el el_GR gr gr_GR; do | ||||
|       echo "$l ISO-8859-7" | ||||
|       echo "$l.iso-8859-7 ISO-8859-7" | ||||
|       echo "$l.cp-869 CP869" | ||||
|       echo "$l.cp-1253 CP1253" | ||||
|       echo "$l.cp-1253@euro CP1253" | ||||
|       echo "$l.utf-8 UTF-8" | ||||
|       echo "$l.utf-8@euro UTF-8" | ||||
|     done | ||||
|     for l in he he_IL iw iw_IL; do | ||||
|       echo "$l ISO-8859-8" | ||||
|       echo "$l.iso-8859-8 ISO-8859-8" | ||||
|       echo "$l.cp-862 CP862" | ||||
|       echo "$l.cp-1255 CP1255" | ||||
|       echo "$l.utf-8 UTF-8" | ||||
|     done | ||||
|     for l in tr tr_TR; do | ||||
|       echo "$l ISO-8859-9" | ||||
|       echo "$l.iso-8859-9 ISO-8859-9" | ||||
|       echo "$l.cp-857 CP857" | ||||
|       echo "$l.cp-1254 CP1254" | ||||
|       echo "$l.utf-8 UTF-8" | ||||
|     done | ||||
|     for l in lt lt_LT lv lv_LV; do | ||||
|       #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name | ||||
|       echo "$l ISO-8859-13" | ||||
|     done | ||||
|     for l in ru_UA uk uk_UA; do | ||||
|       echo "$l KOI8-U" | ||||
|     done | ||||
|     for l in zh zh_CN; do | ||||
|       #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name | ||||
|       echo "$l GB2312" | ||||
|     done | ||||
|     for l in ja ja_JP ja_JP.EUC; do | ||||
|       echo "$l EUC-JP" | ||||
|     done | ||||
|     for l in ko ko_KR; do | ||||
|       echo "$l EUC-KR" | ||||
|     done | ||||
|     for l in th th_TH; do | ||||
|       echo "$l TIS-620" | ||||
|     done | ||||
|     for l in fa fa_IR; do | ||||
|       #echo "$l ISIRI-3342" # a broken encoding | ||||
|       echo "$l.utf-8 UTF-8" | ||||
|     done | ||||
|     ;; | ||||
|   linux* | *-gnu*) | ||||
|     # With glibc-2.1 or newer, we don't need any canonicalization, | ||||
|     # because glibc has iconv and both glibc and libiconv support all | ||||
|     # GNU canonical names directly. Therefore, the Makefile does not | ||||
|     # need to install the alias file at all. | ||||
|     # The following applies only to glibc-2.0.x and older libcs. | ||||
|     echo "ISO_646.IRV:1983 ASCII" | ||||
|     ;; | ||||
|   aix*) | ||||
|     echo "ISO8859-1 ISO-8859-1" | ||||
|     echo "ISO8859-2 ISO-8859-2" | ||||
|     echo "ISO8859-5 ISO-8859-5" | ||||
|     echo "ISO8859-6 ISO-8859-6" | ||||
|     echo "ISO8859-7 ISO-8859-7" | ||||
|     echo "ISO8859-8 ISO-8859-8" | ||||
|     echo "ISO8859-9 ISO-8859-9" | ||||
|     echo "ISO8859-15 ISO-8859-15" | ||||
|     echo "IBM-850 CP850" | ||||
|     echo "IBM-856 CP856" | ||||
|     echo "IBM-921 ISO-8859-13" | ||||
|     echo "IBM-922 CP922" | ||||
|     echo "IBM-932 CP932" | ||||
|     echo "IBM-943 CP943" | ||||
|     echo "IBM-1046 CP1046" | ||||
|     echo "IBM-1124 CP1124" | ||||
|     echo "IBM-1129 CP1129" | ||||
|     echo "IBM-1252 CP1252" | ||||
|     echo "IBM-eucCN GB2312" | ||||
|     echo "IBM-eucJP EUC-JP" | ||||
|     echo "IBM-eucKR EUC-KR" | ||||
|     echo "IBM-eucTW EUC-TW" | ||||
|     echo "big5 BIG5" | ||||
|     echo "GBK GBK" | ||||
|     echo "TIS-620 TIS-620" | ||||
|     echo "UTF-8 UTF-8" | ||||
|     ;; | ||||
|   hpux*) | ||||
|     echo "iso88591 ISO-8859-1" | ||||
|     echo "iso88592 ISO-8859-2" | ||||
|     echo "iso88595 ISO-8859-5" | ||||
|     echo "iso88596 ISO-8859-6" | ||||
|     echo "iso88597 ISO-8859-7" | ||||
|     echo "iso88598 ISO-8859-8" | ||||
|     echo "iso88599 ISO-8859-9" | ||||
|     echo "iso885915 ISO-8859-15" | ||||
|     echo "roman8 HP-ROMAN8" | ||||
|     echo "arabic8 HP-ARABIC8" | ||||
|     echo "greek8 HP-GREEK8" | ||||
|     echo "hebrew8 HP-HEBREW8" | ||||
|     echo "turkish8 HP-TURKISH8" | ||||
|     echo "kana8 HP-KANA8" | ||||
|     echo "tis620 TIS-620" | ||||
|     echo "big5 BIG5" | ||||
|     echo "eucJP EUC-JP" | ||||
|     echo "eucKR EUC-KR" | ||||
|     echo "eucTW EUC-TW" | ||||
|     echo "hp15CN GB2312" | ||||
|     #echo "ccdc ?" # what is this? | ||||
|     echo "SJIS SHIFT_JIS" | ||||
|     echo "utf8 UTF-8" | ||||
|     ;; | ||||
|   irix*) | ||||
|     echo "ISO8859-1 ISO-8859-1" | ||||
|     echo "ISO8859-2 ISO-8859-2" | ||||
|     echo "ISO8859-5 ISO-8859-5" | ||||
|     echo "ISO8859-7 ISO-8859-7" | ||||
|     echo "ISO8859-9 ISO-8859-9" | ||||
|     echo "eucCN GB2312" | ||||
|     echo "eucJP EUC-JP" | ||||
|     echo "eucKR EUC-KR" | ||||
|     echo "eucTW EUC-TW" | ||||
|     ;; | ||||
|   osf*) | ||||
|     echo "ISO8859-1 ISO-8859-1" | ||||
|     echo "ISO8859-2 ISO-8859-2" | ||||
|     echo "ISO8859-4 ISO-8859-4" | ||||
|     echo "ISO8859-5 ISO-8859-5" | ||||
|     echo "ISO8859-7 ISO-8859-7" | ||||
|     echo "ISO8859-8 ISO-8859-8" | ||||
|     echo "ISO8859-9 ISO-8859-9" | ||||
|     echo "ISO8859-15 ISO-8859-15" | ||||
|     echo "cp850 CP850" | ||||
|     echo "big5 BIG5" | ||||
|     echo "dechanyu DEC-HANYU" | ||||
|     echo "dechanzi GB2312" | ||||
|     echo "deckanji DEC-KANJI" | ||||
|     echo "deckorean EUC-KR" | ||||
|     echo "eucJP EUC-JP" | ||||
|     echo "eucKR EUC-KR" | ||||
|     echo "eucTW EUC-TW" | ||||
|     echo "GBK GBK" | ||||
|     echo "KSC5601 CP949" | ||||
|     echo "sdeckanji EUC-JP" | ||||
|     echo "SJIS SHIFT_JIS" | ||||
|     echo "TACTIS TIS-620" | ||||
|     echo "UTF-8 UTF-8" | ||||
|     ;; | ||||
|   solaris*) | ||||
|     echo "646 ASCII" | ||||
|     echo "ISO8859-1 ISO-8859-1" | ||||
|     echo "ISO8859-2 ISO-8859-2" | ||||
|     echo "ISO8859-3 ISO-8859-3" | ||||
|     echo "ISO8859-4 ISO-8859-4" | ||||
|     echo "ISO8859-5 ISO-8859-5" | ||||
|     echo "ISO8859-6 ISO-8859-6" | ||||
|     echo "ISO8859-7 ISO-8859-7" | ||||
|     echo "ISO8859-8 ISO-8859-8" | ||||
|     echo "ISO8859-9 ISO-8859-9" | ||||
|     echo "ISO8859-15 ISO-8859-15" | ||||
|     echo "koi8-r KOI8-R" | ||||
|     echo "ansi-1251 CP1251" | ||||
|     echo "BIG5 BIG5" | ||||
|     echo "Big5-HKSCS BIG5-HKSCS" | ||||
|     echo "gb2312 GB2312" | ||||
|     echo "GBK GBK" | ||||
|     echo "GB18030 GB18030" | ||||
|     echo "cns11643 EUC-TW" | ||||
|     echo "5601 EUC-KR" | ||||
|     echo "ko_KR.johap92 JOHAB" | ||||
|     echo "eucJP EUC-JP" | ||||
|     echo "PCK SHIFT_JIS" | ||||
|     echo "TIS620.2533 TIS-620" | ||||
|     #echo "sun_eu_greek ?" # what is this? | ||||
|     echo "UTF-8 UTF-8" | ||||
|     ;; | ||||
|   freebsd* | os2*) | ||||
|     # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore | ||||
|     # localcharset.c falls back to using the full locale name | ||||
|     # from the environment variables. | ||||
|     # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just | ||||
|     # reuse FreeBSD's locale data for OS/2. | ||||
|     echo "C ASCII" | ||||
|     echo "US-ASCII ASCII" | ||||
|     for l in la_LN lt_LN; do | ||||
|       echo "$l.ASCII ASCII" | ||||
|     done | ||||
|     for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ | ||||
|              fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \ | ||||
|              lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do | ||||
|       echo "$l.ISO_8859-1 ISO-8859-1" | ||||
|       echo "$l.DIS_8859-15 ISO-8859-15" | ||||
|     done | ||||
|     for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do | ||||
|       echo "$l.ISO_8859-2 ISO-8859-2" | ||||
|     done | ||||
|     for l in la_LN lt_LT; do | ||||
|       echo "$l.ISO_8859-4 ISO-8859-4" | ||||
|     done | ||||
|     for l in ru_RU ru_SU; do | ||||
|       echo "$l.KOI8-R KOI8-R" | ||||
|       echo "$l.ISO_8859-5 ISO-8859-5" | ||||
|       echo "$l.CP866 CP866" | ||||
|     done | ||||
|     echo "uk_UA.KOI8-U KOI8-U" | ||||
|     echo "zh_TW.BIG5 BIG5" | ||||
|     echo "zh_TW.Big5 BIG5" | ||||
|     echo "zh_CN.EUC GB2312" | ||||
|     echo "ja_JP.EUC EUC-JP" | ||||
|     echo "ja_JP.SJIS SHIFT_JIS" | ||||
|     echo "ja_JP.Shift_JIS SHIFT_JIS" | ||||
|     echo "ko_KR.EUC EUC-KR" | ||||
|     ;; | ||||
|   netbsd*) | ||||
|     echo "646 ASCII" | ||||
|     echo "ISO8859-1 ISO-8859-1" | ||||
|     echo "ISO8859-2 ISO-8859-2" | ||||
|     echo "ISO8859-4 ISO-8859-4" | ||||
|     echo "ISO8859-5 ISO-8859-5" | ||||
|     echo "ISO8859-7 ISO-8859-7" | ||||
|     echo "ISO8859-13 ISO-8859-13" | ||||
|     echo "ISO8859-15 ISO-8859-15" | ||||
|     echo "eucCN GB2312" | ||||
|     echo "eucJP EUC-JP" | ||||
|     echo "eucKR EUC-KR" | ||||
|     echo "eucTW EUC-TW" | ||||
|     echo "BIG5 BIG5" | ||||
|     echo "SJIS SHIFT_JIS" | ||||
|     ;; | ||||
|   openbsd*) | ||||
|     echo "646 ASCII" | ||||
|     echo "ISO8859-1 ISO-8859-1" | ||||
|     echo "ISO8859-2 ISO-8859-2" | ||||
|     echo "ISO8859-4 ISO-8859-4" | ||||
|     echo "ISO8859-5 ISO-8859-5" | ||||
|     echo "ISO8859-7 ISO-8859-7" | ||||
|     echo "ISO8859-13 ISO-8859-13" | ||||
|     echo "ISO8859-15 ISO-8859-15" | ||||
|     ;; | ||||
|   darwin[56]*) | ||||
|     # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore | ||||
|     # localcharset.c falls back to using the full locale name | ||||
|     # from the environment variables. | ||||
|     echo "C ASCII" | ||||
|     for l in en_AU en_CA en_GB en_US la_LN; do | ||||
|       echo "$l.US-ASCII ASCII" | ||||
|     done | ||||
|     for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \ | ||||
|              fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \ | ||||
|              nl_NL no_NO pt_PT sv_SE; do | ||||
|       echo "$l ISO-8859-1" | ||||
|       echo "$l.ISO8859-1 ISO-8859-1" | ||||
|       echo "$l.ISO8859-15 ISO-8859-15" | ||||
|     done | ||||
|     for l in la_LN; do | ||||
|       echo "$l.ISO8859-1 ISO-8859-1" | ||||
|       echo "$l.ISO8859-15 ISO-8859-15" | ||||
|     done | ||||
|     for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do | ||||
|       echo "$l.ISO8859-2 ISO-8859-2" | ||||
|     done | ||||
|     for l in la_LN lt_LT; do | ||||
|       echo "$l.ISO8859-4 ISO-8859-4" | ||||
|     done | ||||
|     for l in ru_RU; do | ||||
|       echo "$l.KOI8-R KOI8-R" | ||||
|       echo "$l.ISO8859-5 ISO-8859-5" | ||||
|       echo "$l.CP866 CP866" | ||||
|     done | ||||
|     for l in bg_BG; do | ||||
|       echo "$l.CP1251 CP1251" | ||||
|     done | ||||
|     echo "uk_UA.KOI8-U KOI8-U" | ||||
|     echo "zh_TW.BIG5 BIG5" | ||||
|     echo "zh_TW.Big5 BIG5" | ||||
|     echo "zh_CN.EUC GB2312" | ||||
|     echo "ja_JP.EUC EUC-JP" | ||||
|     echo "ja_JP.SJIS SHIFT_JIS" | ||||
|     echo "ko_KR.EUC EUC-KR" | ||||
|     ;; | ||||
|   darwin*) | ||||
|     # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is | ||||
|     # useless: | ||||
|     # - It returns the empty string when LANG is set to a locale of the | ||||
|     #   form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8 | ||||
|     #   LC_CTYPE file. | ||||
|     # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by | ||||
|     #   the system; nl_langinfo(CODESET) returns "US-ASCII" in this case. | ||||
|     # - The documentation says: | ||||
|     #     "... all code that calls BSD system routines should ensure | ||||
|     #      that the const *char parameters of these routines are in UTF-8 | ||||
|     #      encoding. All BSD system functions expect their string | ||||
|     #      parameters to be in UTF-8 encoding and nothing else." | ||||
|     #   It also says | ||||
|     #     "An additional caveat is that string parameters for files, | ||||
|     #      paths, and other file-system entities must be in canonical | ||||
|     #      UTF-8. In a canonical UTF-8 Unicode string, all decomposable | ||||
|     #      characters are decomposed ..." | ||||
|     #   but this is not true: You can pass non-decomposed UTF-8 strings | ||||
|     #   to file system functions, and it is the OS which will convert | ||||
|     #   them to decomposed UTF-8 before accessing the file system. | ||||
|     # - The Apple Terminal application displays UTF-8 by default. | ||||
|     # - However, other applications are free to use different encodings: | ||||
|     #   - xterm uses ISO-8859-1 by default. | ||||
|     #   - TextEdit uses MacRoman by default. | ||||
|     # We prefer UTF-8 over decomposed UTF-8-MAC because one should | ||||
|     # minimize the use of decomposed Unicode. Unfortunately, through the | ||||
|     # Darwin file system, decomposed UTF-8 strings are leaked into user | ||||
|     # space nevertheless. | ||||
|     # Then there are also the locales with encodings other than US-ASCII | ||||
|     # and UTF-8. These locales can be occasionally useful to users (e.g. | ||||
|     # when grepping through ISO-8859-1 encoded text files), when all their | ||||
|     # file names are in US-ASCII. | ||||
|     echo "ISO8859-1 ISO-8859-1" | ||||
|     echo "ISO8859-2 ISO-8859-2" | ||||
|     echo "ISO8859-4 ISO-8859-4" | ||||
|     echo "ISO8859-5 ISO-8859-5" | ||||
|     echo "ISO8859-7 ISO-8859-7" | ||||
|     echo "ISO8859-9 ISO-8859-9" | ||||
|     echo "ISO8859-13 ISO-8859-13" | ||||
|     echo "ISO8859-15 ISO-8859-15" | ||||
|     echo "KOI8-R KOI8-R" | ||||
|     echo "KOI8-U KOI8-U" | ||||
|     echo "CP866 CP866" | ||||
|     echo "CP949 CP949" | ||||
|     echo "CP1131 CP1131" | ||||
|     echo "CP1251 CP1251" | ||||
|     echo "eucCN GB2312" | ||||
|     echo "GB2312 GB2312" | ||||
|     echo "eucJP EUC-JP" | ||||
|     echo "eucKR EUC-KR" | ||||
|     echo "Big5 BIG5" | ||||
|     echo "Big5HKSCS BIG5-HKSCS" | ||||
|     echo "GBK GBK" | ||||
|     echo "GB18030 GB18030" | ||||
|     echo "SJIS SHIFT_JIS" | ||||
|     echo "ARMSCII-8 ARMSCII-8" | ||||
|     echo "PT154 PT154" | ||||
|     #echo "ISCII-DEV ?" | ||||
|     echo "* UTF-8" | ||||
|     ;; | ||||
|   beos* | haiku*) | ||||
|     # BeOS and Haiku have a single locale, and it has UTF-8 encoding. | ||||
|     echo "* UTF-8" | ||||
|     ;; | ||||
|   msdosdjgpp*) | ||||
|     # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore | ||||
|     # localcharset.c falls back to using the full locale name | ||||
|     # from the environment variables. | ||||
|     echo "#" | ||||
|     echo "# The encodings given here may not all be correct." | ||||
|     echo "# If you find that the encoding given for your language and" | ||||
|     echo "# country is not the one your DOS machine actually uses, just" | ||||
|     echo "# correct it in this file, and send a mail to" | ||||
|     echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>" | ||||
|     echo "# and Bruno Haible <bruno@clisp.org>." | ||||
|     echo "#" | ||||
|     echo "C ASCII" | ||||
|     # ISO-8859-1 languages | ||||
|     echo "ca CP850" | ||||
|     echo "ca_ES CP850" | ||||
|     echo "da CP865"    # not CP850 ?? | ||||
|     echo "da_DK CP865" # not CP850 ?? | ||||
|     echo "de CP850" | ||||
|     echo "de_AT CP850" | ||||
|     echo "de_CH CP850" | ||||
|     echo "de_DE CP850" | ||||
|     echo "en CP850" | ||||
|     echo "en_AU CP850" # not CP437 ?? | ||||
|     echo "en_CA CP850" | ||||
|     echo "en_GB CP850" | ||||
|     echo "en_NZ CP437" | ||||
|     echo "en_US CP437" | ||||
|     echo "en_ZA CP850" # not CP437 ?? | ||||
|     echo "es CP850" | ||||
|     echo "es_AR CP850" | ||||
|     echo "es_BO CP850" | ||||
|     echo "es_CL CP850" | ||||
|     echo "es_CO CP850" | ||||
|     echo "es_CR CP850" | ||||
|     echo "es_CU CP850" | ||||
|     echo "es_DO CP850" | ||||
|     echo "es_EC CP850" | ||||
|     echo "es_ES CP850" | ||||
|     echo "es_GT CP850" | ||||
|     echo "es_HN CP850" | ||||
|     echo "es_MX CP850" | ||||
|     echo "es_NI CP850" | ||||
|     echo "es_PA CP850" | ||||
|     echo "es_PY CP850" | ||||
|     echo "es_PE CP850" | ||||
|     echo "es_SV CP850" | ||||
|     echo "es_UY CP850" | ||||
|     echo "es_VE CP850" | ||||
|     echo "et CP850" | ||||
|     echo "et_EE CP850" | ||||
|     echo "eu CP850" | ||||
|     echo "eu_ES CP850" | ||||
|     echo "fi CP850" | ||||
|     echo "fi_FI CP850" | ||||
|     echo "fr CP850" | ||||
|     echo "fr_BE CP850" | ||||
|     echo "fr_CA CP850" | ||||
|     echo "fr_CH CP850" | ||||
|     echo "fr_FR CP850" | ||||
|     echo "ga CP850" | ||||
|     echo "ga_IE CP850" | ||||
|     echo "gd CP850" | ||||
|     echo "gd_GB CP850" | ||||
|     echo "gl CP850" | ||||
|     echo "gl_ES CP850" | ||||
|     echo "id CP850"    # not CP437 ?? | ||||
|     echo "id_ID CP850" # not CP437 ?? | ||||
|     echo "is CP861"    # not CP850 ?? | ||||
|     echo "is_IS CP861" # not CP850 ?? | ||||
|     echo "it CP850" | ||||
|     echo "it_CH CP850" | ||||
|     echo "it_IT CP850" | ||||
|     echo "lt CP775" | ||||
|     echo "lt_LT CP775" | ||||
|     echo "lv CP775" | ||||
|     echo "lv_LV CP775" | ||||
|     echo "nb CP865"    # not CP850 ?? | ||||
|     echo "nb_NO CP865" # not CP850 ?? | ||||
|     echo "nl CP850" | ||||
|     echo "nl_BE CP850" | ||||
|     echo "nl_NL CP850" | ||||
|     echo "nn CP865"    # not CP850 ?? | ||||
|     echo "nn_NO CP865" # not CP850 ?? | ||||
|     echo "no CP865"    # not CP850 ?? | ||||
|     echo "no_NO CP865" # not CP850 ?? | ||||
|     echo "pt CP850" | ||||
|     echo "pt_BR CP850" | ||||
|     echo "pt_PT CP850" | ||||
|     echo "sv CP850" | ||||
|     echo "sv_SE CP850" | ||||
|     # ISO-8859-2 languages | ||||
|     echo "cs CP852" | ||||
|     echo "cs_CZ CP852" | ||||
|     echo "hr CP852" | ||||
|     echo "hr_HR CP852" | ||||
|     echo "hu CP852" | ||||
|     echo "hu_HU CP852" | ||||
|     echo "pl CP852" | ||||
|     echo "pl_PL CP852" | ||||
|     echo "ro CP852" | ||||
|     echo "ro_RO CP852" | ||||
|     echo "sk CP852" | ||||
|     echo "sk_SK CP852" | ||||
|     echo "sl CP852" | ||||
|     echo "sl_SI CP852" | ||||
|     echo "sq CP852" | ||||
|     echo "sq_AL CP852" | ||||
|     echo "sr CP852"    # CP852 or CP866 or CP855 ?? | ||||
|     echo "sr_CS CP852" # CP852 or CP866 or CP855 ?? | ||||
|     echo "sr_YU CP852" # CP852 or CP866 or CP855 ?? | ||||
|     # ISO-8859-3 languages | ||||
|     echo "mt CP850" | ||||
|     echo "mt_MT CP850" | ||||
|     # ISO-8859-5 languages | ||||
|     echo "be CP866" | ||||
|     echo "be_BE CP866" | ||||
|     echo "bg CP866"    # not CP855 ?? | ||||
|     echo "bg_BG CP866" # not CP855 ?? | ||||
|     echo "mk CP866"    # not CP855 ?? | ||||
|     echo "mk_MK CP866" # not CP855 ?? | ||||
|     echo "ru CP866" | ||||
|     echo "ru_RU CP866" | ||||
|     echo "uk CP1125" | ||||
|     echo "uk_UA CP1125" | ||||
|     # ISO-8859-6 languages | ||||
|     echo "ar CP864" | ||||
|     echo "ar_AE CP864" | ||||
|     echo "ar_DZ CP864" | ||||
|     echo "ar_EG CP864" | ||||
|     echo "ar_IQ CP864" | ||||
|     echo "ar_IR CP864" | ||||
|     echo "ar_JO CP864" | ||||
|     echo "ar_KW CP864" | ||||
|     echo "ar_MA CP864" | ||||
|     echo "ar_OM CP864" | ||||
|     echo "ar_QA CP864" | ||||
|     echo "ar_SA CP864" | ||||
|     echo "ar_SY CP864" | ||||
|     # ISO-8859-7 languages | ||||
|     echo "el CP869" | ||||
|     echo "el_GR CP869" | ||||
|     # ISO-8859-8 languages | ||||
|     echo "he CP862" | ||||
|     echo "he_IL CP862" | ||||
|     # ISO-8859-9 languages | ||||
|     echo "tr CP857" | ||||
|     echo "tr_TR CP857" | ||||
|     # Japanese | ||||
|     echo "ja CP932" | ||||
|     echo "ja_JP CP932" | ||||
|     # Chinese | ||||
|     echo "zh_CN GBK" | ||||
|     echo "zh_TW CP950" # not CP938 ?? | ||||
|     # Korean | ||||
|     echo "kr CP949"    # not CP934 ?? | ||||
|     echo "kr_KR CP949" # not CP934 ?? | ||||
|     # Thai | ||||
|     echo "th CP874" | ||||
|     echo "th_TH CP874" | ||||
|     # Other | ||||
|     echo "eo CP850" | ||||
|     echo "eo_EO CP850" | ||||
|     ;; | ||||
| esac | ||||
							
								
								
									
										160
									
								
								grub-core/gnulib/errno.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										160
									
								
								grub-core/gnulib/errno.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,160 @@ | |||
| /* A POSIX-like <errno.h>.
 | ||||
| 
 | ||||
|    Copyright (C) 2008-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _GL_ERRNO_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #@INCLUDE_NEXT@ @NEXT_ERRNO_H@ | ||||
| 
 | ||||
| #ifndef _GL_ERRNO_H | ||||
| #define _GL_ERRNO_H | ||||
| 
 | ||||
| 
 | ||||
| /* On native Windows platforms, many macros are not defined.  */ | ||||
| # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||||
| 
 | ||||
| /* POSIX says that EAGAIN and EWOULDBLOCK may have the same value.  */ | ||||
| #  define EWOULDBLOCK     EAGAIN | ||||
| 
 | ||||
| /* Values >= 100 seem safe to use.  */ | ||||
| #  define ETXTBSY   100 | ||||
| #  define GNULIB_defined_ETXTBSY 1 | ||||
| 
 | ||||
| /* These are intentionally the same values as the WSA* error numbers, defined
 | ||||
|    in <winsock2.h>.  */ | ||||
| #  define EINPROGRESS     10036 | ||||
| #  define EALREADY        10037 | ||||
| #  define ENOTSOCK        10038 | ||||
| #  define EDESTADDRREQ    10039 | ||||
| #  define EMSGSIZE        10040 | ||||
| #  define EPROTOTYPE      10041 | ||||
| #  define ENOPROTOOPT     10042 | ||||
| #  define EPROTONOSUPPORT 10043 | ||||
| #  define ESOCKTNOSUPPORT 10044  /* not required by POSIX */ | ||||
| #  define EOPNOTSUPP      10045 | ||||
| #  define EPFNOSUPPORT    10046  /* not required by POSIX */ | ||||
| #  define EAFNOSUPPORT    10047 | ||||
| #  define EADDRINUSE      10048 | ||||
| #  define EADDRNOTAVAIL   10049 | ||||
| #  define ENETDOWN        10050 | ||||
| #  define ENETUNREACH     10051 | ||||
| #  define ENETRESET       10052 | ||||
| #  define ECONNABORTED    10053 | ||||
| #  define ECONNRESET      10054 | ||||
| #  define ENOBUFS         10055 | ||||
| #  define EISCONN         10056 | ||||
| #  define ENOTCONN        10057 | ||||
| #  define ESHUTDOWN       10058  /* not required by POSIX */ | ||||
| #  define ETOOMANYREFS    10059  /* not required by POSIX */ | ||||
| #  define ETIMEDOUT       10060 | ||||
| #  define ECONNREFUSED    10061 | ||||
| #  define ELOOP           10062 | ||||
| #  define EHOSTDOWN       10064  /* not required by POSIX */ | ||||
| #  define EHOSTUNREACH    10065 | ||||
| #  define EPROCLIM        10067  /* not required by POSIX */ | ||||
| #  define EUSERS          10068  /* not required by POSIX */ | ||||
| #  define EDQUOT          10069 | ||||
| #  define ESTALE          10070 | ||||
| #  define EREMOTE         10071  /* not required by POSIX */ | ||||
| #  define GNULIB_defined_ESOCK 1 | ||||
| 
 | ||||
| # endif | ||||
| 
 | ||||
| 
 | ||||
| /* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
 | ||||
|    EMULTIHOP, ENOLINK, EOVERFLOW are not defined.  */ | ||||
| # if @EMULTIHOP_HIDDEN@ | ||||
| #  define EMULTIHOP @EMULTIHOP_VALUE@ | ||||
| #  define GNULIB_defined_EMULTIHOP 1 | ||||
| # endif | ||||
| # if @ENOLINK_HIDDEN@ | ||||
| #  define ENOLINK   @ENOLINK_VALUE@ | ||||
| #  define GNULIB_defined_ENOLINK 1 | ||||
| # endif | ||||
| # if @EOVERFLOW_HIDDEN@ | ||||
| #  define EOVERFLOW @EOVERFLOW_VALUE@ | ||||
| #  define GNULIB_defined_EOVERFLOW 1 | ||||
| # endif | ||||
| 
 | ||||
| 
 | ||||
| /* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
 | ||||
|    EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined. | ||||
|    Define them here.  Values >= 2000 seem safe to use: Solaris ESTALE = 151, | ||||
|    HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133. | ||||
| 
 | ||||
|    Note: When one of these systems defines some of these macros some day, | ||||
|    binaries will have to be recompiled so that they recognizes the new | ||||
|    errno values from the system.  */ | ||||
| 
 | ||||
| # ifndef ENOMSG | ||||
| #  define ENOMSG    2000 | ||||
| #  define GNULIB_defined_ENOMSG 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef EIDRM | ||||
| #  define EIDRM     2001 | ||||
| #  define GNULIB_defined_EIDRM 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef ENOLINK | ||||
| #  define ENOLINK   2002 | ||||
| #  define GNULIB_defined_ENOLINK 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef EPROTO | ||||
| #  define EPROTO    2003 | ||||
| #  define GNULIB_defined_EPROTO 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef EMULTIHOP | ||||
| #  define EMULTIHOP 2004 | ||||
| #  define GNULIB_defined_EMULTIHOP 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef EBADMSG | ||||
| #  define EBADMSG   2005 | ||||
| #  define GNULIB_defined_EBADMSG 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef EOVERFLOW | ||||
| #  define EOVERFLOW 2006 | ||||
| #  define GNULIB_defined_EOVERFLOW 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef ENOTSUP | ||||
| #  define ENOTSUP   2007 | ||||
| #  define GNULIB_defined_ENOTSUP 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef ESTALE | ||||
| #  define ESTALE    2009 | ||||
| #  define GNULIB_defined_ESTALE 1 | ||||
| # endif | ||||
| 
 | ||||
| # ifndef ECANCELED | ||||
| #  define ECANCELED 2008 | ||||
| #  define GNULIB_defined_ECANCELED 1 | ||||
| # endif | ||||
| 
 | ||||
| 
 | ||||
| #endif /* _GL_ERRNO_H */ | ||||
| #endif /* _GL_ERRNO_H */ | ||||
							
								
								
									
										148
									
								
								grub-core/gnulib/float+.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								grub-core/gnulib/float+.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,148 @@ | |||
| /* Supplemental information about the floating-point formats.
 | ||||
|    Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2007. | ||||
| 
 | ||||
|    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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _FLOATPLUS_H | ||||
| #define _FLOATPLUS_H | ||||
| 
 | ||||
| #include <float.h> | ||||
| #include <limits.h> | ||||
| 
 | ||||
| /* Number of bits in the mantissa of a floating-point number, including the
 | ||||
|    "hidden bit".  */ | ||||
| #if FLT_RADIX == 2 | ||||
| # define FLT_MANT_BIT FLT_MANT_DIG | ||||
| # define DBL_MANT_BIT DBL_MANT_DIG | ||||
| # define LDBL_MANT_BIT LDBL_MANT_DIG | ||||
| #elif FLT_RADIX == 4 | ||||
| # define FLT_MANT_BIT (FLT_MANT_DIG * 2) | ||||
| # define DBL_MANT_BIT (DBL_MANT_DIG * 2) | ||||
| # define LDBL_MANT_BIT (LDBL_MANT_DIG * 2) | ||||
| #elif FLT_RADIX == 16 | ||||
| # define FLT_MANT_BIT (FLT_MANT_DIG * 4) | ||||
| # define DBL_MANT_BIT (DBL_MANT_DIG * 4) | ||||
| # define LDBL_MANT_BIT (LDBL_MANT_DIG * 4) | ||||
| #endif | ||||
| 
 | ||||
| /* Bit mask that can be used to mask the exponent, as an unsigned number.  */ | ||||
| #define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7) | ||||
| #define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7) | ||||
| #define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7) | ||||
| 
 | ||||
| /* Number of bits used for the exponent of a floating-point number, including
 | ||||
|    the exponent's sign.  */ | ||||
| #define FLT_EXP_BIT \ | ||||
|   (FLT_EXP_MASK < 0x100 ? 8 : \ | ||||
|    FLT_EXP_MASK < 0x200 ? 9 : \ | ||||
|    FLT_EXP_MASK < 0x400 ? 10 : \ | ||||
|    FLT_EXP_MASK < 0x800 ? 11 : \ | ||||
|    FLT_EXP_MASK < 0x1000 ? 12 : \ | ||||
|    FLT_EXP_MASK < 0x2000 ? 13 : \ | ||||
|    FLT_EXP_MASK < 0x4000 ? 14 : \ | ||||
|    FLT_EXP_MASK < 0x8000 ? 15 : \ | ||||
|    FLT_EXP_MASK < 0x10000 ? 16 : \ | ||||
|    FLT_EXP_MASK < 0x20000 ? 17 : \ | ||||
|    FLT_EXP_MASK < 0x40000 ? 18 : \ | ||||
|    FLT_EXP_MASK < 0x80000 ? 19 : \ | ||||
|    FLT_EXP_MASK < 0x100000 ? 20 : \ | ||||
|    FLT_EXP_MASK < 0x200000 ? 21 : \ | ||||
|    FLT_EXP_MASK < 0x400000 ? 22 : \ | ||||
|    FLT_EXP_MASK < 0x800000 ? 23 : \ | ||||
|    FLT_EXP_MASK < 0x1000000 ? 24 : \ | ||||
|    FLT_EXP_MASK < 0x2000000 ? 25 : \ | ||||
|    FLT_EXP_MASK < 0x4000000 ? 26 : \ | ||||
|    FLT_EXP_MASK < 0x8000000 ? 27 : \ | ||||
|    FLT_EXP_MASK < 0x10000000 ? 28 : \ | ||||
|    FLT_EXP_MASK < 0x20000000 ? 29 : \ | ||||
|    FLT_EXP_MASK < 0x40000000 ? 30 : \ | ||||
|    FLT_EXP_MASK <= 0x7fffffff ? 31 : \ | ||||
|    32) | ||||
| #define DBL_EXP_BIT \ | ||||
|   (DBL_EXP_MASK < 0x100 ? 8 : \ | ||||
|    DBL_EXP_MASK < 0x200 ? 9 : \ | ||||
|    DBL_EXP_MASK < 0x400 ? 10 : \ | ||||
|    DBL_EXP_MASK < 0x800 ? 11 : \ | ||||
|    DBL_EXP_MASK < 0x1000 ? 12 : \ | ||||
|    DBL_EXP_MASK < 0x2000 ? 13 : \ | ||||
|    DBL_EXP_MASK < 0x4000 ? 14 : \ | ||||
|    DBL_EXP_MASK < 0x8000 ? 15 : \ | ||||
|    DBL_EXP_MASK < 0x10000 ? 16 : \ | ||||
|    DBL_EXP_MASK < 0x20000 ? 17 : \ | ||||
|    DBL_EXP_MASK < 0x40000 ? 18 : \ | ||||
|    DBL_EXP_MASK < 0x80000 ? 19 : \ | ||||
|    DBL_EXP_MASK < 0x100000 ? 20 : \ | ||||
|    DBL_EXP_MASK < 0x200000 ? 21 : \ | ||||
|    DBL_EXP_MASK < 0x400000 ? 22 : \ | ||||
|    DBL_EXP_MASK < 0x800000 ? 23 : \ | ||||
|    DBL_EXP_MASK < 0x1000000 ? 24 : \ | ||||
|    DBL_EXP_MASK < 0x2000000 ? 25 : \ | ||||
|    DBL_EXP_MASK < 0x4000000 ? 26 : \ | ||||
|    DBL_EXP_MASK < 0x8000000 ? 27 : \ | ||||
|    DBL_EXP_MASK < 0x10000000 ? 28 : \ | ||||
|    DBL_EXP_MASK < 0x20000000 ? 29 : \ | ||||
|    DBL_EXP_MASK < 0x40000000 ? 30 : \ | ||||
|    DBL_EXP_MASK <= 0x7fffffff ? 31 : \ | ||||
|    32) | ||||
| #define LDBL_EXP_BIT \ | ||||
|   (LDBL_EXP_MASK < 0x100 ? 8 : \ | ||||
|    LDBL_EXP_MASK < 0x200 ? 9 : \ | ||||
|    LDBL_EXP_MASK < 0x400 ? 10 : \ | ||||
|    LDBL_EXP_MASK < 0x800 ? 11 : \ | ||||
|    LDBL_EXP_MASK < 0x1000 ? 12 : \ | ||||
|    LDBL_EXP_MASK < 0x2000 ? 13 : \ | ||||
|    LDBL_EXP_MASK < 0x4000 ? 14 : \ | ||||
|    LDBL_EXP_MASK < 0x8000 ? 15 : \ | ||||
|    LDBL_EXP_MASK < 0x10000 ? 16 : \ | ||||
|    LDBL_EXP_MASK < 0x20000 ? 17 : \ | ||||
|    LDBL_EXP_MASK < 0x40000 ? 18 : \ | ||||
|    LDBL_EXP_MASK < 0x80000 ? 19 : \ | ||||
|    LDBL_EXP_MASK < 0x100000 ? 20 : \ | ||||
|    LDBL_EXP_MASK < 0x200000 ? 21 : \ | ||||
|    LDBL_EXP_MASK < 0x400000 ? 22 : \ | ||||
|    LDBL_EXP_MASK < 0x800000 ? 23 : \ | ||||
|    LDBL_EXP_MASK < 0x1000000 ? 24 : \ | ||||
|    LDBL_EXP_MASK < 0x2000000 ? 25 : \ | ||||
|    LDBL_EXP_MASK < 0x4000000 ? 26 : \ | ||||
|    LDBL_EXP_MASK < 0x8000000 ? 27 : \ | ||||
|    LDBL_EXP_MASK < 0x10000000 ? 28 : \ | ||||
|    LDBL_EXP_MASK < 0x20000000 ? 29 : \ | ||||
|    LDBL_EXP_MASK < 0x40000000 ? 30 : \ | ||||
|    LDBL_EXP_MASK <= 0x7fffffff ? 31 : \ | ||||
|    32) | ||||
| 
 | ||||
| /* Number of bits used for a floating-point number: the mantissa (not
 | ||||
|    counting the "hidden bit", since it may or may not be explicit), the | ||||
|    exponent, and the sign.  */ | ||||
| #define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1) | ||||
| #define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1) | ||||
| #define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1) | ||||
| 
 | ||||
| /* Number of bytes used for a floating-point number.
 | ||||
|    This can be smaller than the 'sizeof'.  For example, on i386 systems, | ||||
|    'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence | ||||
|    LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but | ||||
|    sizeof (long double) = 12 or = 16.  */ | ||||
| #define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) | ||||
| #define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) | ||||
| #define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) | ||||
| 
 | ||||
| /* Verify that SIZEOF_FLT <= sizeof (float) etc.  */ | ||||
| typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1]; | ||||
| typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1]; | ||||
| typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1]; | ||||
| 
 | ||||
| #endif /* _FLOATPLUS_H */ | ||||
							
								
								
									
										62
									
								
								grub-core/gnulib/float.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								grub-core/gnulib/float.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,62 @@ | |||
| /* A correct <float.h>.
 | ||||
| 
 | ||||
|    Copyright (C) 2007-2010 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 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/>.  */
 | ||||
| 
 | ||||
| #ifndef _GL_FLOAT_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #@INCLUDE_NEXT@ @NEXT_FLOAT_H@ | ||||
| 
 | ||||
| #ifndef _GL_FLOAT_H | ||||
| #define _GL_FLOAT_H | ||||
| 
 | ||||
| /* 'long double' properties.  */ | ||||
| #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) | ||||
| /* Number of mantissa units, in base FLT_RADIX.  */ | ||||
| # undef LDBL_MANT_DIG | ||||
| # define LDBL_MANT_DIG   64 | ||||
| /* Number of decimal digits that is sufficient for representing a number.  */ | ||||
| # undef LDBL_DIG | ||||
| # define LDBL_DIG        18 | ||||
| /* x-1 where x is the smallest representable number > 1.  */ | ||||
| # undef LDBL_EPSILON | ||||
| # define LDBL_EPSILON    1.0842021724855044340E-19L | ||||
| /* Minimum e such that FLT_RADIX^(e-1) is a normalized number.  */ | ||||
| # undef LDBL_MIN_EXP | ||||
| # define LDBL_MIN_EXP    (-16381) | ||||
| /* Maximum e such that FLT_RADIX^(e-1) is a representable finite number.  */ | ||||
| # undef LDBL_MAX_EXP | ||||
| # define LDBL_MAX_EXP    16384 | ||||
| /* Minimum positive normalized number.  */ | ||||
| # undef LDBL_MIN | ||||
| # define LDBL_MIN        3.3621031431120935063E-4932L | ||||
| /* Maximum representable finite number.  */ | ||||
| # undef LDBL_MAX | ||||
| # define LDBL_MAX        1.1897314953572317650E+4932L | ||||
| /* Minimum e such that 10^e is in the range of normalized numbers.  */ | ||||
| # undef LDBL_MIN_10_EXP | ||||
| # define LDBL_MIN_10_EXP (-4931) | ||||
| /* Maximum e such that 10^e is in the range of representable finite numbers.  */ | ||||
| # undef LDBL_MAX_10_EXP | ||||
| # define LDBL_MAX_10_EXP 4932 | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _GL_FLOAT_H */ | ||||
| #endif /* _GL_FLOAT_H */ | ||||
|  | @ -3,7 +3,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
|  | @ -1,11 +1,11 @@ | |||
| /* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
 | ||||
|    2005, 2007 Free Software Foundation, Inc. | ||||
|    2005, 2007, 2009, 2010 Free Software Foundation, Inc. | ||||
| 
 | ||||
|    This file is part of the GNU C Library. | ||||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  | @ -20,6 +20,8 @@ | |||
| #ifndef _FNMATCH_H | ||||
| #define _FNMATCH_H      1 | ||||
| 
 | ||||
| /* The definition of _GL_ARG_NONNULL is copied here.  */ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
|  | @ -56,7 +58,8 @@ extern "C" { | |||
| /* Match NAME against the file name pattern PATTERN,
 | ||||
|    returning zero if it matches, FNM_NOMATCH if not.  */ | ||||
| extern int fnmatch (const char *__pattern, const char *__name, | ||||
| 		    int __flags); | ||||
|                     int __flags) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
|  | @ -4,7 +4,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ | |||
| 
 | ||||
|    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 2, or (at | ||||
|    published by the Free Software Foundation; either version 3, or (at | ||||
|    your option) any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, but | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
| 
 | ||||
|    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 2, or (at | ||||
|    published by the Free Software Foundation; either version 3, or (at | ||||
|    your option) any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, but | ||||
|  | @ -21,7 +21,6 @@ | |||
| #include <config.h> | ||||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <sys/types.h> | ||||
| 
 | ||||
| ssize_t | ||||
| getline (char **lineptr, size_t *n, FILE *stream) | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| /* Declarations for getopt.
 | ||||
|    Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007 | ||||
|    Free Software Foundation, Inc. | ||||
|    Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2010 Free Software | ||||
|    Foundation, Inc. | ||||
|    This file is part of the GNU C Library. | ||||
| 
 | ||||
|    This program is free software: you can redistribute it and/or modify | ||||
|  | @ -16,24 +16,42 @@ | |||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | ||||
| 
 | ||||
| #ifndef _GETOPT_H | ||||
| #ifndef _GL_GETOPT_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  We must
 | ||||
|    also inform the replacement unistd.h to not recursively use | ||||
|    <getopt.h>; our definitions will be present soon enough.  */ | ||||
| #if @HAVE_GETOPT_H@ | ||||
| # define _GL_SYSTEM_GETOPT | ||||
| # @INCLUDE_NEXT@ @NEXT_GETOPT_H@ | ||||
| # undef _GL_SYSTEM_GETOPT | ||||
| #endif | ||||
| 
 | ||||
| #ifndef _GL_GETOPT_H | ||||
| 
 | ||||
| #ifndef __need_getopt | ||||
| # define _GETOPT_H 1 | ||||
| # define _GL_GETOPT_H 1 | ||||
| #endif | ||||
| 
 | ||||
| /* Standalone applications should #define __GETOPT_PREFIX to an
 | ||||
|    identifier that prefixes the external functions and variables | ||||
|    defined in this header.  When this happens, include the | ||||
|    headers that might declare getopt so that they will not cause | ||||
|    confusion if included after this file.  Then systematically rename | ||||
|    confusion if included after this file (if the system had <getopt.h>, | ||||
|    we have already included it).  Then systematically rename | ||||
|    identifiers so that they do not collide with the system functions | ||||
|    and variables.  Renaming avoids problems with some compilers and | ||||
|    linkers.  */ | ||||
| #if defined __GETOPT_PREFIX && !defined __need_getopt | ||||
| # if !@HAVE_GETOPT_H@ | ||||
| #  include <stdlib.h> | ||||
| #  include <stdio.h> | ||||
| #  include <unistd.h> | ||||
| # endif | ||||
| # undef __need_getopt | ||||
| # undef getopt | ||||
| # undef getopt_long | ||||
|  | @ -42,6 +60,7 @@ | |||
| # undef opterr | ||||
| # undef optind | ||||
| # undef optopt | ||||
| # undef option | ||||
| # define __GETOPT_CONCAT(x, y) x ## y | ||||
| # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) | ||||
| # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) | ||||
|  | @ -52,6 +71,8 @@ | |||
| # define opterr __GETOPT_ID (opterr) | ||||
| # define optind __GETOPT_ID (optind) | ||||
| # define optopt __GETOPT_ID (optopt) | ||||
| # define option __GETOPT_ID (option) | ||||
| # define _getopt_internal __GETOPT_ID (getopt_internal) | ||||
| #endif | ||||
| 
 | ||||
| /* Standalone applications get correct prototypes for getopt_long and
 | ||||
|  | @ -100,6 +121,8 @@ | |||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* The definition of _GL_ARG_NONNULL is copied here.  */ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
|  | @ -201,17 +224,17 @@ struct option | |||
|    the environment, then do not permute arguments.  */ | ||||
| 
 | ||||
| extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) | ||||
|        __THROW; | ||||
|        __THROW _GL_ARG_NONNULL ((2, 3)); | ||||
| 
 | ||||
| #ifndef __need_getopt | ||||
| extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, | ||||
|                         const char *__shortopts, | ||||
|                         const struct option *__longopts, int *__longind) | ||||
|        __THROW; | ||||
|        __THROW _GL_ARG_NONNULL ((2, 3)); | ||||
| extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, | ||||
|                              const char *__shortopts, | ||||
|                              const struct option *__longopts, int *__longind) | ||||
|        __THROW; | ||||
|        __THROW _GL_ARG_NONNULL ((2, 3)); | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
|  | @ -223,3 +246,4 @@ extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, | |||
| #undef __need_getopt | ||||
| 
 | ||||
| #endif /* getopt.h */ | ||||
| #endif /* getopt.h */ | ||||
|  | @ -4,7 +4,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
							
								
								
									
										83
									
								
								grub-core/gnulib/intprops.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								grub-core/gnulib/intprops.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,83 @@ | |||
| /* intprops.h -- properties of integer types
 | ||||
| 
 | ||||
|    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 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 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/>.  */
 | ||||
| 
 | ||||
| /* Written by Paul Eggert.  */ | ||||
| 
 | ||||
| #ifndef GL_INTPROPS_H | ||||
| # define GL_INTPROPS_H | ||||
| 
 | ||||
| # include <limits.h> | ||||
| 
 | ||||
| /* The extra casts in the following macros work around compiler bugs,
 | ||||
|    e.g., in Cray C 5.0.3.0.  */ | ||||
| 
 | ||||
| /* True if the arithmetic type T is an integer type.  bool counts as
 | ||||
|    an integer.  */ | ||||
| # define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) | ||||
| 
 | ||||
| /* True if negative values of the signed integer type T use two's
 | ||||
|    complement, ones' complement, or signed magnitude representation, | ||||
|    respectively.  Much GNU code assumes two's complement, but some | ||||
|    people like to be portable to all possible C hosts.  */ | ||||
| # define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) | ||||
| # define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) | ||||
| # define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) | ||||
| 
 | ||||
| /* True if the arithmetic type T is signed.  */ | ||||
| # define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) | ||||
| 
 | ||||
| /* The maximum and minimum values for the integer type T.  These
 | ||||
|    macros have undefined behavior if T is signed and has padding bits. | ||||
|    If this is a problem for you, please let us know how to fix it for | ||||
|    your host.  */ | ||||
| # define TYPE_MINIMUM(t) \ | ||||
|   ((t) (! TYPE_SIGNED (t) \ | ||||
|         ? (t) 0 \ | ||||
|         : TYPE_SIGNED_MAGNITUDE (t) \ | ||||
|         ? ~ (t) 0 \ | ||||
|         : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) | ||||
| # define TYPE_MAXIMUM(t) \ | ||||
|   ((t) (! TYPE_SIGNED (t) \ | ||||
|         ? (t) -1 \ | ||||
|         : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) | ||||
| 
 | ||||
| /* Return zero if T can be determined to be an unsigned type.
 | ||||
|    Otherwise, return 1. | ||||
|    When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a | ||||
|    tighter bound.  Otherwise, it overestimates the true bound by one byte | ||||
|    when applied to unsigned types of size 2, 4, 16, ... bytes. | ||||
|    The symbol signed_type_or_expr__ is private to this header file.  */ | ||||
| # if __GNUC__ >= 2 | ||||
| #  define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) | ||||
| # else | ||||
| #  define signed_type_or_expr__(t) 1 | ||||
| # endif | ||||
| 
 | ||||
| /* Bound on length of the string representing an integer type or expression T.
 | ||||
|    Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485; | ||||
|    add 1 for integer division truncation; add 1 more for a minus sign | ||||
|    if needed.  */ | ||||
| # define INT_STRLEN_BOUND(t) \ | ||||
|   ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \ | ||||
|    + signed_type_or_expr__ (t) + 1) | ||||
| 
 | ||||
| /* Bound on buffer size needed to represent an integer type or expression T,
 | ||||
|    including the terminating null.  */ | ||||
| # define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) | ||||
| 
 | ||||
| #endif /* GL_INTPROPS_H */ | ||||
							
								
								
									
										173
									
								
								grub-core/gnulib/langinfo.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										173
									
								
								grub-core/gnulib/langinfo.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,173 @@ | |||
| /* Substitute for and wrapper around <langinfo.h>.
 | ||||
|    Copyright (C) 2009, 2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /*
 | ||||
|  * POSIX <langinfo.h> for platforms that lack it or have an incomplete one. | ||||
|  * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
 | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _GL_LANGINFO_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #if @HAVE_LANGINFO_H@ | ||||
| # @INCLUDE_NEXT@ @NEXT_LANGINFO_H@ | ||||
| #endif | ||||
| 
 | ||||
| #ifndef _GL_LANGINFO_H | ||||
| #define _GL_LANGINFO_H | ||||
| 
 | ||||
| 
 | ||||
| #if !@HAVE_LANGINFO_H@ | ||||
| 
 | ||||
| /* A platform that lacks <langinfo.h>.  */ | ||||
| 
 | ||||
| /* Assume that it also lacks <nl_types.h> and the nl_item type.  */ | ||||
| typedef int nl_item; | ||||
| 
 | ||||
| /* nl_langinfo items of the LC_CTYPE category */ | ||||
| # define CODESET     10000 | ||||
| /* nl_langinfo items of the LC_NUMERIC category */ | ||||
| # define RADIXCHAR   10001 | ||||
| # define THOUSEP     10002 | ||||
| /* nl_langinfo items of the LC_TIME category */ | ||||
| # define D_T_FMT     10003 | ||||
| # define D_FMT       10004 | ||||
| # define T_FMT       10005 | ||||
| # define T_FMT_AMPM  10006 | ||||
| # define AM_STR      10007 | ||||
| # define PM_STR      10008 | ||||
| # define DAY_1       10009 | ||||
| # define DAY_2       (DAY_1 + 1) | ||||
| # define DAY_3       (DAY_1 + 2) | ||||
| # define DAY_4       (DAY_1 + 3) | ||||
| # define DAY_5       (DAY_1 + 4) | ||||
| # define DAY_6       (DAY_1 + 5) | ||||
| # define DAY_7       (DAY_1 + 6) | ||||
| # define ABDAY_1     10016 | ||||
| # define ABDAY_2     (ABDAY_1 + 1) | ||||
| # define ABDAY_3     (ABDAY_1 + 2) | ||||
| # define ABDAY_4     (ABDAY_1 + 3) | ||||
| # define ABDAY_5     (ABDAY_1 + 4) | ||||
| # define ABDAY_6     (ABDAY_1 + 5) | ||||
| # define ABDAY_7     (ABDAY_1 + 6) | ||||
| # define MON_1       10023 | ||||
| # define MON_2       (MON_1 + 1) | ||||
| # define MON_3       (MON_1 + 2) | ||||
| # define MON_4       (MON_1 + 3) | ||||
| # define MON_5       (MON_1 + 4) | ||||
| # define MON_6       (MON_1 + 5) | ||||
| # define MON_7       (MON_1 + 6) | ||||
| # define MON_8       (MON_1 + 7) | ||||
| # define MON_9       (MON_1 + 8) | ||||
| # define MON_10      (MON_1 + 9) | ||||
| # define MON_11      (MON_1 + 10) | ||||
| # define MON_12      (MON_1 + 11) | ||||
| # define ABMON_1     10035 | ||||
| # define ABMON_2     (ABMON_1 + 1) | ||||
| # define ABMON_3     (ABMON_1 + 2) | ||||
| # define ABMON_4     (ABMON_1 + 3) | ||||
| # define ABMON_5     (ABMON_1 + 4) | ||||
| # define ABMON_6     (ABMON_1 + 5) | ||||
| # define ABMON_7     (ABMON_1 + 6) | ||||
| # define ABMON_8     (ABMON_1 + 7) | ||||
| # define ABMON_9     (ABMON_1 + 8) | ||||
| # define ABMON_10    (ABMON_1 + 9) | ||||
| # define ABMON_11    (ABMON_1 + 10) | ||||
| # define ABMON_12    (ABMON_1 + 11) | ||||
| # define ERA         10047 | ||||
| # define ERA_D_FMT   10048 | ||||
| # define ERA_D_T_FMT 10049 | ||||
| # define ERA_T_FMT   10050 | ||||
| # define ALT_DIGITS  10051 | ||||
| /* nl_langinfo items of the LC_MONETARY category */ | ||||
| # define CRNCYSTR    10052 | ||||
| /* nl_langinfo items of the LC_MESSAGES category */ | ||||
| # define YESEXPR     10053 | ||||
| # define NOEXPR      10054 | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| /* A platform that has <langinfo.h>.  */ | ||||
| 
 | ||||
| # if !@HAVE_LANGINFO_CODESET@ | ||||
| #  define CODESET     10000 | ||||
| #  define GNULIB_defined_CODESET 1 | ||||
| # endif | ||||
| 
 | ||||
| # if !@HAVE_LANGINFO_T_FMT_AMPM@ | ||||
| #  define T_FMT_AMPM  10006 | ||||
| #  define GNULIB_defined_T_FMT_AMPM 1 | ||||
| # endif | ||||
| 
 | ||||
| # if !@HAVE_LANGINFO_ERA@ | ||||
| #  define ERA         10047 | ||||
| #  define ERA_D_FMT   10048 | ||||
| #  define ERA_D_T_FMT 10049 | ||||
| #  define ERA_T_FMT   10050 | ||||
| #  define ALT_DIGITS  10051 | ||||
| #  define GNULIB_defined_ERA 1 | ||||
| # endif | ||||
| 
 | ||||
| # if !@HAVE_LANGINFO_YESEXPR@ | ||||
| #  define YESEXPR     10053 | ||||
| #  define NOEXPR      10054 | ||||
| #  define GNULIB_defined_YESEXPR 1 | ||||
| # endif | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_WARN_ON_USE is copied here.  */ | ||||
| 
 | ||||
| /* Declare overridden functions.  */ | ||||
| 
 | ||||
| 
 | ||||
| /* Return a piece of locale dependent information.
 | ||||
|    Note: The difference between nl_langinfo (CODESET) and locale_charset () | ||||
|    is that the latter normalizes the encoding names to GNU conventions.  */ | ||||
| 
 | ||||
| #if @GNULIB_NL_LANGINFO@ | ||||
| # if @REPLACE_NL_LANGINFO@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef nl_langinfo | ||||
| #   define nl_langinfo rpl_nl_langinfo | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item)); | ||||
| _GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item)); | ||||
| # else | ||||
| #  if !@HAVE_NL_LANGINFO@ | ||||
| _GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item)); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (nl_langinfo); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef nl_langinfo | ||||
| # if HAVE_RAW_DECL_NL_LANGINFO | ||||
| _GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - " | ||||
|                  "use gnulib module nl_langinfo for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #endif /* _GL_LANGINFO_H */ | ||||
| #endif /* _GL_LANGINFO_H */ | ||||
							
								
								
									
										548
									
								
								grub-core/gnulib/localcharset.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										548
									
								
								grub-core/gnulib/localcharset.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,548 @@ | |||
| /* Determine a canonical name for the current locale's character encoding.
 | ||||
| 
 | ||||
|    Copyright (C) 2000-2006, 2008-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /* Written by Bruno Haible <bruno@clisp.org>.  */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include "localcharset.h" | ||||
| 
 | ||||
| #include <fcntl.h> | ||||
| #include <stddef.h> | ||||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| #if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET | ||||
| # define DARWIN7 /* Darwin 7 or newer, i.e. MacOS X 10.3 or newer */ | ||||
| #endif | ||||
| 
 | ||||
| #if defined _WIN32 || defined __WIN32__ | ||||
| # define WIN32_NATIVE | ||||
| #endif | ||||
| 
 | ||||
| #if defined __EMX__ | ||||
| /* Assume EMX program runs on OS/2, even if compiled under DOS.  */ | ||||
| # ifndef OS2 | ||||
| #  define OS2 | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if !defined WIN32_NATIVE | ||||
| # include <unistd.h> | ||||
| # if HAVE_LANGINFO_CODESET | ||||
| #  include <langinfo.h> | ||||
| # else | ||||
| #  if 0 /* see comment below */ | ||||
| #   include <locale.h> | ||||
| #  endif | ||||
| # endif | ||||
| # ifdef __CYGWIN__ | ||||
| #  define WIN32_LEAN_AND_MEAN | ||||
| #  include <windows.h> | ||||
| # endif | ||||
| #elif defined WIN32_NATIVE | ||||
| # define WIN32_LEAN_AND_MEAN | ||||
| # include <windows.h> | ||||
| #endif | ||||
| #if defined OS2 | ||||
| # define INCL_DOS | ||||
| # include <os2.h> | ||||
| #endif | ||||
| 
 | ||||
| #if ENABLE_RELOCATABLE | ||||
| # include "relocatable.h" | ||||
| #else | ||||
| # define relocate(pathname) (pathname) | ||||
| #endif | ||||
| 
 | ||||
| /* Get LIBDIR.  */ | ||||
| #ifndef LIBDIR | ||||
| # include "configmake.h" | ||||
| #endif | ||||
| 
 | ||||
| /* Define O_NOFOLLOW to 0 on platforms where it does not exist.  */ | ||||
| #ifndef O_NOFOLLOW | ||||
| # define O_NOFOLLOW 0 | ||||
| #endif | ||||
| 
 | ||||
| #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ | ||||
|   /* Win32, Cygwin, OS/2, DOS */ | ||||
| # define ISSLASH(C) ((C) == '/' || (C) == '\\') | ||||
| #endif | ||||
| 
 | ||||
| #ifndef DIRECTORY_SEPARATOR | ||||
| # define DIRECTORY_SEPARATOR '/' | ||||
| #endif | ||||
| 
 | ||||
| #ifndef ISSLASH | ||||
| # define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) | ||||
| #endif | ||||
| 
 | ||||
| #if HAVE_DECL_GETC_UNLOCKED | ||||
| # undef getc | ||||
| # define getc getc_unlocked | ||||
| #endif | ||||
| 
 | ||||
| /* The following static variable is declared 'volatile' to avoid a
 | ||||
|    possible multithread problem in the function get_charset_aliases. If we | ||||
|    are running in a threaded environment, and if two threads initialize | ||||
|    'charset_aliases' simultaneously, both will produce the same value, | ||||
|    and everything will be ok if the two assignments to 'charset_aliases' | ||||
|    are atomic. But I don't know what will happen if the two assignments mix.  */ | ||||
| #if __STDC__ != 1 | ||||
| # define volatile /* empty */ | ||||
| #endif | ||||
| /* Pointer to the contents of the charset.alias file, if it has already been
 | ||||
|    read, else NULL.  Its format is: | ||||
|    ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0'  */ | ||||
| static const char * volatile charset_aliases; | ||||
| 
 | ||||
| /* Return a pointer to the contents of the charset.alias file.  */ | ||||
| static const char * | ||||
| get_charset_aliases (void) | ||||
| { | ||||
|   const char *cp; | ||||
| 
 | ||||
|   cp = charset_aliases; | ||||
|   if (cp == NULL) | ||||
|     { | ||||
| #if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__) | ||||
|       const char *dir; | ||||
|       const char *base = "charset.alias"; | ||||
|       char *file_name; | ||||
| 
 | ||||
|       /* Make it possible to override the charset.alias location.  This is
 | ||||
|          necessary for running the testsuite before "make install".  */ | ||||
|       dir = getenv ("CHARSETALIASDIR"); | ||||
|       if (dir == NULL || dir[0] == '\0') | ||||
|         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); | ||||
|           } | ||||
|       } | ||||
| 
 | ||||
|       if (file_name == NULL) | ||||
|         /* Out of memory.  Treat the file as empty.  */ | ||||
|         cp = ""; | ||||
|       else | ||||
|         { | ||||
|           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; | ||||
| 
 | ||||
|               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; | ||||
| 
 | ||||
|                       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); | ||||
|         } | ||||
| 
 | ||||
| #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.  */ | ||||
|       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"; | ||||
| # 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.  */ | ||||
|       /* 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".  */ | ||||
|       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"; | ||||
| # 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.  */ | ||||
| 
 | ||||
|       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"; | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
|       charset_aliases = cp; | ||||
|     } | ||||
| 
 | ||||
|   return cp; | ||||
| } | ||||
| 
 | ||||
| /* Determine the current locale's character encoding, and canonicalize it
 | ||||
|    into one of the canonical names listed in config.charset. | ||||
|    The result must not be freed; it is statically allocated. | ||||
|    If the canonical name cannot be determined, the result is a non-canonical | ||||
|    name.  */ | ||||
| 
 | ||||
| #ifdef STATIC | ||||
| STATIC | ||||
| #endif | ||||
| const char * | ||||
| locale_charset (void) | ||||
| { | ||||
|   const char *codeset; | ||||
|   const char *aliases; | ||||
| 
 | ||||
| #if !(defined WIN32_NATIVE || defined OS2) | ||||
| 
 | ||||
| # if HAVE_LANGINFO_CODESET | ||||
| 
 | ||||
|   /* Most systems support nl_langinfo (CODESET) nowadays.  */ | ||||
|   codeset = nl_langinfo (CODESET); | ||||
| 
 | ||||
| #  ifdef __CYGWIN__ | ||||
|   /* Cygwin < 1.7 does not have locales.  nl_langinfo (CODESET) always
 | ||||
|      returns "US-ASCII".  Return the suffix of the locale name from the | ||||
|      environment variables (if present) or the codepage as a number.  */ | ||||
|   if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) | ||||
|     { | ||||
|       const char *locale; | ||||
|       static char buf[2 + 10 + 1]; | ||||
| 
 | ||||
|       locale = getenv ("LC_ALL"); | ||||
|       if (locale == NULL || locale[0] == '\0') | ||||
|         { | ||||
|           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 (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; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|       /* 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; | ||||
|     } | ||||
| #  endif | ||||
| 
 | ||||
| # else | ||||
| 
 | ||||
|   /* On old systems which lack it, use setlocale or getenv.  */ | ||||
|   const char *locale = NULL; | ||||
| 
 | ||||
|   /* But most old systems don't have a complete set of locales.  Some
 | ||||
|      (like SunOS 4 or DJGPP) have only the C locale.  Therefore we don't | ||||
|      use setlocale here; it would return "C" when it doesn't support the | ||||
|      locale name the user has set.  */ | ||||
| #  if 0 | ||||
|   locale = setlocale (LC_CTYPE, NULL); | ||||
| #  endif | ||||
|   if (locale == NULL || locale[0] == '\0') | ||||
|     { | ||||
|       locale = getenv ("LC_ALL"); | ||||
|       if (locale == NULL || locale[0] == '\0') | ||||
|         { | ||||
|           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,
 | ||||
|      you set it to "language_COUNTRY.charset". In any case, we resolve it | ||||
|      through the charset.alias file.  */ | ||||
|   codeset = locale; | ||||
| 
 | ||||
| # endif | ||||
| 
 | ||||
| #elif defined WIN32_NATIVE | ||||
| 
 | ||||
|   static char buf[2 + 10 + 1]; | ||||
| 
 | ||||
|   /* 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; | ||||
| 
 | ||||
| #elif defined OS2 | ||||
| 
 | ||||
|   const char *locale; | ||||
|   static char buf[2 + 10 + 1]; | ||||
|   ULONG cp[3]; | ||||
|   ULONG cplen; | ||||
| 
 | ||||
|   /* Allow user to override the codeset, as set in the operating system,
 | ||||
|      with standard language environment variables.  */ | ||||
|   locale = getenv ("LC_ALL"); | ||||
|   if (locale == NULL || locale[0] == '\0') | ||||
|     { | ||||
|       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 (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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|       /* Resolve through the charset.alias file.  */ | ||||
|       codeset = locale; | ||||
|     } | ||||
|   else | ||||
|     { | ||||
|       /* OS/2 has a function returning the locale's codepage as a number.  */ | ||||
|       if (DosQueryCp (sizeof (cp), cp, &cplen)) | ||||
|         codeset = ""; | ||||
|       else | ||||
|         { | ||||
|           sprintf (buf, "CP%u", cp[0]); | ||||
|           codeset = buf; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
|   if (codeset == NULL) | ||||
|     /* The canonical name cannot be determined.  */ | ||||
|     codeset = ""; | ||||
| 
 | ||||
|   /* Resolve alias. */ | ||||
|   for (aliases = get_charset_aliases (); | ||||
|        *aliases != '\0'; | ||||
|        aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) | ||||
|     if (strcmp (codeset, aliases) == 0 | ||||
|         || (aliases[0] == '*' && aliases[1] == '\0')) | ||||
|       { | ||||
|         codeset = aliases + strlen (aliases) + 1; | ||||
|         break; | ||||
|       } | ||||
| 
 | ||||
|   /* Don't return an empty string.  GNU libc and GNU libiconv interpret
 | ||||
|      the empty string as denoting "the locale's character encoding", | ||||
|      thus GNU libiconv would call this function a second time.  */ | ||||
|   if (codeset[0] == '\0') | ||||
|     codeset = "ASCII"; | ||||
| 
 | ||||
|   return codeset; | ||||
| } | ||||
							
								
								
									
										41
									
								
								grub-core/gnulib/localcharset.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								grub-core/gnulib/localcharset.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,41 @@ | |||
| /* Determine a canonical name for the current locale's character encoding.
 | ||||
|    Copyright (C) 2000-2003, 2009-2010 Free Software Foundation, Inc. | ||||
|    This file is part of the GNU CHARSET Library. | ||||
| 
 | ||||
|    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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _LOCALCHARSET_H | ||||
| #define _LOCALCHARSET_H | ||||
| 
 | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Determine the current locale's character encoding, and canonicalize it
 | ||||
|    into one of the canonical names listed in config.charset. | ||||
|    The result must not be freed; it is statically allocated. | ||||
|    If the canonical name cannot be determined, the result is a non-canonical | ||||
|    name.  */ | ||||
| extern const char * locale_charset (void); | ||||
| 
 | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #endif /* _LOCALCHARSET_H */ | ||||
							
								
								
									
										60
									
								
								grub-core/gnulib/malloc.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								grub-core/gnulib/malloc.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,60 @@ | |||
| /* malloc() function that is glibc compatible.
 | ||||
| 
 | ||||
|    Copyright (C) 1997-1998, 2006-2007, 2009-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /* written by Jim Meyering and Bruno Haible */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| /* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h.  */ | ||||
| #ifdef malloc | ||||
| # define NEED_MALLOC_GNU 1 | ||||
| # undef malloc | ||||
| /* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU.  */ | ||||
| #elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU | ||||
| # define NEED_MALLOC_GNU 1 | ||||
| #endif | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| #include <errno.h> | ||||
| 
 | ||||
| /* Call the system's malloc below.  */ | ||||
| #undef malloc | ||||
| 
 | ||||
| /* Allocate an N-byte block of memory from the heap.
 | ||||
|    If N is zero, allocate a 1-byte block.  */ | ||||
| 
 | ||||
| void * | ||||
| rpl_malloc (size_t n) | ||||
| { | ||||
|   void *result; | ||||
| 
 | ||||
| #if NEED_MALLOC_GNU | ||||
|   if (n == 0) | ||||
|     n = 1; | ||||
| #endif | ||||
| 
 | ||||
|   result = malloc (n); | ||||
| 
 | ||||
| #if !HAVE_MALLOC_POSIX | ||||
|   if (result == NULL) | ||||
|     errno = ENOMEM; | ||||
| #endif | ||||
| 
 | ||||
|   return result; | ||||
| } | ||||
							
								
								
									
										386
									
								
								grub-core/gnulib/mbrtowc.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										386
									
								
								grub-core/gnulib/mbrtowc.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,386 @@ | |||
| /* Convert multibyte character to wide character.
 | ||||
|    Copyright (C) 1999-2002, 2005-2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2008. | ||||
| 
 | ||||
|    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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <wchar.h> | ||||
| 
 | ||||
| #if GNULIB_defined_mbstate_t | ||||
| /* Implement mbrtowc() on top of mbtowc().  */ | ||||
| 
 | ||||
| # include <errno.h> | ||||
| # include <stdlib.h> | ||||
| 
 | ||||
| # include "localcharset.h" | ||||
| # include "streq.h" | ||||
| # include "verify.h" | ||||
| 
 | ||||
| 
 | ||||
| verify (sizeof (mbstate_t) >= 4); | ||||
| 
 | ||||
| static char internal_state[4]; | ||||
| 
 | ||||
| size_t | ||||
| mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) | ||||
| { | ||||
|   char *pstate = (char *)ps; | ||||
| 
 | ||||
|   if (pstate == NULL) | ||||
|     pstate = internal_state; | ||||
| 
 | ||||
|   if (s == NULL) | ||||
|     { | ||||
|       pwc = NULL; | ||||
|       s = ""; | ||||
|       n = 1; | ||||
|     } | ||||
| 
 | ||||
|   if (n == 0) | ||||
|     return (size_t)(-2); | ||||
| 
 | ||||
|   /* Here n > 0.  */ | ||||
|   { | ||||
|     size_t nstate = pstate[0]; | ||||
|     char buf[4]; | ||||
|     const char *p; | ||||
|     size_t m; | ||||
| 
 | ||||
|     switch (nstate) | ||||
|       { | ||||
|       case 0: | ||||
|         p = s; | ||||
|         m = n; | ||||
|         break; | ||||
|       case 3: | ||||
|         buf[2] = pstate[3]; | ||||
|         /*FALLTHROUGH*/ | ||||
|       case 2: | ||||
|         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; | ||||
|       default: | ||||
|         errno = EINVAL; | ||||
|         return (size_t)(-1); | ||||
|       } | ||||
| 
 | ||||
|     /* Here m > 0.  */ | ||||
| 
 | ||||
| # if __GLIBC__ | ||||
|     /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */ | ||||
|     mbtowc (NULL, NULL, 0); | ||||
| # endif | ||||
|     { | ||||
|       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; | ||||
|         } | ||||
| 
 | ||||
|       /* 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.  */ | ||||
|       if (m >= 4 || m >= MB_CUR_MAX) | ||||
|         goto invalid; | ||||
|       /* Here MB_CUR_MAX > 1 and 0 < m < 4.  */ | ||||
|       { | ||||
|         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 (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 >= 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; | ||||
|           } | ||||
| 
 | ||||
|         /* 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 ((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 (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) || 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 >= 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 (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 ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) | ||||
|                     || (c >= 0xf0 && c <= 0xf9)) | ||||
|                   goto incomplete; | ||||
|               } | ||||
|             goto invalid; | ||||
|           } | ||||
| 
 | ||||
|         /* 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 (); | ||||
|       } | ||||
|       pstate[0] = m; | ||||
|       return (size_t)(-2); | ||||
| 
 | ||||
|      invalid: | ||||
|       errno = EILSEQ; | ||||
|       /* The conversion state is undefined, says POSIX.  */ | ||||
|       return (size_t)(-1); | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| /* Override the system's mbrtowc() function.  */ | ||||
| 
 | ||||
| # undef mbrtowc | ||||
| 
 | ||||
| size_t | ||||
| rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) | ||||
| { | ||||
| # if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG | ||||
|   if (s == NULL) | ||||
|     { | ||||
|       pwc = NULL; | ||||
|       s = ""; | ||||
|       n = 1; | ||||
|     } | ||||
| # endif | ||||
| 
 | ||||
| # if MBRTOWC_RETVAL_BUG | ||||
|   { | ||||
|     static mbstate_t internal_state; | ||||
| 
 | ||||
|     /* Override mbrtowc's internal state.  We can not call mbsinit() on the
 | ||||
|        hidden internal state, but we can call it on our variable.  */ | ||||
|     if (ps == NULL) | ||||
|       ps = &internal_state; | ||||
| 
 | ||||
|     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); | ||||
| 
 | ||||
|             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 | ||||
| 
 | ||||
| # if MBRTOWC_NUL_RETVAL_BUG | ||||
|   { | ||||
|     wchar_t wc; | ||||
|     size_t ret = mbrtowc (&wc, s, n, ps); | ||||
| 
 | ||||
|     if (ret != (size_t)(-1) && ret != (size_t)(-2)) | ||||
|       { | ||||
|         if (pwc != NULL) | ||||
|           *pwc = wc; | ||||
|         if (wc == 0) | ||||
|           ret = 0; | ||||
|       } | ||||
|     return ret; | ||||
|   } | ||||
| # else | ||||
|   return mbrtowc (pwc, s, n, ps); | ||||
| # endif | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										47
									
								
								grub-core/gnulib/mbsinit.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								grub-core/gnulib/mbsinit.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,47 @@ | |||
| /* Test for initial conversion state.
 | ||||
|    Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2008. | ||||
| 
 | ||||
|    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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <wchar.h> | ||||
| 
 | ||||
| #include "verify.h" | ||||
| 
 | ||||
| /* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
 | ||||
|    and wcrtomb(), wcsrtombs(). | ||||
|    We assume that | ||||
|      - sizeof (mbstate_t) >= 4, | ||||
|      - only stateless encodings are supported (such as UTF-8 and EUC-JP, but | ||||
|        not ISO-2022 variants), | ||||
|      - for each encoding, the number of bytes for a wide character is <= 4. | ||||
|        (This maximum is attained for UTF-8, GB18030, EUC-TW.) | ||||
|    We define the meaning of mbstate_t as follows: | ||||
|      - In mb -> wc direction, mbstate_t's first byte contains the number of | ||||
|        buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. | ||||
|      - In wc -> mb direction, mbstate_t contains no information. In other | ||||
|        words, it is always in the initial state.  */ | ||||
| 
 | ||||
| verify (sizeof (mbstate_t) >= 4); | ||||
| 
 | ||||
| int | ||||
| mbsinit (const mbstate_t *ps) | ||||
| { | ||||
|   const char *pstate = (const char *)ps; | ||||
| 
 | ||||
|   return pstate[0] == 0; | ||||
| } | ||||
							
								
								
									
										37
									
								
								grub-core/gnulib/mbsrtowcs-state.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								grub-core/gnulib/mbsrtowcs-state.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| /* Convert string to wide string.
 | ||||
|    Copyright (C) 2008-2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2008. | ||||
| 
 | ||||
|    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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| #include <wchar.h> | ||||
| 
 | ||||
| /* Internal state used by the functions mbsrtowcs() and mbsnrtowcs().  */ | ||||
| mbstate_t _gl_mbsrtowcs_state | ||||
| /* The state must initially be in the "initial state"; so, zero-initialize it.
 | ||||
|    On most systems, putting it into BSS is sufficient.  Not so on MacOS X 10.3, | ||||
|    see <http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>.
 | ||||
|    When it needs an initializer, use 0 or {0} as initializer? 0 only works | ||||
|    when mbstate_t is a scalar type (such as when gnulib defines it, or on | ||||
|    AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct | ||||
|    or union type, but also for a scalar type (ISO C 99, 6.7.8.(11)).  */ | ||||
| #if defined __ELF__ | ||||
|   /* On ELF systems, variables in BSS behave well.  */ | ||||
| #else | ||||
|   /* Use braces, to be on the safe side.  */ | ||||
|   = { 0 } | ||||
| #endif | ||||
|   ; | ||||
							
								
								
									
										136
									
								
								grub-core/gnulib/mbsrtowcs.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								grub-core/gnulib/mbsrtowcs.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,136 @@ | |||
| /* Convert string to wide string.
 | ||||
|    Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2008. | ||||
| 
 | ||||
|    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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <wchar.h> | ||||
| 
 | ||||
| #include <errno.h> | ||||
| #include <limits.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| #include "strnlen1.h" | ||||
| 
 | ||||
| 
 | ||||
| extern mbstate_t _gl_mbsrtowcs_state; | ||||
| 
 | ||||
| size_t | ||||
| mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) | ||||
| { | ||||
|   if (ps == NULL) | ||||
|     ps = &_gl_mbsrtowcs_state; | ||||
|   { | ||||
|     const char *src = *srcp; | ||||
| 
 | ||||
|     if (dest != NULL) | ||||
|       { | ||||
|         wchar_t *destptr = dest; | ||||
| 
 | ||||
|         for (; len > 0; destptr++, len--) | ||||
|           { | ||||
|             size_t src_avail; | ||||
|             size_t ret; | ||||
| 
 | ||||
|             /* An optimized variant of
 | ||||
|                src_avail = strnlen1 (src, MB_LEN_MAX);  */ | ||||
|             if (src[0] == '\0') | ||||
|               src_avail = 1; | ||||
|             else if (src[1] == '\0') | ||||
|               src_avail = 2; | ||||
|             else if (src[2] == '\0') | ||||
|               src_avail = 3; | ||||
|             else if (MB_LEN_MAX <= 4 || src[3] == '\0') | ||||
|               src_avail = 4; | ||||
|             else | ||||
|               src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); | ||||
| 
 | ||||
|             /* Parse the next multibyte character.  */ | ||||
|             ret = mbrtowc (destptr, src, src_avail, ps); | ||||
| 
 | ||||
|             if (ret == (size_t)(-2)) | ||||
|               /* Encountered a multibyte character that extends past a '\0' byte
 | ||||
|                  or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */ | ||||
|               abort (); | ||||
| 
 | ||||
|             if (ret == (size_t)(-1)) | ||||
|               goto bad_input; | ||||
|             if (ret == 0) | ||||
|               { | ||||
|                 src = NULL; | ||||
|                 /* Here mbsinit (ps).  */ | ||||
|                 break; | ||||
|               } | ||||
|             src += ret; | ||||
|           } | ||||
| 
 | ||||
|         *srcp = src; | ||||
|         return destptr - dest; | ||||
|       } | ||||
|     else | ||||
|       { | ||||
|         /* Ignore dest and len, don't store *srcp at the end, and
 | ||||
|            don't clobber *ps.  */ | ||||
|         mbstate_t state = *ps; | ||||
|         size_t totalcount = 0; | ||||
| 
 | ||||
|         for (;; totalcount++) | ||||
|           { | ||||
|             size_t src_avail; | ||||
|             size_t ret; | ||||
| 
 | ||||
|             /* An optimized variant of
 | ||||
|                src_avail = strnlen1 (src, MB_LEN_MAX);  */ | ||||
|             if (src[0] == '\0') | ||||
|               src_avail = 1; | ||||
|             else if (src[1] == '\0') | ||||
|               src_avail = 2; | ||||
|             else if (src[2] == '\0') | ||||
|               src_avail = 3; | ||||
|             else if (MB_LEN_MAX <= 4 || src[3] == '\0') | ||||
|               src_avail = 4; | ||||
|             else | ||||
|               src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4); | ||||
| 
 | ||||
|             /* Parse the next multibyte character.  */ | ||||
|             ret = mbrtowc (NULL, src, src_avail, &state); | ||||
| 
 | ||||
|             if (ret == (size_t)(-2)) | ||||
|               /* Encountered a multibyte character that extends past a '\0' byte
 | ||||
|                  or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */ | ||||
|               abort (); | ||||
| 
 | ||||
|             if (ret == (size_t)(-1)) | ||||
|               goto bad_input2; | ||||
|             if (ret == 0) | ||||
|               { | ||||
|                 /* Here mbsinit (&state).  */ | ||||
|                 break; | ||||
|               } | ||||
|             src += ret; | ||||
|           } | ||||
| 
 | ||||
|         return totalcount; | ||||
|       } | ||||
| 
 | ||||
|    bad_input: | ||||
|     *srcp = src; | ||||
|    bad_input2: | ||||
|     errno = EILSEQ; | ||||
|     return (size_t)(-1); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										172
									
								
								grub-core/gnulib/memchr.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								grub-core/gnulib/memchr.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,172 @@ | |||
| /* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2010
 | ||||
|    Free Software Foundation, Inc. | ||||
| 
 | ||||
|    Based on strlen implementation by Torbjorn Granlund (tege@sics.se), | ||||
|    with help from Dan Sahlin (dan@sics.se) and | ||||
|    commentary by Jim Blandy (jimb@ai.mit.edu); | ||||
|    adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), | ||||
|    and implemented by Roland McGrath (roland@ai.mit.edu). | ||||
| 
 | ||||
| NOTE: The canonical source of this file is maintained with the GNU C Library. | ||||
| Bugs can be reported to bug-glibc@prep.ai.mit.edu. | ||||
| 
 | ||||
| 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 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 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/>.  */
 | ||||
| 
 | ||||
| #ifndef _LIBC | ||||
| # include <config.h> | ||||
| #endif | ||||
| 
 | ||||
| #include <string.h> | ||||
| 
 | ||||
| #include <stddef.h> | ||||
| 
 | ||||
| #if defined _LIBC | ||||
| # include <memcopy.h> | ||||
| #else | ||||
| # define reg_char char | ||||
| #endif | ||||
| 
 | ||||
| #include <limits.h> | ||||
| 
 | ||||
| #if HAVE_BP_SYM_H || defined _LIBC | ||||
| # include <bp-sym.h> | ||||
| #else | ||||
| # define BP_SYM(sym) sym | ||||
| #endif | ||||
| 
 | ||||
| #undef __memchr | ||||
| #ifdef _LIBC | ||||
| # undef memchr | ||||
| #endif | ||||
| 
 | ||||
| #ifndef weak_alias | ||||
| # define __memchr memchr | ||||
| #endif | ||||
| 
 | ||||
| /* Search no more than N bytes of S for C.  */ | ||||
| void * | ||||
| __memchr (void const *s, int c_in, size_t n) | ||||
| { | ||||
|   /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
 | ||||
|      long instead of a 64-bit uintmax_t tends to give better | ||||
|      performance.  On 64-bit hardware, unsigned long is generally 64 | ||||
|      bits already.  Change this typedef to experiment with | ||||
|      performance.  */ | ||||
|   typedef unsigned long int longword; | ||||
| 
 | ||||
|   const unsigned char *char_ptr; | ||||
|   const longword *longword_ptr; | ||||
|   longword repeated_one; | ||||
|   longword repeated_c; | ||||
|   unsigned reg_char c; | ||||
| 
 | ||||
|   c = (unsigned char) c_in; | ||||
| 
 | ||||
|   /* Handle the first few bytes by reading one byte at a time.
 | ||||
|      Do this until CHAR_PTR is aligned on a longword boundary.  */ | ||||
|   for (char_ptr = (const unsigned char *) s; | ||||
|        n > 0 && (size_t) char_ptr % sizeof (longword) != 0; | ||||
|        --n, ++char_ptr) | ||||
|     if (*char_ptr == c) | ||||
|       return (void *) char_ptr; | ||||
| 
 | ||||
|   longword_ptr = (const longword *) char_ptr; | ||||
| 
 | ||||
|   /* All these elucidatory comments refer to 4-byte longwords,
 | ||||
|      but the theory applies equally well to any size longwords.  */ | ||||
| 
 | ||||
|   /* Compute auxiliary longword values:
 | ||||
|      repeated_one is a value which has a 1 in every byte. | ||||
|      repeated_c has c in every byte.  */ | ||||
|   repeated_one = 0x01010101; | ||||
|   repeated_c = c | (c << 8); | ||||
|   repeated_c |= repeated_c << 16; | ||||
|   if (0xffffffffU < (longword) -1) | ||||
|     { | ||||
|       repeated_one |= repeated_one << 31 << 1; | ||||
|       repeated_c |= repeated_c << 31 << 1; | ||||
|       if (8 < sizeof (longword)) | ||||
|         { | ||||
|           size_t 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
 | ||||
|      longword at a time.  The tricky part is testing if *any of the four* | ||||
|      bytes in the longword in question are equal to c.  We first use an xor | ||||
|      with repeated_c.  This reduces the task to testing whether *any of the | ||||
|      four* bytes in longword1 is zero. | ||||
| 
 | ||||
|      We compute tmp = | ||||
|        ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). | ||||
|      That is, we perform the following operations: | ||||
|        1. Subtract repeated_one. | ||||
|        2. & ~longword1. | ||||
|        3. & a mask consisting of 0x80 in every byte. | ||||
|      Consider what happens in each byte: | ||||
|        - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, | ||||
|          and step 3 transforms it into 0x80.  A carry can also be propagated | ||||
|          to more significant bytes. | ||||
|        - If a byte of longword1 is nonzero, let its lowest 1 bit be at | ||||
|          position k (0 <= k <= 7); so the lowest k bits are 0.  After step 1, | ||||
|          the byte ends in a single bit of value 0 and k bits of value 1. | ||||
|          After step 2, the result is just k bits of value 1: 2^k - 1.  After | ||||
|          step 3, the result is 0.  And no carry is produced. | ||||
|      So, if longword1 has only non-zero bytes, tmp is zero. | ||||
|      Whereas if longword1 has a zero byte, call j the position of the least | ||||
|      significant zero byte.  Then the result has a zero at positions 0, ..., | ||||
|      j-1 and a 0x80 at position j.  We cannot predict the result at the more | ||||
|      significant bytes (positions j+1..3), but it does not matter since we | ||||
|      already have a non-zero bit at position 8*j+7. | ||||
| 
 | ||||
|      So, the test whether any byte in longword1 is zero is equivalent to | ||||
|      testing whether tmp is nonzero.  */ | ||||
| 
 | ||||
|   while (n >= sizeof (longword)) | ||||
|     { | ||||
|       longword longword1 = *longword_ptr ^ repeated_c; | ||||
| 
 | ||||
|       if ((((longword1 - repeated_one) & ~longword1) | ||||
|            & (repeated_one << 7)) != 0) | ||||
|         break; | ||||
|       longword_ptr++; | ||||
|       n -= sizeof (longword); | ||||
|     } | ||||
| 
 | ||||
|   char_ptr = (const unsigned char *) longword_ptr; | ||||
| 
 | ||||
|   /* At this point, we know that either n < sizeof (longword), or one of the
 | ||||
|      sizeof (longword) bytes starting at char_ptr is == c.  On little-endian | ||||
|      machines, we could determine the first such byte without any further | ||||
|      memory accesses, just by looking at the tmp result from the last loop | ||||
|      iteration.  But this does not work on big-endian machines.  Choose code | ||||
|      that works in both cases.  */ | ||||
| 
 | ||||
|   for (; n > 0; --n, ++char_ptr) | ||||
|     { | ||||
|       if (*char_ptr == c) | ||||
|         return (void *) char_ptr; | ||||
|     } | ||||
| 
 | ||||
|   return NULL; | ||||
| } | ||||
| #ifdef weak_alias | ||||
| weak_alias (__memchr, BP_SYM (memchr)) | ||||
| #endif | ||||
							
								
								
									
										14
									
								
								grub-core/gnulib/memchr.valgrind
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								grub-core/gnulib/memchr.valgrind
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| # Suppress a valgrind message about use of uninitialized memory in memchr(). | ||||
| # POSIX states that when the character is found, memchr must not read extra | ||||
| # bytes in an overestimated length (for example, where memchr is used to | ||||
| # implement strnlen).  However, we use a safe word read to provide a speedup. | ||||
| { | ||||
|     memchr-value4 | ||||
|     Memcheck:Value4 | ||||
|     fun:rpl_memchr | ||||
| } | ||||
| { | ||||
|     memchr-value8 | ||||
|     Memcheck:Value8 | ||||
|     fun:rpl_memchr | ||||
| } | ||||
							
								
								
									
										29
									
								
								grub-core/gnulib/mempcpy.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								grub-core/gnulib/mempcpy.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| /* Copy memory area and return pointer after last written byte.
 | ||||
|    Copyright (C) 2003, 2007, 2009, 2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <string.h> | ||||
| 
 | ||||
| /* Copy N bytes of SRC to DEST, return pointer to bytes after the
 | ||||
|    last written byte.  */ | ||||
| void * | ||||
| mempcpy (void *dest, const void *src, size_t n) | ||||
| { | ||||
|   return (char *) memcpy (dest, src, n) + n; | ||||
| } | ||||
							
								
								
									
										270
									
								
								grub-core/gnulib/nl_langinfo.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										270
									
								
								grub-core/gnulib/nl_langinfo.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,270 @@ | |||
| /* nl_langinfo() replacement: query locale dependent information.
 | ||||
| 
 | ||||
|    Copyright (C) 2007-2010 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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <langinfo.h> | ||||
| 
 | ||||
| #if REPLACE_NL_LANGINFO | ||||
| 
 | ||||
| /* Override nl_langinfo with support for added nl_item values.  */ | ||||
| 
 | ||||
| # include <locale.h> | ||||
| # include <string.h> | ||||
| 
 | ||||
| # undef nl_langinfo | ||||
| 
 | ||||
| char * | ||||
| rpl_nl_langinfo (nl_item item) | ||||
| { | ||||
|   switch (item) | ||||
|     { | ||||
| # if GNULIB_defined_CODESET | ||||
|     case CODESET: | ||||
|       { | ||||
|         const char *locale; | ||||
|         static char buf[2 + 10 + 1]; | ||||
| 
 | ||||
|         locale = setlocale (LC_CTYPE, NULL); | ||||
|         if (locale != NULL && locale[0] != '\0') | ||||
|           { | ||||
|             /* If the locale name contains an encoding after the dot, return
 | ||||
|                it.  */ | ||||
|             const char *dot = strchr (locale, '.'); | ||||
| 
 | ||||
|             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; | ||||
|                   } | ||||
|               } | ||||
|           } | ||||
|         return ""; | ||||
|       } | ||||
| # endif | ||||
| # if GNULIB_defined_T_FMT_AMPM | ||||
|     case T_FMT_AMPM: | ||||
|       return "%I:%M:%S %p"; | ||||
| # endif | ||||
| # if GNULIB_defined_ERA | ||||
|     case ERA: | ||||
|       /* The format is not standardized.  In glibc it is a sequence of strings
 | ||||
|          of the form "direction:offset:start_date:end_date:era_name:era_format" | ||||
|          with an empty string at the end.  */ | ||||
|       return ""; | ||||
|     case ERA_D_FMT: | ||||
|       /* The %Ex conversion in strftime behaves like %x if the locale does not
 | ||||
|          have an alternative time format.  */ | ||||
|       item = D_FMT; | ||||
|       break; | ||||
|     case ERA_D_T_FMT: | ||||
|       /* The %Ec conversion in strftime behaves like %c if the locale does not
 | ||||
|          have an alternative time format.  */ | ||||
|       item = D_T_FMT; | ||||
|       break; | ||||
|     case ERA_T_FMT: | ||||
|       /* The %EX conversion in strftime behaves like %X if the locale does not
 | ||||
|          have an alternative time format.  */ | ||||
|       item = T_FMT; | ||||
|       break; | ||||
|     case ALT_DIGITS: | ||||
|       /* The format is not standardized.  In glibc it is a sequence of 10
 | ||||
|          strings, appended in memory.  */ | ||||
|       return "\0\0\0\0\0\0\0\0\0\0"; | ||||
| # endif | ||||
| # if GNULIB_defined_YESEXPR | ||||
|     case YESEXPR: | ||||
|       return "^[yY]"; | ||||
|     case NOEXPR: | ||||
|       return "^[nN]"; | ||||
| # endif | ||||
|     default: | ||||
|       break; | ||||
|     } | ||||
|   return nl_langinfo (item); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| /* Provide nl_langinfo from scratch.  */ | ||||
| 
 | ||||
| # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||||
| 
 | ||||
| /* Native Windows platforms.  */ | ||||
| 
 | ||||
| #  define WIN32_LEAN_AND_MEAN  /* avoid including junk */ | ||||
| #  include <windows.h> | ||||
| 
 | ||||
| #  include <stdio.h> | ||||
| 
 | ||||
| # else | ||||
| 
 | ||||
| /* An old Unix platform without locales, such as Linux libc5 or BeOS.  */ | ||||
| 
 | ||||
| # endif | ||||
| 
 | ||||
| # include <locale.h> | ||||
| 
 | ||||
| char * | ||||
| nl_langinfo (nl_item item) | ||||
| { | ||||
|   switch (item) | ||||
|     { | ||||
|     /* nl_langinfo items of the LC_CTYPE category */ | ||||
|     case CODESET: | ||||
| # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||||
|       { | ||||
|         static char buf[2 + 10 + 1]; | ||||
| 
 | ||||
|         /* Woe32 has a function returning the locale's codepage as a number.  */ | ||||
|         sprintf (buf, "CP%u", GetACP ()); | ||||
|         return buf; | ||||
|       } | ||||
| # elif defined __BEOS__ | ||||
|       return "UTF-8"; | ||||
| # else | ||||
|       return "ISO-8859-1"; | ||||
| # endif | ||||
|     /* nl_langinfo items of the LC_NUMERIC category */ | ||||
|     case RADIXCHAR: | ||||
|       return localeconv () ->decimal_point; | ||||
|     case THOUSEP: | ||||
|       return localeconv () ->thousands_sep; | ||||
|     /* nl_langinfo items of the LC_TIME category.
 | ||||
|        TODO: Really use the locale.  */ | ||||
|     case D_T_FMT: | ||||
|     case ERA_D_T_FMT: | ||||
|       return "%a %b %e %H:%M:%S %Y"; | ||||
|     case D_FMT: | ||||
|     case ERA_D_FMT: | ||||
|       return "%m/%d/%y"; | ||||
|     case T_FMT: | ||||
|     case ERA_T_FMT: | ||||
|       return "%H:%M:%S"; | ||||
|     case T_FMT_AMPM: | ||||
|       return "%I:%M:%S %p"; | ||||
|     case AM_STR: | ||||
|       return "AM"; | ||||
|     case PM_STR: | ||||
|       return "PM"; | ||||
|     case DAY_1: | ||||
|       return "Sunday"; | ||||
|     case DAY_2: | ||||
|       return "Monday"; | ||||
|     case DAY_3: | ||||
|       return "Tuesday"; | ||||
|     case DAY_4: | ||||
|       return "Wednesday"; | ||||
|     case DAY_5: | ||||
|       return "Thursday"; | ||||
|     case DAY_6: | ||||
|       return "Friday"; | ||||
|     case DAY_7: | ||||
|       return "Saturday"; | ||||
|     case ABDAY_1: | ||||
|       return "Sun"; | ||||
|     case ABDAY_2: | ||||
|       return "Mon"; | ||||
|     case ABDAY_3: | ||||
|       return "Tue"; | ||||
|     case ABDAY_4: | ||||
|       return "Wed"; | ||||
|     case ABDAY_5: | ||||
|       return "Thu"; | ||||
|     case ABDAY_6: | ||||
|       return "Fri"; | ||||
|     case ABDAY_7: | ||||
|       return "Sat"; | ||||
|     case MON_1: | ||||
|       return "January"; | ||||
|     case MON_2: | ||||
|       return "February"; | ||||
|     case MON_3: | ||||
|       return "March"; | ||||
|     case MON_4: | ||||
|       return "April"; | ||||
|     case MON_5: | ||||
|       return "May"; | ||||
|     case MON_6: | ||||
|       return "June"; | ||||
|     case MON_7: | ||||
|       return "July"; | ||||
|     case MON_8: | ||||
|       return "August"; | ||||
|     case MON_9: | ||||
|       return "September"; | ||||
|     case MON_10: | ||||
|       return "October"; | ||||
|     case MON_11: | ||||
|       return "November"; | ||||
|     case MON_12: | ||||
|       return "December"; | ||||
|     case ABMON_1: | ||||
|       return "Jan"; | ||||
|     case ABMON_2: | ||||
|       return "Feb"; | ||||
|     case ABMON_3: | ||||
|       return "Mar"; | ||||
|     case ABMON_4: | ||||
|       return "Apr"; | ||||
|     case ABMON_5: | ||||
|       return "May"; | ||||
|     case ABMON_6: | ||||
|       return "Jun"; | ||||
|     case ABMON_7: | ||||
|       return "Jul"; | ||||
|     case ABMON_8: | ||||
|       return "Aug"; | ||||
|     case ABMON_9: | ||||
|       return "Sep"; | ||||
|     case ABMON_10: | ||||
|       return "Oct"; | ||||
|     case ABMON_11: | ||||
|       return "Nov"; | ||||
|     case ABMON_12: | ||||
|       return "Dec"; | ||||
|     case ERA: | ||||
|       return ""; | ||||
|     case ALT_DIGITS: | ||||
|       return "\0\0\0\0\0\0\0\0\0\0"; | ||||
|     /* nl_langinfo items of the LC_MONETARY category
 | ||||
|        TODO: Really use the locale. */ | ||||
|     case CRNCYSTR: | ||||
|       return "-"; | ||||
|     /* nl_langinfo items of the LC_MESSAGES category
 | ||||
|        TODO: Really use the locale. */ | ||||
|     case YESEXPR: | ||||
|       return "^[yY]"; | ||||
|     case NOEXPR: | ||||
|       return "^[nN]"; | ||||
|     default: | ||||
|       return ""; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										188
									
								
								grub-core/gnulib/printf-args.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										188
									
								
								grub-core/gnulib/printf-args.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,188 @@ | |||
| /* Decomposed printf argument list.
 | ||||
|    Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /* This file can be parametrized with the following macros:
 | ||||
|      ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions. | ||||
|      PRINTF_FETCHARGS   Name of the function to be defined. | ||||
|      STATIC             Set to 'static' to declare the function static.  */ | ||||
| 
 | ||||
| #ifndef PRINTF_FETCHARGS | ||||
| # include <config.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #ifndef PRINTF_FETCHARGS | ||||
| # include "printf-args.h" | ||||
| #endif | ||||
| 
 | ||||
| #ifdef STATIC | ||||
| STATIC | ||||
| #endif | ||||
| int | ||||
| PRINTF_FETCHARGS (va_list args, arguments *a) | ||||
| { | ||||
|   size_t i; | ||||
|   argument *ap; | ||||
| 
 | ||||
|   for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++) | ||||
|     switch (ap->type) | ||||
|       { | ||||
|       case TYPE_SCHAR: | ||||
|         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; | ||||
|       case TYPE_SHORT: | ||||
|         ap->a.a_short = va_arg (args, /*short*/ int); | ||||
|         break; | ||||
|       case TYPE_USHORT: | ||||
|         ap->a.a_ushort = va_arg (args, /*unsigned short*/ int); | ||||
|         break; | ||||
|       case TYPE_INT: | ||||
|         ap->a.a_int = va_arg (args, int); | ||||
|         break; | ||||
|       case TYPE_UINT: | ||||
|         ap->a.a_uint = va_arg (args, unsigned int); | ||||
|         break; | ||||
|       case TYPE_LONGINT: | ||||
|         ap->a.a_longint = va_arg (args, long int); | ||||
|         break; | ||||
|       case TYPE_ULONGINT: | ||||
|         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; | ||||
|       case TYPE_ULONGLONGINT: | ||||
|         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; | ||||
|       case TYPE_LONGDOUBLE: | ||||
|         ap->a.a_longdouble = va_arg (args, long double); | ||||
|         break; | ||||
|       case TYPE_CHAR: | ||||
|         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; | ||||
| #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; | ||||
| #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; | ||||
| #endif | ||||
|       case TYPE_POINTER: | ||||
|         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; | ||||
|       case TYPE_COUNT_SHORT_POINTER: | ||||
|         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; | ||||
|       case TYPE_COUNT_LONGINT_POINTER: | ||||
|         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; | ||||
| #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; | ||||
|       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; | ||||
|       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; | ||||
| #endif | ||||
|       default: | ||||
|         /* Unknown type.  */ | ||||
|         return -1; | ||||
|       } | ||||
|   return 0; | ||||
| } | ||||
							
								
								
									
										155
									
								
								grub-core/gnulib/printf-args.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								grub-core/gnulib/printf-args.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,155 @@ | |||
| /* Decomposed printf argument list.
 | ||||
|    Copyright (C) 1999, 2002-2003, 2006-2007, 2009-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _PRINTF_ARGS_H | ||||
| #define _PRINTF_ARGS_H | ||||
| 
 | ||||
| /* This file can be parametrized with the following macros:
 | ||||
|      ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions. | ||||
|      PRINTF_FETCHARGS   Name of the function to be declared. | ||||
|      STATIC             Set to 'static' to declare the function static.  */ | ||||
| 
 | ||||
| /* Default parameters.  */ | ||||
| #ifndef PRINTF_FETCHARGS | ||||
| # define PRINTF_FETCHARGS printf_fetchargs | ||||
| #endif | ||||
| 
 | ||||
| /* Get size_t.  */ | ||||
| #include <stddef.h> | ||||
| 
 | ||||
| /* Get wchar_t.  */ | ||||
| #if HAVE_WCHAR_T | ||||
| # include <stddef.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Get wint_t.  */ | ||||
| #if HAVE_WINT_T | ||||
| # include <wchar.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Get va_list.  */ | ||||
| #include <stdarg.h> | ||||
| 
 | ||||
| 
 | ||||
| /* Argument types */ | ||||
| typedef enum | ||||
| { | ||||
|   TYPE_NONE, | ||||
|   TYPE_SCHAR, | ||||
|   TYPE_UCHAR, | ||||
|   TYPE_SHORT, | ||||
|   TYPE_USHORT, | ||||
|   TYPE_INT, | ||||
|   TYPE_UINT, | ||||
|   TYPE_LONGINT, | ||||
|   TYPE_ULONGINT, | ||||
| #if HAVE_LONG_LONG_INT | ||||
|   TYPE_LONGLONGINT, | ||||
|   TYPE_ULONGLONGINT, | ||||
| #endif | ||||
|   TYPE_DOUBLE, | ||||
|   TYPE_LONGDOUBLE, | ||||
|   TYPE_CHAR, | ||||
| #if HAVE_WINT_T | ||||
|   TYPE_WIDE_CHAR, | ||||
| #endif | ||||
|   TYPE_STRING, | ||||
| #if HAVE_WCHAR_T | ||||
|   TYPE_WIDE_STRING, | ||||
| #endif | ||||
|   TYPE_POINTER, | ||||
|   TYPE_COUNT_SCHAR_POINTER, | ||||
|   TYPE_COUNT_SHORT_POINTER, | ||||
|   TYPE_COUNT_INT_POINTER, | ||||
|   TYPE_COUNT_LONGINT_POINTER | ||||
| #if HAVE_LONG_LONG_INT | ||||
| , TYPE_COUNT_LONGLONGINT_POINTER | ||||
| #endif | ||||
| #if ENABLE_UNISTDIO | ||||
|   /* The unistdio extensions.  */ | ||||
| , TYPE_U8_STRING | ||||
| , TYPE_U16_STRING | ||||
| , TYPE_U32_STRING | ||||
| #endif | ||||
| } arg_type; | ||||
| 
 | ||||
| /* Polymorphic argument */ | ||||
| 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; | ||||
| #if HAVE_LONG_LONG_INT | ||||
|     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; | ||||
| #if HAVE_WINT_T | ||||
|     wint_t                      a_wide_char; | ||||
| #endif | ||||
|     const char*                 a_string; | ||||
| #if HAVE_WCHAR_T | ||||
|     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; | ||||
| #if HAVE_LONG_LONG_INT | ||||
|     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; | ||||
| #endif | ||||
|   } | ||||
|   a; | ||||
| } | ||||
| argument; | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
|   size_t count; | ||||
|   argument *arg; | ||||
| } | ||||
| arguments; | ||||
| 
 | ||||
| 
 | ||||
| /* Fetch the arguments, putting them into a. */ | ||||
| #ifdef STATIC | ||||
| STATIC | ||||
| #else | ||||
| extern | ||||
| #endif | ||||
| int PRINTF_FETCHARGS (va_list args, arguments *a); | ||||
| 
 | ||||
| #endif /* _PRINTF_ARGS_H */ | ||||
							
								
								
									
										627
									
								
								grub-core/gnulib/printf-parse.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										627
									
								
								grub-core/gnulib/printf-parse.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,627 @@ | |||
| /* Formatted output to strings.
 | ||||
|    Copyright (C) 1999-2000, 2002-2003, 2006-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /* This file can be parametrized with the following macros:
 | ||||
|      CHAR_T             The element type of the format string. | ||||
|      CHAR_T_ONLY_ASCII  Set to 1 to enable verification that all characters | ||||
|                         in the format string are ASCII. | ||||
|      DIRECTIVE          Structure denoting a format directive. | ||||
|                         Depends on CHAR_T. | ||||
|      DIRECTIVES         Structure denoting the set of format directives of a | ||||
|                         format string.  Depends on CHAR_T. | ||||
|      PRINTF_PARSE       Function that parses a format string. | ||||
|                         Depends on CHAR_T. | ||||
|      STATIC             Set to 'static' to declare the function static. | ||||
|      ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions.  */ | ||||
| 
 | ||||
| #ifndef PRINTF_PARSE | ||||
| # include <config.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #ifndef PRINTF_PARSE | ||||
| # include "printf-parse.h" | ||||
| #endif | ||||
| 
 | ||||
| /* Default parameters.  */ | ||||
| #ifndef PRINTF_PARSE | ||||
| # define PRINTF_PARSE printf_parse | ||||
| # define CHAR_T char | ||||
| # define DIRECTIVE char_directive | ||||
| # define DIRECTIVES char_directives | ||||
| #endif | ||||
| 
 | ||||
| /* Get size_t, NULL.  */ | ||||
| #include <stddef.h> | ||||
| 
 | ||||
| /* Get intmax_t.  */ | ||||
| #if defined IN_LIBINTL || defined IN_LIBASPRINTF | ||||
| # if HAVE_STDINT_H_WITH_UINTMAX | ||||
| #  include <stdint.h> | ||||
| # endif | ||||
| # if HAVE_INTTYPES_H_WITH_UINTMAX | ||||
| #  include <inttypes.h> | ||||
| # endif | ||||
| #else | ||||
| # include <stdint.h> | ||||
| #endif | ||||
| 
 | ||||
| /* malloc(), realloc(), free().  */ | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| /* errno.  */ | ||||
| #include <errno.h> | ||||
| 
 | ||||
| /* Checked size_t computations.  */ | ||||
| #include "xsize.h" | ||||
| 
 | ||||
| #if CHAR_T_ONLY_ASCII | ||||
| /* c_isascii().  */ | ||||
| # include "c-ctype.h" | ||||
| #endif | ||||
| 
 | ||||
| #ifdef STATIC | ||||
| STATIC | ||||
| #endif | ||||
| 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 */ | ||||
|   size_t max_width_length = 0; | ||||
|   size_t max_precision_length = 0; | ||||
| 
 | ||||
|   d->count = 0; | ||||
|   d_allocated = 1; | ||||
|   d->dir = (DIRECTIVE *) malloc (d_allocated * sizeof (DIRECTIVE)); | ||||
|   if (d->dir == NULL) | ||||
|     /* Out of memory.  */ | ||||
|     goto out_of_memory_1; | ||||
| 
 | ||||
|   a->count = 0; | ||||
|   a_allocated = 0; | ||||
|   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;                                                       \ | ||||
|   } | ||||
| 
 | ||||
|   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 */ | ||||
| 
 | ||||
|           /* 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; | ||||
| 
 | ||||
|               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; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|           /* 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; | ||||
| 
 | ||||
|               /* 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++) | ||||
|                         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; | ||||
|             } | ||||
| 
 | ||||
|           /* 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; | ||||
| 
 | ||||
|                       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; | ||||
| 
 | ||||
|                   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; | ||||
| 
 | ||||
|             /* 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++; | ||||
|                     } | ||||
| #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++; | ||||
|                     } | ||||
| #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; | ||||
|                     } | ||||
| #endif | ||||
|                   else | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|               /* 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 | ||||
| #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 HAVE_LONG_LONG_INT | ||||
|                   /* 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 HAVE_WINT_T | ||||
|                     type = TYPE_WIDE_CHAR; | ||||
| #else | ||||
|                     goto error; | ||||
| #endif | ||||
|                   else | ||||
|                     type = TYPE_CHAR; | ||||
|                   break; | ||||
| #if HAVE_WINT_T | ||||
|                 case 'C': | ||||
|                   type = TYPE_WIDE_CHAR; | ||||
|                   c = 'c'; | ||||
|                   break; | ||||
| #endif | ||||
|                 case 's': | ||||
|                   if (flags >= 8) | ||||
| #if HAVE_WCHAR_T | ||||
|                     type = TYPE_WIDE_STRING; | ||||
| #else | ||||
|                     goto error; | ||||
| #endif | ||||
|                   else | ||||
|                     type = TYPE_STRING; | ||||
|                   break; | ||||
| #if HAVE_WCHAR_T | ||||
|                 case 'S': | ||||
|                   type = TYPE_WIDE_STRING; | ||||
|                   c = 's'; | ||||
|                   break; | ||||
| #endif | ||||
|                 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 | ||||
| #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 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; | ||||
| #endif | ||||
|                 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; | ||||
|           } | ||||
| 
 | ||||
|           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; | ||||
|             } | ||||
|         } | ||||
| #if CHAR_T_ONLY_ASCII | ||||
|       else if (!c_isascii (c)) | ||||
|         { | ||||
|           /* Non-ASCII character.  Not supported.  */ | ||||
|           goto error; | ||||
|         } | ||||
| #endif | ||||
|     } | ||||
|   d->dir[d->count].dir_start = cp; | ||||
| 
 | ||||
|   d->max_width_length = max_width_length; | ||||
|   d->max_precision_length = max_precision_length; | ||||
|   return 0; | ||||
| 
 | ||||
| error: | ||||
|   if (a->arg) | ||||
|     free (a->arg); | ||||
|   if (d->dir) | ||||
|     free (d->dir); | ||||
|   errno = EINVAL; | ||||
|   return -1; | ||||
| 
 | ||||
| out_of_memory: | ||||
|   if (a->arg) | ||||
|     free (a->arg); | ||||
|   if (d->dir) | ||||
|     free (d->dir); | ||||
| out_of_memory_1: | ||||
|   errno = ENOMEM; | ||||
|   return -1; | ||||
| } | ||||
| 
 | ||||
| #undef PRINTF_PARSE | ||||
| #undef DIRECTIVES | ||||
| #undef DIRECTIVE | ||||
| #undef CHAR_T_ONLY_ASCII | ||||
| #undef CHAR_T | ||||
							
								
								
									
										180
									
								
								grub-core/gnulib/printf-parse.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										180
									
								
								grub-core/gnulib/printf-parse.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,180 @@ | |||
| /* Parse printf format string.
 | ||||
|    Copyright (C) 1999, 2002-2003, 2005, 2007, 2009-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _PRINTF_PARSE_H | ||||
| #define _PRINTF_PARSE_H | ||||
| 
 | ||||
| /* This file can be parametrized with the following macros:
 | ||||
|      ENABLE_UNISTDIO    Set to 1 to enable the unistdio extensions. | ||||
|      STATIC             Set to 'static' to declare the function static.  */ | ||||
| 
 | ||||
| #include "printf-args.h" | ||||
| 
 | ||||
| 
 | ||||
| /* 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 | ||||
| 
 | ||||
| /* arg_index value indicating that no argument is consumed.  */ | ||||
| #define ARG_NONE        (~(size_t)0) | ||||
| 
 | ||||
| /* xxx_directive: A parsed directive.
 | ||||
|    xxx_directives: A parsed format string.  */ | ||||
| 
 | ||||
| /* A parsed directive.  */ | ||||
| typedef struct | ||||
| { | ||||
|   const char* dir_start; | ||||
|   const char* dir_end; | ||||
|   int flags; | ||||
|   const char* width_start; | ||||
|   const char* width_end; | ||||
|   size_t width_arg_index; | ||||
|   const char* precision_start; | ||||
|   const char* precision_end; | ||||
|   size_t precision_arg_index; | ||||
|   char conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ | ||||
|   size_t arg_index; | ||||
| } | ||||
| char_directive; | ||||
| 
 | ||||
| /* A parsed format string.  */ | ||||
| typedef struct | ||||
| { | ||||
|   size_t count; | ||||
|   char_directive *dir; | ||||
|   size_t max_width_length; | ||||
|   size_t max_precision_length; | ||||
| } | ||||
| char_directives; | ||||
| 
 | ||||
| #if ENABLE_UNISTDIO | ||||
| 
 | ||||
| /* A parsed directive.  */ | ||||
| typedef struct | ||||
| { | ||||
|   const uint8_t* dir_start; | ||||
|   const uint8_t* dir_end; | ||||
|   int flags; | ||||
|   const uint8_t* width_start; | ||||
|   const uint8_t* width_end; | ||||
|   size_t width_arg_index; | ||||
|   const uint8_t* precision_start; | ||||
|   const uint8_t* precision_end; | ||||
|   size_t precision_arg_index; | ||||
|   uint8_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ | ||||
|   size_t arg_index; | ||||
| } | ||||
| u8_directive; | ||||
| 
 | ||||
| /* A parsed format string.  */ | ||||
| typedef struct | ||||
| { | ||||
|   size_t count; | ||||
|   u8_directive *dir; | ||||
|   size_t max_width_length; | ||||
|   size_t max_precision_length; | ||||
| } | ||||
| u8_directives; | ||||
| 
 | ||||
| /* A parsed directive.  */ | ||||
| typedef struct | ||||
| { | ||||
|   const uint16_t* dir_start; | ||||
|   const uint16_t* dir_end; | ||||
|   int flags; | ||||
|   const uint16_t* width_start; | ||||
|   const uint16_t* width_end; | ||||
|   size_t width_arg_index; | ||||
|   const uint16_t* precision_start; | ||||
|   const uint16_t* precision_end; | ||||
|   size_t precision_arg_index; | ||||
|   uint16_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ | ||||
|   size_t arg_index; | ||||
| } | ||||
| u16_directive; | ||||
| 
 | ||||
| /* A parsed format string.  */ | ||||
| typedef struct | ||||
| { | ||||
|   size_t count; | ||||
|   u16_directive *dir; | ||||
|   size_t max_width_length; | ||||
|   size_t max_precision_length; | ||||
| } | ||||
| u16_directives; | ||||
| 
 | ||||
| /* A parsed directive.  */ | ||||
| typedef struct | ||||
| { | ||||
|   const uint32_t* dir_start; | ||||
|   const uint32_t* dir_end; | ||||
|   int flags; | ||||
|   const uint32_t* width_start; | ||||
|   const uint32_t* width_end; | ||||
|   size_t width_arg_index; | ||||
|   const uint32_t* precision_start; | ||||
|   const uint32_t* precision_end; | ||||
|   size_t precision_arg_index; | ||||
|   uint32_t conversion; /* d i o u x X f F e E g G a A c s p n U % but not C S */ | ||||
|   size_t arg_index; | ||||
| } | ||||
| u32_directive; | ||||
| 
 | ||||
| /* A parsed format string.  */ | ||||
| typedef struct | ||||
| { | ||||
|   size_t count; | ||||
|   u32_directive *dir; | ||||
|   size_t max_width_length; | ||||
|   size_t max_precision_length; | ||||
| } | ||||
| u32_directives; | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Parses the format string.  Fills in the number N of directives, and fills
 | ||||
|    in directives[0], ..., directives[N-1], and sets directives[N].dir_start | ||||
|    to the end of the format string.  Also fills in the arg_type fields of the | ||||
|    arguments and the needed count of arguments.  */ | ||||
| #if ENABLE_UNISTDIO | ||||
| extern int | ||||
|        ulc_printf_parse (const char *format, char_directives *d, arguments *a); | ||||
| 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); | ||||
| extern int | ||||
|        u32_printf_parse (const uint32_t *format, u32_directives *d, | ||||
|                          arguments *a); | ||||
| #else | ||||
| # ifdef STATIC | ||||
| STATIC | ||||
| # else | ||||
| extern | ||||
| # endif | ||||
| int printf_parse (const char *format, char_directives *d, arguments *a); | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _PRINTF_PARSE_H */ | ||||
							
								
								
									
										136
									
								
								grub-core/gnulib/rawmemchr.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								grub-core/gnulib/rawmemchr.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,136 @@ | |||
| /* Searching in a string.
 | ||||
|    Copyright (C) 2008, 2009, 2010 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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <string.h> | ||||
| 
 | ||||
| /* Find the first occurrence of C in S.  */ | ||||
| void * | ||||
| rawmemchr (const void *s, int c_in) | ||||
| { | ||||
|   /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
 | ||||
|      long instead of a 64-bit uintmax_t tends to give better | ||||
|      performance.  On 64-bit hardware, unsigned long is generally 64 | ||||
|      bits already.  Change this typedef to experiment with | ||||
|      performance.  */ | ||||
|   typedef unsigned long int longword; | ||||
| 
 | ||||
|   const unsigned char *char_ptr; | ||||
|   const longword *longword_ptr; | ||||
|   longword repeated_one; | ||||
|   longword repeated_c; | ||||
|   unsigned char c; | ||||
| 
 | ||||
|   c = (unsigned char) c_in; | ||||
| 
 | ||||
|   /* Handle the first few bytes by reading one byte at a time.
 | ||||
|      Do this until CHAR_PTR is aligned on a longword boundary.  */ | ||||
|   for (char_ptr = (const unsigned char *) s; | ||||
|        (size_t) char_ptr % sizeof (longword) != 0; | ||||
|        ++char_ptr) | ||||
|     if (*char_ptr == c) | ||||
|       return (void *) char_ptr; | ||||
| 
 | ||||
|   longword_ptr = (const longword *) char_ptr; | ||||
| 
 | ||||
|   /* All these elucidatory comments refer to 4-byte longwords,
 | ||||
|      but the theory applies equally well to any size longwords.  */ | ||||
| 
 | ||||
|   /* Compute auxiliary longword values:
 | ||||
|      repeated_one is a value which has a 1 in every byte. | ||||
|      repeated_c has c in every byte.  */ | ||||
|   repeated_one = 0x01010101; | ||||
|   repeated_c = c | (c << 8); | ||||
|   repeated_c |= repeated_c << 16; | ||||
|   if (0xffffffffU < (longword) -1) | ||||
|     { | ||||
|       repeated_one |= repeated_one << 31 << 1; | ||||
|       repeated_c |= repeated_c << 31 << 1; | ||||
|       if (8 < sizeof (longword)) | ||||
|         { | ||||
|           size_t 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 longword at a time.  The tricky part is testing if *any of | ||||
|      the four* bytes in the longword in question are equal to NUL or | ||||
|      c.  We first use an xor with repeated_c.  This reduces the task | ||||
|      to testing whether *any of the four* bytes in longword1 is zero. | ||||
| 
 | ||||
|      We compute tmp = | ||||
|        ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). | ||||
|      That is, we perform the following operations: | ||||
|        1. Subtract repeated_one. | ||||
|        2. & ~longword1. | ||||
|        3. & a mask consisting of 0x80 in every byte. | ||||
|      Consider what happens in each byte: | ||||
|        - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, | ||||
|          and step 3 transforms it into 0x80.  A carry can also be propagated | ||||
|          to more significant bytes. | ||||
|        - If a byte of longword1 is nonzero, let its lowest 1 bit be at | ||||
|          position k (0 <= k <= 7); so the lowest k bits are 0.  After step 1, | ||||
|          the byte ends in a single bit of value 0 and k bits of value 1. | ||||
|          After step 2, the result is just k bits of value 1: 2^k - 1.  After | ||||
|          step 3, the result is 0.  And no carry is produced. | ||||
|      So, if longword1 has only non-zero bytes, tmp is zero. | ||||
|      Whereas if longword1 has a zero byte, call j the position of the least | ||||
|      significant zero byte.  Then the result has a zero at positions 0, ..., | ||||
|      j-1 and a 0x80 at position j.  We cannot predict the result at the more | ||||
|      significant bytes (positions j+1..3), but it does not matter since we | ||||
|      already have a non-zero bit at position 8*j+7. | ||||
| 
 | ||||
|      The test whether any byte in longword1 is zero is equivalent | ||||
|      to testing whether tmp is nonzero. | ||||
| 
 | ||||
|      This test can read beyond the end of a string, depending on where | ||||
|      C_IN is encountered.  However, this is considered safe since the | ||||
|      initialization phase ensured that the read will be aligned, | ||||
|      therefore, the read will not cross page boundaries and will not | ||||
|      cause a fault.  */ | ||||
| 
 | ||||
|   while (1) | ||||
|     { | ||||
|       longword longword1 = *longword_ptr ^ repeated_c; | ||||
| 
 | ||||
|       if ((((longword1 - repeated_one) & ~longword1) | ||||
|            & (repeated_one << 7)) != 0) | ||||
|         break; | ||||
|       longword_ptr++; | ||||
|     } | ||||
| 
 | ||||
|   char_ptr = (const unsigned char *) longword_ptr; | ||||
| 
 | ||||
|   /* At this point, we know that one of the sizeof (longword) bytes
 | ||||
|      starting at char_ptr is == c.  On little-endian machines, we | ||||
|      could determine the first such byte without any further memory | ||||
|      accesses, just by looking at the tmp result from the last loop | ||||
|      iteration.  But this does not work on big-endian machines. | ||||
|      Choose code that works in both cases.  */ | ||||
| 
 | ||||
|   char_ptr = (unsigned char *) longword_ptr; | ||||
|   while (*char_ptr != c) | ||||
|     char_ptr++; | ||||
|   return (void *) char_ptr; | ||||
| } | ||||
							
								
								
									
										12
									
								
								grub-core/gnulib/rawmemchr.valgrind
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								grub-core/gnulib/rawmemchr.valgrind
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | |||
| # Suppress a valgrind message about use of uninitialized memory in rawmemchr(). | ||||
| # This use is OK because it provides only a speedup. | ||||
| { | ||||
|     rawmemchr-value4 | ||||
|     Memcheck:Value4 | ||||
|     fun:rawmemchr | ||||
| } | ||||
| { | ||||
|     rawmemchr-value8 | ||||
|     Memcheck:Value8 | ||||
|     fun:rawmemchr | ||||
| } | ||||
							
								
								
									
										91
									
								
								grub-core/gnulib/realloc.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								grub-core/gnulib/realloc.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,91 @@ | |||
| /* realloc() function that is glibc compatible.
 | ||||
| 
 | ||||
|    Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2010 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 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/>.  */
 | ||||
| 
 | ||||
| /* written by Jim Meyering and Bruno Haible */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h.  */ | ||||
| #ifdef realloc | ||||
| # define NEED_REALLOC_GNU 1 | ||||
| /* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU.  */ | ||||
| #elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU | ||||
| # define NEED_REALLOC_GNU 1 | ||||
| #endif | ||||
| 
 | ||||
| /* Infer the properties of the system's malloc function.
 | ||||
|    The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU.  */ | ||||
| #if GNULIB_MALLOC_GNU && HAVE_MALLOC_GNU | ||||
| # define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1 | ||||
| #endif | ||||
| 
 | ||||
| /* Below we want to call the system's malloc and realloc.
 | ||||
|    Undefine the symbols here so that including <stdlib.h> provides a | ||||
|    declaration of malloc(), not of rpl_malloc(), and likewise for realloc.  */ | ||||
| #undef malloc | ||||
| #undef realloc | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| #include <errno.h> | ||||
| 
 | ||||
| /* Below we want to call the system's malloc and realloc.
 | ||||
|    Undefine the symbols, if they were defined by gnulib's <stdlib.h> | ||||
|    replacement.  */ | ||||
| #undef malloc | ||||
| #undef realloc | ||||
| 
 | ||||
| /* Change the size of an allocated block of memory P to N bytes,
 | ||||
|    with error checking.  If N is zero, change it to 1.  If P is NULL, | ||||
|    use malloc.  */ | ||||
| 
 | ||||
| void * | ||||
| rpl_realloc (void *p, size_t n) | ||||
| { | ||||
|   void *result; | ||||
| 
 | ||||
| #if NEED_REALLOC_GNU | ||||
|   if (n == 0) | ||||
|     { | ||||
|       n = 1; | ||||
| 
 | ||||
|       /* In theory realloc might fail, so don't rely on it to free.  */ | ||||
|       free (p); | ||||
|       p = NULL; | ||||
|     } | ||||
| #endif | ||||
| 
 | ||||
|   if (p == NULL) | ||||
|     { | ||||
| #if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE | ||||
|       if (n == 0) | ||||
|         n = 1; | ||||
| #endif | ||||
|       result = malloc (n); | ||||
|     } | ||||
|   else | ||||
|     result = realloc (p, n); | ||||
| 
 | ||||
| #if !HAVE_REALLOC_POSIX | ||||
|   if (result == NULL) | ||||
|     errno = ENOMEM; | ||||
| #endif | ||||
| 
 | ||||
|   return result; | ||||
| } | ||||
							
								
								
									
										30
									
								
								grub-core/gnulib/ref-add.sin
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								grub-core/gnulib/ref-add.sin
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| # Add this package to a list of references stored in a text file. | ||||
| # | ||||
| #   Copyright (C) 2000, 2009, 2010 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, 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 General Public License for more details. | ||||
| # | ||||
| #   You should have received a copy of the GNU General Public License along | ||||
| #   with this program; if not, write to the Free Software Foundation, | ||||
| #   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| # | ||||
| # Written by Bruno Haible <haible@clisp.cons.org>. | ||||
| # | ||||
| /^# Packages using this file: / { | ||||
|   s/# Packages using this file:// | ||||
|   ta | ||||
|   :a | ||||
|   s/ @PACKAGE@ / @PACKAGE@ / | ||||
|   tb | ||||
|   s/ $/ @PACKAGE@ / | ||||
|   :b | ||||
|   s/^/# Packages using this file:/ | ||||
| } | ||||
							
								
								
									
										25
									
								
								grub-core/gnulib/ref-del.sin
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								grub-core/gnulib/ref-del.sin
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | |||
| # Remove this package from a list of references stored in a text file. | ||||
| # | ||||
| #   Copyright (C) 2000, 2009, 2010 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, 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 General Public License for more details. | ||||
| # | ||||
| #   You should have received a copy of the GNU General Public License along | ||||
| #   with this program; if not, write to the Free Software Foundation, | ||||
| #   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| # | ||||
| # Written by Bruno Haible <haible@clisp.cons.org>. | ||||
| # | ||||
| /^# Packages using this file: / { | ||||
|   s/# Packages using this file:// | ||||
|   s/ @PACKAGE@ / / | ||||
|   s/^/# Packages using this file:/ | ||||
| } | ||||
|  | @ -6,7 +6,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ | |||
| 
 | ||||
|    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 2, or (at your option) | ||||
|    the Free Software Foundation; either version 3, or (at your option) | ||||
|    any later version. | ||||
| 
 | ||||
|    This program is distributed in the hope that it will be useful, | ||||
|  |  | |||
							
								
								
									
										31
									
								
								grub-core/gnulib/size_max.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								grub-core/gnulib/size_max.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| /* size_max.h -- declare SIZE_MAX through system headers
 | ||||
|    Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. | ||||
|    Written by Simon Josefsson. | ||||
| 
 | ||||
|    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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef GNULIB_SIZE_MAX_H | ||||
| #define GNULIB_SIZE_MAX_H | ||||
| 
 | ||||
| /* Get SIZE_MAX declaration on systems like Solaris 7/8/9.  */ | ||||
| # include <limits.h> | ||||
| /* Get SIZE_MAX declaration on systems like glibc 2.  */ | ||||
| # if HAVE_STDINT_H | ||||
| #  include <stdint.h> | ||||
| # endif | ||||
| /* On systems where these include files don't define it, SIZE_MAX is defined
 | ||||
|    in config.h.  */ | ||||
| 
 | ||||
| #endif /* GNULIB_SIZE_MAX_H */ | ||||
							
								
								
									
										75
									
								
								grub-core/gnulib/sleep.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								grub-core/gnulib/sleep.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,75 @@ | |||
| /* Pausing execution of the current thread.
 | ||||
|    Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2007. | ||||
| 
 | ||||
|    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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| #include <limits.h> | ||||
| 
 | ||||
| #include "verify.h" | ||||
| 
 | ||||
| #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||||
| 
 | ||||
| # define WIN32_LEAN_AND_MEAN  /* avoid including junk */ | ||||
| # include <windows.h> | ||||
| 
 | ||||
| unsigned int | ||||
| sleep (unsigned int seconds) | ||||
| { | ||||
|   unsigned int remaining; | ||||
| 
 | ||||
|   /* Sleep for 1 second many times, because
 | ||||
|        1. Sleep is not interruptiple by Ctrl-C, | ||||
|        2. we want to avoid arithmetic overflow while multiplying with 1000.  */ | ||||
|   for (remaining = seconds; remaining > 0; remaining--) | ||||
|     Sleep (1000); | ||||
| 
 | ||||
|   return remaining; | ||||
| } | ||||
| 
 | ||||
| #elif HAVE_SLEEP | ||||
| 
 | ||||
| # undef sleep | ||||
| 
 | ||||
| /* Guarantee unlimited sleep and a reasonable return value.  Cygwin
 | ||||
|    1.5.x rejects attempts to sleep more than 49.7 days (2**32 | ||||
|    milliseconds), but uses uninitialized memory which results in a | ||||
|    garbage answer.  */ | ||||
| unsigned int | ||||
| rpl_sleep (unsigned int seconds) | ||||
| { | ||||
|   /* This requires int larger than 16 bits.  */ | ||||
|   verify (UINT_MAX / 49 / 24 / 60 / 60); | ||||
|   const unsigned int limit = 49 * 24 * 60 * 60; | ||||
|   while (limit < seconds) | ||||
|     { | ||||
|       unsigned int result; | ||||
|       seconds -= limit; | ||||
|       result = sleep (limit); | ||||
|       if (result) | ||||
|         return seconds + result; | ||||
|     } | ||||
|   return sleep (seconds); | ||||
| } | ||||
| 
 | ||||
| #else /* !HAVE_SLEEP */ | ||||
| 
 | ||||
|  #error "Please port gnulib sleep.c to your platform, possibly using usleep() or select(), then report this to bug-gnulib." | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										122
									
								
								grub-core/gnulib/stdbool.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								grub-core/gnulib/stdbool.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,122 @@ | |||
| /* Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc.
 | ||||
|    Written by Bruno Haible <haible@clisp.cons.org>, 2001. | ||||
| 
 | ||||
|    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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _GL_STDBOOL_H | ||||
| #define _GL_STDBOOL_H | ||||
| 
 | ||||
| /* ISO C 99 <stdbool.h> for platforms that lack it.  */ | ||||
| 
 | ||||
| /* Usage suggestions:
 | ||||
| 
 | ||||
|    Programs that use <stdbool.h> should be aware of some limitations | ||||
|    and standards compliance issues. | ||||
| 
 | ||||
|    Standards compliance: | ||||
| 
 | ||||
|        - <stdbool.h> must be #included before 'bool', 'false', 'true' | ||||
|          can be used. | ||||
| 
 | ||||
|        - You cannot assume that sizeof (bool) == 1. | ||||
| 
 | ||||
|        - Programs should not undefine the macros bool, true, and false, | ||||
|          as C99 lists that as an "obsolescent feature". | ||||
| 
 | ||||
|    Limitations of this substitute, when used in a C89 environment: | ||||
| 
 | ||||
|        - <stdbool.h> must be #included before the '_Bool' type can be used. | ||||
| 
 | ||||
|        - You cannot assume that _Bool is a typedef; it might be a macro. | ||||
| 
 | ||||
|        - Bit-fields of type 'bool' are not supported.  Portable code | ||||
|          should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. | ||||
| 
 | ||||
|        - In C99, casts and automatic conversions to '_Bool' or 'bool' are | ||||
|          performed in such a way that every nonzero value gets converted | ||||
|          to 'true', and zero gets converted to 'false'.  This doesn't work | ||||
|          with this substitute.  With this substitute, only the values 0 and 1 | ||||
|          give the expected result when converted to _Bool' or 'bool'. | ||||
| 
 | ||||
|        - C99 allows the use of (_Bool)0.0 in constant expressions, but | ||||
|          this substitute cannot always provide this property. | ||||
| 
 | ||||
|    Also, it is suggested that programs use 'bool' rather than '_Bool'; | ||||
|    this isn't required, but 'bool' is more common.  */ | ||||
| 
 | ||||
| 
 | ||||
| /* 7.16. Boolean type and values */ | ||||
| 
 | ||||
| /* BeOS <sys/socket.h> already #defines false 0, true 1.  We use the same
 | ||||
|    definitions below, but temporarily we have to #undef them.  */ | ||||
| #if defined __BEOS__ && !defined __HAIKU__ | ||||
| # include <OS.h> /* defines bool but not _Bool */ | ||||
| # undef false | ||||
| # undef true | ||||
| #endif | ||||
| 
 | ||||
| /* For the sake of symbolic names in gdb, we define true and false as
 | ||||
|    enum constants, not only as macros. | ||||
|    It is tempting to write | ||||
|       typedef enum { false = 0, true = 1 } _Bool; | ||||
|    so that gdb prints values of type 'bool' symbolically. But if we do | ||||
|    this, values of type '_Bool' may promote to 'int' or 'unsigned int' | ||||
|    (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' | ||||
|    (see ISO C 99 6.3.1.1.(2)).  So we add a negative value to the | ||||
|    enum; this ensures that '_Bool' promotes to 'int'.  */ | ||||
| #if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__) | ||||
|   /* A compiler known to have 'bool'.  */ | ||||
|   /* If the compiler already has both 'bool' and '_Bool', we can assume they
 | ||||
|      are the same types.  */ | ||||
| # if !@HAVE__BOOL@ | ||||
| typedef bool _Bool; | ||||
| # endif | ||||
| #else | ||||
| # if !defined __GNUC__ | ||||
|    /* If @HAVE__BOOL@:
 | ||||
|         Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when | ||||
|         the built-in _Bool type is used.  See | ||||
|           http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
 | ||||
|           http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
 | ||||
|           http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
 | ||||
|         Similar bugs are likely with other compilers as well; this file | ||||
|         wouldn't be used if <stdbool.h> was working. | ||||
|         So we override the _Bool type. | ||||
|       If !@HAVE__BOOL@: | ||||
|         Need to define _Bool ourselves. As 'signed char' or as an enum type? | ||||
|         Use of a typedef, with SunPRO C, leads to a stupid | ||||
|           "warning: _Bool is a keyword in ISO C99". | ||||
|         Use of an enum type, with IRIX cc, leads to a stupid | ||||
|           "warning(1185): enumerated type mixed with another type". | ||||
|         Even the existence of an enum type, without a typedef, | ||||
|           "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. | ||||
|         The only benefit of the enum, debuggability, is not important | ||||
|         with these compilers.  So use 'signed char' and no enum.  */ | ||||
| #  define _Bool signed char | ||||
| # else | ||||
|    /* With this compiler, trust the _Bool type if the compiler has it.  */ | ||||
| #  if !@HAVE__BOOL@ | ||||
| typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; | ||||
| #  endif | ||||
| # endif | ||||
| #endif | ||||
| #define bool _Bool | ||||
| 
 | ||||
| /* The other macros must be usable in preprocessor directives.  */ | ||||
| #define false 0 | ||||
| #define true 1 | ||||
| #define __bool_true_false_are_defined 1 | ||||
| 
 | ||||
| #endif /* _GL_STDBOOL_H */ | ||||
							
								
								
									
										86
									
								
								grub-core/gnulib/stddef.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								grub-core/gnulib/stddef.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,86 @@ | |||
| /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
 | ||||
| 
 | ||||
|    Copyright (C) 2009, 2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /* Written by Eric Blake.  */ | ||||
| 
 | ||||
| /*
 | ||||
|  * POSIX 2008 <stddef.h> for platforms that have issues. | ||||
|  * <http://www.opengroup.org/susv3xbd/stddef.h.html>
 | ||||
|  */ | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| #if defined __need_wchar_t || defined __need_size_t  \ | ||||
|   || defined __need_ptrdiff_t || defined __need_NULL \ | ||||
|   || defined __need_wint_t | ||||
| /* Special invocation convention inside gcc header files.  In
 | ||||
|    particular, gcc provides a version of <stddef.h> that blindly | ||||
|    redefines NULL even when __need_wint_t was defined, even though | ||||
|    wint_t is not normally provided by <stddef.h>.  Hence, we must | ||||
|    remember if special invocation has ever been used to obtain wint_t, | ||||
|    in which case we need to clean up NULL yet again.  */ | ||||
| 
 | ||||
| # if !(defined _GL_STDDEF_H && defined _GL_STDDEF_WINT_T) | ||||
| #  ifdef __need_wint_t | ||||
| #   undef _GL_STDDEF_H | ||||
| #   define _GL_STDDEF_WINT_T | ||||
| #  endif | ||||
| #  @INCLUDE_NEXT@ @NEXT_STDDEF_H@ | ||||
| # endif | ||||
| 
 | ||||
| #else | ||||
| /* Normal invocation convention.  */ | ||||
| 
 | ||||
| # ifndef _GL_STDDEF_H | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| 
 | ||||
| #  @INCLUDE_NEXT@ @NEXT_STDDEF_H@ | ||||
| 
 | ||||
| #  ifndef _GL_STDDEF_H | ||||
| #   define _GL_STDDEF_H | ||||
| 
 | ||||
| /* On NetBSD 5.0, the definition of NULL lacks proper parentheses.  */ | ||||
| #if @REPLACE_NULL@ | ||||
| # undef NULL | ||||
| # ifdef __cplusplus | ||||
|    /* ISO C++ says that the macro NULL must expand to an integer constant
 | ||||
|       expression, hence '((void *) 0)' is not allowed in C++.  */ | ||||
| #  if __GNUG__ >= 3 | ||||
|     /* GNU C++ has a __null macro that behaves like an integer ('int' or
 | ||||
|        'long') but has the same size as a pointer.  Use that, to avoid | ||||
|        warnings.  */ | ||||
| #   define NULL __null | ||||
| #  else | ||||
| #   define NULL 0L | ||||
| #  endif | ||||
| # else | ||||
| #  define NULL ((void *) 0) | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Some platforms lack wchar_t.  */ | ||||
| #if !@HAVE_WCHAR_T@ | ||||
| # define wchar_t int | ||||
| #endif | ||||
| 
 | ||||
| #  endif /* _GL_STDDEF_H */ | ||||
| # endif /* _GL_STDDEF_H */ | ||||
| #endif /* __need_XXX */ | ||||
							
								
								
									
										568
									
								
								grub-core/gnulib/stdint.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										568
									
								
								grub-core/gnulib/stdint.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,568 @@ | |||
| /* Copyright (C) 2001-2002, 2004-2010 Free Software Foundation, Inc.
 | ||||
|    Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. | ||||
|    This file is part of gnulib. | ||||
| 
 | ||||
|    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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /*
 | ||||
|  * ISO C 99 <stdint.h> for platforms that lack it. | ||||
|  * <http://www.opengroup.org/susv3xbd/stdint.h.html>
 | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _GL_STDINT_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| /* When including a system file that in turn includes <inttypes.h>,
 | ||||
|    use the system <inttypes.h>, not our substitute.  This avoids | ||||
|    problems with (for example) VMS, whose <sys/bitypes.h> includes | ||||
|    <inttypes.h>.  */ | ||||
| #define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H | ||||
| 
 | ||||
| /* Get those types that are already defined in other system include
 | ||||
|    files, so that we can "#define int8_t signed char" below without | ||||
|    worrying about a later system include file containing a "typedef | ||||
|    signed char int8_t;" that will get messed up by our macro.  Our | ||||
|    macros should all be consistent with the system versions, except | ||||
|    for the "fast" types and macros, which we recommend against using | ||||
|    in public interfaces due to compiler differences.  */ | ||||
| 
 | ||||
| #if @HAVE_STDINT_H@ | ||||
| # if defined __sgi && ! defined __c99 | ||||
|    /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
 | ||||
|       with "This header file is to be used only for c99 mode compilations" | ||||
|       diagnostics.  */ | ||||
| #  define __STDINT_H__ | ||||
| # endif | ||||
|   /* Other systems may have an incomplete or buggy <stdint.h>.
 | ||||
|      Include it before <inttypes.h>, since any "#include <stdint.h>" | ||||
|      in <inttypes.h> would reinclude us, skipping our contents because | ||||
|      _GL_STDINT_H is defined. | ||||
|      The include_next requires a split double-inclusion guard.  */ | ||||
| # @INCLUDE_NEXT@ @NEXT_STDINT_H@ | ||||
| #endif | ||||
| 
 | ||||
| #if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H | ||||
| #define _GL_STDINT_H | ||||
| 
 | ||||
| /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
 | ||||
|    IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). | ||||
|    AIX 5.2 <sys/types.h> isn't needed and causes troubles. | ||||
|    MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but | ||||
|    relies on the system <stdint.h> definitions, so include | ||||
|    <sys/types.h> after @NEXT_STDINT_H@.  */ | ||||
| #if @HAVE_SYS_TYPES_H@ && ! defined _AIX | ||||
| # include <sys/types.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Get LONG_MIN, LONG_MAX, ULONG_MAX.  */ | ||||
| #include <limits.h> | ||||
| 
 | ||||
| #if @HAVE_INTTYPES_H@ | ||||
|   /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
 | ||||
|      int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. | ||||
|      <inttypes.h> also defines intptr_t and uintptr_t.  */ | ||||
| # include <inttypes.h> | ||||
| #elif @HAVE_SYS_INTTYPES_H@ | ||||
|   /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
 | ||||
|      the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX.  */ | ||||
| # include <sys/inttypes.h> | ||||
| #endif | ||||
| 
 | ||||
| #if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ | ||||
|   /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
 | ||||
|      int{8,16,32,64}_t and __BIT_TYPES_DEFINED__.  In libc5 >= 5.2.2 it is | ||||
|      included by <sys/types.h>.  */ | ||||
| # include <sys/bitypes.h> | ||||
| #endif | ||||
| 
 | ||||
| #undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H | ||||
| 
 | ||||
| /* Minimum and maximum values for a integer type under the usual assumption.
 | ||||
|    Return an unspecified value if BITS == 0, adding a check to pacify | ||||
|    picky compilers.  */ | ||||
| 
 | ||||
| #define _STDINT_MIN(signed, bits, zero) \ | ||||
|   ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero)) | ||||
| 
 | ||||
| #define _STDINT_MAX(signed, bits, zero) \ | ||||
|   ((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.  */ \ | ||||
|      ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) | ||||
| 
 | ||||
| /* 7.18.1.1. Exact-width integer types */ | ||||
| 
 | ||||
| /* Here we assume a standard architecture where the hardware integer
 | ||||
|    types have 8, 16, 32, optionally 64 bits.  */ | ||||
| 
 | ||||
| #undef int8_t | ||||
| #undef uint8_t | ||||
| typedef signed char gl_int8_t; | ||||
| typedef unsigned char gl_uint8_t; | ||||
| #define int8_t gl_int8_t | ||||
| #define uint8_t gl_uint8_t | ||||
| 
 | ||||
| #undef int16_t | ||||
| #undef uint16_t | ||||
| typedef short int gl_int16_t; | ||||
| typedef unsigned short int gl_uint16_t; | ||||
| #define int16_t gl_int16_t | ||||
| #define uint16_t gl_uint16_t | ||||
| 
 | ||||
| #undef int32_t | ||||
| #undef uint32_t | ||||
| typedef int gl_int32_t; | ||||
| typedef unsigned int gl_uint32_t; | ||||
| #define int32_t gl_int32_t | ||||
| #define uint32_t gl_uint32_t | ||||
| 
 | ||||
| /* Do not undefine int64_t if gnulib is not being used with 64-bit
 | ||||
|    types, since otherwise it breaks platforms like Tandem/NSK.  */ | ||||
| #if LONG_MAX >> 31 >> 31 == 1 | ||||
| # undef int64_t | ||||
| typedef long int gl_int64_t; | ||||
| # define int64_t gl_int64_t | ||||
| # define GL_INT64_T | ||||
| #elif defined _MSC_VER | ||||
| # undef int64_t | ||||
| typedef __int64 gl_int64_t; | ||||
| # define int64_t gl_int64_t | ||||
| # define GL_INT64_T | ||||
| #elif @HAVE_LONG_LONG_INT@ | ||||
| # undef int64_t | ||||
| typedef long long int gl_int64_t; | ||||
| # define int64_t gl_int64_t | ||||
| # define GL_INT64_T | ||||
| #endif | ||||
| 
 | ||||
| #if ULONG_MAX >> 31 >> 31 >> 1 == 1 | ||||
| # undef uint64_t | ||||
| typedef unsigned long int gl_uint64_t; | ||||
| # define uint64_t gl_uint64_t | ||||
| # define GL_UINT64_T | ||||
| #elif defined _MSC_VER | ||||
| # undef uint64_t | ||||
| typedef unsigned __int64 gl_uint64_t; | ||||
| # define uint64_t gl_uint64_t | ||||
| # define GL_UINT64_T | ||||
| #elif @HAVE_UNSIGNED_LONG_LONG_INT@ | ||||
| # undef uint64_t | ||||
| typedef unsigned long long int gl_uint64_t; | ||||
| # define uint64_t gl_uint64_t | ||||
| # define GL_UINT64_T | ||||
| #endif | ||||
| 
 | ||||
| /* Avoid collision with Solaris 2.5.1 <pthread.h> etc.  */ | ||||
| #define _UINT8_T | ||||
| #define _UINT32_T | ||||
| #define _UINT64_T | ||||
| 
 | ||||
| 
 | ||||
| /* 7.18.1.2. Minimum-width integer types */ | ||||
| 
 | ||||
| /* Here we assume a standard architecture where the hardware integer
 | ||||
|    types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types | ||||
|    are the same as the corresponding N_t types.  */ | ||||
| 
 | ||||
| #undef int_least8_t | ||||
| #undef uint_least8_t | ||||
| #undef int_least16_t | ||||
| #undef uint_least16_t | ||||
| #undef int_least32_t | ||||
| #undef uint_least32_t | ||||
| #undef int_least64_t | ||||
| #undef uint_least64_t | ||||
| #define int_least8_t int8_t | ||||
| #define uint_least8_t uint8_t | ||||
| #define int_least16_t int16_t | ||||
| #define uint_least16_t uint16_t | ||||
| #define int_least32_t int32_t | ||||
| #define uint_least32_t uint32_t | ||||
| #ifdef GL_INT64_T | ||||
| # define int_least64_t int64_t | ||||
| #endif | ||||
| #ifdef GL_UINT64_T | ||||
| # define uint_least64_t uint64_t | ||||
| #endif | ||||
| 
 | ||||
| /* 7.18.1.3. Fastest minimum-width integer types */ | ||||
| 
 | ||||
| /* Note: Other <stdint.h> substitutes may define these types differently.
 | ||||
|    It is not recommended to use these types in public header files. */ | ||||
| 
 | ||||
| /* Here we assume a standard architecture where the hardware integer
 | ||||
|    types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types | ||||
|    are taken from the same list of types.  Assume that 'long int' | ||||
|    is fast enough for all narrower integers.  */ | ||||
| 
 | ||||
| #undef int_fast8_t | ||||
| #undef uint_fast8_t | ||||
| #undef int_fast16_t | ||||
| #undef uint_fast16_t | ||||
| #undef int_fast32_t | ||||
| #undef uint_fast32_t | ||||
| #undef int_fast64_t | ||||
| #undef uint_fast64_t | ||||
| typedef long int gl_int_fast8_t; | ||||
| typedef unsigned long int gl_uint_fast8_t; | ||||
| typedef long int gl_int_fast16_t; | ||||
| typedef unsigned long int gl_uint_fast16_t; | ||||
| typedef long int gl_int_fast32_t; | ||||
| typedef unsigned long int gl_uint_fast32_t; | ||||
| #define int_fast8_t gl_int_fast8_t | ||||
| #define uint_fast8_t gl_uint_fast8_t | ||||
| #define int_fast16_t gl_int_fast16_t | ||||
| #define uint_fast16_t gl_uint_fast16_t | ||||
| #define int_fast32_t gl_int_fast32_t | ||||
| #define uint_fast32_t gl_uint_fast32_t | ||||
| #ifdef GL_INT64_T | ||||
| # define int_fast64_t int64_t | ||||
| #endif | ||||
| #ifdef GL_UINT64_T | ||||
| # define uint_fast64_t uint64_t | ||||
| #endif | ||||
| 
 | ||||
| /* 7.18.1.4. Integer types capable of holding object pointers */ | ||||
| 
 | ||||
| #undef intptr_t | ||||
| #undef uintptr_t | ||||
| typedef long int gl_intptr_t; | ||||
| typedef unsigned long int gl_uintptr_t; | ||||
| #define intptr_t gl_intptr_t | ||||
| #define uintptr_t gl_uintptr_t | ||||
| 
 | ||||
| /* 7.18.1.5. Greatest-width integer types */ | ||||
| 
 | ||||
| /* Note: These types are compiler dependent. It may be unwise to use them in
 | ||||
|    public header files. */ | ||||
| 
 | ||||
| #undef intmax_t | ||||
| #if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 | ||||
| typedef long long int gl_intmax_t; | ||||
| # define intmax_t gl_intmax_t | ||||
| #elif defined GL_INT64_T | ||||
| # define intmax_t int64_t | ||||
| #else | ||||
| typedef long int gl_intmax_t; | ||||
| # define intmax_t gl_intmax_t | ||||
| #endif | ||||
| 
 | ||||
| #undef uintmax_t | ||||
| #if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 | ||||
| typedef unsigned long long int gl_uintmax_t; | ||||
| # define uintmax_t gl_uintmax_t | ||||
| #elif defined GL_UINT64_T | ||||
| # define uintmax_t uint64_t | ||||
| #else | ||||
| typedef unsigned long int gl_uintmax_t; | ||||
| # define uintmax_t gl_uintmax_t | ||||
| #endif | ||||
| 
 | ||||
| /* Verify that intmax_t and uintmax_t have the same size.  Too much code
 | ||||
|    breaks if this is not the case.  If this check fails, the reason is likely | ||||
|    to be found in the autoconf macros.  */ | ||||
| typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - 1]; | ||||
| 
 | ||||
| /* 7.18.2. Limits of specified-width integer types */ | ||||
| 
 | ||||
| #if ! defined __cplusplus || defined __STDC_LIMIT_MACROS | ||||
| 
 | ||||
| /* 7.18.2.1. Limits of exact-width integer types */ | ||||
| 
 | ||||
| /* Here we assume a standard architecture where the hardware integer
 | ||||
|    types have 8, 16, 32, optionally 64 bits.  */ | ||||
| 
 | ||||
| #undef INT8_MIN | ||||
| #undef INT8_MAX | ||||
| #undef UINT8_MAX | ||||
| #define INT8_MIN  (~ INT8_MAX) | ||||
| #define INT8_MAX  127 | ||||
| #define UINT8_MAX  255 | ||||
| 
 | ||||
| #undef INT16_MIN | ||||
| #undef INT16_MAX | ||||
| #undef UINT16_MAX | ||||
| #define INT16_MIN  (~ INT16_MAX) | ||||
| #define INT16_MAX  32767 | ||||
| #define UINT16_MAX  65535 | ||||
| 
 | ||||
| #undef INT32_MIN | ||||
| #undef INT32_MAX | ||||
| #undef UINT32_MAX | ||||
| #define INT32_MIN  (~ INT32_MAX) | ||||
| #define INT32_MAX  2147483647 | ||||
| #define UINT32_MAX  4294967295U | ||||
| 
 | ||||
| #undef INT64_MIN | ||||
| #undef INT64_MAX | ||||
| #ifdef GL_INT64_T | ||||
| /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
 | ||||
|    evaluates the latter incorrectly in preprocessor expressions.  */ | ||||
| # define INT64_MIN  (- INTMAX_C (1) << 63) | ||||
| # define INT64_MAX  INTMAX_C (9223372036854775807) | ||||
| #endif | ||||
| 
 | ||||
| #undef UINT64_MAX | ||||
| #ifdef GL_UINT64_T | ||||
| # define UINT64_MAX  UINTMAX_C (18446744073709551615) | ||||
| #endif | ||||
| 
 | ||||
| /* 7.18.2.2. Limits of minimum-width integer types */ | ||||
| 
 | ||||
| /* Here we assume a standard architecture where the hardware integer
 | ||||
|    types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types | ||||
|    are the same as the corresponding N_t types.  */ | ||||
| 
 | ||||
| #undef INT_LEAST8_MIN | ||||
| #undef INT_LEAST8_MAX | ||||
| #undef UINT_LEAST8_MAX | ||||
| #define INT_LEAST8_MIN  INT8_MIN | ||||
| #define INT_LEAST8_MAX  INT8_MAX | ||||
| #define UINT_LEAST8_MAX  UINT8_MAX | ||||
| 
 | ||||
| #undef INT_LEAST16_MIN | ||||
| #undef INT_LEAST16_MAX | ||||
| #undef UINT_LEAST16_MAX | ||||
| #define INT_LEAST16_MIN  INT16_MIN | ||||
| #define INT_LEAST16_MAX  INT16_MAX | ||||
| #define UINT_LEAST16_MAX  UINT16_MAX | ||||
| 
 | ||||
| #undef INT_LEAST32_MIN | ||||
| #undef INT_LEAST32_MAX | ||||
| #undef UINT_LEAST32_MAX | ||||
| #define INT_LEAST32_MIN  INT32_MIN | ||||
| #define INT_LEAST32_MAX  INT32_MAX | ||||
| #define UINT_LEAST32_MAX  UINT32_MAX | ||||
| 
 | ||||
| #undef INT_LEAST64_MIN | ||||
| #undef INT_LEAST64_MAX | ||||
| #ifdef GL_INT64_T | ||||
| # define INT_LEAST64_MIN  INT64_MIN | ||||
| # define INT_LEAST64_MAX  INT64_MAX | ||||
| #endif | ||||
| 
 | ||||
| #undef UINT_LEAST64_MAX | ||||
| #ifdef GL_UINT64_T | ||||
| # define UINT_LEAST64_MAX  UINT64_MAX | ||||
| #endif | ||||
| 
 | ||||
| /* 7.18.2.3. Limits of fastest minimum-width integer types */ | ||||
| 
 | ||||
| /* Here we assume a standard architecture where the hardware integer
 | ||||
|    types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types | ||||
|    are taken from the same list of types.  */ | ||||
| 
 | ||||
| #undef INT_FAST8_MIN | ||||
| #undef INT_FAST8_MAX | ||||
| #undef UINT_FAST8_MAX | ||||
| #define INT_FAST8_MIN  LONG_MIN | ||||
| #define INT_FAST8_MAX  LONG_MAX | ||||
| #define UINT_FAST8_MAX  ULONG_MAX | ||||
| 
 | ||||
| #undef INT_FAST16_MIN | ||||
| #undef INT_FAST16_MAX | ||||
| #undef UINT_FAST16_MAX | ||||
| #define INT_FAST16_MIN  LONG_MIN | ||||
| #define INT_FAST16_MAX  LONG_MAX | ||||
| #define UINT_FAST16_MAX  ULONG_MAX | ||||
| 
 | ||||
| #undef INT_FAST32_MIN | ||||
| #undef INT_FAST32_MAX | ||||
| #undef UINT_FAST32_MAX | ||||
| #define INT_FAST32_MIN  LONG_MIN | ||||
| #define INT_FAST32_MAX  LONG_MAX | ||||
| #define UINT_FAST32_MAX  ULONG_MAX | ||||
| 
 | ||||
| #undef INT_FAST64_MIN | ||||
| #undef INT_FAST64_MAX | ||||
| #ifdef GL_INT64_T | ||||
| # define INT_FAST64_MIN  INT64_MIN | ||||
| # define INT_FAST64_MAX  INT64_MAX | ||||
| #endif | ||||
| 
 | ||||
| #undef UINT_FAST64_MAX | ||||
| #ifdef GL_UINT64_T | ||||
| # define UINT_FAST64_MAX  UINT64_MAX | ||||
| #endif | ||||
| 
 | ||||
| /* 7.18.2.4. Limits of integer types capable of holding object pointers */ | ||||
| 
 | ||||
| #undef INTPTR_MIN | ||||
| #undef INTPTR_MAX | ||||
| #undef UINTPTR_MAX | ||||
| #define INTPTR_MIN  LONG_MIN | ||||
| #define INTPTR_MAX  LONG_MAX | ||||
| #define UINTPTR_MAX  ULONG_MAX | ||||
| 
 | ||||
| /* 7.18.2.5. Limits of greatest-width integer types */ | ||||
| 
 | ||||
| #undef INTMAX_MIN | ||||
| #undef INTMAX_MAX | ||||
| #ifdef INT64_MAX | ||||
| # define INTMAX_MIN  INT64_MIN | ||||
| # define INTMAX_MAX  INT64_MAX | ||||
| #else | ||||
| # define INTMAX_MIN  INT32_MIN | ||||
| # define INTMAX_MAX  INT32_MAX | ||||
| #endif | ||||
| 
 | ||||
| #undef UINTMAX_MAX | ||||
| #ifdef UINT64_MAX | ||||
| # define UINTMAX_MAX  UINT64_MAX | ||||
| #else | ||||
| # define UINTMAX_MAX  UINT32_MAX | ||||
| #endif | ||||
| 
 | ||||
| /* 7.18.3. Limits of other integer types */ | ||||
| 
 | ||||
| /* ptrdiff_t limits */ | ||||
| #undef PTRDIFF_MIN | ||||
| #undef PTRDIFF_MAX | ||||
| #if @APPLE_UNIVERSAL_BUILD@ | ||||
| # ifdef _LP64 | ||||
| #  define PTRDIFF_MIN  _STDINT_MIN (1, 64, 0l) | ||||
| #  define PTRDIFF_MAX  _STDINT_MAX (1, 64, 0l) | ||||
| # else | ||||
| #  define PTRDIFF_MIN  _STDINT_MIN (1, 32, 0) | ||||
| #  define PTRDIFF_MAX  _STDINT_MAX (1, 32, 0) | ||||
| # endif | ||||
| #else | ||||
| # define PTRDIFF_MIN  \ | ||||
|     _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) | ||||
| # define PTRDIFF_MAX  \ | ||||
|     _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) | ||||
| #endif | ||||
| 
 | ||||
| /* sig_atomic_t limits */ | ||||
| #undef SIG_ATOMIC_MIN | ||||
| #undef SIG_ATOMIC_MAX | ||||
| #define SIG_ATOMIC_MIN  \ | ||||
|    _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ | ||||
|                 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@) | ||||
| 
 | ||||
| 
 | ||||
| /* size_t limit */ | ||||
| #undef SIZE_MAX | ||||
| #if @APPLE_UNIVERSAL_BUILD@ | ||||
| # ifdef _LP64 | ||||
| #  define SIZE_MAX  _STDINT_MAX (0, 64, 0ul) | ||||
| # else | ||||
| #  define SIZE_MAX  _STDINT_MAX (0, 32, 0ul) | ||||
| # endif | ||||
| #else | ||||
| # define SIZE_MAX  _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) | ||||
| #endif | ||||
| 
 | ||||
| /* wchar_t limits */ | ||||
| /* Get WCHAR_MIN, WCHAR_MAX.
 | ||||
|    This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested | ||||
|    includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes | ||||
|    <stdint.h> and assumes its types are already defined.  */ | ||||
| #if ! (defined WCHAR_MIN && defined WCHAR_MAX) | ||||
| # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H | ||||
| # include <wchar.h> | ||||
| # undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H | ||||
| #endif | ||||
| #undef WCHAR_MIN | ||||
| #undef WCHAR_MAX | ||||
| #define WCHAR_MIN  \ | ||||
|    _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) | ||||
| #define WCHAR_MAX  \ | ||||
|    _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) | ||||
| 
 | ||||
| /* wint_t limits */ | ||||
| #undef WINT_MIN | ||||
| #undef WINT_MAX | ||||
| #define WINT_MIN  \ | ||||
|    _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) | ||||
| #define WINT_MAX  \ | ||||
|    _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) | ||||
| 
 | ||||
| #endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */ | ||||
| 
 | ||||
| /* 7.18.4. Macros for integer constants */ | ||||
| 
 | ||||
| #if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS | ||||
| 
 | ||||
| /* 7.18.4.1. Macros for minimum-width integer constants */ | ||||
| /* According to ISO C 99 Technical Corrigendum 1 */ | ||||
| 
 | ||||
| /* Here we assume a standard architecture where the hardware integer
 | ||||
|    types have 8, 16, 32, optionally 64 bits, and int is 32 bits.  */ | ||||
| 
 | ||||
| #undef INT8_C | ||||
| #undef UINT8_C | ||||
| #define INT8_C(x) x | ||||
| #define UINT8_C(x) x | ||||
| 
 | ||||
| #undef INT16_C | ||||
| #undef UINT16_C | ||||
| #define INT16_C(x) x | ||||
| #define UINT16_C(x) x | ||||
| 
 | ||||
| #undef INT32_C | ||||
| #undef UINT32_C | ||||
| #define INT32_C(x) x | ||||
| #define UINT32_C(x) x ## U | ||||
| 
 | ||||
| #undef INT64_C | ||||
| #undef UINT64_C | ||||
| #if LONG_MAX >> 31 >> 31 == 1 | ||||
| # define INT64_C(x) x##L | ||||
| #elif defined _MSC_VER | ||||
| # define INT64_C(x) x##i64 | ||||
| #elif @HAVE_LONG_LONG_INT@ | ||||
| # define INT64_C(x) x##LL | ||||
| #endif | ||||
| #if ULONG_MAX >> 31 >> 31 >> 1 == 1 | ||||
| # define UINT64_C(x) x##UL | ||||
| #elif defined _MSC_VER | ||||
| # define UINT64_C(x) x##ui64 | ||||
| #elif @HAVE_UNSIGNED_LONG_LONG_INT@ | ||||
| # define UINT64_C(x) x##ULL | ||||
| #endif | ||||
| 
 | ||||
| /* 7.18.4.2. Macros for greatest-width integer constants */ | ||||
| 
 | ||||
| #undef INTMAX_C | ||||
| #if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 | ||||
| # define INTMAX_C(x)   x##LL | ||||
| #elif defined GL_INT64_T | ||||
| # define INTMAX_C(x)   INT64_C(x) | ||||
| #else | ||||
| # define INTMAX_C(x)   x##L | ||||
| #endif | ||||
| 
 | ||||
| #undef UINTMAX_C | ||||
| #if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 | ||||
| # define UINTMAX_C(x)  x##ULL | ||||
| #elif defined GL_UINT64_T | ||||
| # define UINTMAX_C(x)  UINT64_C(x) | ||||
| #else | ||||
| # define UINTMAX_C(x)  x##UL | ||||
| #endif | ||||
| 
 | ||||
| #endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */ | ||||
| 
 | ||||
| #endif /* _GL_STDINT_H */ | ||||
| #endif /* !defined _GL_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ | ||||
							
								
								
									
										148
									
								
								grub-core/gnulib/stdio-write.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								grub-core/gnulib/stdio-write.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,148 @@ | |||
| /* POSIX compatible FILE stream write function.
 | ||||
|    Copyright (C) 2008-2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2008. | ||||
| 
 | ||||
|    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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| /* Replace these functions only if module 'sigpipe' is requested.  */ | ||||
| #if GNULIB_SIGPIPE | ||||
| 
 | ||||
| /* On native Windows platforms, SIGPIPE does not exist.  When write() is
 | ||||
|    called on a pipe with no readers, WriteFile() fails with error | ||||
|    GetLastError() = ERROR_NO_DATA, and write() in consequence fails with | ||||
|    error EINVAL.  This write() function is at the basis of the function | ||||
|    which flushes the buffer of a FILE stream.  */ | ||||
| 
 | ||||
| # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||||
| 
 | ||||
| #  include <errno.h> | ||||
| #  include <signal.h> | ||||
| #  include <io.h> | ||||
| 
 | ||||
| #  define WIN32_LEAN_AND_MEAN  /* avoid including junk */ | ||||
| #  include <windows.h> | ||||
| 
 | ||||
| #  define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \ | ||||
|   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;                                                             \ | ||||
|     } | ||||
| 
 | ||||
| #  if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ | ||||
| int | ||||
| printf (const char *format, ...) | ||||
| { | ||||
|   int retval; | ||||
|   va_list args; | ||||
| 
 | ||||
|   va_start (args, format); | ||||
|   retval = vfprintf (stdout, format, args); | ||||
|   va_end (args); | ||||
| 
 | ||||
|   return retval; | ||||
| } | ||||
| #  endif | ||||
| 
 | ||||
| #  if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ | ||||
| int | ||||
| fprintf (FILE *stream, const char *format, ...) | ||||
| { | ||||
|   int retval; | ||||
|   va_list args; | ||||
| 
 | ||||
|   va_start (args, format); | ||||
|   retval = vfprintf (stream, format, args); | ||||
|   va_end (args); | ||||
| 
 | ||||
|   return retval; | ||||
| } | ||||
| #  endif | ||||
| 
 | ||||
| #  if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */ | ||||
| int | ||||
| vprintf (const char *format, va_list args) | ||||
| { | ||||
|   return vfprintf (stdout, format, args); | ||||
| } | ||||
| #  endif | ||||
| 
 | ||||
| #  if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */ | ||||
| int | ||||
| vfprintf (FILE *stream, const char *format, va_list args) | ||||
| #undef vfprintf | ||||
| { | ||||
|   CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF) | ||||
| } | ||||
| #  endif | ||||
| 
 | ||||
| int | ||||
| putchar (int c) | ||||
| { | ||||
|   return fputc (c, stdout); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| fputc (int c, FILE *stream) | ||||
| #undef fputc | ||||
| { | ||||
|   CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF) | ||||
| } | ||||
| 
 | ||||
| int | ||||
| fputs (const char *string, FILE *stream) | ||||
| #undef fputs | ||||
| { | ||||
|   CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF) | ||||
| } | ||||
| 
 | ||||
| int | ||||
| puts (const char *string) | ||||
| #undef puts | ||||
| { | ||||
|   FILE *stream = stdout; | ||||
|   CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF) | ||||
| } | ||||
| 
 | ||||
| size_t | ||||
| fwrite (const void *ptr, size_t s, size_t n, FILE *stream) | ||||
| #undef fwrite | ||||
| { | ||||
|   CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n) | ||||
| } | ||||
| 
 | ||||
| # endif | ||||
| #endif | ||||
							
								
								
									
										1071
									
								
								grub-core/gnulib/stdio.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1071
									
								
								grub-core/gnulib/stdio.in.h
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										715
									
								
								grub-core/gnulib/stdlib.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										715
									
								
								grub-core/gnulib/stdlib.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,715 @@ | |||
| /* A GNU-like <stdlib.h>.
 | ||||
| 
 | ||||
|    Copyright (C) 1995, 2001-2004, 2006-2010 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 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/>.  */
 | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| #if defined __need_malloc_and_calloc | ||||
| /* Special invocation convention inside glibc header files.  */ | ||||
| 
 | ||||
| #@INCLUDE_NEXT@ @NEXT_STDLIB_H@ | ||||
| 
 | ||||
| #else | ||||
| /* Normal invocation convention.  */ | ||||
| 
 | ||||
| #ifndef _GL_STDLIB_H | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #@INCLUDE_NEXT@ @NEXT_STDLIB_H@ | ||||
| 
 | ||||
| #ifndef _GL_STDLIB_H | ||||
| #define _GL_STDLIB_H | ||||
| 
 | ||||
| /* NetBSD 5.0 mis-defines NULL.  */ | ||||
| #include <stddef.h> | ||||
| 
 | ||||
| /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.  */ | ||||
| #ifndef WEXITSTATUS | ||||
| # include <sys/wait.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Solaris declares getloadavg() in <sys/loadavg.h>.  */ | ||||
| #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ | ||||
| # include <sys/loadavg.h> | ||||
| #endif | ||||
| 
 | ||||
| /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
 | ||||
|    from <stdlib.h> if _REENTRANT is defined.  Include it always.  */ | ||||
| #if @HAVE_RANDOM_H@ | ||||
| # include <random.h> | ||||
| #endif | ||||
| 
 | ||||
| #if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \ | ||||
|     || defined GNULIB_POSIXCHECK | ||||
| # include <stdint.h> | ||||
| #endif | ||||
| 
 | ||||
| #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.  */ | ||||
| }; | ||||
| #endif | ||||
| 
 | ||||
| #if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) | ||||
| /* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */ | ||||
| /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt.  */ | ||||
| /* But avoid namespace pollution on glibc systems and native Windows.  */ | ||||
| # include <unistd.h> | ||||
| #endif | ||||
| 
 | ||||
| #ifndef __attribute__ | ||||
| # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) | ||||
| #  define __attribute__(Spec)   /* empty */ | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_ARG_NONNULL is copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_WARN_ON_USE is copied here.  */ | ||||
| 
 | ||||
| 
 | ||||
| /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */ | ||||
| #ifndef EXIT_SUCCESS | ||||
| # define EXIT_SUCCESS 0 | ||||
| #endif | ||||
| /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
 | ||||
|    with proper operation of xargs.  */ | ||||
| #ifndef EXIT_FAILURE | ||||
| # define EXIT_FAILURE 1 | ||||
| #elif EXIT_FAILURE != 1 | ||||
| # undef EXIT_FAILURE | ||||
| # define EXIT_FAILURE 1 | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #if @GNULIB__EXIT@ | ||||
| /* Terminate the current process with the given return code, without running
 | ||||
|    the 'atexit' handlers.  */ | ||||
| # if !@HAVE__EXIT@ | ||||
| _GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (_Exit, void, (int status)); | ||||
| _GL_CXXALIASWARN (_Exit); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef _Exit | ||||
| # if HAVE_RAW_DECL__EXIT | ||||
| _GL_WARN_ON_USE (_Exit, "_Exit is unportable - " | ||||
|                  "use gnulib module _Exit for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #if @GNULIB_ATOLL@ | ||||
| /* Parse a signed decimal integer.
 | ||||
|    Returns the value of the integer.  Errors are not detected.  */ | ||||
| # if !@HAVE_ATOLL@ | ||||
| _GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (atoll, long long, (const char *string)); | ||||
| _GL_CXXALIASWARN (atoll); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef atoll | ||||
| # if HAVE_RAW_DECL_ATOLL | ||||
| _GL_WARN_ON_USE (atoll, "atoll is unportable - " | ||||
|                  "use gnulib module atoll for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_CALLOC_POSIX@ | ||||
| # if @REPLACE_CALLOC@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef calloc | ||||
| #   define calloc rpl_calloc | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size)); | ||||
| _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); | ||||
| # else | ||||
| _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (calloc); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef calloc | ||||
| /* Assume calloc is always declared.  */ | ||||
| _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " | ||||
|                  "use gnulib module calloc-posix for portability"); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_CANONICALIZE_FILE_NAME@ | ||||
| # if @REPLACE_CANONICALIZE_FILE_NAME@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define canonicalize_file_name rpl_canonicalize_file_name | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name) | ||||
|                                                   _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); | ||||
| # else | ||||
| #  if !@HAVE_CANONICALIZE_FILE_NAME@ | ||||
| _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) | ||||
|                                                   _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (canonicalize_file_name); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef canonicalize_file_name | ||||
| # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME | ||||
| _GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - " | ||||
|                  "use gnulib module canonicalize-lgpl for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_GETLOADAVG@ | ||||
| /* Store max(NELEM,3) load average numbers in LOADAVG[].
 | ||||
|    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.  */ | ||||
| # if !@HAVE_DECL_GETLOADAVG@ | ||||
| _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) | ||||
|                                    _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); | ||||
| _GL_CXXALIASWARN (getloadavg); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef getloadavg | ||||
| # if HAVE_RAW_DECL_GETLOADAVG | ||||
| _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " | ||||
|                  "use gnulib module getloadavg for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_GETSUBOPT@ | ||||
| /* Assuming *OPTIONP is a comma separated list of elements of the form
 | ||||
|    "token" or "token=value", getsubopt parses the first of these elements. | ||||
|    If the first element refers to a "token" that is member of the given | ||||
|    NULL-terminated array of tokens: | ||||
|      - It replaces the comma with a NUL byte, updates *OPTIONP to point past | ||||
|        the first option and the comma, sets *VALUEP to the value of the | ||||
|        element (or NULL if it doesn't contain an "=" sign), | ||||
|      - It returns the index of the "token" in the given array of tokens. | ||||
|    Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. | ||||
|    For more details see the POSIX:2001 specification. | ||||
|    http://www.opengroup.org/susv3xsh/getsubopt.html */
 | ||||
| # if !@HAVE_GETSUBOPT@ | ||||
| _GL_FUNCDECL_SYS (getsubopt, int, | ||||
|                   (char **optionp, char *const *tokens, char **valuep) | ||||
|                   _GL_ARG_NONNULL ((1, 2, 3))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (getsubopt, int, | ||||
|                   (char **optionp, char *const *tokens, char **valuep)); | ||||
| _GL_CXXALIASWARN (getsubopt); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef getsubopt | ||||
| # if HAVE_RAW_DECL_GETSUBOPT | ||||
| _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - " | ||||
|                  "use gnulib module getsubopt for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_GRANTPT@ | ||||
| /* Change the ownership and access permission of the slave side of the
 | ||||
|    pseudo-terminal whose master side is specified by FD.  */ | ||||
| # if !@HAVE_GRANTPT@ | ||||
| _GL_FUNCDECL_SYS (grantpt, int, (int fd)); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (grantpt, int, (int fd)); | ||||
| _GL_CXXALIASWARN (grantpt); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef grantpt | ||||
| # if HAVE_RAW_DECL_GRANTPT | ||||
| _GL_WARN_ON_USE (ptsname, "grantpt is not portable - " | ||||
|                  "use gnulib module grantpt for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MALLOC_POSIX@ | ||||
| # if @REPLACE_MALLOC@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef malloc | ||||
| #   define malloc rpl_malloc | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (malloc, void *, (size_t size)); | ||||
| _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); | ||||
| # else | ||||
| _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (malloc); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef malloc | ||||
| /* Assume malloc is always declared.  */ | ||||
| _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " | ||||
|                  "use gnulib module malloc-posix for portability"); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MKDTEMP@ | ||||
| /* Create a unique temporary directory from TEMPLATE.
 | ||||
|    The last six characters of TEMPLATE must be "XXXXXX"; | ||||
|    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.  */ | ||||
| # if !@HAVE_MKDTEMP@ | ||||
| _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); | ||||
| _GL_CXXALIASWARN (mkdtemp); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mkdtemp | ||||
| # if HAVE_RAW_DECL_MKDTEMP | ||||
| _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " | ||||
|                  "use gnulib module mkdtemp for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MKOSTEMP@ | ||||
| /* Create a unique temporary file from TEMPLATE.
 | ||||
|    The last six characters of TEMPLATE must be "XXXXXX"; | ||||
|    they are replaced with a string that makes the file name unique. | ||||
|    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | ||||
|    and O_TEXT, O_BINARY (defined in "binary-io.h"). | ||||
|    The file is then created, with the specified flags, ensuring it didn't exist | ||||
|    before. | ||||
|    The file is created read-write (mask at least 0600 & ~umask), but it may be | ||||
|    world-readable and world-writable (mask 0666 & ~umask), depending on the | ||||
|    implementation. | ||||
|    Returns the open file descriptor if successful, otherwise -1 and errno | ||||
|    set.  */ | ||||
| # if !@HAVE_MKOSTEMP@ | ||||
| _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) | ||||
|                                  _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); | ||||
| _GL_CXXALIASWARN (mkostemp); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mkostemp | ||||
| # if HAVE_RAW_DECL_MKOSTEMP | ||||
| _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " | ||||
|                  "use gnulib module mkostemp for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MKOSTEMPS@ | ||||
| /* Create a unique temporary file from TEMPLATE.
 | ||||
|    The last six characters of TEMPLATE before a suffix of length | ||||
|    SUFFIXLEN must be "XXXXXX"; | ||||
|    they are replaced with a string that makes the file name unique. | ||||
|    The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | ||||
|    and O_TEXT, O_BINARY (defined in "binary-io.h"). | ||||
|    The file is then created, with the specified flags, ensuring it didn't exist | ||||
|    before. | ||||
|    The file is created read-write (mask at least 0600 & ~umask), but it may be | ||||
|    world-readable and world-writable (mask 0666 & ~umask), depending on the | ||||
|    implementation. | ||||
|    Returns the open file descriptor if successful, otherwise -1 and errno | ||||
|    set.  */ | ||||
| # if !@HAVE_MKOSTEMPS@ | ||||
| _GL_FUNCDECL_SYS (mkostemps, int, | ||||
|                   (char * /*template*/, int /*suffixlen*/, int /*flags*/) | ||||
|                   _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (mkostemps, int, | ||||
|                   (char * /*template*/, int /*suffixlen*/, int /*flags*/)); | ||||
| _GL_CXXALIASWARN (mkostemps); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mkostemps | ||||
| # if HAVE_RAW_DECL_MKOSTEMPS | ||||
| _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " | ||||
|                  "use gnulib module mkostemps for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MKSTEMP@ | ||||
| /* Create a unique temporary file from TEMPLATE.
 | ||||
|    The last six characters of TEMPLATE must be "XXXXXX"; | ||||
|    they are replaced with a string that makes the file name unique. | ||||
|    The file is then created, ensuring it didn't exist before. | ||||
|    The file is created read-write (mask at least 0600 & ~umask), but it may be | ||||
|    world-readable and world-writable (mask 0666 & ~umask), depending on the | ||||
|    implementation. | ||||
|    Returns the open file descriptor if successful, otherwise -1 and errno | ||||
|    set.  */ | ||||
| # if @REPLACE_MKSTEMP@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define mkstemp rpl_mkstemp | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); | ||||
| # else | ||||
| #  if ! @HAVE_MKSTEMP@ | ||||
| _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mkstemp); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mkstemp | ||||
| # if HAVE_RAW_DECL_MKSTEMP | ||||
| _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " | ||||
|                  "use gnulib module mkstemp for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MKSTEMPS@ | ||||
| /* Create a unique temporary file from TEMPLATE.
 | ||||
|    The last six characters of TEMPLATE prior to a suffix of length | ||||
|    SUFFIXLEN must be "XXXXXX"; | ||||
|    they are replaced with a string that makes the file name unique. | ||||
|    The file is then created, ensuring it didn't exist before. | ||||
|    The file is created read-write (mask at least 0600 & ~umask), but it may be | ||||
|    world-readable and world-writable (mask 0666 & ~umask), depending on the | ||||
|    implementation. | ||||
|    Returns the open file descriptor if successful, otherwise -1 and errno | ||||
|    set.  */ | ||||
| # if !@HAVE_MKSTEMPS@ | ||||
| _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) | ||||
|                                  _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); | ||||
| _GL_CXXALIASWARN (mkstemps); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mkstemps | ||||
| # if HAVE_RAW_DECL_MKSTEMPS | ||||
| _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " | ||||
|                  "use gnulib module mkstemps for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_PTSNAME@ | ||||
| /* Return the pathname of the pseudo-terminal slave associated with
 | ||||
|    the master FD is open on, or NULL on errors.  */ | ||||
| # if !@HAVE_PTSNAME@ | ||||
| _GL_FUNCDECL_SYS (ptsname, char *, (int fd)); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (ptsname, char *, (int fd)); | ||||
| _GL_CXXALIASWARN (ptsname); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef ptsname | ||||
| # if HAVE_RAW_DECL_PTSNAME | ||||
| _GL_WARN_ON_USE (ptsname, "ptsname is not portable - " | ||||
|                  "use gnulib module ptsname for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_PUTENV@ | ||||
| # if @REPLACE_PUTENV@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef putenv | ||||
| #   define putenv rpl_putenv | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (putenv, int, (char *string)); | ||||
| # else | ||||
| _GL_CXXALIAS_SYS (putenv, int, (char *string)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (putenv); | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #if @GNULIB_RANDOM_R@ | ||||
| # if !@HAVE_RANDOM_R@ | ||||
| #  ifndef RAND_MAX | ||||
| #   define RAND_MAX 2147483647 | ||||
| #  endif | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_RANDOM_R@ | ||||
| # if !@HAVE_RANDOM_R@ | ||||
| _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) | ||||
|                                  _GL_ARG_NONNULL ((1, 2))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); | ||||
| _GL_CXXALIASWARN (random_r); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef random_r | ||||
| # if HAVE_RAW_DECL_RANDOM_R | ||||
| _GL_WARN_ON_USE (random_r, "random_r is unportable - " | ||||
|                  "use gnulib module random_r for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_RANDOM_R@ | ||||
| # if !@HAVE_RANDOM_R@ | ||||
| _GL_FUNCDECL_SYS (srandom_r, int, | ||||
|                   (unsigned int seed, struct random_data *rand_state) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (srandom_r, int, | ||||
|                   (unsigned int seed, struct random_data *rand_state)); | ||||
| _GL_CXXALIASWARN (srandom_r); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef srandom_r | ||||
| # if HAVE_RAW_DECL_SRANDOM_R | ||||
| _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " | ||||
|                  "use gnulib module random_r for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_RANDOM_R@ | ||||
| # if !@HAVE_RANDOM_R@ | ||||
| _GL_FUNCDECL_SYS (initstate_r, int, | ||||
|                   (unsigned int seed, char *buf, size_t buf_size, | ||||
|                    struct random_data *rand_state) | ||||
|                   _GL_ARG_NONNULL ((2, 4))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (initstate_r, int, | ||||
|                   (unsigned int seed, char *buf, size_t buf_size, | ||||
|                    struct random_data *rand_state)); | ||||
| _GL_CXXALIASWARN (initstate_r); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef initstate_r | ||||
| # if HAVE_RAW_DECL_INITSTATE_R | ||||
| _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " | ||||
|                  "use gnulib module random_r for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_RANDOM_R@ | ||||
| # if !@HAVE_RANDOM_R@ | ||||
| _GL_FUNCDECL_SYS (setstate_r, int, | ||||
|                   (char *arg_state, struct random_data *rand_state) | ||||
|                   _GL_ARG_NONNULL ((1, 2))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (setstate_r, int, | ||||
|                   (char *arg_state, struct random_data *rand_state)); | ||||
| _GL_CXXALIASWARN (setstate_r); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef setstate_r | ||||
| # if HAVE_RAW_DECL_SETSTATE_R | ||||
| _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " | ||||
|                  "use gnulib module random_r for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #if @GNULIB_REALLOC_POSIX@ | ||||
| # if @REPLACE_REALLOC@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef realloc | ||||
| #   define realloc rpl_realloc | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); | ||||
| _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); | ||||
| # else | ||||
| _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (realloc); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef realloc | ||||
| /* Assume realloc is always declared.  */ | ||||
| _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " | ||||
|                  "use gnulib module realloc-posix for portability"); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_REALPATH@ | ||||
| # if @REPLACE_REALPATH@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define realpath rpl_realpath | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved) | ||||
|                                     _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved)); | ||||
| # else | ||||
| #  if !@HAVE_REALPATH@ | ||||
| _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved) | ||||
|                                     _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (realpath); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef realpath | ||||
| # if HAVE_RAW_DECL_REALPATH | ||||
| _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " | ||||
|                  "canonicalize or canonicalize-lgpl for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_RPMATCH@ | ||||
| /* Test a user response to a question.
 | ||||
|    Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear.  */ | ||||
| # if !@HAVE_RPMATCH@ | ||||
| _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); | ||||
| _GL_CXXALIASWARN (rpmatch); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef rpmatch | ||||
| # if HAVE_RAW_DECL_RPMATCH | ||||
| _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " | ||||
|                  "use gnulib module rpmatch for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_SETENV@ | ||||
| /* Set NAME to VALUE in the environment.
 | ||||
|    If REPLACE is nonzero, overwrite an existing value.  */ | ||||
| # if @REPLACE_SETENV@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef setenv | ||||
| #   define setenv rpl_setenv | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (setenv, int, | ||||
|                   (const char *name, const char *value, int replace) | ||||
|                   _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (setenv, int, | ||||
|                   (const char *name, const char *value, int replace)); | ||||
| # else | ||||
| #  if !@HAVE_SETENV@ | ||||
| _GL_FUNCDECL_SYS (setenv, int, | ||||
|                   (const char *name, const char *value, int replace) | ||||
|                   _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (setenv, int, | ||||
|                   (const char *name, const char *value, int replace)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (setenv); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef setenv | ||||
| # if HAVE_RAW_DECL_SETENV | ||||
| _GL_WARN_ON_USE (setenv, "setenv is unportable - " | ||||
|                  "use gnulib module setenv for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_STRTOD@ | ||||
|  /* Parse a double from STRING, updating ENDP if appropriate.  */ | ||||
| # if @REPLACE_STRTOD@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define strtod rpl_strtod | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp) | ||||
|                                   _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp)); | ||||
| # else | ||||
| #  if !@HAVE_STRTOD@ | ||||
| _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) | ||||
|                                   _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (strtod); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strtod | ||||
| # if HAVE_RAW_DECL_STRTOD | ||||
| _GL_WARN_ON_USE (strtod, "strtod is unportable - " | ||||
|                  "use gnulib module strtod for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_STRTOLL@ | ||||
| /* Parse a signed integer whose textual representation starts at STRING.
 | ||||
|    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, | ||||
|    it may be decimal or octal (with prefix "0") or hexadecimal (with prefix | ||||
|    "0x"). | ||||
|    If ENDPTR is not NULL, the address of the first byte after the integer is | ||||
|    stored in *ENDPTR. | ||||
|    Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set | ||||
|    to ERANGE.  */ | ||||
| # if !@HAVE_STRTOLL@ | ||||
| _GL_FUNCDECL_SYS (strtoll, long long, | ||||
|                   (const char *string, char **endptr, int base) | ||||
|                   _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (strtoll, long long, | ||||
|                   (const char *string, char **endptr, int base)); | ||||
| _GL_CXXALIASWARN (strtoll); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strtoll | ||||
| # if HAVE_RAW_DECL_STRTOLL | ||||
| _GL_WARN_ON_USE (strtoll, "strtoll is unportable - " | ||||
|                  "use gnulib module strtoll for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_STRTOULL@ | ||||
| /* Parse an unsigned integer whose textual representation starts at STRING.
 | ||||
|    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, | ||||
|    it may be decimal or octal (with prefix "0") or hexadecimal (with prefix | ||||
|    "0x"). | ||||
|    If ENDPTR is not NULL, the address of the first byte after the integer is | ||||
|    stored in *ENDPTR. | ||||
|    Upon overflow, the return value is ULLONG_MAX, and errno is set to | ||||
|    ERANGE.  */ | ||||
| # if !@HAVE_STRTOULL@ | ||||
| _GL_FUNCDECL_SYS (strtoull, unsigned long long, | ||||
|                   (const char *string, char **endptr, int base) | ||||
|                   _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (strtoull, unsigned long long, | ||||
|                   (const char *string, char **endptr, int base)); | ||||
| _GL_CXXALIASWARN (strtoull); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strtoull | ||||
| # if HAVE_RAW_DECL_STRTOULL | ||||
| _GL_WARN_ON_USE (strtoull, "strtoull is unportable - " | ||||
|                  "use gnulib module strtoull for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_UNLOCKPT@ | ||||
| /* Unlock the slave side of the pseudo-terminal whose master side is specified
 | ||||
|    by FD, so that it can be opened.  */ | ||||
| # if !@HAVE_UNLOCKPT@ | ||||
| _GL_FUNCDECL_SYS (unlockpt, int, (int fd)); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (unlockpt, int, (int fd)); | ||||
| _GL_CXXALIASWARN (unlockpt); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef unlockpt | ||||
| # if HAVE_RAW_DECL_UNLOCKPT | ||||
| _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " | ||||
|                  "use gnulib module unlockpt for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_UNSETENV@ | ||||
| /* Remove the variable NAME from the environment.  */ | ||||
| # if @REPLACE_UNSETENV@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef unsetenv | ||||
| #   define unsetenv rpl_unsetenv | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); | ||||
| # else | ||||
| #  if !@HAVE_UNSETENV@ | ||||
| _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (unsetenv); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef unsetenv | ||||
| # if HAVE_RAW_DECL_UNSETENV | ||||
| _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " | ||||
|                  "use gnulib module unsetenv for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #endif /* _GL_STDLIB_H */ | ||||
| #endif /* _GL_STDLIB_H */ | ||||
| #endif | ||||
							
								
								
									
										63
									
								
								grub-core/gnulib/strcasecmp.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								grub-core/gnulib/strcasecmp.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,63 @@ | |||
| /* Case-insensitive string comparison function.
 | ||||
|    Copyright (C) 1998-1999, 2005-2007, 2009-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <string.h> | ||||
| 
 | ||||
| #include <ctype.h> | ||||
| #include <limits.h> | ||||
| 
 | ||||
| #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) | ||||
| 
 | ||||
| /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
 | ||||
|    greater than zero if S1 is lexicographically less than, equal to or greater | ||||
|    than S2. | ||||
|    Note: This function does not work with multibyte strings!  */ | ||||
| 
 | ||||
| int | ||||
| strcasecmp (const char *s1, const char *s2) | ||||
| { | ||||
|   const unsigned char *p1 = (const unsigned char *) s1; | ||||
|   const unsigned char *p2 = (const unsigned char *) s2; | ||||
|   unsigned char c1, c2; | ||||
| 
 | ||||
|   if (p1 == p2) | ||||
|     return 0; | ||||
| 
 | ||||
|   do | ||||
|     { | ||||
|       c1 = TOLOWER (*p1); | ||||
|       c2 = TOLOWER (*p2); | ||||
| 
 | ||||
|       if (c1 == '\0') | ||||
|         break; | ||||
| 
 | ||||
|       ++p1; | ||||
|       ++p2; | ||||
|     } | ||||
|   while (c1 == c2); | ||||
| 
 | ||||
|   if (UCHAR_MAX <= INT_MAX) | ||||
|     return c1 - c2; | ||||
|   else | ||||
|     /* On machines where 'char' and 'int' are types of the same size, the
 | ||||
|        difference of two 'unsigned char' values - including the sign bit - | ||||
|        doesn't fit in an 'int'.  */ | ||||
|     return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); | ||||
| } | ||||
							
								
								
									
										142
									
								
								grub-core/gnulib/strchrnul.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								grub-core/gnulib/strchrnul.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,142 @@ | |||
| /* Searching in a string.
 | ||||
|    Copyright (C) 2003, 2007, 2008, 2009, 2010 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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <string.h> | ||||
| 
 | ||||
| /* Find the first occurrence of C in S or the final NUL byte.  */ | ||||
| char * | ||||
| strchrnul (const char *s, int c_in) | ||||
| { | ||||
|   /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
 | ||||
|      long instead of a 64-bit uintmax_t tends to give better | ||||
|      performance.  On 64-bit hardware, unsigned long is generally 64 | ||||
|      bits already.  Change this typedef to experiment with | ||||
|      performance.  */ | ||||
|   typedef unsigned long int longword; | ||||
| 
 | ||||
|   const unsigned char *char_ptr; | ||||
|   const longword *longword_ptr; | ||||
|   longword repeated_one; | ||||
|   longword repeated_c; | ||||
|   unsigned char c; | ||||
| 
 | ||||
|   c = (unsigned char) c_in; | ||||
|   if (!c) | ||||
|     return rawmemchr (s, 0); | ||||
| 
 | ||||
|   /* Handle the first few bytes by reading one byte at a time.
 | ||||
|      Do this until CHAR_PTR is aligned on a longword boundary.  */ | ||||
|   for (char_ptr = (const unsigned char *) s; | ||||
|        (size_t) char_ptr % sizeof (longword) != 0; | ||||
|        ++char_ptr) | ||||
|     if (!*char_ptr || *char_ptr == c) | ||||
|       return (char *) char_ptr; | ||||
| 
 | ||||
|   longword_ptr = (const longword *) char_ptr; | ||||
| 
 | ||||
|   /* All these elucidatory comments refer to 4-byte longwords,
 | ||||
|      but the theory applies equally well to any size longwords.  */ | ||||
| 
 | ||||
|   /* Compute auxiliary longword values:
 | ||||
|      repeated_one is a value which has a 1 in every byte. | ||||
|      repeated_c has c in every byte.  */ | ||||
|   repeated_one = 0x01010101; | ||||
|   repeated_c = c | (c << 8); | ||||
|   repeated_c |= repeated_c << 16; | ||||
|   if (0xffffffffU < (longword) -1) | ||||
|     { | ||||
|       repeated_one |= repeated_one << 31 << 1; | ||||
|       repeated_c |= repeated_c << 31 << 1; | ||||
|       if (8 < sizeof (longword)) | ||||
|         { | ||||
|           size_t 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 longword at a time.  The tricky part is testing if *any of | ||||
|      the four* bytes in the longword in question are equal to NUL or | ||||
|      c.  We first use an xor with repeated_c.  This reduces the task | ||||
|      to testing whether *any of the four* bytes in longword1 or | ||||
|      longword2 is zero. | ||||
| 
 | ||||
|      Let's consider longword1.  We compute tmp = | ||||
|        ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). | ||||
|      That is, we perform the following operations: | ||||
|        1. Subtract repeated_one. | ||||
|        2. & ~longword1. | ||||
|        3. & a mask consisting of 0x80 in every byte. | ||||
|      Consider what happens in each byte: | ||||
|        - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, | ||||
|          and step 3 transforms it into 0x80.  A carry can also be propagated | ||||
|          to more significant bytes. | ||||
|        - If a byte of longword1 is nonzero, let its lowest 1 bit be at | ||||
|          position k (0 <= k <= 7); so the lowest k bits are 0.  After step 1, | ||||
|          the byte ends in a single bit of value 0 and k bits of value 1. | ||||
|          After step 2, the result is just k bits of value 1: 2^k - 1.  After | ||||
|          step 3, the result is 0.  And no carry is produced. | ||||
|      So, if longword1 has only non-zero bytes, tmp is zero. | ||||
|      Whereas if longword1 has a zero byte, call j the position of the least | ||||
|      significant zero byte.  Then the result has a zero at positions 0, ..., | ||||
|      j-1 and a 0x80 at position j.  We cannot predict the result at the more | ||||
|      significant bytes (positions j+1..3), but it does not matter since we | ||||
|      already have a non-zero bit at position 8*j+7. | ||||
| 
 | ||||
|      The test whether any byte in longword1 or longword2 is zero is equivalent | ||||
|      to testing whether tmp1 is nonzero or tmp2 is nonzero.  We can combine | ||||
|      this into a single test, whether (tmp1 | tmp2) is nonzero. | ||||
| 
 | ||||
|      This test can read more than one byte beyond the end of a string, | ||||
|      depending on where the terminating NUL is encountered.  However, | ||||
|      this is considered safe since the initialization phase ensured | ||||
|      that the read will be aligned, therefore, the read will not cross | ||||
|      page boundaries and will not cause a fault.  */ | ||||
| 
 | ||||
|   while (1) | ||||
|     { | ||||
|       longword longword1 = *longword_ptr ^ repeated_c; | ||||
|       longword longword2 = *longword_ptr; | ||||
| 
 | ||||
|       if (((((longword1 - repeated_one) & ~longword1) | ||||
|             | ((longword2 - repeated_one) & ~longword2)) | ||||
|            & (repeated_one << 7)) != 0) | ||||
|         break; | ||||
|       longword_ptr++; | ||||
|     } | ||||
| 
 | ||||
|   char_ptr = (const unsigned char *) longword_ptr; | ||||
| 
 | ||||
|   /* At this point, we know that one of the sizeof (longword) bytes
 | ||||
|      starting at char_ptr is == 0 or == c.  On little-endian machines, | ||||
|      we could determine the first such byte without any further memory | ||||
|      accesses, just by looking at the tmp result from the last loop | ||||
|      iteration.  But this does not work on big-endian machines. | ||||
|      Choose code that works in both cases.  */ | ||||
| 
 | ||||
|   char_ptr = (unsigned char *) longword_ptr; | ||||
|   while (*char_ptr && (*char_ptr != c)) | ||||
|     char_ptr++; | ||||
|   return (char *) char_ptr; | ||||
| } | ||||
							
								
								
									
										12
									
								
								grub-core/gnulib/strchrnul.valgrind
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								grub-core/gnulib/strchrnul.valgrind
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | |||
| # Suppress a valgrind message about use of uninitialized memory in strchrnul(). | ||||
| # This use is OK because it provides only a speedup. | ||||
| { | ||||
|     strchrnul-value4 | ||||
|     Memcheck:Value4 | ||||
|     fun:strchrnul | ||||
| } | ||||
| { | ||||
|     strchrnul-value8 | ||||
|     Memcheck:Value8 | ||||
|     fun:strchrnul | ||||
| } | ||||
							
								
								
									
										176
									
								
								grub-core/gnulib/streq.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										176
									
								
								grub-core/gnulib/streq.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,176 @@ | |||
| /* Optimized string comparison.
 | ||||
|    Copyright (C) 2001-2002, 2007, 2009-2010 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/>.  */
 | ||||
| 
 | ||||
| /* Written by Bruno Haible <bruno@clisp.org>.  */ | ||||
| 
 | ||||
| #ifndef _GL_STREQ_H | ||||
| #define _GL_STREQ_H | ||||
| 
 | ||||
| #include <string.h> | ||||
| 
 | ||||
| /* STREQ allows to optimize string comparison with a small literal string.
 | ||||
|      STREQ (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) | ||||
|    is semantically equivalent to | ||||
|      strcmp (s, "EUC-KR") == 0 | ||||
|    just faster.  */ | ||||
| 
 | ||||
| /* Help GCC to generate good code for string comparisons with
 | ||||
|    immediate strings. */ | ||||
| #if defined (__GNUC__) && defined (__OPTIMIZE__) | ||||
| 
 | ||||
| static inline int | ||||
| streq9 (const char *s1, const char *s2) | ||||
| { | ||||
|   return strcmp (s1 + 9, s2 + 9) == 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq8 (const char *s1, const char *s2, char s28) | ||||
| { | ||||
|   if (s1[8] == s28) | ||||
|     { | ||||
|       if (s28 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq9 (s1, s2); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq7 (const char *s1, const char *s2, char s27, char s28) | ||||
| { | ||||
|   if (s1[7] == s27) | ||||
|     { | ||||
|       if (s27 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq8 (s1, s2, s28); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq6 (const char *s1, const char *s2, char s26, char s27, char s28) | ||||
| { | ||||
|   if (s1[6] == s26) | ||||
|     { | ||||
|       if (s26 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq7 (s1, s2, s27, s28); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28) | ||||
| { | ||||
|   if (s1[5] == s25) | ||||
|     { | ||||
|       if (s25 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq6 (s1, s2, s26, s27, s28); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28) | ||||
| { | ||||
|   if (s1[4] == s24) | ||||
|     { | ||||
|       if (s24 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq5 (s1, s2, s25, s26, s27, s28); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28) | ||||
| { | ||||
|   if (s1[3] == s23) | ||||
|     { | ||||
|       if (s23 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq4 (s1, s2, s24, s25, s26, s27, s28); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28) | ||||
| { | ||||
|   if (s1[2] == s22) | ||||
|     { | ||||
|       if (s22 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq3 (s1, s2, s23, s24, s25, s26, s27, s28); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) | ||||
| { | ||||
|   if (s1[1] == s21) | ||||
|     { | ||||
|       if (s21 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28) | ||||
| { | ||||
|   if (s1[0] == s20) | ||||
|     { | ||||
|       if (s20 == 0) | ||||
|         return 1; | ||||
|       else | ||||
|         return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28); | ||||
|     } | ||||
|   else | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| #define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ | ||||
|   streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28) | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| #define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ | ||||
|   (strcmp (s1, s2) == 0) | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _GL_STREQ_H */ | ||||
							
								
								
									
										350
									
								
								grub-core/gnulib/strerror.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										350
									
								
								grub-core/gnulib/strerror.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,350 @@ | |||
| /* strerror.c --- POSIX compatible system error routine
 | ||||
| 
 | ||||
|    Copyright (C) 2007-2010 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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| #include <string.h> | ||||
| 
 | ||||
| #if REPLACE_STRERROR | ||||
| 
 | ||||
| # include <errno.h> | ||||
| # include <stdio.h> | ||||
| 
 | ||||
| # if GNULIB_defined_ESOCK /* native Windows platforms */ | ||||
| #  if HAVE_WINSOCK2_H | ||||
| #   include <winsock2.h> | ||||
| #  endif | ||||
| # endif | ||||
| 
 | ||||
| # include "intprops.h" | ||||
| 
 | ||||
| /* Use the system functions, not the gnulib overrides in this file.  */ | ||||
| # undef sprintf | ||||
| 
 | ||||
| # undef strerror | ||||
| # if ! HAVE_DECL_STRERROR | ||||
| #  define strerror(n) NULL | ||||
| # endif | ||||
| 
 | ||||
| char * | ||||
| rpl_strerror (int n) | ||||
| { | ||||
|   char const *msg = NULL; | ||||
|   /* These error messages are taken from glibc/sysdeps/gnu/errlist.c.  */ | ||||
|   switch (n) | ||||
|     { | ||||
| # if GNULIB_defined_ETXTBSY | ||||
|     case ETXTBSY: | ||||
|       msg = "Text file busy"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_ESOCK /* native Windows platforms */ | ||||
|     /* EWOULDBLOCK is the same as EAGAIN.  */ | ||||
|     case EINPROGRESS: | ||||
|       msg = "Operation now in progress"; | ||||
|       break; | ||||
|     case EALREADY: | ||||
|       msg = "Operation already in progress"; | ||||
|       break; | ||||
|     case ENOTSOCK: | ||||
|       msg = "Socket operation on non-socket"; | ||||
|       break; | ||||
|     case EDESTADDRREQ: | ||||
|       msg = "Destination address required"; | ||||
|       break; | ||||
|     case EMSGSIZE: | ||||
|       msg = "Message too long"; | ||||
|       break; | ||||
|     case EPROTOTYPE: | ||||
|       msg = "Protocol wrong type for socket"; | ||||
|       break; | ||||
|     case ENOPROTOOPT: | ||||
|       msg = "Protocol not available"; | ||||
|       break; | ||||
|     case EPROTONOSUPPORT: | ||||
|       msg = "Protocol not supported"; | ||||
|       break; | ||||
|     case ESOCKTNOSUPPORT: | ||||
|       msg = "Socket type not supported"; | ||||
|       break; | ||||
|     case EOPNOTSUPP: | ||||
|       msg = "Operation not supported"; | ||||
|       break; | ||||
|     case EPFNOSUPPORT: | ||||
|       msg = "Protocol family not supported"; | ||||
|       break; | ||||
|     case EAFNOSUPPORT: | ||||
|       msg = "Address family not supported by protocol"; | ||||
|       break; | ||||
|     case EADDRINUSE: | ||||
|       msg = "Address already in use"; | ||||
|       break; | ||||
|     case EADDRNOTAVAIL: | ||||
|       msg = "Cannot assign requested address"; | ||||
|       break; | ||||
|     case ENETDOWN: | ||||
|       msg = "Network is down"; | ||||
|       break; | ||||
|     case ENETUNREACH: | ||||
|       msg = "Network is unreachable"; | ||||
|       break; | ||||
|     case ENETRESET: | ||||
|       msg = "Network dropped connection on reset"; | ||||
|       break; | ||||
|     case ECONNABORTED: | ||||
|       msg = "Software caused connection abort"; | ||||
|       break; | ||||
|     case ECONNRESET: | ||||
|       msg = "Connection reset by peer"; | ||||
|       break; | ||||
|     case ENOBUFS: | ||||
|       msg = "No buffer space available"; | ||||
|       break; | ||||
|     case EISCONN: | ||||
|       msg = "Transport endpoint is already connected"; | ||||
|       break; | ||||
|     case ENOTCONN: | ||||
|       msg = "Transport endpoint is not connected"; | ||||
|       break; | ||||
|     case ESHUTDOWN: | ||||
|       msg = "Cannot send after transport endpoint shutdown"; | ||||
|       break; | ||||
|     case ETOOMANYREFS: | ||||
|       msg = "Too many references: cannot splice"; | ||||
|       break; | ||||
|     case ETIMEDOUT: | ||||
|       msg = "Connection timed out"; | ||||
|       break; | ||||
|     case ECONNREFUSED: | ||||
|       msg = "Connection refused"; | ||||
|       break; | ||||
|     case ELOOP: | ||||
|       msg = "Too many levels of symbolic links"; | ||||
|       break; | ||||
|     case EHOSTDOWN: | ||||
|       msg = "Host is down"; | ||||
|       break; | ||||
|     case EHOSTUNREACH: | ||||
|       msg = "No route to host"; | ||||
|       break; | ||||
|     case EPROCLIM: | ||||
|       msg = "Too many processes"; | ||||
|       break; | ||||
|     case EUSERS: | ||||
|       msg = "Too many users"; | ||||
|       break; | ||||
|     case EDQUOT: | ||||
|       msg = "Disk quota exceeded"; | ||||
|       break; | ||||
|     case ESTALE: | ||||
|       msg = "Stale NFS file handle"; | ||||
|       break; | ||||
|     case EREMOTE: | ||||
|       msg = "Object is remote"; | ||||
|       break; | ||||
| #  if HAVE_WINSOCK2_H | ||||
|     /* WSA_INVALID_HANDLE maps to EBADF */ | ||||
|     /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ | ||||
|     /* WSA_INVALID_PARAMETER maps to EINVAL */ | ||||
|     case WSA_OPERATION_ABORTED: | ||||
|       msg = "Overlapped operation aborted"; | ||||
|       break; | ||||
|     case WSA_IO_INCOMPLETE: | ||||
|       msg = "Overlapped I/O event object not in signaled state"; | ||||
|       break; | ||||
|     case WSA_IO_PENDING: | ||||
|       msg = "Overlapped operations will complete later"; | ||||
|       break; | ||||
|     /* WSAEINTR maps to EINTR */ | ||||
|     /* WSAEBADF maps to EBADF */ | ||||
|     /* WSAEACCES maps to EACCES */ | ||||
|     /* WSAEFAULT maps to EFAULT */ | ||||
|     /* WSAEINVAL maps to EINVAL */ | ||||
|     /* WSAEMFILE maps to EMFILE */ | ||||
|     /* WSAEWOULDBLOCK maps to EWOULDBLOCK */ | ||||
|     /* WSAEINPROGRESS is EINPROGRESS */ | ||||
|     /* WSAEALREADY is EALREADY */ | ||||
|     /* WSAENOTSOCK is ENOTSOCK */ | ||||
|     /* WSAEDESTADDRREQ is EDESTADDRREQ */ | ||||
|     /* WSAEMSGSIZE is EMSGSIZE */ | ||||
|     /* WSAEPROTOTYPE is EPROTOTYPE */ | ||||
|     /* WSAENOPROTOOPT is ENOPROTOOPT */ | ||||
|     /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */ | ||||
|     /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */ | ||||
|     /* WSAEOPNOTSUPP is EOPNOTSUPP */ | ||||
|     /* WSAEPFNOSUPPORT is EPFNOSUPPORT */ | ||||
|     /* WSAEAFNOSUPPORT is EAFNOSUPPORT */ | ||||
|     /* WSAEADDRINUSE is EADDRINUSE */ | ||||
|     /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */ | ||||
|     /* WSAENETDOWN is ENETDOWN */ | ||||
|     /* WSAENETUNREACH is ENETUNREACH */ | ||||
|     /* WSAENETRESET is ENETRESET */ | ||||
|     /* WSAECONNABORTED is ECONNABORTED */ | ||||
|     /* WSAECONNRESET is ECONNRESET */ | ||||
|     /* WSAENOBUFS is ENOBUFS */ | ||||
|     /* WSAEISCONN is EISCONN */ | ||||
|     /* WSAENOTCONN is ENOTCONN */ | ||||
|     /* WSAESHUTDOWN is ESHUTDOWN */ | ||||
|     /* WSAETOOMANYREFS is ETOOMANYREFS */ | ||||
|     /* WSAETIMEDOUT is ETIMEDOUT */ | ||||
|     /* WSAECONNREFUSED is ECONNREFUSED */ | ||||
|     /* WSAELOOP is ELOOP */ | ||||
|     /* WSAENAMETOOLONG maps to ENAMETOOLONG */ | ||||
|     /* WSAEHOSTDOWN is EHOSTDOWN */ | ||||
|     /* WSAEHOSTUNREACH is EHOSTUNREACH */ | ||||
|     /* WSAENOTEMPTY maps to ENOTEMPTY */ | ||||
|     /* WSAEPROCLIM is EPROCLIM */ | ||||
|     /* WSAEUSERS is EUSERS */ | ||||
|     /* WSAEDQUOT is EDQUOT */ | ||||
|     /* WSAESTALE is ESTALE */ | ||||
|     /* WSAEREMOTE is EREMOTE */ | ||||
|     case WSASYSNOTREADY: | ||||
|       msg = "Network subsystem is unavailable"; | ||||
|       break; | ||||
|     case WSAVERNOTSUPPORTED: | ||||
|       msg = "Winsock.dll version out of range"; | ||||
|       break; | ||||
|     case WSANOTINITIALISED: | ||||
|       msg = "Successful WSAStartup not yet performed"; | ||||
|       break; | ||||
|     case WSAEDISCON: | ||||
|       msg = "Graceful shutdown in progress"; | ||||
|       break; | ||||
|     case WSAENOMORE: case WSA_E_NO_MORE: | ||||
|       msg = "No more results"; | ||||
|       break; | ||||
|     case WSAECANCELLED: case WSA_E_CANCELLED: | ||||
|       msg = "Call was canceled"; | ||||
|       break; | ||||
|     case WSAEINVALIDPROCTABLE: | ||||
|       msg = "Procedure call table is invalid"; | ||||
|       break; | ||||
|     case WSAEINVALIDPROVIDER: | ||||
|       msg = "Service provider is invalid"; | ||||
|       break; | ||||
|     case WSAEPROVIDERFAILEDINIT: | ||||
|       msg = "Service provider failed to initialize"; | ||||
|       break; | ||||
|     case WSASYSCALLFAILURE: | ||||
|       msg = "System call failure"; | ||||
|       break; | ||||
|     case WSASERVICE_NOT_FOUND: | ||||
|       msg = "Service not found"; | ||||
|       break; | ||||
|     case WSATYPE_NOT_FOUND: | ||||
|       msg = "Class type not found"; | ||||
|       break; | ||||
|     case WSAEREFUSED: | ||||
|       msg = "Database query was refused"; | ||||
|       break; | ||||
|     case WSAHOST_NOT_FOUND: | ||||
|       msg = "Host not found"; | ||||
|       break; | ||||
|     case WSATRY_AGAIN: | ||||
|       msg = "Nonauthoritative host not found"; | ||||
|       break; | ||||
|     case WSANO_RECOVERY: | ||||
|       msg = "Nonrecoverable error"; | ||||
|       break; | ||||
|     case WSANO_DATA: | ||||
|       msg = "Valid name, no data record of requested type"; | ||||
|       break; | ||||
|     /* WSA_QOS_* omitted */ | ||||
| #  endif | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_ENOMSG | ||||
|     case ENOMSG: | ||||
|       msg = "No message of desired type"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_EIDRM | ||||
|     case EIDRM: | ||||
|       msg = "Identifier removed"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_ENOLINK | ||||
|     case ENOLINK: | ||||
|       msg = "Link has been severed"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_EPROTO | ||||
|     case EPROTO: | ||||
|       msg = "Protocol error"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_EMULTIHOP | ||||
|     case EMULTIHOP: | ||||
|       msg = "Multihop attempted"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_EBADMSG | ||||
|     case EBADMSG: | ||||
|       msg = "Bad message"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_EOVERFLOW | ||||
|     case EOVERFLOW: | ||||
|       msg = "Value too large for defined data type"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_ENOTSUP | ||||
|     case ENOTSUP: | ||||
|       msg = "Not supported"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_ESTALE | ||||
|     case ESTALE: | ||||
|       msg = "Stale NFS file handle"; | ||||
|       break; | ||||
| # endif | ||||
| 
 | ||||
| # if GNULIB_defined_ECANCELED | ||||
|     case ECANCELED: | ||||
|       msg = "Operation canceled"; | ||||
|       break; | ||||
| # endif | ||||
|     } | ||||
| 
 | ||||
|   if (msg) | ||||
|     return (char *) msg; | ||||
| 
 | ||||
|   { | ||||
|     char *result = strerror (n); | ||||
| 
 | ||||
|     if (result == NULL || result[0] == '\0') | ||||
|       { | ||||
|         static char const fmt[] = "Unknown error (%d)"; | ||||
|         static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)]; | ||||
|         sprintf (msg_buf, fmt, n); | ||||
|         return msg_buf; | ||||
|       } | ||||
| 
 | ||||
|     return result; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										945
									
								
								grub-core/gnulib/string.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										945
									
								
								grub-core/gnulib/string.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,945 @@ | |||
| /* A GNU-like <string.h>.
 | ||||
| 
 | ||||
|    Copyright (C) 1995-1996, 2001-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _GL_STRING_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #@INCLUDE_NEXT@ @NEXT_STRING_H@ | ||||
| 
 | ||||
| #ifndef _GL_STRING_H | ||||
| #define _GL_STRING_H | ||||
| 
 | ||||
| /* NetBSD 5.0 mis-defines NULL.  */ | ||||
| #include <stddef.h> | ||||
| 
 | ||||
| /* MirBSD defines mbslen as a macro.  */ | ||||
| #if @GNULIB_MBSLEN@ && defined __MirBSD__ | ||||
| # include <wchar.h> | ||||
| #endif | ||||
| 
 | ||||
| #ifndef __attribute__ | ||||
| /* This feature is available in gcc versions 2.5 and later.  */ | ||||
| # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) | ||||
| #  define __attribute__(Spec) /* empty */ | ||||
| # endif | ||||
| #endif | ||||
| /* The attribute __pure__ was added in gcc 2.96.  */ | ||||
| #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) | ||||
| # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) | ||||
| #else | ||||
| # define _GL_ATTRIBUTE_PURE /* empty */ | ||||
| #endif | ||||
| 
 | ||||
| /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>.  */ | ||||
| /* But avoid namespace pollution on glibc systems.  */ | ||||
| #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK)  \ | ||||
|     && ! defined __GLIBC__ | ||||
| # include <unistd.h> | ||||
| #endif | ||||
| 
 | ||||
| /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_ARG_NONNULL is copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_WARN_ON_USE is copied here.  */ | ||||
| 
 | ||||
| 
 | ||||
| /* Return the first instance of C within N bytes of S, or NULL.  */ | ||||
| #if @GNULIB_MEMCHR@ | ||||
| # if @REPLACE_MEMCHR@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define memchr rpl_memchr | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) | ||||
|                                   _GL_ATTRIBUTE_PURE | ||||
|                                   _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); | ||||
| # else | ||||
| #  if ! @HAVE_MEMCHR@ | ||||
| _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) | ||||
|                                   _GL_ATTRIBUTE_PURE | ||||
|                                   _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
|   /* On some systems, this function is defined as an overloaded function:
 | ||||
|        extern "C" { const void * std::memchr (const void *, int, size_t); } | ||||
|        extern "C++" { void * std::memchr (void *, int, size_t); }  */ | ||||
| _GL_CXXALIAS_SYS_CAST2 (memchr, | ||||
|                         void *, (void const *__s, int __c, size_t __n), | ||||
|                         void const *, (void const *__s, int __c, size_t __n)); | ||||
| # endif | ||||
| # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | ||||
|      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||||
| _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); | ||||
| _GL_CXXALIASWARN1 (memchr, void const *, | ||||
|                    (void const *__s, int __c, size_t __n)); | ||||
| # else | ||||
| _GL_CXXALIASWARN (memchr); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef memchr | ||||
| /* Assume memchr is always declared.  */ | ||||
| _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " | ||||
|                  "use gnulib module memchr for portability" ); | ||||
| #endif | ||||
| 
 | ||||
| /* Return the first occurrence of NEEDLE in HAYSTACK.  */ | ||||
| #if @GNULIB_MEMMEM@ | ||||
| # if @REPLACE_MEMMEM@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define memmem rpl_memmem | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (memmem, void *, | ||||
|                   (void const *__haystack, size_t __haystack_len, | ||||
|                    void const *__needle, size_t __needle_len) | ||||
|                   _GL_ATTRIBUTE_PURE | ||||
|                   _GL_ARG_NONNULL ((1, 3))); | ||||
| _GL_CXXALIAS_RPL (memmem, void *, | ||||
|                   (void const *__haystack, size_t __haystack_len, | ||||
|                    void const *__needle, size_t __needle_len)); | ||||
| # else | ||||
| #  if ! @HAVE_DECL_MEMMEM@ | ||||
| _GL_FUNCDECL_SYS (memmem, void *, | ||||
|                   (void const *__haystack, size_t __haystack_len, | ||||
|                    void const *__needle, size_t __needle_len) | ||||
|                   _GL_ATTRIBUTE_PURE | ||||
|                   _GL_ARG_NONNULL ((1, 3))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (memmem, void *, | ||||
|                   (void const *__haystack, size_t __haystack_len, | ||||
|                    void const *__needle, size_t __needle_len)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (memmem); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef memmem | ||||
| # if HAVE_RAW_DECL_MEMMEM | ||||
| _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " | ||||
|                  "use gnulib module memmem-simple for portability, " | ||||
|                  "and module memmem for speed" ); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Copy N bytes of SRC to DEST, return pointer to bytes after the
 | ||||
|    last written byte.  */ | ||||
| #if @GNULIB_MEMPCPY@ | ||||
| # if ! @HAVE_MEMPCPY@ | ||||
| _GL_FUNCDECL_SYS (mempcpy, void *, | ||||
|                   (void *restrict __dest, void const *restrict __src, | ||||
|                    size_t __n) | ||||
|                   _GL_ARG_NONNULL ((1, 2))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (mempcpy, void *, | ||||
|                   (void *restrict __dest, void const *restrict __src, | ||||
|                    size_t __n)); | ||||
| _GL_CXXALIASWARN (mempcpy); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mempcpy | ||||
| # if HAVE_RAW_DECL_MEMPCPY | ||||
| _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " | ||||
|                  "use gnulib module mempcpy for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Search backwards through a block for a byte (specified as an int).  */ | ||||
| #if @GNULIB_MEMRCHR@ | ||||
| # if ! @HAVE_DECL_MEMRCHR@ | ||||
| _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) | ||||
|                                    _GL_ATTRIBUTE_PURE | ||||
|                                    _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
|   /* On some systems, this function is defined as an overloaded function:
 | ||||
|        extern "C++" { const void * std::memrchr (const void *, int, size_t); } | ||||
|        extern "C++" { void * std::memrchr (void *, int, size_t); }  */ | ||||
| _GL_CXXALIAS_SYS_CAST2 (memrchr, | ||||
|                         void *, (void const *, int, size_t), | ||||
|                         void const *, (void const *, int, size_t)); | ||||
| # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | ||||
|      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||||
| _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); | ||||
| _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); | ||||
| # else | ||||
| _GL_CXXALIASWARN (memrchr); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef memrchr | ||||
| # if HAVE_RAW_DECL_MEMRCHR | ||||
| _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " | ||||
|                  "use gnulib module memrchr for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Find the first occurrence of C in S.  More efficient than
 | ||||
|    memchr(S,C,N), at the expense of undefined behavior if C does not | ||||
|    occur within N bytes.  */ | ||||
| #if @GNULIB_RAWMEMCHR@ | ||||
| # if ! @HAVE_RAWMEMCHR@ | ||||
| _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) | ||||
|                                      _GL_ATTRIBUTE_PURE | ||||
|                                      _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
|   /* On some systems, this function is defined as an overloaded function:
 | ||||
|        extern "C++" { const void * std::rawmemchr (const void *, int); } | ||||
|        extern "C++" { void * std::rawmemchr (void *, int); }  */ | ||||
| _GL_CXXALIAS_SYS_CAST2 (rawmemchr, | ||||
|                         void *, (void const *__s, int __c_in), | ||||
|                         void const *, (void const *__s, int __c_in)); | ||||
| # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | ||||
|      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||||
| _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); | ||||
| _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); | ||||
| # else | ||||
| _GL_CXXALIASWARN (rawmemchr); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef rawmemchr | ||||
| # if HAVE_RAW_DECL_RAWMEMCHR | ||||
| _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " | ||||
|                  "use gnulib module rawmemchr for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */ | ||||
| #if @GNULIB_STPCPY@ | ||||
| # if ! @HAVE_STPCPY@ | ||||
| _GL_FUNCDECL_SYS (stpcpy, char *, | ||||
|                   (char *restrict __dst, char const *restrict __src) | ||||
|                   _GL_ARG_NONNULL ((1, 2))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (stpcpy, char *, | ||||
|                   (char *restrict __dst, char const *restrict __src)); | ||||
| _GL_CXXALIASWARN (stpcpy); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef stpcpy | ||||
| # if HAVE_RAW_DECL_STPCPY | ||||
| _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " | ||||
|                  "use gnulib module stpcpy for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Copy no more than N bytes of SRC to DST, returning a pointer past the
 | ||||
|    last non-NUL byte written into DST.  */ | ||||
| #if @GNULIB_STPNCPY@ | ||||
| # if @REPLACE_STPNCPY@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef stpncpy | ||||
| #   define stpncpy rpl_stpncpy | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (stpncpy, char *, | ||||
|                   (char *restrict __dst, char const *restrict __src, | ||||
|                    size_t __n) | ||||
|                   _GL_ARG_NONNULL ((1, 2))); | ||||
| _GL_CXXALIAS_RPL (stpncpy, char *, | ||||
|                   (char *restrict __dst, char const *restrict __src, | ||||
|                    size_t __n)); | ||||
| # else | ||||
| #  if ! @HAVE_STPNCPY@ | ||||
| _GL_FUNCDECL_SYS (stpncpy, char *, | ||||
|                   (char *restrict __dst, char const *restrict __src, | ||||
|                    size_t __n) | ||||
|                   _GL_ARG_NONNULL ((1, 2))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (stpncpy, char *, | ||||
|                   (char *restrict __dst, char const *restrict __src, | ||||
|                    size_t __n)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (stpncpy); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef stpncpy | ||||
| # if HAVE_RAW_DECL_STPNCPY | ||||
| _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " | ||||
|                  "use gnulib module stpncpy for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if defined GNULIB_POSIXCHECK | ||||
| /* strchr() does not work with multibyte strings if the locale encoding is
 | ||||
|    GB18030 and the character to be searched is a digit.  */ | ||||
| # undef strchr | ||||
| /* Assume strchr is always declared.  */ | ||||
| _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " | ||||
|                  "in some multibyte locales - " | ||||
|                  "use mbschr if you care about internationalization"); | ||||
| #endif | ||||
| 
 | ||||
| /* Find the first occurrence of C in S or the final NUL byte.  */ | ||||
| #if @GNULIB_STRCHRNUL@ | ||||
| # if ! @HAVE_STRCHRNUL@ | ||||
| _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) | ||||
|                                      _GL_ATTRIBUTE_PURE | ||||
|                                      _GL_ARG_NONNULL ((1))); | ||||
| # endif | ||||
|   /* On some systems, this function is defined as an overloaded function:
 | ||||
|        extern "C++" { const char * std::strchrnul (const char *, int); } | ||||
|        extern "C++" { char * std::strchrnul (char *, int); }  */ | ||||
| _GL_CXXALIAS_SYS_CAST2 (strchrnul, | ||||
|                         char *, (char const *__s, int __c_in), | ||||
|                         char const *, (char const *__s, int __c_in)); | ||||
| # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | ||||
|      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||||
| _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); | ||||
| _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); | ||||
| # else | ||||
| _GL_CXXALIASWARN (strchrnul); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strchrnul | ||||
| # if HAVE_RAW_DECL_STRCHRNUL | ||||
| _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " | ||||
|                  "use gnulib module strchrnul for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Duplicate S, returning an identical malloc'd string.  */ | ||||
| #if @GNULIB_STRDUP@ | ||||
| # if @REPLACE_STRDUP@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef strdup | ||||
| #   define strdup rpl_strdup | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); | ||||
| # else | ||||
| #  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup | ||||
|     /* strdup exists as a function and as a macro.  Get rid of the macro.  */ | ||||
| #   undef strdup | ||||
| #  endif | ||||
| #  if !(@HAVE_DECL_STRDUP@ || defined strdup) | ||||
| _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (strdup); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strdup | ||||
| # if HAVE_RAW_DECL_STRDUP | ||||
| _GL_WARN_ON_USE (strdup, "strdup is unportable - " | ||||
|                  "use gnulib module strdup for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Append no more than N characters from SRC onto DEST.  */ | ||||
| #if @GNULIB_STRNCAT@ | ||||
| # if @REPLACE_STRNCAT@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef strncat | ||||
| #   define strncat rpl_strncat | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) | ||||
|                                    _GL_ARG_NONNULL ((1, 2))); | ||||
| _GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); | ||||
| # else | ||||
| _GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (strncat); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strncat | ||||
| # if HAVE_RAW_DECL_STRNCAT | ||||
| _GL_WARN_ON_USE (strncat, "strncat is unportable - " | ||||
|                  "use gnulib module strncat for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Return a newly allocated copy of at most N bytes of STRING.  */ | ||||
| #if @GNULIB_STRNDUP@ | ||||
| # if @REPLACE_STRNDUP@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef strndup | ||||
| #   define strndup rpl_strndup | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) | ||||
|                                    _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); | ||||
| # else | ||||
| #  if ! @HAVE_DECL_STRNDUP@ | ||||
| _GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) | ||||
|                                    _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (strndup); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strndup | ||||
| # if HAVE_RAW_DECL_STRNDUP | ||||
| _GL_WARN_ON_USE (strndup, "strndup is unportable - " | ||||
|                  "use gnulib module strndup for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Find the length (number of bytes) of STRING, but scan at most
 | ||||
|    MAXLEN bytes.  If no '\0' terminator is found in that many bytes, | ||||
|    return MAXLEN.  */ | ||||
| #if @GNULIB_STRNLEN@ | ||||
| # if @REPLACE_STRNLEN@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef strnlen | ||||
| #   define strnlen rpl_strnlen | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) | ||||
|                                    _GL_ATTRIBUTE_PURE | ||||
|                                    _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); | ||||
| # else | ||||
| #  if ! @HAVE_DECL_STRNLEN@ | ||||
| _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) | ||||
|                                    _GL_ATTRIBUTE_PURE | ||||
|                                    _GL_ARG_NONNULL ((1))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (strnlen); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strnlen | ||||
| # if HAVE_RAW_DECL_STRNLEN | ||||
| _GL_WARN_ON_USE (strnlen, "strnlen is unportable - " | ||||
|                  "use gnulib module strnlen for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if defined GNULIB_POSIXCHECK | ||||
| /* strcspn() assumes the second argument is a list of single-byte characters.
 | ||||
|    Even in this simple case, it does not work with multibyte strings if the | ||||
|    locale encoding is GB18030 and one of the characters to be searched is a | ||||
|    digit.  */ | ||||
| # undef strcspn | ||||
| /* Assume strcspn is always declared.  */ | ||||
| _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " | ||||
|                  "in multibyte locales - " | ||||
|                  "use mbscspn if you care about internationalization"); | ||||
| #endif | ||||
| 
 | ||||
| /* Find the first occurrence in S of any character in ACCEPT.  */ | ||||
| #if @GNULIB_STRPBRK@ | ||||
| # if ! @HAVE_STRPBRK@ | ||||
| _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) | ||||
|                                    _GL_ATTRIBUTE_PURE | ||||
|                                    _GL_ARG_NONNULL ((1, 2))); | ||||
| # endif | ||||
|   /* On some systems, this function is defined as an overloaded function:
 | ||||
|        extern "C" { const char * strpbrk (const char *, const char *); } | ||||
|        extern "C++" { char * strpbrk (char *, const char *); }  */ | ||||
| _GL_CXXALIAS_SYS_CAST2 (strpbrk, | ||||
|                         char *, (char const *__s, char const *__accept), | ||||
|                         const char *, (char const *__s, char const *__accept)); | ||||
| # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | ||||
|      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||||
| _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); | ||||
| _GL_CXXALIASWARN1 (strpbrk, char const *, | ||||
|                    (char const *__s, char const *__accept)); | ||||
| # else | ||||
| _GL_CXXALIASWARN (strpbrk); | ||||
| # endif | ||||
| # if defined GNULIB_POSIXCHECK | ||||
| /* strpbrk() assumes the second argument is a list of single-byte characters.
 | ||||
|    Even in this simple case, it does not work with multibyte strings if the | ||||
|    locale encoding is GB18030 and one of the characters to be searched is a | ||||
|    digit.  */ | ||||
| #  undef strpbrk | ||||
| _GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " | ||||
|                  "in multibyte locales - " | ||||
|                  "use mbspbrk if you care about internationalization"); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strpbrk | ||||
| # if HAVE_RAW_DECL_STRPBRK | ||||
| _GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " | ||||
|                  "use gnulib module strpbrk for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if defined GNULIB_POSIXCHECK | ||||
| /* strspn() assumes the second argument is a list of single-byte characters.
 | ||||
|    Even in this simple case, it cannot work with multibyte strings.  */ | ||||
| # undef strspn | ||||
| /* Assume strspn is always declared.  */ | ||||
| _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " | ||||
|                  "in multibyte locales - " | ||||
|                  "use mbsspn if you care about internationalization"); | ||||
| #endif | ||||
| 
 | ||||
| #if defined GNULIB_POSIXCHECK | ||||
| /* strrchr() does not work with multibyte strings if the locale encoding is
 | ||||
|    GB18030 and the character to be searched is a digit.  */ | ||||
| # undef strrchr | ||||
| /* Assume strrchr is always declared.  */ | ||||
| _GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " | ||||
|                  "in some multibyte locales - " | ||||
|                  "use mbsrchr if you care about internationalization"); | ||||
| #endif | ||||
| 
 | ||||
| /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
 | ||||
|    If one is found, overwrite it with a NUL, and advance *STRINGP | ||||
|    to point to the next char after it.  Otherwise, set *STRINGP to NULL. | ||||
|    If *STRINGP was already NULL, nothing happens. | ||||
|    Return the old value of *STRINGP. | ||||
| 
 | ||||
|    This is a variant of strtok() that is multithread-safe and supports | ||||
|    empty fields. | ||||
| 
 | ||||
|    Caveat: It modifies the original string. | ||||
|    Caveat: These functions cannot be used on constant strings. | ||||
|    Caveat: The identity of the delimiting character is lost. | ||||
|    Caveat: It doesn't work with multibyte strings unless all of the delimiter | ||||
|            characters are ASCII characters < 0x30. | ||||
| 
 | ||||
|    See also strtok_r().  */ | ||||
| #if @GNULIB_STRSEP@ | ||||
| # if ! @HAVE_STRSEP@ | ||||
| _GL_FUNCDECL_SYS (strsep, char *, | ||||
|                   (char **restrict __stringp, char const *restrict __delim) | ||||
|                   _GL_ARG_NONNULL ((1, 2))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (strsep, char *, | ||||
|                   (char **restrict __stringp, char const *restrict __delim)); | ||||
| _GL_CXXALIASWARN (strsep); | ||||
| # if defined GNULIB_POSIXCHECK | ||||
| #  undef strsep | ||||
| _GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " | ||||
|                  "in multibyte locales - " | ||||
|                  "use mbssep if you care about internationalization"); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strsep | ||||
| # if HAVE_RAW_DECL_STRSEP | ||||
| _GL_WARN_ON_USE (strsep, "strsep is unportable - " | ||||
|                  "use gnulib module strsep for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_STRSTR@ | ||||
| # if @REPLACE_STRSTR@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define strstr rpl_strstr | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) | ||||
|                                   _GL_ATTRIBUTE_PURE | ||||
|                                   _GL_ARG_NONNULL ((1, 2))); | ||||
| _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); | ||||
| # else | ||||
|   /* On some systems, this function is defined as an overloaded function:
 | ||||
|        extern "C++" { const char * strstr (const char *, const char *); } | ||||
|        extern "C++" { char * strstr (char *, const char *); }  */ | ||||
| _GL_CXXALIAS_SYS_CAST2 (strstr, | ||||
|                         char *, (const char *haystack, const char *needle), | ||||
|                         const char *, (const char *haystack, const char *needle)); | ||||
| # endif | ||||
| # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | ||||
|      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||||
| _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); | ||||
| _GL_CXXALIASWARN1 (strstr, const char *, | ||||
|                    (const char *haystack, const char *needle)); | ||||
| # else | ||||
| _GL_CXXALIASWARN (strstr); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| /* strstr() does not work with multibyte strings if the locale encoding is
 | ||||
|    different from UTF-8: | ||||
|    POSIX says that it operates on "strings", and "string" in POSIX is defined | ||||
|    as a sequence of bytes, not of characters.  */ | ||||
| # undef strstr | ||||
| /* Assume strstr is always declared.  */ | ||||
| _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " | ||||
|                  "work correctly on character strings in most " | ||||
|                  "multibyte locales - " | ||||
|                  "use mbsstr if you care about internationalization, " | ||||
|                  "or use strstr if you care about speed"); | ||||
| #endif | ||||
| 
 | ||||
| /* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
 | ||||
|    comparison.  */ | ||||
| #if @GNULIB_STRCASESTR@ | ||||
| # if @REPLACE_STRCASESTR@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define strcasestr rpl_strcasestr | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strcasestr, char *, | ||||
|                   (const char *haystack, const char *needle) | ||||
|                   _GL_ATTRIBUTE_PURE | ||||
|                   _GL_ARG_NONNULL ((1, 2))); | ||||
| _GL_CXXALIAS_RPL (strcasestr, char *, | ||||
|                   (const char *haystack, const char *needle)); | ||||
| # else | ||||
| #  if ! @HAVE_STRCASESTR@ | ||||
| _GL_FUNCDECL_SYS (strcasestr, char *, | ||||
|                   (const char *haystack, const char *needle) | ||||
|                   _GL_ATTRIBUTE_PURE | ||||
|                   _GL_ARG_NONNULL ((1, 2))); | ||||
| #  endif | ||||
|   /* On some systems, this function is defined as an overloaded function:
 | ||||
|        extern "C++" { const char * strcasestr (const char *, const char *); } | ||||
|        extern "C++" { char * strcasestr (char *, const char *); }  */ | ||||
| _GL_CXXALIAS_SYS_CAST2 (strcasestr, | ||||
|                         char *, (const char *haystack, const char *needle), | ||||
|                         const char *, (const char *haystack, const char *needle)); | ||||
| # endif | ||||
| # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ | ||||
|      && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) | ||||
| _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); | ||||
| _GL_CXXALIASWARN1 (strcasestr, const char *, | ||||
|                    (const char *haystack, const char *needle)); | ||||
| # else | ||||
| _GL_CXXALIASWARN (strcasestr); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| /* strcasestr() does not work with multibyte strings:
 | ||||
|    It is a glibc extension, and glibc implements it only for unibyte | ||||
|    locales.  */ | ||||
| # undef strcasestr | ||||
| # if HAVE_RAW_DECL_STRCASESTR | ||||
| _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " | ||||
|                  "strings in multibyte locales - " | ||||
|                  "use mbscasestr if you care about " | ||||
|                  "internationalization, or use c-strcasestr if you want " | ||||
|                  "a locale independent function"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* 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"
 | ||||
| 
 | ||||
|    This is a variant of strtok() that is multithread-safe. | ||||
| 
 | ||||
|    For the POSIX documentation for this function, see: | ||||
|    http://www.opengroup.org/susv3xsh/strtok.html
 | ||||
| 
 | ||||
|    Caveat: It modifies the original string. | ||||
|    Caveat: These functions cannot be used on constant strings. | ||||
|    Caveat: The identity of the delimiting character is lost. | ||||
|    Caveat: It doesn't work with multibyte strings unless all of the delimiter | ||||
|            characters are ASCII characters < 0x30. | ||||
| 
 | ||||
|    See also strsep().  */ | ||||
| #if @GNULIB_STRTOK_R@ | ||||
| # if @REPLACE_STRTOK_R@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef strtok_r | ||||
| #   define strtok_r rpl_strtok_r | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strtok_r, char *, | ||||
|                   (char *restrict s, char const *restrict delim, | ||||
|                    char **restrict save_ptr) | ||||
|                   _GL_ARG_NONNULL ((2, 3))); | ||||
| _GL_CXXALIAS_RPL (strtok_r, char *, | ||||
|                   (char *restrict s, char const *restrict delim, | ||||
|                    char **restrict save_ptr)); | ||||
| # else | ||||
| #  if @UNDEFINE_STRTOK_R@ || defined GNULIB_POSIXCHECK | ||||
| #   undef strtok_r | ||||
| #  endif | ||||
| #  if ! @HAVE_DECL_STRTOK_R@ | ||||
| _GL_FUNCDECL_SYS (strtok_r, char *, | ||||
|                   (char *restrict s, char const *restrict delim, | ||||
|                    char **restrict save_ptr) | ||||
|                   _GL_ARG_NONNULL ((2, 3))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (strtok_r, char *, | ||||
|                   (char *restrict s, char const *restrict delim, | ||||
|                    char **restrict save_ptr)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (strtok_r); | ||||
| # if defined GNULIB_POSIXCHECK | ||||
| _GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " | ||||
|                  "strings in multibyte locales - " | ||||
|                  "use mbstok_r if you care about internationalization"); | ||||
| # endif | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strtok_r | ||||
| # if HAVE_RAW_DECL_STRTOK_R | ||||
| _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " | ||||
|                  "use gnulib module strtok_r for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* The following functions are not specified by POSIX.  They are gnulib
 | ||||
|    extensions.  */ | ||||
| 
 | ||||
| #if @GNULIB_MBSLEN@ | ||||
| /* Return the number of multibyte characters in the character string STRING.
 | ||||
|    This considers multibyte characters, unlike strlen, which counts bytes.  */ | ||||
| # ifdef __MirBSD__  /* MirBSD defines mbslen as a macro.  Override it.  */ | ||||
| #  undef mbslen | ||||
| # endif | ||||
| # if @HAVE_MBSLEN@  /* AIX, OSF/1, MirBSD define mbslen already in libc.  */ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define mbslen rpl_mbslen | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); | ||||
| # else | ||||
| _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbslen); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSNLEN@ | ||||
| /* Return the number of multibyte characters in the character string starting
 | ||||
|    at STRING and ending at STRING + LEN.  */ | ||||
| _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) | ||||
|      _GL_ARG_NONNULL ((1)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSCHR@ | ||||
| /* Locate the first single-byte character C in the character string STRING,
 | ||||
|    and return a pointer to it.  Return NULL if C is not found in STRING. | ||||
|    Unlike strchr(), this function works correctly in multibyte locales with | ||||
|    encodings such as GB18030.  */ | ||||
| # if defined __hpux | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define mbschr rpl_mbschr /* avoid collision with HP-UX function */ | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) | ||||
|                                   _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); | ||||
| # else | ||||
| _GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) | ||||
|                                   _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbschr); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSRCHR@ | ||||
| /* Locate the last single-byte character C in the character string STRING,
 | ||||
|    and return a pointer to it.  Return NULL if C is not found in STRING. | ||||
|    Unlike strrchr(), this function works correctly in multibyte locales with | ||||
|    encodings such as GB18030.  */ | ||||
| # if defined __hpux | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) | ||||
|                                    _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); | ||||
| # else | ||||
| _GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) | ||||
|                                    _GL_ARG_NONNULL ((1))); | ||||
| _GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbsrchr); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSSTR@ | ||||
| /* Find the first occurrence of the character string NEEDLE in the character
 | ||||
|    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.  */ | ||||
| _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSCASECMP@ | ||||
| /* Compare the character strings S1 and S2, ignoring case, returning less than,
 | ||||
|    equal to or greater than zero if S1 is lexicographically less than, equal to | ||||
|    or greater than S2. | ||||
|    Note: This function may, in multibyte locales, return 0 for strings of | ||||
|    different lengths! | ||||
|    Unlike strcasecmp(), this function works correctly in multibyte locales.  */ | ||||
| _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSNCASECMP@ | ||||
| /* Compare the initial segment of the character string S1 consisting of at most
 | ||||
|    N characters with the initial segment of the character string S2 consisting | ||||
|    of at most N characters, ignoring case, returning less than, equal to or | ||||
|    greater than zero if the initial segment of S1 is lexicographically less | ||||
|    than, equal to or greater than the initial segment of S2. | ||||
|    Note: This function may, in multibyte locales, return 0 for initial segments | ||||
|    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!  */ | ||||
| _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSPCASECMP@ | ||||
| /* Compare the initial segment of the character string STRING consisting of
 | ||||
|    at most mbslen (PREFIX) characters with the character string PREFIX, | ||||
|    ignoring case.  If the two match, return a pointer to the first byte | ||||
|    after this prefix in STRING.  Otherwise, return NULL. | ||||
|    Note: This function may, in multibyte locales, return non-NULL if STRING | ||||
|    is of smaller length than PREFIX! | ||||
|    Unlike strncasecmp(), this function works correctly in multibyte | ||||
|    locales.  */ | ||||
| _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSCASESTR@ | ||||
| /* Find the first occurrence of the character string NEEDLE in the character
 | ||||
|    string HAYSTACK, using case-insensitive comparison. | ||||
|    Note: This function may, in multibyte locales, return success even if | ||||
|    strlen (haystack) < strlen (needle) ! | ||||
|    Unlike strcasestr(), this function works correctly in multibyte locales.  */ | ||||
| _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSCSPN@ | ||||
| /* Find the first occurrence in the character string STRING of any character
 | ||||
|    in the character string ACCEPT.  Return the number of bytes from the | ||||
|    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.  */ | ||||
| _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSPBRK@ | ||||
| /* Find the first occurrence in the character string STRING of any character
 | ||||
|    in the character string ACCEPT.  Return the pointer to it, or NULL if none | ||||
|    exists. | ||||
|    Unlike strpbrk(), this function works correctly in multibyte locales.  */ | ||||
| # if defined __hpux | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) | ||||
|                                    _GL_ARG_NONNULL ((1, 2))); | ||||
| _GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); | ||||
| # else | ||||
| _GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) | ||||
|                                    _GL_ARG_NONNULL ((1, 2))); | ||||
| _GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbspbrk); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSSPN@ | ||||
| /* Find the first occurrence in the character string STRING of any character
 | ||||
|    not in the character string REJECT.  Return the number of bytes from the | ||||
|    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.  */ | ||||
| _GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSSEP@ | ||||
| /* Search the next delimiter (multibyte character listed in the character
 | ||||
|    string DELIM) starting at the character string *STRINGP. | ||||
|    If one is found, overwrite it with a NUL, and advance *STRINGP to point | ||||
|    to the next multibyte character after it.  Otherwise, set *STRINGP to NULL. | ||||
|    If *STRINGP was already NULL, nothing happens. | ||||
|    Return the old value of *STRINGP. | ||||
| 
 | ||||
|    This is a variant of mbstok_r() that supports empty fields. | ||||
| 
 | ||||
|    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 mbstok_r().  */ | ||||
| _GL_EXTERN_C char * mbssep (char **stringp, const char *delim) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_MBSTOK_R@ | ||||
| /* Parse the character string STRING into tokens separated by characters in
 | ||||
|    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"
 | ||||
| 
 | ||||
|    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().  */ | ||||
| _GL_EXTERN_C 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.  */ | ||||
| #if @GNULIB_STRERROR@ | ||||
| # if @REPLACE_STRERROR@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef strerror | ||||
| #   define strerror rpl_strerror | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strerror, char *, (int)); | ||||
| _GL_CXXALIAS_RPL (strerror, char *, (int)); | ||||
| # else | ||||
| _GL_CXXALIAS_SYS (strerror, char *, (int)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (strerror); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strerror | ||||
| /* Assume strerror is always declared.  */ | ||||
| _GL_WARN_ON_USE (strerror, "strerror is unportable - " | ||||
|                  "use gnulib module strerror to guarantee non-NULL result"); | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_STRSIGNAL@ | ||||
| # if @REPLACE_STRSIGNAL@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define strsignal rpl_strsignal | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); | ||||
| _GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); | ||||
| # else | ||||
| #  if ! @HAVE_DECL_STRSIGNAL@ | ||||
| _GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); | ||||
| #  endif | ||||
| /* Need to cast, because on Cygwin 1.5.x systems, the return type is
 | ||||
|    'const char *'.  */ | ||||
| _GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (strsignal); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strsignal | ||||
| # if HAVE_RAW_DECL_STRSIGNAL | ||||
| _GL_WARN_ON_USE (strsignal, "strsignal is unportable - " | ||||
|                  "use gnulib module strsignal for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #if @GNULIB_STRVERSCMP@ | ||||
| # if !@HAVE_STRVERSCMP@ | ||||
| _GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) | ||||
|                                    _GL_ARG_NONNULL ((1, 2))); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); | ||||
| _GL_CXXALIASWARN (strverscmp); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef strverscmp | ||||
| # if HAVE_RAW_DECL_STRVERSCMP | ||||
| _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " | ||||
|                  "use gnulib module strverscmp for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #endif /* _GL_STRING_H */ | ||||
| #endif /* _GL_STRING_H */ | ||||
							
								
								
									
										93
									
								
								grub-core/gnulib/strings.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								grub-core/gnulib/strings.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,93 @@ | |||
| /* A substitute <strings.h>.
 | ||||
| 
 | ||||
|    Copyright (C) 2007-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _GL_STRINGS_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #@INCLUDE_NEXT@ @NEXT_STRINGS_H@ | ||||
| 
 | ||||
| #ifndef _GL_STRINGS_H | ||||
| #define _GL_STRINGS_H | ||||
| 
 | ||||
| 
 | ||||
| /* The definition of _GL_ARG_NONNULL is copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_WARN_ON_USE is copied here.  */ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
 | ||||
|    greater than zero if S1 is lexicographically less than, equal to or greater | ||||
|    than S2. | ||||
|    Note: This function does not work in multibyte locales.  */ | ||||
| #if ! @HAVE_STRCASECMP@ | ||||
| extern int strcasecmp (char const *s1, char const *s2) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| #if defined GNULIB_POSIXCHECK | ||||
| /* strcasecmp() does not work with multibyte strings:
 | ||||
|    POSIX says that it operates on "strings", and "string" in POSIX is defined | ||||
|    as a sequence of bytes, not of characters.   */ | ||||
| # undef strcasecmp | ||||
| # if HAVE_RAW_DECL_STRCASECMP | ||||
| _GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character " | ||||
|                  "strings in multibyte locales - " | ||||
|                  "use mbscasecmp if you care about " | ||||
|                  "internationalization, or use c_strcasecmp , " | ||||
|                  "gnulib module c-strcase) if you want a locale " | ||||
|                  "independent function"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| /* Compare no more than N bytes of strings S1 and S2, ignoring case,
 | ||||
|    returning less than, equal to or greater than zero if S1 is | ||||
|    lexicographically less than, equal to or greater than S2. | ||||
|    Note: This function cannot work correctly in multibyte locales.  */ | ||||
| #if ! @HAVE_DECL_STRNCASECMP@ | ||||
| extern int strncasecmp (char const *s1, char const *s2, size_t n) | ||||
|      _GL_ARG_NONNULL ((1, 2)); | ||||
| #endif | ||||
| #if defined GNULIB_POSIXCHECK | ||||
| /* strncasecmp() does not work with multibyte strings:
 | ||||
|    POSIX says that it operates on "strings", and "string" in POSIX is defined | ||||
|    as a sequence of bytes, not of characters.  */ | ||||
| # undef strncasecmp | ||||
| # if HAVE_RAW_DECL_STRNCASECMP | ||||
| _GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character " | ||||
|                  "strings in multibyte locales - " | ||||
|                  "use mbsncasecmp or mbspcasecmp if you care about " | ||||
|                  "internationalization, or use c_strncasecmp , " | ||||
|                  "gnulib module c-strcase) if you want a locale " | ||||
|                  "independent function"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _GL_STRING_H */ | ||||
| #endif /* _GL_STRING_H */ | ||||
							
								
								
									
										63
									
								
								grub-core/gnulib/strncasecmp.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								grub-core/gnulib/strncasecmp.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,63 @@ | |||
| /* strncasecmp.c -- case insensitive string comparator
 | ||||
|    Copyright (C) 1998-1999, 2005-2007, 2009-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <string.h> | ||||
| 
 | ||||
| #include <ctype.h> | ||||
| #include <limits.h> | ||||
| 
 | ||||
| #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) | ||||
| 
 | ||||
| /* Compare no more than N bytes of strings S1 and S2, ignoring case,
 | ||||
|    returning less than, equal to or greater than zero if S1 is | ||||
|    lexicographically less than, equal to or greater than S2. | ||||
|    Note: This function cannot work correctly in multibyte locales.  */ | ||||
| 
 | ||||
| int | ||||
| strncasecmp (const char *s1, const char *s2, size_t n) | ||||
| { | ||||
|   register const unsigned char *p1 = (const unsigned char *) s1; | ||||
|   register const unsigned char *p2 = (const unsigned char *) s2; | ||||
|   unsigned char c1, c2; | ||||
| 
 | ||||
|   if (p1 == p2 || n == 0) | ||||
|     return 0; | ||||
| 
 | ||||
|   do | ||||
|     { | ||||
|       c1 = TOLOWER (*p1); | ||||
|       c2 = TOLOWER (*p2); | ||||
| 
 | ||||
|       if (--n == 0 || c1 == '\0') | ||||
|         break; | ||||
| 
 | ||||
|       ++p1; | ||||
|       ++p2; | ||||
|     } | ||||
|   while (c1 == c2); | ||||
| 
 | ||||
|   if (UCHAR_MAX <= INT_MAX) | ||||
|     return c1 - c2; | ||||
|   else | ||||
|     /* On machines where 'char' and 'int' are types of the same size, the
 | ||||
|        difference of two 'unsigned char' values - including the sign bit - | ||||
|        doesn't fit in an 'int'.  */ | ||||
|     return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); | ||||
| } | ||||
							
								
								
									
										37
									
								
								grub-core/gnulib/strndup.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								grub-core/gnulib/strndup.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| /* A replacement function, for systems that lack strndup.
 | ||||
| 
 | ||||
|    Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006, 2007, 2009, | ||||
|    2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| #include <string.h> | ||||
| 
 | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| char * | ||||
| strndup (char const *s, size_t n) | ||||
| { | ||||
|   size_t len = strnlen (s, n); | ||||
|   char *new = malloc (len + 1); | ||||
| 
 | ||||
|   if (new == NULL) | ||||
|     return NULL; | ||||
| 
 | ||||
|   new[len] = '\0'; | ||||
|   return memcpy (new, s, len); | ||||
| } | ||||
							
								
								
									
										31
									
								
								grub-core/gnulib/strnlen.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								grub-core/gnulib/strnlen.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| /* Find the length of STRING, but scan at most MAXLEN characters.
 | ||||
|    Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. | ||||
|    Written by Simon Josefsson. | ||||
| 
 | ||||
|    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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| #include <string.h> | ||||
| 
 | ||||
| /* Find the length of STRING, but scan at most MAXLEN characters.
 | ||||
|    If no '\0' terminator is found in that many characters, return MAXLEN.  */ | ||||
| 
 | ||||
| size_t | ||||
| strnlen (const char *string, size_t maxlen) | ||||
| { | ||||
|   const char *end = memchr (string, '\0', maxlen); | ||||
|   return end ? (size_t) (end - string) : maxlen; | ||||
| } | ||||
|  | @ -1,5 +1,5 @@ | |||
| /* Version hook for Argp.
 | ||||
|    Copyright (C) 2009, 2010 Free Software Foundation, Inc. | ||||
| /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
 | ||||
|    Copyright (C) 2005-2006, 2009-2010 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 | ||||
|  | @ -15,24 +15,21 @@ | |||
|    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| #include <version-etc.h> | ||||
| #include <argp.h> | ||||
| #include <argp-version-etc.h> | ||||
| 
 | ||||
| static const char *program_canonical_name; | ||||
| static const char * const *program_authors; | ||||
| /* Specification.  */ | ||||
| #include "strnlen1.h" | ||||
| 
 | ||||
| static void | ||||
| version_etc_hook (FILE *stream, struct argp_state *state) | ||||
| #include <string.h> | ||||
| 
 | ||||
| /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
 | ||||
|    If no '\0' terminator is found in that many characters, return MAXLEN.  */ | ||||
| /* This is the same as strnlen (string, maxlen - 1) + 1.  */ | ||||
| size_t | ||||
| strnlen1 (const char *string, size_t maxlen) | ||||
| { | ||||
|   version_etc_ar (stream, program_canonical_name, PACKAGE_NAME, VERSION, | ||||
|                   program_authors); | ||||
| } | ||||
| 
 | ||||
| void | ||||
| argp_version_setup (const char *name, const char * const *authors) | ||||
| { | ||||
|   argp_program_version_hook = version_etc_hook; | ||||
|   program_canonical_name = name; | ||||
|   program_authors = authors; | ||||
|   const char *end = (const char *) memchr (string, '\0', maxlen); | ||||
|   if (end != NULL) | ||||
|     return end - string + 1; | ||||
|   else | ||||
|     return maxlen; | ||||
| } | ||||
|  | @ -1,5 +1,5 @@ | |||
| /* Version hook for Argp.
 | ||||
|    Copyright (C) 2009, 2010 Free Software Foundation, Inc. | ||||
| /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
 | ||||
|    Copyright (C) 2005, 2009, 2010 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 | ||||
|  | @ -14,27 +14,26 @@ | |||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 | ||||
| 
 | ||||
| #ifndef _ARGP_VERSION_ETC_H | ||||
| #define _ARGP_VERSION_ETC_H | ||||
| #ifndef _STRNLEN1_H | ||||
| #define _STRNLEN1_H | ||||
| 
 | ||||
| #include <stddef.h> | ||||
| 
 | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Setup standard display of the version information for the `--version'
 | ||||
|    option.  NAME is the canonical program name, and AUTHORS is a NULL- | ||||
|    terminated array of author names. At least one author name must be | ||||
|    given. | ||||
| 
 | ||||
|    If NAME is NULL, the package name (as given by the PACKAGE macro) | ||||
|    is asumed to be the name of the program. | ||||
| /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
 | ||||
|    If no '\0' terminator is found in that many characters, return MAXLEN.  */ | ||||
| /* This is the same as strnlen (string, maxlen - 1) + 1.  */ | ||||
| extern size_t strnlen1 (const char *string, size_t maxlen); | ||||
| 
 | ||||
|    This function is intended to be called before argp_parse(). | ||||
| */ | ||||
| extern void argp_version_setup (const char *name, const char * const *authors); | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _ARGP_VERSION_ETC_H */ | ||||
| 
 | ||||
| #endif /* _STRNLEN1_H */ | ||||
							
								
								
									
										106
									
								
								grub-core/gnulib/sys_wait.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								grub-core/gnulib/sys_wait.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,106 @@ | |||
| /* A POSIX-like <sys/wait.h>.
 | ||||
|    Copyright (C) 2001-2003, 2005-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| 
 | ||||
| #ifndef _GL_SYS_WAIT_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) | ||||
| # @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@ | ||||
| #endif | ||||
| 
 | ||||
| #ifndef _GL_SYS_WAIT_H | ||||
| #define _GL_SYS_WAIT_H | ||||
| 
 | ||||
| #if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) | ||||
| /* Unix API.  */ | ||||
| 
 | ||||
| /* The following macros apply to an argument x, that is a status of a process,
 | ||||
|    as returned by waitpid(). | ||||
|    On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and | ||||
|    WTERMSIG are bits 7..0, while BeOS uses the opposite.  Therefore programs | ||||
|    have to use the abstract macros.  */ | ||||
| 
 | ||||
| /* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x)
 | ||||
|    is true.  */ | ||||
| # ifndef WIFSIGNALED | ||||
| #  define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f) | ||||
| # endif | ||||
| # ifndef WIFEXITED | ||||
| #  define WIFEXITED(x) (WTERMSIG (x) == 0) | ||||
| # endif | ||||
| # ifndef WIFSTOPPED | ||||
| #  define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f) | ||||
| # endif | ||||
| 
 | ||||
| /* The termination signal. Only to be accessed if WIFSIGNALED(x) is true.  */ | ||||
| # ifndef WTERMSIG | ||||
| #  define WTERMSIG(x) ((x) & 0x7f) | ||||
| # endif | ||||
| 
 | ||||
| /* The exit status. Only to be accessed if WIFEXITED(x) is true.  */ | ||||
| # ifndef WEXITSTATUS | ||||
| #  define WEXITSTATUS(x) (((x) >> 8) & 0xff) | ||||
| # endif | ||||
| 
 | ||||
| /* True if the process dumped core.  Not standardized by POSIX.  */ | ||||
| # ifndef WCOREDUMP | ||||
| #  define WCOREDUMP(x) ((x) & 0x80) | ||||
| # endif | ||||
| 
 | ||||
| # ifdef __cplusplus | ||||
| extern "C" { | ||||
| # endif | ||||
| 
 | ||||
| /* Declarations of functions.  */ | ||||
| 
 | ||||
| # ifdef __cplusplus | ||||
| } | ||||
| # endif | ||||
| 
 | ||||
| #else | ||||
| /* Native Windows API.  */ | ||||
| 
 | ||||
| # include <process.h> | ||||
| 
 | ||||
| # define waitpid(pid,statusp,options) _cwait (statusp, pid, WAIT_CHILD) | ||||
| 
 | ||||
| /* The following macros apply to an argument x, that is a status of a process,
 | ||||
|    as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess(). | ||||
|    This value is simply an 'int', not composed of bit fields.  */ | ||||
| 
 | ||||
| /* When an unhandled fatal signal terminates a process, the exit code is 3.  */ | ||||
| # define WIFSIGNALED(x) ((x) == 3) | ||||
| # define WIFEXITED(x) ((x) != 3) | ||||
| # define WIFSTOPPED(x) 0 | ||||
| 
 | ||||
| /* The signal that terminated a process is not known posthum.  */ | ||||
| # define WTERMSIG(x) SIGTERM | ||||
| 
 | ||||
| # define WEXITSTATUS(x) (x) | ||||
| 
 | ||||
| /* There are no core dumps.  */ | ||||
| # define WCOREDUMP(x) 0 | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _GL_SYS_WAIT_H */ | ||||
| #endif /* _GL_SYS_WAIT_H */ | ||||
							
								
								
									
										71
									
								
								grub-core/gnulib/sysexits.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								grub-core/gnulib/sysexits.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,71 @@ | |||
| /* exit() exit codes for some BSD system programs.
 | ||||
|    Copyright (C) 2003, 2006-2010 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 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/>.  */
 | ||||
| 
 | ||||
| /* Written by Simon Josefsson based on sysexits(3) man page */ | ||||
| 
 | ||||
| #ifndef _GL_SYSEXITS_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| #if @HAVE_SYSEXITS_H@ | ||||
| 
 | ||||
| /* IRIX 6.5 has an <unistd.h> that defines a macro EX_OK with a nonzero
 | ||||
|    value.  Override it.  See | ||||
|    <http://lists.gnu.org/archive/html/bug-gnulib/2007-03/msg00361.html>  */
 | ||||
| # ifdef __sgi | ||||
| #  include <unistd.h> | ||||
| #  undef EX_OK | ||||
| # endif | ||||
| 
 | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| # @INCLUDE_NEXT@ @NEXT_SYSEXITS_H@ | ||||
| 
 | ||||
| /* HP-UX 11 <sysexits.h> ends at EX_NOPERM.  */ | ||||
| # ifndef EX_CONFIG | ||||
| #  define EX_CONFIG 78 | ||||
| # endif | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #ifndef _GL_SYSEXITS_H | ||||
| #define _GL_SYSEXITS_H | ||||
| 
 | ||||
| #if !@HAVE_SYSEXITS_H@ | ||||
| 
 | ||||
| # define EX_OK 0 /* same value as EXIT_SUCCESS */ | ||||
| 
 | ||||
| # define EX_USAGE 64 | ||||
| # define EX_DATAERR 65 | ||||
| # define EX_NOINPUT 66 | ||||
| # define EX_NOUSER 67 | ||||
| # define EX_NOHOST 68 | ||||
| # define EX_UNAVAILABLE 69 | ||||
| # define EX_SOFTWARE 70 | ||||
| # define EX_OSERR 71 | ||||
| # define EX_OSFILE 72 | ||||
| # define EX_CANTCREAT 73 | ||||
| # define EX_IOERR 74 | ||||
| # define EX_TEMPFAIL 75 | ||||
| # define EX_PROTOCOL 76 | ||||
| # define EX_NOPERM 77 | ||||
| # define EX_CONFIG 78 | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _GL_SYSEXITS_H */ | ||||
| #endif /* _GL_SYSEXITS_H */ | ||||
							
								
								
									
										1326
									
								
								grub-core/gnulib/unistd.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1326
									
								
								grub-core/gnulib/unistd.in.h
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										5567
									
								
								grub-core/gnulib/vasnprintf.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5567
									
								
								grub-core/gnulib/vasnprintf.c
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										80
									
								
								grub-core/gnulib/vasnprintf.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								grub-core/gnulib/vasnprintf.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,80 @@ | |||
| /* vsprintf with automatic memory allocation.
 | ||||
|    Copyright (C) 2002-2004, 2007-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _VASNPRINTF_H | ||||
| #define _VASNPRINTF_H | ||||
| 
 | ||||
| /* Get va_list.  */ | ||||
| #include <stdarg.h> | ||||
| 
 | ||||
| /* Get size_t.  */ | ||||
| #include <stddef.h> | ||||
| 
 | ||||
| #ifndef __attribute__ | ||||
| /* The __attribute__ feature is available in gcc versions 2.5 and later.
 | ||||
|    The __-protected variants of the attributes 'format' and 'printf' are | ||||
|    accepted by gcc versions 2.6.4 (effectively 2.7) and later. | ||||
|    We enable __attribute__ only if these are supported too, because | ||||
|    gnulib and libintl do '#define printf __printf__' when they override | ||||
|    the 'printf' function.  */ | ||||
| # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) | ||||
| #  define __attribute__(Spec)   /* empty */ | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
| 
 | ||||
| /* Write formatted output to a string dynamically allocated with malloc().
 | ||||
|    You can pass a preallocated buffer for the result in RESULTBUF and its | ||||
|    size in *LENGTHP; otherwise you pass RESULTBUF = NULL. | ||||
|    If successful, return the address of the string (this may be = RESULTBUF | ||||
|    if no dynamic memory allocation was necessary) and set *LENGTHP to the | ||||
|    number of resulting bytes, excluding the trailing NUL.  Upon error, set | ||||
|    errno and return NULL. | ||||
| 
 | ||||
|    When dynamic memory allocation occurs, the preallocated buffer is left | ||||
|    alone (with possibly modified contents).  This makes it possible to use | ||||
|    a statically allocated or stack-allocated buffer, like this: | ||||
| 
 | ||||
|           char buf[100]; | ||||
|           size_t len = sizeof (buf); | ||||
|           char *output = vasnprintf (buf, &len, format, args); | ||||
|           if (output == NULL) | ||||
|             ... error handling ...; | ||||
|           else | ||||
|             { | ||||
|               ... use the output string ...; | ||||
|               if (output != buf) | ||||
|                 free (output); | ||||
|             } | ||||
|   */ | ||||
| #if REPLACE_VASNPRINTF | ||||
| # define asnprintf rpl_asnprintf | ||||
| # define vasnprintf rpl_vasnprintf | ||||
| #endif | ||||
| extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) | ||||
|        __attribute__ ((__format__ (__printf__, 3, 4))); | ||||
| extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) | ||||
|        __attribute__ ((__format__ (__printf__, 3, 0))); | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| #endif /* _VASNPRINTF_H */ | ||||
							
								
								
									
										163
									
								
								grub-core/gnulib/verify.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										163
									
								
								grub-core/gnulib/verify.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,163 @@ | |||
| /* Compile-time assert-like macros.
 | ||||
| 
 | ||||
|    Copyright (C) 2005-2006, 2009-2010 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 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/>.  */
 | ||||
| 
 | ||||
| /* Written by Paul Eggert, Bruno Haible, and Jim Meyering.  */ | ||||
| 
 | ||||
| #ifndef VERIFY_H | ||||
| # define VERIFY_H 1 | ||||
| 
 | ||||
| /* Each of these macros verifies that its argument R is nonzero.  To
 | ||||
|    be portable, R should be an integer constant expression.  Unlike | ||||
|    assert (R), there is no run-time overhead. | ||||
| 
 | ||||
|    There are two macros, since no single macro can be used in all | ||||
|    contexts in C.  verify_true (R) is for scalar contexts, including | ||||
|    integer constant expression contexts.  verify (R) is for declaration | ||||
|    contexts, e.g., the top level. | ||||
| 
 | ||||
|    Symbols ending in "__" are private to this header. | ||||
| 
 | ||||
|    The code below uses several ideas. | ||||
| 
 | ||||
|    * The first step is ((R) ? 1 : -1).  Given an expression R, of | ||||
|      integral or boolean or floating-point type, this yields an | ||||
|      expression of integral type, whose value is later verified to be | ||||
|      constant and nonnegative. | ||||
| 
 | ||||
|    * Next this expression W is wrapped in a type | ||||
|      struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }. | ||||
|      If W is negative, this yields a compile-time error.  No compiler can | ||||
|      deal with a bit-field of negative size. | ||||
| 
 | ||||
|      One might think that an array size check would have the same | ||||
|      effect, that is, that the type struct { unsigned int dummy[W]; } | ||||
|      would work as well.  However, inside a function, some compilers | ||||
|      (such as C++ compilers and GNU C) allow local parameters and | ||||
|      variables inside array size expressions.  With these compilers, | ||||
|      an array size check would not properly diagnose this misuse of | ||||
|      the verify macro: | ||||
| 
 | ||||
|        void function (int n) { verify (n < 0); } | ||||
| 
 | ||||
|    * For the verify macro, the struct verify_type__ will need to | ||||
|      somehow be embedded into a declaration.  To be portable, this | ||||
|      declaration must declare an object, a constant, a function, or a | ||||
|      typedef name.  If the declared entity uses the type directly, | ||||
|      such as in | ||||
| 
 | ||||
|        struct dummy {...}; | ||||
|        typedef struct {...} dummy; | ||||
|        extern struct {...} *dummy; | ||||
|        extern void dummy (struct {...} *); | ||||
|        extern struct {...} *dummy (void); | ||||
| 
 | ||||
|      two uses of the verify macro would yield colliding declarations | ||||
|      if the entity names are not disambiguated.  A workaround is to | ||||
|      attach the current line number to the entity name: | ||||
| 
 | ||||
|        #define _GL_CONCAT0(x, y) x##y | ||||
|        #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) | ||||
|        extern struct {...} * _GL_CONCAT (dummy, __LINE__); | ||||
| 
 | ||||
|      But this has the problem that two invocations of verify from | ||||
|      within the same macro would collide, since the __LINE__ value | ||||
|      would be the same for both invocations.  (The GCC __COUNTER__ | ||||
|      macro solves this problem, but is not portable.) | ||||
| 
 | ||||
|      A solution is to use the sizeof operator.  It yields a number, | ||||
|      getting rid of the identity of the type.  Declarations like | ||||
| 
 | ||||
|        extern int dummy [sizeof (struct {...})]; | ||||
|        extern void dummy (int [sizeof (struct {...})]); | ||||
|        extern int (*dummy (void)) [sizeof (struct {...})]; | ||||
| 
 | ||||
|      can be repeated. | ||||
| 
 | ||||
|    * Should the implementation use a named struct or an unnamed struct? | ||||
|      Which of the following alternatives can be used? | ||||
| 
 | ||||
|        extern int dummy [sizeof (struct {...})]; | ||||
|        extern int dummy [sizeof (struct verify_type__ {...})]; | ||||
|        extern void dummy (int [sizeof (struct {...})]); | ||||
|        extern void dummy (int [sizeof (struct verify_type__ {...})]); | ||||
|        extern int (*dummy (void)) [sizeof (struct {...})]; | ||||
|        extern int (*dummy (void)) [sizeof (struct verify_type__ {...})]; | ||||
| 
 | ||||
|      In the second and sixth case, the struct type is exported to the | ||||
|      outer scope; two such declarations therefore collide.  GCC warns | ||||
|      about the first, third, and fourth cases.  So the only remaining | ||||
|      possibility is the fifth case: | ||||
| 
 | ||||
|        extern int (*dummy (void)) [sizeof (struct {...})]; | ||||
| 
 | ||||
|    * GCC warns about duplicate declarations of the dummy function if | ||||
|      -Wredundant_decls is used.  GCC 4.3 and later have a builtin | ||||
|      __COUNTER__ macro that can let us generate unique identifiers for | ||||
|      each dummy function, to suppress this warning. | ||||
| 
 | ||||
|    * This implementation exploits the fact that GCC does not warn about | ||||
|      the last declaration mentioned above.  If a future version of GCC | ||||
|      introduces a warning for this, the problem could be worked around | ||||
|      by using code specialized to GCC, just as __COUNTER__ is already | ||||
|      being used if available. | ||||
| 
 | ||||
|        #if 4 <= __GNUC__ | ||||
|        # define verify(R) [another version to keep GCC happy] | ||||
|        #endif | ||||
| 
 | ||||
|    * In C++, any struct definition inside sizeof is invalid. | ||||
|      Use a template type to work around the problem.  */ | ||||
| 
 | ||||
| /* Concatenate two preprocessor tokens.  */ | ||||
| # define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) | ||||
| # define _GL_CONCAT0(x, y) x##y | ||||
| 
 | ||||
| /* _GL_COUNTER is an integer, preferably one that changes each time we
 | ||||
|    use it.  Use __COUNTER__ if it works, falling back on __LINE__ | ||||
|    otherwise.  __LINE__ isn't perfect, but it's better than a | ||||
|    constant.  */ | ||||
| # if defined __COUNTER__ && __COUNTER__ != __COUNTER__ | ||||
| #  define _GL_COUNTER __COUNTER__ | ||||
| # else | ||||
| #  define _GL_COUNTER __LINE__ | ||||
| # endif | ||||
| 
 | ||||
| /* Generate a symbol with the given prefix, making it unique if
 | ||||
|    possible.  */ | ||||
| # define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) | ||||
| 
 | ||||
| /* Verify requirement R at compile-time, as an integer constant expression.
 | ||||
|    Return 1.  */ | ||||
| 
 | ||||
| # ifdef __cplusplus | ||||
| template <int w> | ||||
|   struct verify_type__ { unsigned int verify_error_if_negative_size__: w; }; | ||||
| #  define verify_true(R) \ | ||||
|      (!!sizeof (verify_type__<(R) ? 1 : -1>)) | ||||
| # else | ||||
| #  define verify_true(R) \ | ||||
|      (!!sizeof \ | ||||
|       (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; })) | ||||
| # endif | ||||
| 
 | ||||
| /* Verify requirement R at compile-time, as a declaration without a
 | ||||
|    trailing ';'.  */ | ||||
| 
 | ||||
| # define verify(R) \ | ||||
|     extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)] | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										71
									
								
								grub-core/gnulib/vsnprintf.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								grub-core/gnulib/vsnprintf.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,71 @@ | |||
| /* Formatted output to strings.
 | ||||
|    Copyright (C) 2004, 2006-2010 Free Software Foundation, Inc. | ||||
|    Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. | ||||
| 
 | ||||
|    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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License along | ||||
|    with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifdef HAVE_CONFIG_H | ||||
| # include <config.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <stdio.h> | ||||
| 
 | ||||
| #include <errno.h> | ||||
| #include <limits.h> | ||||
| #include <stdarg.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| 
 | ||||
| #include "vasnprintf.h" | ||||
| 
 | ||||
| /* Print formatted output to string STR.  Similar to vsprintf, but
 | ||||
|    additional length SIZE limit how much is written into STR.  Returns | ||||
|    string length of formatted string (which may be larger than SIZE). | ||||
|    STR may be NULL, in which case nothing will be written.  On error, | ||||
|    return a negative value.  */ | ||||
| int | ||||
| vsnprintf (char *str, size_t size, const char *format, va_list args) | ||||
| { | ||||
|   char *output; | ||||
|   size_t len; | ||||
|   size_t lenbuf = size; | ||||
| 
 | ||||
|   output = vasnprintf (str, &lenbuf, format, args); | ||||
|   len = lenbuf; | ||||
| 
 | ||||
|   if (!output) | ||||
|     return -1; | ||||
| 
 | ||||
|   if (output != str) | ||||
|     { | ||||
|       if (size) | ||||
|         { | ||||
|           size_t pruned_len = (len < size ? len : size - 1); | ||||
|           memcpy (str, output, pruned_len); | ||||
|           str[pruned_len] = '\0'; | ||||
|         } | ||||
| 
 | ||||
|       free (output); | ||||
|     } | ||||
| 
 | ||||
|   if (len > INT_MAX) | ||||
|     { | ||||
|       errno = EOVERFLOW; | ||||
|       return -1; | ||||
|     } | ||||
| 
 | ||||
|   return len; | ||||
| } | ||||
							
								
								
									
										428
									
								
								grub-core/gnulib/wchar.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										428
									
								
								grub-core/gnulib/wchar.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,428 @@ | |||
| /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
 | ||||
| 
 | ||||
|    Copyright (C) 2007-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /* Written by Eric Blake.  */ | ||||
| 
 | ||||
| /*
 | ||||
|  * ISO C 99 <wchar.h> for platforms that have issues. | ||||
|  * <http://www.opengroup.org/susv3xbd/wchar.h.html>
 | ||||
|  * | ||||
|  * For now, this just ensures proper prerequisite inclusion order and | ||||
|  * the declaration of wcwidth(). | ||||
|  */ | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| #if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H | ||||
| /* Special invocation convention:
 | ||||
|    - Inside glibc and uClibc header files. | ||||
|    - On HP-UX 11.00 we have a sequence of nested includes | ||||
|      <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>, | ||||
|      once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h> | ||||
|      and once directly.  In both situations 'wint_t' is not yet defined, | ||||
|      therefore we cannot provide the function overrides; instead include only | ||||
|      the system's <wchar.h>. | ||||
|    - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and | ||||
|      the latter includes <wchar.h>.  But here, we have no way to detect whether | ||||
|      <wctype.h> is completely included or is still being included.  */ | ||||
| 
 | ||||
| #@INCLUDE_NEXT@ @NEXT_WCHAR_H@ | ||||
| 
 | ||||
| #else | ||||
| /* Normal invocation convention.  */ | ||||
| 
 | ||||
| #ifndef _GL_WCHAR_H | ||||
| 
 | ||||
| #define _GL_ALREADY_INCLUDING_WCHAR_H | ||||
| 
 | ||||
| /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
 | ||||
|    <wchar.h>. | ||||
|    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||||
|    included before <wchar.h>. | ||||
|    But avoid namespace pollution on glibc systems.  */ | ||||
| #ifndef __GLIBC__ | ||||
| # include <stddef.h> | ||||
| # include <stdio.h> | ||||
| # include <time.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Include the original <wchar.h> if it exists.
 | ||||
|    Some builds of uClibc lack it.  */ | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #if @HAVE_WCHAR_H@ | ||||
| # @INCLUDE_NEXT@ @NEXT_WCHAR_H@ | ||||
| #endif | ||||
| 
 | ||||
| #undef _GL_ALREADY_INCLUDING_WCHAR_H | ||||
| 
 | ||||
| #ifndef _GL_WCHAR_H | ||||
| #define _GL_WCHAR_H | ||||
| 
 | ||||
| /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_ARG_NONNULL is copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_WARN_ON_USE is copied here.  */ | ||||
| 
 | ||||
| 
 | ||||
| /* Define wint_t and WEOF.  (Also done in wctype.in.h.)  */ | ||||
| #if !@HAVE_WINT_T@ && !defined wint_t | ||||
| # define wint_t int | ||||
| # ifndef WEOF | ||||
| #  define WEOF -1 | ||||
| # endif | ||||
| #else | ||||
| # ifndef WEOF | ||||
| #  define WEOF ((wint_t) -1) | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Override mbstate_t if it is too small.
 | ||||
|    On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for | ||||
|    implementing mbrtowc for encodings like UTF-8.  */ | ||||
| #if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ | ||||
| typedef int rpl_mbstate_t; | ||||
| # undef mbstate_t | ||||
| # define mbstate_t rpl_mbstate_t | ||||
| # define GNULIB_defined_mbstate_t 1 | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Convert a single-byte character to a wide character.  */ | ||||
| #if @GNULIB_BTOWC@ | ||||
| # if @REPLACE_BTOWC@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef btowc | ||||
| #   define btowc rpl_btowc | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (btowc, wint_t, (int c)); | ||||
| _GL_CXXALIAS_RPL (btowc, wint_t, (int c)); | ||||
| # else | ||||
| #  if !@HAVE_BTOWC@ | ||||
| _GL_FUNCDECL_SYS (btowc, wint_t, (int c)); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (btowc, wint_t, (int c)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (btowc); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef btowc | ||||
| # if HAVE_RAW_DECL_BTOWC | ||||
| _GL_WARN_ON_USE (btowc, "btowc is unportable - " | ||||
|                  "use gnulib module btowc for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Convert a wide character to a single-byte character.  */ | ||||
| #if @GNULIB_WCTOB@ | ||||
| # if @REPLACE_WCTOB@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef wctob | ||||
| #   define wctob rpl_wctob | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (wctob, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (wctob, int, (wint_t wc)); | ||||
| # else | ||||
| #  if !defined wctob && !@HAVE_DECL_WCTOB@ | ||||
| /* wctob is provided by gnulib, or wctob exists but is not declared.  */ | ||||
| _GL_FUNCDECL_SYS (wctob, int, (wint_t wc)); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (wctob); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef wctob | ||||
| # if HAVE_RAW_DECL_WCTOB | ||||
| _GL_WARN_ON_USE (wctob, "wctob is unportable - " | ||||
|                  "use gnulib module wctob for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Test whether *PS is in the initial state.  */ | ||||
| #if @GNULIB_MBSINIT@ | ||||
| # if @REPLACE_MBSINIT@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef mbsinit | ||||
| #   define mbsinit rpl_mbsinit | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbsinit, int, (const mbstate_t *ps)); | ||||
| _GL_CXXALIAS_RPL (mbsinit, int, (const mbstate_t *ps)); | ||||
| # else | ||||
| #  if !@HAVE_MBSINIT@ | ||||
| _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps)); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbsinit); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mbsinit | ||||
| # if HAVE_RAW_DECL_MBSINIT | ||||
| _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - " | ||||
|                  "use gnulib module mbsinit for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Convert a multibyte character to a wide character.  */ | ||||
| #if @GNULIB_MBRTOWC@ | ||||
| # if @REPLACE_MBRTOWC@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef mbrtowc | ||||
| #   define mbrtowc rpl_mbrtowc | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbrtowc, size_t, | ||||
|                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); | ||||
| _GL_CXXALIAS_RPL (mbrtowc, size_t, | ||||
|                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); | ||||
| # else | ||||
| #  if !@HAVE_MBRTOWC@ | ||||
| _GL_FUNCDECL_SYS (mbrtowc, size_t, | ||||
|                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (mbrtowc, size_t, | ||||
|                   (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbrtowc); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mbrtowc | ||||
| # if HAVE_RAW_DECL_MBRTOWC | ||||
| _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - " | ||||
|                  "use gnulib module mbrtowc for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Recognize a multibyte character.  */ | ||||
| #if @GNULIB_MBRLEN@ | ||||
| # if @REPLACE_MBRLEN@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef mbrlen | ||||
| #   define mbrlen rpl_mbrlen | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); | ||||
| _GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); | ||||
| # else | ||||
| #  if !@HAVE_MBRLEN@ | ||||
| _GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbrlen); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mbrlen | ||||
| # if HAVE_RAW_DECL_MBRLEN | ||||
| _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - " | ||||
|                  "use gnulib module mbrlen for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Convert a string to a wide string.  */ | ||||
| #if @GNULIB_MBSRTOWCS@ | ||||
| # if @REPLACE_MBSRTOWCS@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef mbsrtowcs | ||||
| #   define mbsrtowcs rpl_mbsrtowcs | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbsrtowcs, size_t, | ||||
|                   (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| _GL_CXXALIAS_RPL (mbsrtowcs, size_t, | ||||
|                   (wchar_t *dest, const char **srcp, size_t len, | ||||
|                    mbstate_t *ps)); | ||||
| # else | ||||
| #  if !@HAVE_MBSRTOWCS@ | ||||
| _GL_FUNCDECL_SYS (mbsrtowcs, size_t, | ||||
|                   (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (mbsrtowcs, size_t, | ||||
|                   (wchar_t *dest, const char **srcp, size_t len, | ||||
|                    mbstate_t *ps)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbsrtowcs); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mbsrtowcs | ||||
| # if HAVE_RAW_DECL_MBSRTOWCS | ||||
| _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - " | ||||
|                  "use gnulib module mbsrtowcs for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Convert a string to a wide string.  */ | ||||
| #if @GNULIB_MBSNRTOWCS@ | ||||
| # if @REPLACE_MBSNRTOWCS@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef mbsnrtowcs | ||||
| #   define mbsnrtowcs rpl_mbsnrtowcs | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (mbsnrtowcs, size_t, | ||||
|                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len, | ||||
|                    mbstate_t *ps) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| _GL_CXXALIAS_RPL (mbsnrtowcs, size_t, | ||||
|                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len, | ||||
|                    mbstate_t *ps)); | ||||
| # else | ||||
| #  if !@HAVE_MBSNRTOWCS@ | ||||
| _GL_FUNCDECL_SYS (mbsnrtowcs, size_t, | ||||
|                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len, | ||||
|                    mbstate_t *ps) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (mbsnrtowcs, size_t, | ||||
|                   (wchar_t *dest, const char **srcp, size_t srclen, size_t len, | ||||
|                    mbstate_t *ps)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (mbsnrtowcs); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef mbsnrtowcs | ||||
| # if HAVE_RAW_DECL_MBSNRTOWCS | ||||
| _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - " | ||||
|                  "use gnulib module mbsnrtowcs for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Convert a wide character to a multibyte character.  */ | ||||
| #if @GNULIB_WCRTOMB@ | ||||
| # if @REPLACE_WCRTOMB@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef wcrtomb | ||||
| #   define wcrtomb rpl_wcrtomb | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); | ||||
| _GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); | ||||
| # else | ||||
| #  if !@HAVE_WCRTOMB@ | ||||
| _GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (wcrtomb); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef wcrtomb | ||||
| # if HAVE_RAW_DECL_WCRTOMB | ||||
| _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - " | ||||
|                  "use gnulib module wcrtomb for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Convert a wide string to a string.  */ | ||||
| #if @GNULIB_WCSRTOMBS@ | ||||
| # if @REPLACE_WCSRTOMBS@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef wcsrtombs | ||||
| #   define wcsrtombs rpl_wcsrtombs | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (wcsrtombs, size_t, | ||||
|                   (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| _GL_CXXALIAS_RPL (wcsrtombs, size_t, | ||||
|                   (char *dest, const wchar_t **srcp, size_t len, | ||||
|                    mbstate_t *ps)); | ||||
| # else | ||||
| #  if !@HAVE_WCSRTOMBS@ | ||||
| _GL_FUNCDECL_SYS (wcsrtombs, size_t, | ||||
|                   (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (wcsrtombs, size_t, | ||||
|                   (char *dest, const wchar_t **srcp, size_t len, | ||||
|                    mbstate_t *ps)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (wcsrtombs); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef wcsrtombs | ||||
| # if HAVE_RAW_DECL_WCSRTOMBS | ||||
| _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - " | ||||
|                  "use gnulib module wcsrtombs for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Convert a wide string to a string.  */ | ||||
| #if @GNULIB_WCSNRTOMBS@ | ||||
| # if @REPLACE_WCSNRTOMBS@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef wcsnrtombs | ||||
| #   define wcsnrtombs rpl_wcsnrtombs | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (wcsnrtombs, size_t, | ||||
|                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len, | ||||
|                    mbstate_t *ps) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| _GL_CXXALIAS_RPL (wcsnrtombs, size_t, | ||||
|                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len, | ||||
|                    mbstate_t *ps)); | ||||
| # else | ||||
| #  if !@HAVE_WCSNRTOMBS@ | ||||
| _GL_FUNCDECL_SYS (wcsnrtombs, size_t, | ||||
|                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len, | ||||
|                    mbstate_t *ps) | ||||
|                   _GL_ARG_NONNULL ((2))); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (wcsnrtombs, size_t, | ||||
|                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len, | ||||
|                    mbstate_t *ps)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (wcsnrtombs); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef wcsnrtombs | ||||
| # if HAVE_RAW_DECL_WCSNRTOMBS | ||||
| _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - " | ||||
|                  "use gnulib module wcsnrtombs for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* Return the number of screen columns needed for WC.  */ | ||||
| #if @GNULIB_WCWIDTH@ | ||||
| # if @REPLACE_WCWIDTH@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   undef wcwidth | ||||
| #   define wcwidth rpl_wcwidth | ||||
| #  endif | ||||
| _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t)); | ||||
| _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); | ||||
| # else | ||||
| #  if !@HAVE_DECL_WCWIDTH@ | ||||
| /* wcwidth exists but is not declared.  */ | ||||
| _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t)); | ||||
| #  endif | ||||
| _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); | ||||
| # endif | ||||
| _GL_CXXALIASWARN (wcwidth); | ||||
| #elif defined GNULIB_POSIXCHECK | ||||
| # undef wcwidth | ||||
| # if HAVE_RAW_DECL_WCWIDTH | ||||
| _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - " | ||||
|                  "use gnulib module wcwidth for portability"); | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #endif /* _GL_WCHAR_H */ | ||||
| #endif /* _GL_WCHAR_H */ | ||||
| #endif | ||||
							
								
								
									
										53
									
								
								grub-core/gnulib/wcrtomb.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								grub-core/gnulib/wcrtomb.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,53 @@ | |||
| /* Convert wide character to multibyte character.
 | ||||
|    Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. | ||||
|    Written by Bruno Haible <bruno@clisp.org>, 2008. | ||||
| 
 | ||||
|    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 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/>.  */
 | ||||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| /* Specification.  */ | ||||
| #include <wchar.h> | ||||
| 
 | ||||
| #include <errno.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| 
 | ||||
| size_t | ||||
| wcrtomb (char *s, wchar_t wc, mbstate_t *ps) | ||||
| { | ||||
|   /* This implementation of wcrtomb on top of wctomb() supports only
 | ||||
|      stateless encodings.  ps must be in the initial state.  */ | ||||
|   if (ps != NULL && !mbsinit (ps)) | ||||
|     { | ||||
|       errno = EINVAL; | ||||
|       return (size_t)(-1); | ||||
|     } | ||||
| 
 | ||||
|   if (s == NULL) | ||||
|     /* We know the NUL wide character corresponds to the NUL character.  */ | ||||
|     return 1; | ||||
|   else | ||||
|     { | ||||
|       int ret = wctomb (s, wc); | ||||
| 
 | ||||
|       if (ret >= 0) | ||||
|         return ret; | ||||
|       else | ||||
|         { | ||||
|           errno = EILSEQ; | ||||
|           return (size_t)(-1); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										392
									
								
								grub-core/gnulib/wctype.in.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										392
									
								
								grub-core/gnulib/wctype.in.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,392 @@ | |||
| /* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
 | ||||
| 
 | ||||
|    Copyright (C) 2006-2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| /* Written by Bruno Haible and Paul Eggert.  */ | ||||
| 
 | ||||
| /*
 | ||||
|  * ISO C 99 <wctype.h> for platforms that lack it. | ||||
|  * <http://www.opengroup.org/susv3xbd/wctype.h.html>
 | ||||
|  * | ||||
|  * iswctype, towctrans, towlower, towupper, wctrans, wctype, | ||||
|  * wctrans_t, and wctype_t are not yet implemented. | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _GL_WCTYPE_H | ||||
| 
 | ||||
| #if __GNUC__ >= 3 | ||||
| @PRAGMA_SYSTEM_HEADER@ | ||||
| #endif | ||||
| 
 | ||||
| #if @HAVE_WINT_T@ | ||||
| /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
 | ||||
|    Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | ||||
|    <wchar.h>. | ||||
|    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | ||||
|    included before <wchar.h>.  */ | ||||
| # include <stddef.h> | ||||
| # include <stdio.h> | ||||
| # include <time.h> | ||||
| # include <wchar.h> | ||||
| #endif | ||||
| 
 | ||||
| /* Include the original <wctype.h> if it exists.
 | ||||
|    BeOS 5 has the functions but no <wctype.h>.  */ | ||||
| /* The include_next requires a split double-inclusion guard.  */ | ||||
| #if @HAVE_WCTYPE_H@ | ||||
| # @INCLUDE_NEXT@ @NEXT_WCTYPE_H@ | ||||
| #endif | ||||
| 
 | ||||
| #ifndef _GL_WCTYPE_H | ||||
| #define _GL_WCTYPE_H | ||||
| 
 | ||||
| /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */ | ||||
| 
 | ||||
| /* The definition of _GL_WARN_ON_USE is copied here.  */ | ||||
| 
 | ||||
| /* Define wint_t and WEOF.  (Also done in wchar.in.h.)  */ | ||||
| #if !@HAVE_WINT_T@ && !defined wint_t | ||||
| # define wint_t int | ||||
| # ifndef WEOF | ||||
| #  define WEOF -1 | ||||
| # endif | ||||
| #else | ||||
| # ifndef WEOF | ||||
| #  define WEOF ((wint_t) -1) | ||||
| # endif | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
 | ||||
|    Linux libc5 has <wctype.h> and the functions but they are broken. | ||||
|    Assume all 11 functions (all isw* except iswblank) are implemented the | ||||
|    same way, or not at all.  */ | ||||
| #if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ | ||||
| 
 | ||||
| /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
 | ||||
|    undefined variable _ctmp_ and to <ctype.h> macros like _P, and they | ||||
|    refer to system functions like _iswctype that are not in the | ||||
|    standard C library.  Rather than try to get ancient buggy | ||||
|    implementations like this to work, just disable them.  */ | ||||
| # undef iswalnum | ||||
| # undef iswalpha | ||||
| # undef iswblank | ||||
| # undef iswcntrl | ||||
| # undef iswdigit | ||||
| # undef iswgraph | ||||
| # undef iswlower | ||||
| # undef iswprint | ||||
| # undef iswpunct | ||||
| # undef iswspace | ||||
| # undef iswupper | ||||
| # undef iswxdigit | ||||
| # undef towlower | ||||
| # undef towupper | ||||
| 
 | ||||
| /* Linux libc5 has <wctype.h> and the functions but they are broken.  */ | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define iswalnum rpl_iswalnum | ||||
| #   define iswalpha rpl_iswalpha | ||||
| #   define iswblank rpl_iswblank | ||||
| #   define iswcntrl rpl_iswcntrl | ||||
| #   define iswdigit rpl_iswdigit | ||||
| #   define iswgraph rpl_iswgraph | ||||
| #   define iswlower rpl_iswlower | ||||
| #   define iswprint rpl_iswprint | ||||
| #   define iswpunct rpl_iswpunct | ||||
| #   define iswspace rpl_iswspace | ||||
| #   define iswupper rpl_iswupper | ||||
| #   define iswxdigit rpl_iswxdigit | ||||
| #   define towlower rpl_towlower | ||||
| #   define towupper rpl_towupper | ||||
| #  endif | ||||
| # endif | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswalnum | ||||
| # else | ||||
| iswalnum | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return ((wc >= '0' && wc <= '9') | ||||
|           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswalpha | ||||
| # else | ||||
| iswalpha | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswblank | ||||
| # else | ||||
| iswblank | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return wc == ' ' || wc == '\t'; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswcntrl | ||||
| # else | ||||
| iswcntrl | ||||
| # endif | ||||
|         (wint_t wc) | ||||
| { | ||||
|   return (wc & ~0x1f) == 0 || wc == 0x7f; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswdigit | ||||
| # else | ||||
| iswdigit | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return wc >= '0' && wc <= '9'; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswgraph | ||||
| # else | ||||
| iswgraph | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return wc >= '!' && wc <= '~'; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswlower | ||||
| # else | ||||
| iswlower | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return wc >= 'a' && wc <= 'z'; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswprint | ||||
| # else | ||||
| iswprint | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return wc >= ' ' && wc <= '~'; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswpunct | ||||
| # else | ||||
| iswpunct | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return (wc >= '!' && wc <= '~' | ||||
|           && !((wc >= '0' && wc <= '9') | ||||
|                || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswspace | ||||
| # else | ||||
| iswspace | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return (wc == ' ' || wc == '\t' | ||||
|           || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswupper | ||||
| # else | ||||
| iswupper | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return wc >= 'A' && wc <= 'Z'; | ||||
| } | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_iswxdigit | ||||
| # else | ||||
| iswxdigit | ||||
| # endif | ||||
|           (wint_t wc) | ||||
| { | ||||
|   return ((wc >= '0' && wc <= '9') | ||||
|           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); | ||||
| } | ||||
| 
 | ||||
| static inline wint_t | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_towlower | ||||
| # else | ||||
| towlower | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); | ||||
| } | ||||
| 
 | ||||
| static inline wint_t | ||||
| # if @REPLACE_ISWCNTRL@ | ||||
| rpl_towupper | ||||
| # else | ||||
| towupper | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); | ||||
| } | ||||
| 
 | ||||
| #elif ! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@ | ||||
| /* Only the iswblank function is missing.  */ | ||||
| 
 | ||||
| # if @REPLACE_ISWBLANK@ | ||||
| #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #   define iswblank rpl_iswblank | ||||
| #  endif | ||||
| # endif | ||||
| 
 | ||||
| static inline int | ||||
| # if @REPLACE_ISWBLANK@ | ||||
| rpl_iswblank | ||||
| # else | ||||
| iswblank | ||||
| # endif | ||||
|          (wint_t wc) | ||||
| { | ||||
|   return wc == ' ' || wc == '\t'; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #if defined __MINGW32__ | ||||
| 
 | ||||
| /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
 | ||||
|    The functions towlower and towupper are implemented in the MSVCRT library | ||||
|    to take a wchar_t argument and return a wchar_t result.  mingw declares | ||||
|    these functions to take a wint_t argument and return a wint_t result. | ||||
|    This means that: | ||||
|    1. When the user passes an argument outside the range 0x0000..0xFFFF, the | ||||
|       function will look only at the lower 16 bits.  This is allowed according | ||||
|       to POSIX. | ||||
|    2. The return value is returned in the lower 16 bits of the result register. | ||||
|       The upper 16 bits are random: whatever happened to be in that part of the | ||||
|       result register.  We need to fix this by adding a zero-extend from | ||||
|       wchar_t to wint_t after the call.  */ | ||||
| 
 | ||||
| static inline wint_t | ||||
| rpl_towlower (wint_t wc) | ||||
| { | ||||
|   return (wint_t) (wchar_t) towlower (wc); | ||||
| } | ||||
| # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #  define towlower rpl_towlower | ||||
| # endif | ||||
| 
 | ||||
| static inline wint_t | ||||
| rpl_towupper (wint_t wc) | ||||
| { | ||||
|   return (wint_t) (wchar_t) towupper (wc); | ||||
| } | ||||
| # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||||
| #  define towupper rpl_towupper | ||||
| # endif | ||||
| 
 | ||||
| #endif /* __MINGW32__ */ | ||||
| 
 | ||||
| #if @REPLACE_ISWCNTRL@ | ||||
| _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswlower, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswprint, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswspace, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswupper, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc)); | ||||
| #else | ||||
| _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); | ||||
| # if @REPLACE_ISWBLANK@ | ||||
| _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc)); | ||||
| # else | ||||
| _GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); | ||||
| # endif | ||||
| _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); | ||||
| #endif | ||||
| _GL_CXXALIASWARN (iswalnum); | ||||
| _GL_CXXALIASWARN (iswalpha); | ||||
| _GL_CXXALIASWARN (iswblank); | ||||
| _GL_CXXALIASWARN (iswcntrl); | ||||
| _GL_CXXALIASWARN (iswdigit); | ||||
| _GL_CXXALIASWARN (iswgraph); | ||||
| _GL_CXXALIASWARN (iswlower); | ||||
| _GL_CXXALIASWARN (iswprint); | ||||
| _GL_CXXALIASWARN (iswpunct); | ||||
| _GL_CXXALIASWARN (iswspace); | ||||
| _GL_CXXALIASWARN (iswupper); | ||||
| _GL_CXXALIASWARN (iswxdigit); | ||||
| 
 | ||||
| #if @REPLACE_ISWCNTRL@ || defined __MINGW32__ | ||||
| _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); | ||||
| _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); | ||||
| #else | ||||
| _GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); | ||||
| _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); | ||||
| #endif | ||||
| _GL_CXXALIASWARN (towlower); | ||||
| _GL_CXXALIASWARN (towupper); | ||||
| 
 | ||||
| 
 | ||||
| #endif /* _GL_WCTYPE_H */ | ||||
| #endif /* _GL_WCTYPE_H */ | ||||
							
								
								
									
										108
									
								
								grub-core/gnulib/xsize.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								grub-core/gnulib/xsize.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,108 @@ | |||
| /* xsize.h -- Checked size_t computations.
 | ||||
| 
 | ||||
|    Copyright (C) 2003, 2008, 2009, 2010 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, 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 General Public License for more details. | ||||
| 
 | ||||
|    You should have received a copy of the GNU General Public License | ||||
|    along with this program; if not, write to the Free Software Foundation, | ||||
|    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */ | ||||
| 
 | ||||
| #ifndef _XSIZE_H | ||||
| #define _XSIZE_H | ||||
| 
 | ||||
| /* Get size_t.  */ | ||||
| #include <stddef.h> | ||||
| 
 | ||||
| /* Get SIZE_MAX.  */ | ||||
| #include <limits.h> | ||||
| #if HAVE_STDINT_H | ||||
| # include <stdint.h> | ||||
| #endif | ||||
| 
 | ||||
| /* The size of memory objects is often computed through expressions of
 | ||||
|    type size_t. Example: | ||||
|       void* p = malloc (header_size + n * element_size). | ||||
|    These computations can lead to overflow.  When this happens, malloc() | ||||
|    returns a piece of memory that is way too small, and the program then | ||||
|    crashes while attempting to fill the memory. | ||||
|    To avoid this, the functions and macros in this file check for overflow. | ||||
|    The convention is that SIZE_MAX represents overflow. | ||||
|    malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc | ||||
|    implementation that uses mmap --, it's recommended to use size_overflow_p() | ||||
|    or size_in_bounds_p() before invoking malloc(). | ||||
|    The example thus becomes: | ||||
|       size_t size = xsum (header_size, xtimes (n, element_size)); | ||||
|       void *p = (size_in_bounds_p (size) ? malloc (size) : NULL); | ||||
| */ | ||||
| 
 | ||||
| /* Convert an arbitrary value >= 0 to type size_t.  */ | ||||
| #define xcast_size_t(N) \ | ||||
|   ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) | ||||
| 
 | ||||
| /* Sum of two sizes, with overflow check.  */ | ||||
| static inline size_t | ||||
| #if __GNUC__ >= 3 | ||||
| __attribute__ ((__pure__)) | ||||
| #endif | ||||
| xsum (size_t size1, size_t size2) | ||||
| { | ||||
|   size_t sum = size1 + size2; | ||||
|   return (sum >= size1 ? sum : SIZE_MAX); | ||||
| } | ||||
| 
 | ||||
| /* Sum of three sizes, with overflow check.  */ | ||||
| static inline size_t | ||||
| #if __GNUC__ >= 3 | ||||
| __attribute__ ((__pure__)) | ||||
| #endif | ||||
| xsum3 (size_t size1, size_t size2, size_t size3) | ||||
| { | ||||
|   return xsum (xsum (size1, size2), size3); | ||||
| } | ||||
| 
 | ||||
| /* Sum of four sizes, with overflow check.  */ | ||||
| static inline size_t | ||||
| #if __GNUC__ >= 3 | ||||
| __attribute__ ((__pure__)) | ||||
| #endif | ||||
| xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) | ||||
| { | ||||
|   return xsum (xsum (xsum (size1, size2), size3), size4); | ||||
| } | ||||
| 
 | ||||
| /* Maximum of two sizes, with overflow check.  */ | ||||
| static inline size_t | ||||
| #if __GNUC__ >= 3 | ||||
| __attribute__ ((__pure__)) | ||||
| #endif | ||||
| xmax (size_t size1, size_t size2) | ||||
| { | ||||
|   /* No explicit check is needed here, because for any n:
 | ||||
|      max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX.  */ | ||||
|   return (size1 >= size2 ? size1 : size2); | ||||
| } | ||||
| 
 | ||||
| /* Multiplication of a count with an element size, with overflow check.
 | ||||
|    The count must be >= 0 and the element size must be > 0. | ||||
|    This is a macro, not an inline function, so that it works correctly even | ||||
|    when N is of a wider type and N > SIZE_MAX.  */ | ||||
| #define xtimes(N, ELSIZE) \ | ||||
|   ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX) | ||||
| 
 | ||||
| /* Check for overflow.  */ | ||||
| #define size_overflow_p(SIZE) \ | ||||
|   ((SIZE) == SIZE_MAX) | ||||
| /* Check against overflow.  */ | ||||
| #define size_in_bounds_p(SIZE) \ | ||||
|   ((SIZE) != SIZE_MAX) | ||||
| 
 | ||||
| #endif /* _XSIZE_H */ | ||||
|  | @ -29,7 +29,7 @@ nl_langinfo (nl_item item) | |||
|   switch (item) | ||||
|     { | ||||
|     case CODESET: | ||||
|       return locale_charset (); | ||||
|       return "UTF-8"; | ||||
|     default: | ||||
|       return ""; | ||||
|     } | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ | |||
| #ifndef GRUB_POSIX_LOCALCHARSET_H | ||||
| #define GRUB_POSIX_LOCALCHARSET_H	1 | ||||
| 
 | ||||
| static inline char * | ||||
| static inline const char * | ||||
| locale_charset (void) | ||||
| { | ||||
|   return "UTF-8"; | ||||
|  |  | |||
							
								
								
									
										30
									
								
								m4/00gnulib.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								m4/00gnulib.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| # 00gnulib.m4 serial 2 | ||||
| dnl Copyright (C) 2009-2010 Free Software Foundation, Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| dnl This file must be named something that sorts before all other | ||||
| dnl gnulib-provided .m4 files.  It is needed until such time as we can | ||||
| dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. | ||||
| 
 | ||||
| # AC_DEFUN_ONCE([NAME], VALUE) | ||||
| # ---------------------------- | ||||
| # Define NAME to expand to VALUE on the first use (whether by direct | ||||
| # expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. | ||||
| # Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier.  This | ||||
| # definition is slower than the version in Autoconf 2.64, because it | ||||
| # can only use interfaces that existed since 2.59; but it achieves the | ||||
| # same effect.  Quoting is necessary to avoid confusing Automake. | ||||
| m4_version_prereq([2.63.263], [], | ||||
| [m4_define([AC][_DEFUN_ONCE], | ||||
|   [AC][_DEFUN([$1], | ||||
|     [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], | ||||
|       [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl | ||||
| [AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) | ||||
| 
 | ||||
| # gl_00GNULIB | ||||
| # ----------- | ||||
| # Witness macro that this file has been included.  Needed to force | ||||
| # Automake to include this file prior to all other gnulib .m4 files. | ||||
| AC_DEFUN([gl_00GNULIB]) | ||||
							
								
								
									
										47
									
								
								m4/alloca.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								m4/alloca.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,47 @@ | |||
| # alloca.m4 serial 9 | ||||
| dnl Copyright (C) 2002-2004, 2006-2007, 2009-2010 Free Software Foundation, | ||||
| dnl Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| AC_DEFUN([gl_FUNC_ALLOCA], | ||||
| [ | ||||
|   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57. | ||||
|   AC_REQUIRE([AC_PROG_CPP]) | ||||
|   AC_REQUIRE([AC_PROG_EGREP]) | ||||
| 
 | ||||
|   AC_REQUIRE([AC_FUNC_ALLOCA]) | ||||
|   if test $ac_cv_func_alloca_works = no; then | ||||
|     gl_PREREQ_ALLOCA | ||||
|   fi | ||||
| 
 | ||||
|   # Define an additional variable used in the Makefile substitution. | ||||
|   if test $ac_cv_working_alloca_h = yes; then | ||||
|     AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [ | ||||
|       AC_EGREP_CPP([Need own alloca], [ | ||||
| #if defined __GNUC__ || defined _AIX || defined _MSC_VER | ||||
|         Need own alloca | ||||
| #endif | ||||
|         ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no]) | ||||
|     ]) | ||||
|     if test $gl_cv_rpl_alloca = yes; then | ||||
|       dnl OK, alloca can be implemented through a compiler built-in. | ||||
|       AC_DEFINE([HAVE_ALLOCA], [1], | ||||
|         [Define to 1 if you have 'alloca' after including <alloca.h>, | ||||
|          a header that may be supplied by this distribution.]) | ||||
|       ALLOCA_H=alloca.h | ||||
|     else | ||||
|       dnl alloca exists as a library function, i.e. it is slow and probably | ||||
|       dnl a memory leak. Don't define HAVE_ALLOCA in this case. | ||||
|       ALLOCA_H= | ||||
|     fi | ||||
|   else | ||||
|     ALLOCA_H=alloca.h | ||||
|   fi | ||||
|   AC_SUBST([ALLOCA_H]) | ||||
| ]) | ||||
| 
 | ||||
| # Prerequisites of lib/alloca.c. | ||||
| # STACK_DIRECTION is already handled by AC_FUNC_ALLOCA. | ||||
| AC_DEFUN([gl_PREREQ_ALLOCA], [:]) | ||||
							
								
								
									
										65
									
								
								m4/argp.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								m4/argp.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,65 @@ | |||
| # argp.m4 serial 11 | ||||
| dnl Copyright (C) 2003-2010 Free Software Foundation, Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| AC_DEFUN([gl_ARGP], | ||||
| [ | ||||
|   AC_REQUIRE([AC_C_INLINE]) | ||||
|   AC_REQUIRE([AC_C_RESTRICT]) | ||||
|   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||||
|   dnl argp-parse.c depends on GNU getopt internals, therefore use GNU getopt | ||||
|   dnl always. | ||||
|   gl_REPLACE_GETOPT | ||||
|   dnl Note: gl_REPLACE_GETOPT does AC_LIBOBJ([getopt]), AC_LIBOBJ([getopt1]). | ||||
| 
 | ||||
|   AC_CHECK_DECL([program_invocation_name], | ||||
|                 [AC_DEFINE([HAVE_DECL_PROGRAM_INVOCATION_NAME], [1], | ||||
|                            [Define if program_invocation_name is declared])], | ||||
|                 [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_NAME], [1], | ||||
|                            [Define to 1 to add extern declaration of program_invocation_name to argp.h])], | ||||
|                 [#include <errno.h>]) | ||||
|   AC_CHECK_DECL([program_invocation_short_name], | ||||
|                 [AC_DEFINE([HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME], [1], | ||||
|                            [Define if program_invocation_short_name is declared])], | ||||
|                 [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_SHORT_NAME], [1], | ||||
|                            [Define to 1 to add extern declaration of program_invocation_short_name to argp.h])], | ||||
|                 [#include <errno.h>]) | ||||
| 
 | ||||
|   # Check if program_invocation_name and program_invocation_short_name | ||||
|   # are defined elsewhere. It is improbable that only one of them will | ||||
|   # be defined and other not, I prefer to stay on the safe side and to | ||||
|   # test each one separately. | ||||
|   AC_MSG_CHECKING([whether program_invocation_name is defined]) | ||||
|   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <argp.h>]], | ||||
|                                   [[program_invocation_name = "test";]])], | ||||
|                  [AC_DEFINE([HAVE_PROGRAM_INVOCATION_NAME], [1], | ||||
|                             [Define if program_invocation_name is defined]) | ||||
|                   AC_MSG_RESULT([yes])], | ||||
|                  [AC_MSG_RESULT([no])]) | ||||
| 
 | ||||
|   AC_MSG_CHECKING([whether program_invocation_short_name is defined]) | ||||
|   AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <argp.h>]], | ||||
|                                   [[program_invocation_short_name = "test";]])], | ||||
|                  [AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1], | ||||
|                             [Define if program_invocation_short_name is defined]) | ||||
|                   AC_MSG_RESULT([yes])], | ||||
|                  [AC_MSG_RESULT([no])]) | ||||
| 
 | ||||
|   AC_CHECK_DECLS_ONCE([clearerr_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([feof_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([ferror_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([fflush_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([fgets_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([fputc_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([fputs_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([fread_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([fwrite_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([getc_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([getchar_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([putc_unlocked]) | ||||
|   AC_CHECK_DECLS_ONCE([putchar_unlocked]) | ||||
|   AC_CHECK_FUNCS_ONCE([flockfile funlockfile]) | ||||
|   AC_CHECK_HEADERS_ONCE([features.h linewrap.h]) | ||||
| ]) | ||||
							
								
								
									
										48
									
								
								m4/asm-underscore.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								m4/asm-underscore.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,48 @@ | |||
| # asm-underscore.m4 serial 1 | ||||
| dnl Copyright (C) 2010 Free Software Foundation, Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp. | ||||
| 
 | ||||
| # gl_ASM_SYMBOL_PREFIX | ||||
| # Tests for the prefix of C symbols at the assembly language level and the | ||||
| # linker level. This prefix is either an underscore or empty. Defines the | ||||
| # C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to | ||||
| # a stringified variant of this prefix. | ||||
| 
 | ||||
| AC_DEFUN([gl_ASM_SYMBOL_PREFIX], | ||||
| [ | ||||
|   dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because | ||||
|   dnl 1. It works only for GCC. | ||||
|   dnl 2. It is incorrectly defined on some platforms, in some GCC versions. | ||||
|   AC_CACHE_CHECK( | ||||
|     [whether C symbols are prefixed with underscore at the linker level], | ||||
|     [gl_cv_prog_as_underscore], | ||||
|     [cat > conftest.c <<EOF | ||||
| #ifdef __cplusplus | ||||
| extern "C" int foo (void); | ||||
| #endif | ||||
| int foo(void) { return 0; } | ||||
| EOF | ||||
|      # Look for the assembly language name in the .s file. | ||||
|      AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c) >/dev/null 2>&1 | ||||
|      if grep _foo conftest.s >/dev/null ; then | ||||
|        gl_cv_prog_as_underscore=yes | ||||
|      else | ||||
|        gl_cv_prog_as_underscore=no | ||||
|      fi | ||||
|      rm -f conftest* | ||||
|     ]) | ||||
|   if test $gl_cv_prog_as_underscore = yes; then | ||||
|     USER_LABEL_PREFIX=_ | ||||
|   else | ||||
|     USER_LABEL_PREFIX= | ||||
|   fi | ||||
|   AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX], | ||||
|     [Define to the prefix of C symbols at the assembler and linker level, | ||||
|      either an underscore or empty.]) | ||||
|   ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"' | ||||
|   AC_SUBST([ASM_SYMBOL_PREFIX]) | ||||
| ]) | ||||
							
								
								
									
										109
									
								
								m4/btowc.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								m4/btowc.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,109 @@ | |||
| # btowc.m4 serial 7 | ||||
| dnl Copyright (C) 2008-2010 Free Software Foundation, Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| AC_DEFUN([gl_FUNC_BTOWC], | ||||
| [ | ||||
|   AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | ||||
| 
 | ||||
|   dnl Check whether <wchar.h> is usable at all, first. Otherwise the test | ||||
|   dnl program below may lead to an endless loop. See | ||||
|   dnl <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. | ||||
|   AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) | ||||
| 
 | ||||
|   AC_CHECK_FUNCS_ONCE([btowc]) | ||||
|   if test $ac_cv_func_btowc = no; then | ||||
|     HAVE_BTOWC=0 | ||||
|   else | ||||
| 
 | ||||
|     AC_REQUIRE([AC_PROG_CC]) | ||||
|     AC_REQUIRE([gt_LOCALE_FR]) | ||||
|     AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles | ||||
| 
 | ||||
|     dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0. | ||||
|     AC_CACHE_CHECK([whether btowc(0) is correct], | ||||
|       [gl_cv_func_btowc_nul], | ||||
|       [ | ||||
|         AC_RUN_IFELSE( | ||||
|           [AC_LANG_SOURCE([[ | ||||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
| #include <wchar.h> | ||||
| int main () | ||||
| { | ||||
|   if (btowc ('\0') != 0) | ||||
|     return 1; | ||||
|   return 0; | ||||
| }]])], | ||||
|           [gl_cv_func_btowc_nul=yes], | ||||
|           [gl_cv_func_btowc_nul=no], | ||||
|           [ | ||||
| changequote(,)dnl | ||||
|            case "$host_os" in | ||||
|                       # Guess no on Cygwin. | ||||
|              cygwin*) gl_cv_func_btowc_nul="guessing no" ;; | ||||
|                       # Guess yes otherwise. | ||||
|              *)       gl_cv_func_btowc_nul="guessing yes" ;; | ||||
|            esac | ||||
| changequote([,])dnl | ||||
|           ]) | ||||
|       ]) | ||||
| 
 | ||||
|     dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF. | ||||
|     AC_CACHE_CHECK([whether btowc(EOF) is correct], | ||||
|       [gl_cv_func_btowc_eof], | ||||
|       [ | ||||
|         dnl Initial guess, used when cross-compiling or when no suitable locale | ||||
|         dnl is present. | ||||
| changequote(,)dnl | ||||
|         case "$host_os" in | ||||
|                  # Guess no on IRIX. | ||||
|           irix*) gl_cv_func_btowc_eof="guessing no" ;; | ||||
|                  # Guess yes otherwise. | ||||
|           *)     gl_cv_func_btowc_eof="guessing yes" ;; | ||||
|         esac | ||||
| changequote([,])dnl | ||||
|         if test $LOCALE_FR != none; then | ||||
|           AC_RUN_IFELSE( | ||||
|             [AC_LANG_SOURCE([[ | ||||
| #include <locale.h> | ||||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
| #include <wchar.h> | ||||
| int main () | ||||
| { | ||||
|   if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) | ||||
|     { | ||||
|       if (btowc (EOF) != WEOF) | ||||
|         return 1; | ||||
|     } | ||||
|   return 0; | ||||
| }]])], | ||||
|             [gl_cv_func_btowc_eof=yes], | ||||
|             [gl_cv_func_btowc_eof=no], | ||||
|             [:]) | ||||
|         fi | ||||
|       ]) | ||||
| 
 | ||||
|     case "$gl_cv_func_btowc_nul" in | ||||
|       *yes) ;; | ||||
|       *) REPLACE_BTOWC=1 ;; | ||||
|     esac | ||||
|     case "$gl_cv_func_btowc_eof" in | ||||
|       *yes) ;; | ||||
|       *) REPLACE_BTOWC=1 ;; | ||||
|     esac | ||||
|   fi | ||||
|   if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then | ||||
|     gl_REPLACE_WCHAR_H | ||||
|     AC_LIBOBJ([btowc]) | ||||
|     gl_PREREQ_BTOWC | ||||
|   fi | ||||
| ]) | ||||
| 
 | ||||
| # Prerequisites of lib/btowc.c. | ||||
| AC_DEFUN([gl_PREREQ_BTOWC], [ | ||||
|   : | ||||
| ]) | ||||
							
								
								
									
										23
									
								
								m4/codeset.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								m4/codeset.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | |||
| # codeset.m4 serial 5 (gettext-0.18.2) | ||||
| dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| dnl From Bruno Haible. | ||||
| 
 | ||||
| AC_DEFUN([AM_LANGINFO_CODESET], | ||||
| [ | ||||
|   AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], | ||||
|     [AC_LINK_IFELSE( | ||||
|        [AC_LANG_PROGRAM( | ||||
|           [[#include <langinfo.h>]], | ||||
|           [[char* cs = nl_langinfo(CODESET); return !cs;]])], | ||||
|        [am_cv_langinfo_codeset=yes], | ||||
|        [am_cv_langinfo_codeset=no]) | ||||
|     ]) | ||||
|   if test $am_cv_langinfo_codeset = yes; then | ||||
|     AC_DEFINE([HAVE_LANGINFO_CODESET], [1], | ||||
|       [Define if you have <langinfo.h> and nl_langinfo(CODESET).]) | ||||
|   fi | ||||
| ]) | ||||
							
								
								
									
										26
									
								
								m4/dirname.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								m4/dirname.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,26 @@ | |||
| #serial 8   -*- autoconf -*- | ||||
| dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| AC_DEFUN([gl_DIRNAME], | ||||
| [ | ||||
|   AC_REQUIRE([gl_DIRNAME_LGPL]) | ||||
|   AC_LIBOBJ([basename]) | ||||
|   AC_LIBOBJ([dirname]) | ||||
| ]) | ||||
| 
 | ||||
| AC_DEFUN([gl_DIRNAME_LGPL], | ||||
| [ | ||||
|   AC_LIBOBJ([basename-lgpl]) | ||||
|   AC_LIBOBJ([dirname-lgpl]) | ||||
|   AC_LIBOBJ([stripslash]) | ||||
| 
 | ||||
|   dnl Prerequisites of lib/dirname.h. | ||||
|   AC_REQUIRE([gl_AC_DOS]) | ||||
|   AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) | ||||
| 
 | ||||
|   dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c, | ||||
|   dnl lib/stripslash.c. | ||||
| ]) | ||||
							
								
								
									
										71
									
								
								m4/dos.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								m4/dos.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,71 @@ | |||
| #serial 11   -*- autoconf -*- | ||||
| 
 | ||||
| # Define some macros required for proper operation of code in lib/*.c | ||||
| # on MSDOS/Windows systems. | ||||
| 
 | ||||
| # Copyright (C) 2000-2001, 2004-2006, 2009-2010 Free Software Foundation, Inc. | ||||
| # This file is free software; the Free Software Foundation | ||||
| # gives unlimited permission to copy and/or distribute it, | ||||
| # with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| # From Jim Meyering. | ||||
| 
 | ||||
| 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([], [[ | ||||
| #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]) | ||||
|       ]) | ||||
| 
 | ||||
|     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([], [[ | ||||
| #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]) | ||||
|         ]) | ||||
|       if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then | ||||
|         ac_fs_drive_letter_can_be_relative=1 | ||||
|       else | ||||
|         ac_fs_drive_letter_can_be_relative=0 | ||||
|       fi | ||||
|     else | ||||
|       ac_fs_accepts_drive_letter_prefix=0 | ||||
|       ac_fs_backslash_is_file_name_separator=0 | ||||
|       ac_fs_drive_letter_can_be_relative=0 | ||||
|     fi | ||||
| 
 | ||||
|     AC_DEFINE_UNQUOTED([FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX], | ||||
|       $ac_fs_accepts_drive_letter_prefix, | ||||
|       [Define on systems for which file names may have a so-called | ||||
|        `drive letter' prefix, define this to compute the length of that | ||||
|        prefix, including the colon.]) | ||||
| 
 | ||||
|     AH_VERBATIM(ISSLASH, | ||||
|     [#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR | ||||
| # define ISSLASH(C) ((C) == '/' || (C) == '\\') | ||||
| #else | ||||
| # define ISSLASH(C) ((C) == '/') | ||||
| #endif]) | ||||
| 
 | ||||
|     AC_DEFINE_UNQUOTED([FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR], | ||||
|       $ac_fs_backslash_is_file_name_separator, | ||||
|       [Define if the backslash character may also serve as a file name | ||||
|        component separator.]) | ||||
| 
 | ||||
|     AC_DEFINE_UNQUOTED([FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE], | ||||
|       $ac_fs_drive_letter_can_be_relative, | ||||
|       [Define if a drive letter prefix denotes a relative path if it is | ||||
|        not followed by a file name component separator.]) | ||||
|   ]) | ||||
							
								
								
									
										38
									
								
								m4/double-slash-root.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								m4/double-slash-root.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,38 @@ | |||
| # double-slash-root.m4 serial 4   -*- Autoconf -*- | ||||
| dnl Copyright (C) 2006, 2008-2010 Free Software Foundation, Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| AC_DEFUN([gl_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 | ||||
|       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 | ||||
|       fi]) | ||||
|   if test "$gl_cv_double_slash_root" = yes; then | ||||
|     AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1], | ||||
|       [Define to 1 if // is a file system root distinct from /.]) | ||||
|   fi | ||||
| ]) | ||||
							
								
								
									
										115
									
								
								m4/errno_h.m4
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								m4/errno_h.m4
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,115 @@ | |||
| # errno_h.m4 serial 6 | ||||
| dnl Copyright (C) 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. | ||||
| dnl This file is free software; the Free Software Foundation | ||||
| dnl gives unlimited permission to copy and/or distribute it, | ||||
| dnl with or without modifications, as long as this notice is preserved. | ||||
| 
 | ||||
| AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], | ||||
| [ | ||||
|   AC_REQUIRE([AC_PROG_CC]) | ||||
|   AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [ | ||||
|     AC_EGREP_CPP([booboo],[ | ||||
| #include <errno.h> | ||||
| #if !defined ENOMSG | ||||
| booboo | ||||
| #endif | ||||
| #if !defined EIDRM | ||||
| booboo | ||||
| #endif | ||||
| #if !defined ENOLINK | ||||
| booboo | ||||
| #endif | ||||
| #if !defined EPROTO | ||||
| booboo | ||||
| #endif | ||||
| #if !defined EMULTIHOP | ||||
| booboo | ||||
| #endif | ||||
| #if !defined EBADMSG | ||||
| booboo | ||||
| #endif | ||||
| #if !defined EOVERFLOW | ||||
| booboo | ||||
| #endif | ||||
| #if !defined ENOTSUP | ||||
| booboo | ||||
| #endif | ||||
| #if !defined ESTALE | ||||
| booboo | ||||
| #endif | ||||
| #if !defined ECANCELED | ||||
| booboo | ||||
| #endif | ||||
|       ], | ||||
|       [gl_cv_header_errno_h_complete=no], | ||||
|       [gl_cv_header_errno_h_complete=yes]) | ||||
|   ]) | ||||
|   if test $gl_cv_header_errno_h_complete = yes; then | ||||
|     ERRNO_H='' | ||||
|   else | ||||
|     gl_CHECK_NEXT_HEADERS([errno.h]) | ||||
|     ERRNO_H='errno.h' | ||||
|   fi | ||||
|   AC_SUBST([ERRNO_H]) | ||||
|   gl_REPLACE_ERRNO_VALUE([EMULTIHOP]) | ||||
|   gl_REPLACE_ERRNO_VALUE([ENOLINK]) | ||||
|   gl_REPLACE_ERRNO_VALUE([EOVERFLOW]) | ||||
| ]) | ||||
| 
 | ||||
| # Assuming $1 = EOVERFLOW. | ||||
| # The EOVERFLOW errno value ought to be defined in <errno.h>, according to | ||||
| # POSIX.  But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and | ||||
| # some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined. | ||||
| # Check for the value of EOVERFLOW. | ||||
| # Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE. | ||||
| AC_DEFUN([gl_REPLACE_ERRNO_VALUE], | ||||
| [ | ||||
|   if test -n "$ERRNO_H"; then | ||||
|     AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [ | ||||
|       AC_EGREP_CPP([yes],[ | ||||
| #include <errno.h> | ||||
| #ifdef ]$1[ | ||||
| yes | ||||
| #endif | ||||
|       ], | ||||
|       [gl_cv_header_errno_h_]$1[=yes], | ||||
|       [gl_cv_header_errno_h_]$1[=no]) | ||||
|       if test $gl_cv_header_errno_h_]$1[ = no; then | ||||
|         AC_EGREP_CPP([yes],[ | ||||
| #define _XOPEN_SOURCE_EXTENDED 1 | ||||
| #include <errno.h> | ||||
| #ifdef ]$1[ | ||||
| yes | ||||
| #endif | ||||
|           ], [gl_cv_header_errno_h_]$1[=hidden]) | ||||
|         if test $gl_cv_header_errno_h_]$1[ = hidden; then | ||||
|           dnl The macro exists but is hidden. | ||||
|           dnl Define it to the same value. | ||||
|           AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [ | ||||
| #define _XOPEN_SOURCE_EXTENDED 1 | ||||
| #include <errno.h> | ||||
| /* The following two lines are a workaround against an autoconf-2.52 bug.  */ | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| ]) | ||||
|         fi | ||||
|       fi | ||||
|     ]) | ||||
|     case $gl_cv_header_errno_h_]$1[ in | ||||
|       yes | no) | ||||
|         ]$1[_HIDDEN=0; ]$1[_VALUE= | ||||
|         ;; | ||||
|       *) | ||||
|         ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1[" | ||||
|         ;; | ||||
|     esac | ||||
|     AC_SUBST($1[_HIDDEN]) | ||||
|     AC_SUBST($1[_VALUE]) | ||||
|   fi | ||||
| ]) | ||||
| 
 | ||||
| dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in. | ||||
| dnl Remove this when we can assume autoconf >= 2.61. | ||||
| m4_ifdef([AC_COMPUTE_INT], [], [ | ||||
|   AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])]) | ||||
| ]) | ||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue