Blame SOURCES/saplocales-2.2.5-rhel8.patch

1a097b
diff -rNu compat-locales-sap-1.0.10.orig/saplocales-2.2.5/iconv/libc-diag.h compat-locales-sap-1.0.10/saplocales-2.2.5/iconv/libc-diag.h
1a097b
--- compat-locales-sap-1.0.10.orig/saplocales-2.2.5/iconv/libc-diag.h	1970-01-01 01:00:00.000000000 +0100
1a097b
+++ compat-locales-sap-1.0.10/saplocales-2.2.5/iconv/libc-diag.h	2018-01-10 07:36:33.762358809 +0100
1a097b
@@ -0,0 +1,74 @@
1a097b
+/* Macros for controlling diagnostic output from the compiler.
1a097b
+   Copyright (C) 2014-2018 Free Software Foundation, Inc.
1a097b
+   This file is part of the GNU C Library.
1a097b
+
1a097b
+   The GNU C Library is free software; you can redistribute it and/or
1a097b
+   modify it under the terms of the GNU Lesser General Public
1a097b
+   License as published by the Free Software Foundation; either
1a097b
+   version 2.1 of the License, or (at your option) any later version.
1a097b
+
1a097b
+   The GNU C Library is distributed in the hope that it will be useful,
1a097b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
1a097b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1a097b
+   Lesser General Public License for more details.
1a097b
+
1a097b
+   You should have received a copy of the GNU Lesser General Public
1a097b
+   License along with the GNU C Library; if not, see
1a097b
+   <http://www.gnu.org/licenses/>.  */
1a097b
+
1a097b
+#ifndef _LIBC_DIAG_H
1a097b
+#define _LIBC_DIAG_H 1
1a097b
+
1a097b
+/* Ignore the value of an expression when a cast to void does not
1a097b
+   suffice (in particular, for a call to a function declared with
1a097b
+   attribute warn_unused_result).  */
1a097b
+#define ignore_value(x) \
1a097b
+  ({ __typeof__ (x) __ignored_value = (x); (void) __ignored_value; })
1a097b
+
1a097b
+/* The macros to control diagnostics are structured like this, rather
1a097b
+   than a single macro that both pushes and pops diagnostic state and
1a097b
+   takes the affected code as an argument, because the GCC pragmas
1a097b
+   work by disabling the diagnostic for a range of source locations
1a097b
+   and do not work when all the pragmas and the affected code are in a
1a097b
+   single macro expansion.  */
1a097b
+
1a097b
+/* Push diagnostic state.  */
1a097b
+#define DIAG_PUSH_NEEDS_COMMENT _Pragma ("GCC diagnostic push")
1a097b
+
1a097b
+/* Pop diagnostic state.  */
1a097b
+#define DIAG_POP_NEEDS_COMMENT _Pragma ("GCC diagnostic pop")
1a097b
+
1a097b
+#define _DIAG_STR1(s) #s
1a097b
+#define _DIAG_STR(s) _DIAG_STR1(s)
1a097b
+
1a097b
+/* Ignore the diagnostic OPTION.  VERSION is the most recent GCC
1a097b
+   version for which the diagnostic has been confirmed to appear in
1a097b
+   the absence of the pragma (in the form MAJOR.MINOR for GCC 4.x,
1a097b
+   just MAJOR for GCC 5 and later).  Uses of this pragma should be
1a097b
+   reviewed when the GCC version given is no longer supported for
1a097b
+   building glibc; the version number should always be on the same
1a097b
+   source line as the macro name, so such uses can be found with grep.
1a097b
+   Uses should come with a comment giving more details of the
1a097b
+   diagnostic, and an architecture on which it is seen if possibly
1a097b
+   optimization-related and not in architecture-specific code.  This
1a097b
+   macro should only be used if the diagnostic seems hard to fix (for
1a097b
+   example, optimization-related false positives).  */
1a097b
+#define DIAG_IGNORE_NEEDS_COMMENT(version, option)     \
1a097b
+  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
1a097b
+
1a097b
+/* Similar to DIAG_IGNORE_NEEDS_COMMENT the following macro ignores the
1a097b
+   diagnostic OPTION but only if optimizations for size are enabled.
1a097b
+   This is required because different warnings may be generated for
1a097b
+   different optimization levels.  For example a key piece of code may
1a097b
+   only generate a warning when compiled at -Os, but at -O2 you could
1a097b
+   still want the warning to be enabled to catch errors.  In this case
1a097b
+   you would use DIAG_IGNORE_Os_NEEDS_COMMENT to disable the warning
1a097b
+   only for -Os.  */
1a097b
+#ifdef __OPTIMIZE_SIZE__
1a097b
+# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option) \
1a097b
+  _Pragma (_DIAG_STR (GCC diagnostic ignored option))
1a097b
+#else
1a097b
+# define DIAG_IGNORE_Os_NEEDS_COMMENT(version, option)
1a097b
+#endif
1a097b
+
1a097b
+#endif /* libc-diag.h */
1a097b
diff -rNu compat-locales-sap-1.0.10.orig/saplocales-2.2.5/iconv/loop.c compat-locales-sap-1.0.10/saplocales-2.2.5/iconv/loop.c
1a097b
--- compat-locales-sap-1.0.10.orig/saplocales-2.2.5/iconv/loop.c	2018-01-09 12:42:01.393580878 +0100
1a097b
+++ compat-locales-sap-1.0.10/saplocales-2.2.5/iconv/loop.c	2018-01-09 12:42:28.069281608 +0100
1a097b
@@ -1,5 +1,5 @@
1a097b
 /* Conversion loop frame work.
1a097b
-   Copyright (C) 1998-2002, 2003, 2005, 2008 Free Software Foundation, Inc.
1a097b
+   Copyright (C) 1998-2018 Free Software Foundation, Inc.
1a097b
    This file is part of the GNU C Library.
1a097b
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
1a097b
 
1a097b
@@ -14,9 +14,8 @@
1a097b
    Lesser General Public License for more details.
1a097b
 
1a097b
    You should have received a copy of the GNU Lesser General Public
1a097b
-   License along with the GNU C Library; if not, write to the Free
1a097b
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1a097b
-   02111-1307 USA.  */
1a097b
+   License along with the GNU C Library; if not, see
1a097b
+   <http://www.gnu.org/licenses/>.  */
1a097b
 
1a097b
 /* This file provides a frame for the reader loop in all conversion modules.
1a097b
    The actual code must (of course) be provided in the actual module source
1a097b
@@ -39,7 +38,7 @@
1a097b
      BODY		this is supposed to expand to the body of the loop.
1a097b
 			The user must provide this.
1a097b
 
1a097b
-     EXTRA_LOOP_DECLS	extra arguments passed from converion loop call.
1a097b
+     EXTRA_LOOP_DECLS	extra arguments passed from conversion loop call.
1a097b
 
1a097b
      INIT_PARAMS	code to define and initialize variables from params.
1a097b
      UPDATE_PARAMS	code to store result in params.
1a097b
@@ -57,17 +56,17 @@
1a097b
 #include <sys/param.h>		/* For MIN.  */
1a097b
 #define __need_size_t
1a097b
 #include <stddef.h>
1a097b
-
1a097b
+#include <libc-diag.h>
1a097b
 
1a097b
 /* We have to provide support for machines which are not able to handled
1a097b
    unaligned memory accesses.  Some of the character encodings have
1a097b
    representations with a fixed width of 2 or 4 bytes.  But if we cannot
1a097b
    access unaligned memory we still have to read byte-wise.  */
1a097b
 #undef FCTNAME2
1a097b
-#if defined _STRING_ARCH_unaligned || !defined DEFINE_UNALIGNED
1a097b
+#if _STRING_ARCH_unaligned || !defined DEFINE_UNALIGNED
1a097b
 /* We can handle unaligned memory access.  */
1a097b
-# define get16(addr) *((__const uint16_t *) (addr))
1a097b
-# define get32(addr) *((__const uint32_t *) (addr))
1a097b
+# define get16(addr) *((const uint16_t *) (addr))
1a097b
+# define get32(addr) *((const uint32_t *) (addr))
1a097b
 
1a097b
 /* We need no special support for writing values either.  */
1a097b
 # define put16(addr, val) *((uint16_t *) (addr)) = (val)
1a097b
@@ -78,13 +77,13 @@
1a097b
 /* Distinguish between big endian and little endian.  */
1a097b
 # if __BYTE_ORDER == __LITTLE_ENDIAN
1a097b
 #  define get16(addr) \
1a097b
-     (((__const unsigned char *) (addr))[1] << 8			      \
1a097b
-      | ((__const unsigned char *) (addr))[0])
1a097b
+     (((const unsigned char *) (addr))[1] << 8				      \
1a097b
+      | ((const unsigned char *) (addr))[0])
1a097b
 #  define get32(addr) \
1a097b
-     (((((__const unsigned char *) (addr))[3] << 8			      \
1a097b
-	| ((__const unsigned char *) (addr))[2]) << 8			      \
1a097b
-       | ((__const unsigned char *) (addr))[1]) << 8			      \
1a097b
-      | ((__const unsigned char *) (addr))[0])
1a097b
+     (((((const unsigned char *) (addr))[3] << 8			      \
1a097b
+	| ((const unsigned char *) (addr))[2]) << 8			      \
1a097b
+       | ((const unsigned char *) (addr))[1]) << 8			      \
1a097b
+      | ((const unsigned char *) (addr))[0])
1a097b
 
1a097b
 #  define put16(addr, val) \
1a097b
      ({ uint16_t __val = (val);						      \
1a097b
@@ -103,13 +102,13 @@
1a097b
 	(void) 0; })
1a097b
 # else
1a097b
 #  define get16(addr) \
1a097b
-     (((__const unsigned char *) (addr))[0] << 8			      \
1a097b
-      | ((__const unsigned char *) (addr))[1])
1a097b
+     (((const unsigned char *) (addr))[0] << 8				      \
1a097b
+      | ((const unsigned char *) (addr))[1])
1a097b
 #  define get32(addr) \
1a097b
-     (((((__const unsigned char *) (addr))[0] << 8			      \
1a097b
-	| ((__const unsigned char *) (addr))[1]) << 8			      \
1a097b
-       | ((__const unsigned char *) (addr))[2]) << 8			      \
1a097b
-      | ((__const unsigned char *) (addr))[3])
1a097b
+     (((((const unsigned char *) (addr))[0] << 8			      \
1a097b
+	| ((const unsigned char *) (addr))[1]) << 8			      \
1a097b
+       | ((const unsigned char *) (addr))[2]) << 8			      \
1a097b
+      | ((const unsigned char *) (addr))[3])
1a097b
 
1a097b
 #  define put16(addr, val) \
1a097b
      ({ uint16_t __val = (val);						      \
1a097b
@@ -214,8 +213,6 @@
1a097b
    points.  */
1a097b
 #define STANDARD_TO_LOOP_ERR_HANDLER(Incr) \
1a097b
   {									      \
1a097b
-    struct __gconv_trans_data *trans;					      \
1a097b
-									      \
1a097b
     result = __GCONV_ILLEGAL_INPUT;					      \
1a097b
 									      \
1a097b
     if (irreversible == NULL)						      \
1a097b
@@ -228,21 +225,17 @@
1a097b
     UPDATE_PARAMS;							      \
1a097b
 									      \
1a097b
     /* First try the transliteration methods.  */			      \
1a097b
-    for (trans = step_data->__trans; trans != NULL; trans = trans->__next)    \
1a097b
-      {									      \
1a097b
-	result = DL_CALL_FCT (trans->__trans_fct,			      \
1a097b
-			      (step, step_data, trans->__data, *inptrp,	      \
1a097b
-			       &inptr, inend, &outptr, irreversible));	      \
1a097b
-	if (result != __GCONV_ILLEGAL_INPUT)				      \
1a097b
-	  break;							      \
1a097b
-      }									      \
1a097b
+    if ((step_data->__flags & __GCONV_TRANSLIT) != 0)			      \
1a097b
+      result = __gconv_transliterate					      \
1a097b
+	(step, step_data, *inptrp,					      \
1a097b
+	 &inptr, inend, &outptr, irreversible);			      \
1a097b
 									      \
1a097b
     REINIT_PARAMS;							      \
1a097b
 									      \
1a097b
     /* If any of them recognized the input continue with the loop.  */	      \
1a097b
     if (result != __GCONV_ILLEGAL_INPUT)				      \
1a097b
       {									      \
1a097b
-	if (__builtin_expect (result == __GCONV_FULL_OUTPUT, 0))	      \
1a097b
+	if (__glibc_unlikely (result == __GCONV_FULL_OUTPUT))		      \
1a097b
 	  break;							      \
1a097b
 									      \
1a097b
 	continue;							      \
1a097b
@@ -343,7 +336,7 @@
1a097b
 
1a097b
 /* Include the file a second time to define the function to handle
1a097b
    unaligned access.  */
1a097b
-#if !defined DEFINE_UNALIGNED && !defined _STRING_ARCH_unaligned \
1a097b
+#if !defined DEFINE_UNALIGNED && !_STRING_ARCH_unaligned \
1a097b
     && MIN_NEEDED_INPUT != 1 && MAX_NEEDED_INPUT % MIN_NEEDED_INPUT == 0 \
1a097b
     && MIN_NEEDED_OUTPUT != 1 && MAX_NEEDED_OUTPUT % MIN_NEEDED_OUTPUT == 0
1a097b
 # undef get16
1a097b
@@ -355,12 +348,10 @@
1a097b
 # define DEFINE_UNALIGNED
1a097b
 # include "loop.c"
1a097b
 # undef DEFINE_UNALIGNED
1a097b
-#endif
1a097b
-
1a097b
-
1a097b
-#if MAX_NEEDED_INPUT > 1
1a097b
-# define SINGLE(fct) SINGLE2 (fct)
1a097b
-# define SINGLE2(fct) fct##_single
1a097b
+#else
1a097b
+# if MAX_NEEDED_INPUT > 1
1a097b
+#  define SINGLE(fct) SINGLE2 (fct)
1a097b
+#  define SINGLE2(fct) fct##_single
1a097b
 static inline int
1a097b
 __attribute ((always_inline))
1a097b
 SINGLE(LOOPFCT) (struct __gconv_step *step,
1a097b
@@ -370,46 +361,57 @@
1a097b
 		 size_t *irreversible EXTRA_LOOP_DECLS)
1a097b
 {
1a097b
   mbstate_t *state = step_data->__statep;
1a097b
-#ifdef LOOP_NEED_FLAGS
1a097b
+#  ifdef LOOP_NEED_FLAGS
1a097b
   int flags = step_data->__flags;
1a097b
-#endif
1a097b
-#ifdef LOOP_NEED_DATA
1a097b
+#  endif
1a097b
+#  ifdef LOOP_NEED_DATA
1a097b
   void *data = step->__data;
1a097b
-#endif
1a097b
+#  endif
1a097b
   int result = __GCONV_OK;
1a097b
   unsigned char bytebuf[MAX_NEEDED_INPUT];
1a097b
   const unsigned char *inptr = *inptrp;
1a097b
   unsigned char *outptr = *outptrp;
1a097b
   size_t inlen;
1a097b
 
1a097b
-#ifdef INIT_PARAMS
1a097b
+#  ifdef INIT_PARAMS
1a097b
   INIT_PARAMS;
1a097b
-#endif
1a097b
+#  endif
1a097b
 
1a097b
-#ifdef UNPACK_BYTES
1a097b
+#  ifdef UNPACK_BYTES
1a097b
   UNPACK_BYTES
1a097b
-#else
1a097b
+#  else
1a097b
   /* Add the bytes from the state to the input buffer.  */
1a097b
+  assert ((state->__count & 7) <= sizeof (state->__value));
1a097b
   for (inlen = 0; inlen < (size_t) (state->__count & 7); ++inlen)
1a097b
     bytebuf[inlen] = state->__value.__wchb[inlen];
1a097b
-#endif
1a097b
+#  endif
1a097b
 
1a097b
   /* Are there enough bytes in the input buffer?  */
1a097b
-  if (__builtin_expect (inptr + (MIN_NEEDED_INPUT - inlen) > inend, 0))
1a097b
+  if (MIN_NEEDED_INPUT > 1
1a097b
+      && __builtin_expect (inptr + (MIN_NEEDED_INPUT - inlen) > inend, 0))
1a097b
     {
1a097b
       *inptrp = inend;
1a097b
-#ifdef STORE_REST
1a097b
+#  ifdef STORE_REST
1a097b
+
1a097b
+      /* Building with -O3 GCC emits a `array subscript is above array
1a097b
+	 bounds' warning.  GCC BZ #64739 has been opened for this.  */
1a097b
+      DIAG_PUSH_NEEDS_COMMENT;
1a097b
+      DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Warray-bounds");
1a097b
+      while (inptr < inend)
1a097b
+	bytebuf[inlen++] = *inptr++;
1a097b
+      DIAG_POP_NEEDS_COMMENT;
1a097b
+
1a097b
       inptr = bytebuf;
1a097b
       inptrp = &inptr;
1a097b
       inend = &bytebuf[inlen];
1a097b
 
1a097b
       STORE_REST
1a097b
-#else
1a097b
+#  else
1a097b
       /* We don't have enough input for another complete input
1a097b
 	 character.  */
1a097b
       while (inptr < inend)
1a097b
 	state->__value.__wchb[inlen++] = *inptr++;
1a097b
-#endif
1a097b
+#  endif
1a097b
 
1a097b
       return __GCONV_INCOMPLETE_INPUT;
1a097b
     }
1a097b
@@ -438,7 +440,7 @@
1a097b
      bytes from the state and at least one more, or the character is still
1a097b
      incomplete, or we have some other error (like illegal input character,
1a097b
      no space in output buffer).  */
1a097b
-  if (__builtin_expect (inptr != bytebuf, 1))
1a097b
+  if (__glibc_likely (inptr != bytebuf))
1a097b
     {
1a097b
       /* We found a new character.  */
1a097b
       assert (inptr - bytebuf > (state->__count & 7));
1a097b
@@ -449,11 +451,11 @@
1a097b
       result = __GCONV_OK;
1a097b
 
1a097b
       /* Clear the state buffer.  */
1a097b
-#ifdef CLEAR_STATE
1a097b
+#  ifdef CLEAR_STATE
1a097b
       CLEAR_STATE;
1a097b
-#else
1a097b
+#  else
1a097b
       state->__count &= ~7;
1a097b
-#endif
1a097b
+#  endif
1a097b
     }
1a097b
   else if (result == __GCONV_INCOMPLETE_INPUT)
1a097b
     {
1a097b
@@ -462,37 +464,38 @@
1a097b
       assert (inend != &bytebuf[MAX_NEEDED_INPUT]);
1a097b
 
1a097b
       *inptrp += inend - bytebuf - (state->__count & 7);
1a097b
-#ifdef STORE_REST
1a097b
+#  ifdef STORE_REST
1a097b
       inptrp = &inptr;
1a097b
 
1a097b
       STORE_REST
1a097b
-#else
1a097b
+#  else
1a097b
       /* We don't have enough input for another complete input
1a097b
 	 character.  */
1a097b
       assert (inend - inptr > (state->__count & ~7));
1a097b
-      assert (inend - inptr <= 7);
1a097b
+      assert (inend - inptr <= sizeof (state->__value));
1a097b
       state->__count = (state->__count & ~7) | (inend - inptr);
1a097b
       inlen = 0;
1a097b
       while (inptr < inend)
1a097b
 	state->__value.__wchb[inlen++] = *inptr++;
1a097b
-#endif
1a097b
+#  endif
1a097b
     }
1a097b
 
1a097b
   return result;
1a097b
 }
1a097b
-# undef SINGLE
1a097b
-# undef SINGLE2
1a097b
-#endif
1a097b
+#  undef SINGLE
1a097b
+#  undef SINGLE2
1a097b
+# endif
1a097b
 
1a097b
 
1a097b
-#ifdef ONEBYTE_BODY
1a097b
+# ifdef ONEBYTE_BODY
1a097b
 /* Define the shortcut function for btowc.  */
1a097b
 static wint_t
1a097b
 gconv_btowc (struct __gconv_step *step, unsigned char c)
1a097b
   ONEBYTE_BODY
1a097b
-# define FROM_ONEBYTE gconv_btowc
1a097b
-#endif
1a097b
+#  define FROM_ONEBYTE gconv_btowc
1a097b
+# endif
1a097b
 
1a097b
+#endif
1a097b
 
1a097b
 /* We remove the macro definitions so that we can include this file again
1a097b
    for the definition of another function.  */
1a097b
diff -rNu compat-locales-sap-1.0.10.orig/saplocales-2.2.5/iconv/skeleton.c compat-locales-sap-1.0.10/saplocales-2.2.5/iconv/skeleton.c
1a097b
--- compat-locales-sap-1.0.10.orig/saplocales-2.2.5/iconv/skeleton.c	2018-01-09 12:42:01.394580867 +0100
1a097b
+++ compat-locales-sap-1.0.10/saplocales-2.2.5/iconv/skeleton.c	2018-01-10 07:58:37.922439161 +0100
1a097b
@@ -1,5 +1,5 @@
1a097b
 /* Skeleton for a conversion module.
1a097b
-   Copyright (C) 1998-2002, 2005 Free Software Foundation, Inc.
1a097b
+   Copyright (C) 1998-2018 Free Software Foundation, Inc.
1a097b
    This file is part of the GNU C Library.
1a097b
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
1a097b
 
1a097b
@@ -14,9 +14,8 @@
1a097b
    Lesser General Public License for more details.
1a097b
 
1a097b
    You should have received a copy of the GNU Lesser General Public
1a097b
-   License along with the GNU C Library; if not, write to the Free
1a097b
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1a097b
-   02111-1307 USA.  */
1a097b
+   License along with the GNU C Library; if not, see
1a097b
+   <http://www.gnu.org/licenses/>.  */
1a097b
 
1a097b
 /* This file can be included to provide definitions of several things
1a097b
    many modules have in common.  It can be customized using the following
1a097b
@@ -39,24 +38,24 @@
1a097b
 
1a097b
      FROM_LOOP_MIN_NEEDED_FROM
1a097b
      FROM_LOOP_MAX_NEEDED_FROM
1a097b
-                        minimal/maximal number of bytes needed on input
1a097b
-                        of one round through the FROM_LOOP.  Defaults
1a097b
-                        to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively.
1a097b
+			minimal/maximal number of bytes needed on input
1a097b
+			of one round through the FROM_LOOP.  Defaults
1a097b
+			to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively.
1a097b
      FROM_LOOP_MIN_NEEDED_TO
1a097b
      FROM_LOOP_MAX_NEEDED_TO
1a097b
-                        minimal/maximal number of bytes needed on output
1a097b
-                        of one round through the FROM_LOOP.  Defaults
1a097b
-                        to MIN_NEEDED_TO and MAX_NEEDED_TO, respectively.
1a097b
+			minimal/maximal number of bytes needed on output
1a097b
+			of one round through the FROM_LOOP.  Defaults
1a097b
+			to MIN_NEEDED_TO and MAX_NEEDED_TO, respectively.
1a097b
      TO_LOOP_MIN_NEEDED_FROM
1a097b
      TO_LOOP_MAX_NEEDED_FROM
1a097b
-                        minimal/maximal number of bytes needed on input
1a097b
-                        of one round through the TO_LOOP.  Defaults
1a097b
-                        to MIN_NEEDED_TO and MAX_NEEDED_TO, respectively.
1a097b
+			minimal/maximal number of bytes needed on input
1a097b
+			of one round through the TO_LOOP.  Defaults
1a097b
+			to MIN_NEEDED_TO and MAX_NEEDED_TO, respectively.
1a097b
      TO_LOOP_MIN_NEEDED_TO
1a097b
      TO_LOOP_MAX_NEEDED_TO
1a097b
-                        minimal/maximal number of bytes needed on output
1a097b
-                        of one round through the TO_LOOP.  Defaults
1a097b
-                        to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively.
1a097b
+			minimal/maximal number of bytes needed on output
1a097b
+			of one round through the TO_LOOP.  Defaults
1a097b
+			to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively.
1a097b
 
1a097b
      FROM_DIRECTION	this macro is supposed to return a value != 0
1a097b
 			if we convert from the current character set,
1a097b
@@ -145,6 +144,7 @@
1a097b
 #endif
1a097b
 
1a097b
 #include <sysdep.h>
1a097b
+#include <stdint.h>
1a097b
 
1a097b
 #ifndef DL_CALL_FCT
1a097b
 # define DL_CALL_FCT(fct, args) fct args
1a097b
@@ -163,7 +163,6 @@
1a097b
 # endif
1a097b
 #endif
1a097b
 
1a097b
-
1a097b
 /* How many bytes are needed at most for the from-charset.  */
1a097b
 #ifndef MAX_NEEDED_FROM
1a097b
 # define MAX_NEEDED_FROM	MIN_NEEDED_FROM
1a097b
@@ -204,10 +203,10 @@
1a097b
 /* Define macros which can access unaligned buffers.  These macros are
1a097b
    supposed to be used only in code outside the inner loops.  For the inner
1a097b
    loops we have other definitions which allow optimized access.  */
1a097b
-#ifdef _STRING_ARCH_unaligned
1a097b
+#if _STRING_ARCH_unaligned
1a097b
 /* We can handle unaligned memory access.  */
1a097b
-# define get16u(addr) *((__const uint16_t *) (addr))
1a097b
-# define get32u(addr) *((__const uint32_t *) (addr))
1a097b
+# define get16u(addr) *((const uint16_t *) (addr))
1a097b
+# define get32u(addr) *((const uint32_t *) (addr))
1a097b
 
1a097b
 /* We need no special support for writing values either.  */
1a097b
 # define put16u(addr, val) *((uint16_t *) (addr)) = (val)
1a097b
@@ -216,13 +215,13 @@
1a097b
 /* Distinguish between big endian and little endian.  */
1a097b
 # if __BYTE_ORDER == __LITTLE_ENDIAN
1a097b
 #  define get16u(addr) \
1a097b
-     (((__const unsigned char *) (addr))[1] << 8			      \
1a097b
-      | ((__const unsigned char *) (addr))[0])
1a097b
+     (((const unsigned char *) (addr))[1] << 8				      \
1a097b
+      | ((const unsigned char *) (addr))[0])
1a097b
 #  define get32u(addr) \
1a097b
-     (((((__const unsigned char *) (addr))[3] << 8			      \
1a097b
-	| ((__const unsigned char *) (addr))[2]) << 8			      \
1a097b
-       | ((__const unsigned char *) (addr))[1]) << 8			      \
1a097b
-      | ((__const unsigned char *) (addr))[0])
1a097b
+     (((((const unsigned char *) (addr))[3] << 8			      \
1a097b
+	| ((const unsigned char *) (addr))[2]) << 8			      \
1a097b
+       | ((const unsigned char *) (addr))[1]) << 8			      \
1a097b
+      | ((const unsigned char *) (addr))[0])
1a097b
 
1a097b
 #  define put16u(addr, val) \
1a097b
      ({ uint16_t __val = (val);						      \
1a097b
@@ -241,13 +240,13 @@
1a097b
 	(void) 0; })
1a097b
 # else
1a097b
 #  define get16u(addr) \
1a097b
-     (((__const unsigned char *) (addr))[0] << 8			      \
1a097b
-      | ((__const unsigned char *) (addr))[1])
1a097b
+     (((const unsigned char *) (addr))[0] << 8				      \
1a097b
+      | ((const unsigned char *) (addr))[1])
1a097b
 #  define get32u(addr) \
1a097b
-     (((((__const unsigned char *) (addr))[0] << 8			      \
1a097b
-	| ((__const unsigned char *) (addr))[1]) << 8			      \
1a097b
-       | ((__const unsigned char *) (addr))[2]) << 8			      \
1a097b
-      | ((__const unsigned char *) (addr))[3])
1a097b
+     (((((const unsigned char *) (addr))[0] << 8			      \
1a097b
+	| ((const unsigned char *) (addr))[1]) << 8			      \
1a097b
+       | ((const unsigned char *) (addr))[2]) << 8			      \
1a097b
+      | ((const unsigned char *) (addr))[3])
1a097b
 
1a097b
 #  define put16u(addr, val) \
1a097b
      ({ uint16_t __val = (val);						      \
1a097b
@@ -410,7 +409,7 @@
1a097b
   /* If the function is called with no input this means we have to reset
1a097b
      to the initial state.  The possibly partly converted input is
1a097b
      dropped.  */
1a097b
-  if (__builtin_expect (do_flush, 0))
1a097b
+  if (__glibc_unlikely (do_flush))
1a097b
     {
1a097b
       /* This should never happen during error handling.  */
1a097b
       assert (outbufstart == NULL);
1a097b
@@ -461,7 +460,7 @@
1a097b
 
1a097b
 		      if (result != __GCONV_EMPTY_INPUT)
1a097b
 			{
1a097b
-			  if (__builtin_expect (outerr != outbuf, 0))
1a097b
+			  if (__glibc_unlikely (outerr != outbuf))
1a097b
 			    {
1a097b
 			      /* We have a problem.  Undo the conversion.  */
1a097b
 			      outbuf = outstart;
1a097b
@@ -502,8 +501,9 @@
1a097b
     }
1a097b
   else
1a097b
     {
1a097b
-      /* We preserve the initial values of the pointer variables.  */
1a097b
-      const unsigned char *inptr = *inptrp;
1a097b
+      /* We preserve the initial values of the pointer variables,
1a097b
+	 but only some conversion modules need it.  */
1a097b
+      const unsigned char *inptr __attribute__ ((__unused__)) = *inptrp;
1a097b
       unsigned char *outbuf = (__builtin_expect (outbufstart == NULL, 1)
1a097b
 			       ? data->__outbuf : *outbufstart);
1a097b
       unsigned char *outend = data->__outbufend;
1a097b
@@ -514,7 +514,7 @@
1a097b
       size_t *lirreversiblep = irreversible ? &lirreversible : NULL;
1a097b
 
1a097b
       /* The following assumes that encodings, which have a variable length
1a097b
-	 what might unalign a buffer even though it is a aligned in the
1a097b
+	 what might unalign a buffer even though it is an aligned in the
1a097b
 	 beginning, either don't have the minimal number of bytes as a divisor
1a097b
 	 of the maximum length or have a minimum length of 1.  This is true
1a097b
 	 for all known and supported encodings.
1a097b
@@ -523,7 +523,7 @@
1a097b
 	 INTERNAL, for which the subexpression evaluates to 1, but INTERNAL
1a097b
 	 buffers are always aligned correctly.  */
1a097b
 #define POSSIBLY_UNALIGNED \
1a097b
-  (!defined _STRING_ARCH_unaligned					      \
1a097b
+  (!_STRING_ARCH_unaligned					              \
1a097b
    && (((FROM_LOOP_MIN_NEEDED_FROM != 1					      \
1a097b
 	 && FROM_LOOP_MAX_NEEDED_FROM % FROM_LOOP_MIN_NEEDED_FROM == 0)	      \
1a097b
 	&& (FROM_LOOP_MIN_NEEDED_TO != 1				      \
1a097b
@@ -554,8 +554,8 @@
1a097b
 	  && consume_incomplete && (data->__statep->__count & 7) != 0)
1a097b
 	{
1a097b
 	  /* Yep, we have some bytes left over.  Process them now.
1a097b
-             But this must not happen while we are called from an
1a097b
-             error handler.  */
1a097b
+	     But this must not happen while we are called from an
1a097b
+	     error handler.  */
1a097b
 	  assert (outbufstart == NULL);
1a097b
 
1a097b
 # if FROM_LOOP_MAX_NEEDED_FROM > 1
1a097b
@@ -593,8 +593,6 @@
1a097b
 
1a097b
       while (1)
1a097b
 	{
1a097b
-	  struct __gconv_trans_data *trans;
1a097b
-
1a097b
 	  /* Remember the start value for this round.  */
1a097b
 	  inptr = *inptrp;
1a097b
 	  /* The outbuf buffer is empty.  */
1a097b
@@ -604,7 +602,7 @@
1a097b
 	  SAVE_RESET_STATE (1);
1a097b
 #endif
1a097b
 
1a097b
-	  if (__builtin_expect (!unaligned, 1))
1a097b
+	  if (__glibc_likely (!unaligned))
1a097b
 	    {
1a097b
 	      if (FROM_DIRECTION)
1a097b
 		/* Run the conversion loop.  */
1a097b
@@ -635,38 +633,31 @@
1a097b
 
1a097b
 	  /* If we were called as part of an error handling module we
1a097b
 	     don't do anything else here.  */
1a097b
-	  if (__builtin_expect (outbufstart != NULL, 0))
1a097b
+	  if (__glibc_unlikely (outbufstart != NULL))
1a097b
 	    {
1a097b
 	      *outbufstart = outbuf;
1a097b
 	      return status;
1a097b
 	    }
1a097b
 
1a097b
-	  /* Give the transliteration module the chance to store the
1a097b
-	     original text and the result in case it needs a context.  */
1a097b
-	  for (trans = data->__trans; trans != NULL; trans = trans->__next)
1a097b
-	    if (trans->__trans_context_fct != NULL)
1a097b
-	      DL_CALL_FCT (trans->__trans_context_fct,
1a097b
-			   (trans->__data, inptr, *inptrp, outstart, outbuf));
1a097b
-
1a097b
 	  /* We finished one use of the loops.  */
1a097b
 	  ++data->__invocation_counter;
1a097b
 
1a097b
 	  /* If this is the last step leave the loop, there is nothing
1a097b
-             we can do.  */
1a097b
-	  if (__builtin_expect (data->__flags & __GCONV_IS_LAST, 0))
1a097b
+	     we can do.  */
1a097b
+	  if (__glibc_unlikely (data->__flags & __GCONV_IS_LAST))
1a097b
 	    {
1a097b
 	      /* Store information about how many bytes are available.  */
1a097b
 	      data->__outbuf = outbuf;
1a097b
 
1a097b
 	      /* Remember how many non-identical characters we
1a097b
-                 converted in a irreversible way.  */
1a097b
+		 converted in an irreversible way.  */
1a097b
 	      *irreversible += lirreversible;
1a097b
 
1a097b
 	      break;
1a097b
 	    }
1a097b
 
1a097b
 	  /* Write out all output which was produced.  */
1a097b
-	  if (__builtin_expect (outbuf > outstart, 1))
1a097b
+	  if (__glibc_likely (outbuf > outstart))
1a097b
 	    {
1a097b
 	      const unsigned char *outerr = data->__outbuf;
1a097b
 	      int result;
1a097b
@@ -677,14 +668,14 @@
1a097b
 
1a097b
 	      if (result != __GCONV_EMPTY_INPUT)
1a097b
 		{
1a097b
-		  if (__builtin_expect (outerr != outbuf, 0))
1a097b
+		  if (__glibc_unlikely (outerr != outbuf))
1a097b
 		    {
1a097b
 #ifdef RESET_INPUT_BUFFER
1a097b
 		      RESET_INPUT_BUFFER;
1a097b
 #else
1a097b
 		      /* We have a problem in one of the functions below.
1a097b
 			 Undo the conversion upto the error point.  */
1a097b
-		      size_t nstatus;
1a097b
+		      size_t nstatus __attribute__ ((unused));
1a097b
 
1a097b
 		      /* Reload the pointers.  */
1a097b
 		      *inptrp = inptr;
1a097b
@@ -695,7 +686,7 @@
1a097b
 		      SAVE_RESET_STATE (0);
1a097b
 # endif
1a097b
 
1a097b
-		      if (__builtin_expect (!unaligned, 1))
1a097b
+		      if (__glibc_likely (!unaligned))
1a097b
 			{
1a097b
 			  if (FROM_DIRECTION)
1a097b
 			    /* Run the conversion loop.  */
1a097b
@@ -738,7 +729,7 @@
1a097b
 
1a097b
 		      /* If we haven't consumed a single byte decrement
1a097b
 			 the invocation counter.  */
1a097b
-		      if (__builtin_expect (outbuf == outstart, 0))
1a097b
+		      if (__glibc_unlikely (outbuf == outstart))
1a097b
 			--data->__invocation_counter;
1a097b
 #endif	/* reset input buffer */
1a097b
 		    }
1a097b
@@ -782,7 +773,7 @@
1a097b
 	  STORE_REST
1a097b
 # else
1a097b
 	  /* Make sure the remaining bytes fit into the state objects
1a097b
-             buffer.  */
1a097b
+	     buffer.  */
1a097b
 	  assert (inend - *inptrp < 4);
1a097b
 
1a097b
 	  size_t cnt;