Blame SOURCES/saplocales-2.2.5-rhel5.patch

1a097b
diff -up saplocales-2.2.5/ASIANUNI.c-sap saplocales-2.2.5/ASIANUNI.c
1a097b
--- saplocales-2.2.5/ASIANUNI.c-sap	2009-02-18 15:07:53.000000000 -0800
1a097b
+++ saplocales-2.2.5/ASIANUNI.c	2009-02-18 15:09:57.000000000 -0800
1a097b
@@ -14151,7 +14151,8 @@ static const char from_ucs4_asianuni[0x7
1a097b
           }                                                                   \
1a097b
       }									      \
1a097b
 									      \
1a097b
-    *((uint32_t *) outptr)++ = ch;					      \
1a097b
+    put32 (outptr, ch);							      \
1a097b
+    outptr += 4;							      \
1a097b
   }
1a097b
 #include <iconv/loop.c>
1a097b
 
1a097b
@@ -14163,7 +14164,7 @@ static const char from_ucs4_asianuni[0x7
1a097b
 #define LOOPFCT			TO_LOOP
1a097b
 #define BODY \
1a097b
   {									      \
1a097b
-    uint32_t ch = *((uint32_t *) inptr);				      \
1a097b
+    uint32_t ch = get32 (inptr);					      \
1a097b
     const char *cp;							      \
1a097b
 									      \
1a097b
     if (ch <= 0x7f)							      \
1a097b
diff -up saplocales-2.2.5/DIOCLETIAN.c-sap saplocales-2.2.5/DIOCLETIAN.c
1a097b
--- saplocales-2.2.5/DIOCLETIAN.c-sap	2009-02-18 15:13:56.000000000 -0800
1a097b
+++ saplocales-2.2.5/DIOCLETIAN.c	2009-02-18 15:15:09.000000000 -0800
1a097b
@@ -561,7 +561,8 @@ static const uint32_t from_ucs4_diocleti
1a097b
     uint32_t ch = to_ucs4_diocletian[*inptr];                                 \
1a097b
     ++inptr;                                                                  \
1a097b
                                                                               \
1a097b
-    *((uint32_t *) outptr)++ = ch;                                            \
1a097b
+    put32 (outptr, ch);							      \
1a097b
+    outptr += 4;		                                              \
1a097b
   }
1a097b
 #include <iconv/loop.c>
1a097b
 
1a097b
@@ -572,7 +573,7 @@ static const uint32_t from_ucs4_diocleti
1a097b
 #define LOOPFCT                 TO_LOOP
1a097b
 #define BODY \
1a097b
   {                                                                           \
1a097b
-    uint32_t ch = *((uint32_t *) inptr);                                      \
1a097b
+    uint32_t ch = get32 (inptr);	                                      \
1a097b
                                                                               \
1a097b
     if (ch != 0 && from_ucs4_diocletian[ch] == '\0')                          \
1a097b
       {                                                                       \
1a097b
diff -up saplocales-2.2.5/EUROJAPAN.c-sap saplocales-2.2.5/EUROJAPAN.c
1a097b
--- saplocales-2.2.5/EUROJAPAN.c-sap	2009-02-18 15:10:30.000000000 -0800
1a097b
+++ saplocales-2.2.5/EUROJAPAN.c	2009-02-18 15:11:37.000000000 -0800
1a097b
@@ -3679,7 +3679,8 @@ static const char from_ucs4_double[0x1eb
1a097b
           }                                                                   \
1a097b
       }									      \
1a097b
 									      \
1a097b
-    *((uint32_t *) outptr)++ = ch;					      \
1a097b
+    put32 (outptr, ch);							      \
1a097b
+    outptr += 4;							      \
1a097b
   }
1a097b
 #include <iconv/loop.c>
1a097b
 
1a097b
@@ -3691,7 +3692,7 @@ static const char from_ucs4_double[0x1eb
1a097b
 #define LOOPFCT			TO_LOOP
1a097b
 #define BODY \
1a097b
   {									      \
1a097b
-    uint32_t ch = *((uint32_t *) inptr);				      \
1a097b
+    uint32_t ch = get32 (inptr);					      \
1a097b
     const char *cp;							      \
1a097b
 									      \
1a097b
     if (ch <= 0xff)							      \
1a097b
diff -up saplocales-2.2.5/iconv/loop.c-sap saplocales-2.2.5/iconv/loop.c
1a097b
--- saplocales-2.2.5/iconv/loop.c-sap	2002-04-30 05:45:10.000000000 -0700
1a097b
+++ saplocales-2.2.5/iconv/loop.c	2009-02-18 14:47:18.000000000 -0800
1a097b
@@ -1,5 +1,5 @@
1a097b
 /* Conversion loop frame work.
1a097b
-   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
1a097b
+   Copyright (C) 1998-2002, 2003, 2005, 2008 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
@@ -43,6 +43,9 @@
1a097b
 
1a097b
      INIT_PARAMS	code to define and initialize variables from params.
1a097b
      UPDATE_PARAMS	code to store result in params.
1a097b
+
1a097b
+     ONEBYTE_BODY	body of the specialized conversion function for a
1a097b
+			single byte from the current character set to INTERNAL.
1a097b
 */
1a097b
 
1a097b
 #include <assert.h>
1a097b
@@ -133,6 +136,8 @@
1a097b
 /* We need at least one byte for the next round.  */
1a097b
 #ifndef MIN_NEEDED_INPUT
1a097b
 # error "MIN_NEEDED_INPUT definition missing"
1a097b
+#elif MIN_NEEDED_INPUT < 1
1a097b
+# error "MIN_NEEDED_INPUT must be >= 1"
1a097b
 #endif
1a097b
 
1a097b
 /* Let's see how many bytes we produce.  */
1a097b
@@ -143,6 +148,8 @@
1a097b
 /* We produce at least one byte in the next round.  */
1a097b
 #ifndef MIN_NEEDED_OUTPUT
1a097b
 # error "MIN_NEEDED_OUTPUT definition missing"
1a097b
+#elif MIN_NEEDED_OUTPUT < 1
1a097b
+# error "MIN_NEEDED_OUTPUT must be >= 1"
1a097b
 #endif
1a097b
 
1a097b
 /* Let's see how many bytes we produce.  */
1a097b
@@ -167,6 +174,15 @@
1a097b
 # define EXTRA_LOOP_DECLS
1a097b
 #endif
1a097b
 
1a097b
+/* Allow using UPDATE_PARAMS in macros where #ifdef UPDATE_PARAMS test
1a097b
+   isn't possible.  */
1a097b
+#ifndef UPDATE_PARAMS
1a097b
+# define UPDATE_PARAMS do { } while (0)
1a097b
+#endif
1a097b
+#ifndef REINIT_PARAMS
1a097b
+# define REINIT_PARAMS do { } while (0)
1a097b
+#endif
1a097b
+
1a097b
 
1a097b
 /* To make it easier for the writers of the modules, we define a macro
1a097b
    to test whether we have to ignore errors.  */
1a097b
@@ -174,10 +190,29 @@
1a097b
   (irreversible != NULL && (flags & __GCONV_IGNORE_ERRORS))
1a097b
 
1a097b
 
1a097b
-/* Error handling with transliteration/transcription function use and
1a097b
-   ignoring of errors.  Note that we cannot use the do while (0) trick
1a097b
-   since `break' and `continue' must reach certain points.  */
1a097b
-#define STANDARD_ERR_HANDLER(Incr) \
1a097b
+/* Error handling for the FROM_LOOP direction, with ignoring of errors.
1a097b
+   Note that we cannot use the do while (0) trick since `break' and
1a097b
+   `continue' must reach certain points.  */
1a097b
+#define STANDARD_FROM_LOOP_ERR_HANDLER(Incr) \
1a097b
+  {									      \
1a097b
+    result = __GCONV_ILLEGAL_INPUT;					      \
1a097b
+									      \
1a097b
+    if (! ignore_errors_p ())						      \
1a097b
+      break;								      \
1a097b
+									      \
1a097b
+    /* We ignore the invalid input byte sequence.  */			      \
1a097b
+    inptr += (Incr);							      \
1a097b
+    ++*irreversible;							      \
1a097b
+    /* But we keep result == __GCONV_ILLEGAL_INPUT, because of the constraint \
1a097b
+       that "iconv -c" must give the same exitcode as "iconv".  */	      \
1a097b
+    continue;								      \
1a097b
+  }
1a097b
+
1a097b
+/* Error handling for the TO_LOOP direction, with use of transliteration/
1a097b
+   transcription functions and ignoring of errors.  Note that we cannot use
1a097b
+   the do while (0) trick since `break' and `continue' must reach certain
1a097b
+   points.  */
1a097b
+#define STANDARD_TO_LOOP_ERR_HANDLER(Incr) \
1a097b
   {									      \
1a097b
     struct __gconv_trans_data *trans;					      \
1a097b
 									      \
1a097b
@@ -188,6 +223,10 @@
1a097b
 	 case we are not doing any error recovery outself.  */		      \
1a097b
       break;								      \
1a097b
 									      \
1a097b
+    /* If needed, flush any conversion state, so that __gconv_transliterate   \
1a097b
+       starts with current shift state.  */				      \
1a097b
+    UPDATE_PARAMS;							      \
1a097b
+									      \
1a097b
     /* First try the transliteration methods.  */			      \
1a097b
     for (trans = step_data->__trans; trans != NULL; trans = trans->__next)    \
1a097b
       {									      \
1a097b
@@ -197,9 +236,17 @@
1a097b
 	if (result != __GCONV_ILLEGAL_INPUT)				      \
1a097b
 	  break;							      \
1a097b
       }									      \
1a097b
+									      \
1a097b
+    REINIT_PARAMS;							      \
1a097b
+									      \
1a097b
     /* If any of them recognized the input continue with the loop.  */	      \
1a097b
     if (result != __GCONV_ILLEGAL_INPUT)				      \
1a097b
-      continue;								      \
1a097b
+      {									      \
1a097b
+	if (__builtin_expect (result == __GCONV_FULL_OUTPUT, 0))	      \
1a097b
+	  break;							      \
1a097b
+									      \
1a097b
+	continue;							      \
1a097b
+      }									      \
1a097b
 									      \
1a097b
     /* Next see whether we have to ignore the error.  If not, stop.  */	      \
1a097b
     if (! ignore_errors_p ())						      \
1a097b
@@ -208,14 +255,16 @@
1a097b
     /* When we come here it means we ignore the character.  */		      \
1a097b
     ++*irreversible;							      \
1a097b
     inptr += Incr;							      \
1a097b
+    /* But we keep result == __GCONV_ILLEGAL_INPUT, because of the constraint \
1a097b
+       that "iconv -c" must give the same exitcode as "iconv".  */	      \
1a097b
     continue;								      \
1a097b
   }
1a097b
 
1a097b
 
1a097b
 /* Handling of Unicode 3.1 TAG characters.  Unicode recommends
1a097b
    "If language codes are not relevant to the particular processing
1a097b
-    operation, then they should be ignored."
1a097b
-   This macro is usually called right before STANDARD_ERR_HANDLER (Incr).  */
1a097b
+    operation, then they should be ignored."  This macro is usually
1a097b
+   called right before  STANDARD_TO_LOOP_ERR_HANDLER (Incr).  */
1a097b
 #define UNICODE_TAG_HANDLER(Character, Incr) \
1a097b
   {									      \
1a097b
     /* TAG characters are those in the range U+E0000..U+E007F.  */	      \
1a097b
@@ -229,6 +278,7 @@
1a097b
 
1a097b
 /* The function returns the status, as defined in gconv.h.  */
1a097b
 static inline int
1a097b
+__attribute ((always_inline))
1a097b
 FCTNAME (LOOPFCT) (struct __gconv_step *step,
1a097b
 		   struct __gconv_step_data *step_data,
1a097b
 		   const unsigned char **inptrp, const unsigned char *inend,
1a097b
@@ -257,6 +307,14 @@ FCTNAME (LOOPFCT) (struct __gconv_step *
1a097b
       /* `if' cases for MIN_NEEDED_OUTPUT ==/!= 1 is made to help the
1a097b
 	 compiler generating better code.  They will be optimized away
1a097b
 	 since MIN_NEEDED_OUTPUT is always a constant.  */
1a097b
+      if (MIN_NEEDED_INPUT > 1
1a097b
+	  && __builtin_expect (inptr + MIN_NEEDED_INPUT > inend, 0))
1a097b
+	{
1a097b
+	  /* We don't have enough input for another complete input
1a097b
+	     character.  */
1a097b
+	  result = __GCONV_INCOMPLETE_INPUT;
1a097b
+	  break;
1a097b
+	}
1a097b
       if ((MIN_NEEDED_OUTPUT != 1
1a097b
 	   && __builtin_expect (outptr + MIN_NEEDED_OUTPUT > outend, 0))
1a097b
 	  || (MIN_NEEDED_OUTPUT == 1
1a097b
@@ -266,14 +324,6 @@ FCTNAME (LOOPFCT) (struct __gconv_step *
1a097b
 	  result = __GCONV_FULL_OUTPUT;
1a097b
 	  break;
1a097b
 	}
1a097b
-      if (MIN_NEEDED_INPUT > 1
1a097b
-	  && __builtin_expect (inptr + MIN_NEEDED_INPUT > inend, 0))
1a097b
-	{
1a097b
-	  /* We don't have enough input for another complete input
1a097b
-	     character.  */
1a097b
-	  result = __GCONV_INCOMPLETE_INPUT;
1a097b
-	  break;
1a097b
-	}
1a097b
 
1a097b
       /* Here comes the body the user provides.  It can stop with
1a097b
 	 RESULT set to GCONV_INCOMPLETE_INPUT (if the size of the
1a097b
@@ -285,9 +335,7 @@ FCTNAME (LOOPFCT) (struct __gconv_step *
1a097b
   /* Update the pointers pointed to by the parameters.  */
1a097b
   *inptrp = inptr;
1a097b
   *outptrp = outptr;
1a097b
-#ifdef UPDATE_PARAMS
1a097b
   UPDATE_PARAMS;
1a097b
-#endif
1a097b
 
1a097b
   return result;
1a097b
 }
1a097b
@@ -296,8 +344,8 @@ FCTNAME (LOOPFCT) (struct __gconv_step *
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
-    && MIN_NEEDED_FROM != 1 && MAX_NEEDED_FROM % MIN_NEEDED_FROM == 0 \
1a097b
-    && MIN_NEEDED_TO != 1 && MAX_NEEDED_TO % MIN_NEEDED_TO == 0
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
 # undef get32
1a097b
 # undef put16
1a097b
@@ -314,6 +362,7 @@ FCTNAME (LOOPFCT) (struct __gconv_step *
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
 		 struct __gconv_step_data *step_data,
1a097b
 		 const unsigned char **inptrp, const unsigned char *inend,
1a097b
@@ -400,7 +449,11 @@ SINGLE(LOOPFCT) (struct __gconv_step *st
1a097b
       result = __GCONV_OK;
1a097b
 
1a097b
       /* Clear the state buffer.  */
1a097b
+#ifdef CLEAR_STATE
1a097b
+      CLEAR_STATE;
1a097b
+#else
1a097b
       state->__count &= ~7;
1a097b
+#endif
1a097b
     }
1a097b
   else if (result == __GCONV_INCOMPLETE_INPUT)
1a097b
     {
1a097b
@@ -416,6 +469,10 @@ SINGLE(LOOPFCT) (struct __gconv_step *st
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
+      state->__count = (state->__count & ~7) | (inend - inptr);
1a097b
+      inlen = 0;
1a097b
       while (inptr < inend)
1a097b
 	state->__value.__wchb[inlen++] = *inptr++;
1a097b
 #endif
1a097b
@@ -428,6 +485,15 @@ SINGLE(LOOPFCT) (struct __gconv_step *st
1a097b
 #endif
1a097b
 
1a097b
 
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
+
1a097b
+
1a097b
 /* We remove the macro definitions so that we can include this file again
1a097b
    for the definition of another function.  */
1a097b
 #undef MIN_NEEDED_INPUT
1a097b
@@ -440,7 +506,10 @@ SINGLE(LOOPFCT) (struct __gconv_step *st
1a097b
 #undef EXTRA_LOOP_DECLS
1a097b
 #undef INIT_PARAMS
1a097b
 #undef UPDATE_PARAMS
1a097b
+#undef REINIT_PARAMS
1a097b
+#undef ONEBYTE_BODY
1a097b
 #undef UNPACK_BYTES
1a097b
+#undef CLEAR_STATE
1a097b
 #undef LOOP_NEED_STATE
1a097b
 #undef LOOP_NEED_FLAGS
1a097b
 #undef LOOP_NEED_DATA
1a097b
diff -up saplocales-2.2.5/iconv/skeleton.c-sap saplocales-2.2.5/iconv/skeleton.c
1a097b
--- saplocales-2.2.5/iconv/skeleton.c-sap	2002-04-30 05:45:10.000000000 -0700
1a097b
+++ saplocales-2.2.5/iconv/skeleton.c	2009-02-18 14:47:14.000000000 -0800
1a097b
@@ -1,5 +1,5 @@
1a097b
 /* Skeleton for a conversion module.
1a097b
-   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
1a097b
+   Copyright (C) 1998-2002, 2005 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
@@ -37,12 +37,26 @@
1a097b
 			This macro is optional, it defaults to MIN_NEEDED_FROM.
1a097b
      MAX_NEEDED_TO	likewise for the to-charset.
1a097b
 
1a097b
-     DEFINE_DIRECTION_OBJECTS
1a097b
-			two objects will be defined to be used when the
1a097b
-			`gconv' function must only distinguish two
1a097b
-			directions.  This is implied by DEFINE_INIT.
1a097b
-			If this macro is not defined the following
1a097b
-			macro must be available.
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
+     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
+     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
+     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
 
1a097b
      FROM_DIRECTION	this macro is supposed to return a value != 0
1a097b
 			if we convert from the current character set,
1a097b
@@ -50,11 +64,11 @@
1a097b
 
1a097b
      EMIT_SHIFT_TO_INIT	this symbol is optional.  If it is defined it
1a097b
 			defines some code which writes out a sequence
1a097b
-			of characters which bring the current state into
1a097b
+			of bytes which bring the current state into
1a097b
 			the initial state.
1a097b
 
1a097b
      FROM_LOOP		name of the function implementing the conversion
1a097b
-			from the current characters.
1a097b
+			from the current character set.
1a097b
      TO_LOOP		likewise for the other direction
1a097b
 
1a097b
      ONE_DIRECTION	optional.  If defined to 1, only one conversion
1a097b
@@ -79,6 +93,44 @@
1a097b
 
1a097b
      EXTRA_LOOP_ARGS	optional macro specifying extra arguments passed
1a097b
 			to loop function.
1a097b
+
1a097b
+     STORE_REST		optional, needed only when MAX_NEEDED_FROM > 4.
1a097b
+			This macro stores the seen but unconverted input bytes
1a097b
+			in the state.
1a097b
+
1a097b
+     FROM_ONEBYTE	optional.  If defined, should be the name of a
1a097b
+			specialized conversion function for a single byte
1a097b
+			from the current character set to INTERNAL.  This
1a097b
+			function has prototype
1a097b
+			   wint_t
1a097b
+			   FROM_ONEBYTE (struct __gconv_step *, unsigned char);
1a097b
+			and does a special conversion:
1a097b
+			- The input is a single byte.
1a097b
+			- The output is a single uint32_t.
1a097b
+			- The state before the conversion is the initial state;
1a097b
+			  the state after the conversion is irrelevant.
1a097b
+			- No transliteration.
1a097b
+			- __invocation_counter = 0.
1a097b
+			- __internal_use = 1.
1a097b
+			- do_flush = 0.
1a097b
+
1a097b
+   Modules can use mbstate_t to store conversion state as follows:
1a097b
+
1a097b
+   * Bits 2..0 of '__count' contain the number of lookahead input bytes
1a097b
+     stored in __value.__wchb.  Always zero if the converter never
1a097b
+     returns __GCONV_INCOMPLETE_INPUT.
1a097b
+
1a097b
+   * Bits 31..3 of '__count' are module dependent shift state.
1a097b
+
1a097b
+   * __value: When STORE_REST/UNPACK_BYTES aren't defined and when the
1a097b
+     converter has returned __GCONV_INCOMPLETE_INPUT, this contains
1a097b
+     at most 4 lookahead bytes. Converters with an mb_cur_max > 4
1a097b
+     (currently only UTF-8) must find a way to store their state
1a097b
+     in __value.__wch and define STORE_REST/UNPACK_BYTES appropriately.
1a097b
+
1a097b
+   When __value contains lookahead, __count must not be zero, because
1a097b
+   the converter is not in the initial state then, and mbsinit() --
1a097b
+   defined as a (__count == 0) test -- must reflect this.
1a097b
  */
1a097b
 
1a097b
 #include <assert.h>
1a097b
@@ -92,21 +144,22 @@
1a097b
 # include <dlfcn.h>
1a097b
 #endif
1a097b
 
1a097b
+#include <sysdep.h>
1a097b
+
1a097b
 #ifndef DL_CALL_FCT
1a097b
 # define DL_CALL_FCT(fct, args) fct args
1a097b
 #endif
1a097b
 
1a097b
 /* The direction objects.  */
1a097b
-#if DEFINE_DIRECTION_OBJECTS || DEFINE_INIT
1a097b
-static int from_object;
1a097b
-static int to_object;
1a097b
-
1a097b
+#if DEFINE_INIT
1a097b
 # ifndef FROM_DIRECTION
1a097b
-#  define FROM_DIRECTION (step->__data == &from_object)
1a097b
+#  define FROM_DIRECTION_VAL NULL
1a097b
+#  define TO_DIRECTION_VAL ((void *) ~((uintptr_t) 0))
1a097b
+#  define FROM_DIRECTION (step->__data == FROM_DIRECTION_VAL)
1a097b
 # endif
1a097b
 #else
1a097b
 # ifndef FROM_DIRECTION
1a097b
-#  error "FROM_DIRECTION must be provided if direction objects are not used"
1a097b
+#  error "FROM_DIRECTION must be provided if non-default init is used"
1a097b
 # endif
1a097b
 #endif
1a097b
 
1a097b
@@ -121,6 +174,32 @@ static int to_object;
1a097b
 # define MAX_NEEDED_TO		MIN_NEEDED_TO
1a097b
 #endif
1a097b
 
1a097b
+/* Defaults for the per-direction min/max constants.  */
1a097b
+#ifndef FROM_LOOP_MIN_NEEDED_FROM
1a097b
+# define FROM_LOOP_MIN_NEEDED_FROM	MIN_NEEDED_FROM
1a097b
+#endif
1a097b
+#ifndef FROM_LOOP_MAX_NEEDED_FROM
1a097b
+# define FROM_LOOP_MAX_NEEDED_FROM	MAX_NEEDED_FROM
1a097b
+#endif
1a097b
+#ifndef FROM_LOOP_MIN_NEEDED_TO
1a097b
+# define FROM_LOOP_MIN_NEEDED_TO	MIN_NEEDED_TO
1a097b
+#endif
1a097b
+#ifndef FROM_LOOP_MAX_NEEDED_TO
1a097b
+# define FROM_LOOP_MAX_NEEDED_TO	MAX_NEEDED_TO
1a097b
+#endif
1a097b
+#ifndef TO_LOOP_MIN_NEEDED_FROM
1a097b
+# define TO_LOOP_MIN_NEEDED_FROM	MIN_NEEDED_TO
1a097b
+#endif
1a097b
+#ifndef TO_LOOP_MAX_NEEDED_FROM
1a097b
+# define TO_LOOP_MAX_NEEDED_FROM	MAX_NEEDED_TO
1a097b
+#endif
1a097b
+#ifndef TO_LOOP_MIN_NEEDED_TO
1a097b
+# define TO_LOOP_MIN_NEEDED_TO		MIN_NEEDED_FROM
1a097b
+#endif
1a097b
+#ifndef TO_LOOP_MAX_NEEDED_TO
1a097b
+# define TO_LOOP_MAX_NEEDED_TO		MAX_NEEDED_FROM
1a097b
+#endif
1a097b
+
1a097b
 
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
@@ -192,16 +271,40 @@ static int to_object;
1a097b
 /* For conversions from a fixed width character set to another fixed width
1a097b
    character set we can define RESET_INPUT_BUFFER in a very fast way.  */
1a097b
 #if !defined RESET_INPUT_BUFFER && !defined SAVE_RESET_STATE
1a097b
-# if MIN_NEEDED_FROM == MAX_NEEDED_FROM && MIN_NEEDED_TO == MAX_NEEDED_TO
1a097b
+# if FROM_LOOP_MIN_NEEDED_FROM == FROM_LOOP_MAX_NEEDED_FROM \
1a097b
+     && FROM_LOOP_MIN_NEEDED_TO == FROM_LOOP_MAX_NEEDED_TO \
1a097b
+     && TO_LOOP_MIN_NEEDED_FROM == TO_LOOP_MAX_NEEDED_FROM \
1a097b
+     && TO_LOOP_MIN_NEEDED_TO == TO_LOOP_MAX_NEEDED_TO
1a097b
 /* We have to use these `if's here since the compiler cannot know that
1a097b
-   (outbuf - outerr) is always divisible by MIN_NEEDED_TO.  */
1a097b
+   (outbuf - outerr) is always divisible by FROM/TO_LOOP_MIN_NEEDED_TO.
1a097b
+   The ?:1 avoids division by zero warnings that gcc 3.2 emits even for
1a097b
+   obviously unreachable code.  */
1a097b
 #  define RESET_INPUT_BUFFER \
1a097b
-  if (MIN_NEEDED_FROM % MIN_NEEDED_TO == 0)				      \
1a097b
-    *inptrp -= (outbuf - outerr) * (MIN_NEEDED_FROM / MIN_NEEDED_TO);	      \
1a097b
-  else if (MIN_NEEDED_TO % MIN_NEEDED_FROM == 0)			      \
1a097b
-    *inptrp -= (outbuf - outerr) / (MIN_NEEDED_TO / MIN_NEEDED_FROM);	      \
1a097b
+  if (FROM_DIRECTION)							      \
1a097b
+    {									      \
1a097b
+      if (FROM_LOOP_MIN_NEEDED_FROM % FROM_LOOP_MIN_NEEDED_TO == 0)	      \
1a097b
+	*inptrp -= (outbuf - outerr)					      \
1a097b
+		   * (FROM_LOOP_MIN_NEEDED_FROM / FROM_LOOP_MIN_NEEDED_TO);   \
1a097b
+      else if (FROM_LOOP_MIN_NEEDED_TO % FROM_LOOP_MIN_NEEDED_FROM == 0)      \
1a097b
+	*inptrp -= (outbuf - outerr)					      \
1a097b
+		   / (FROM_LOOP_MIN_NEEDED_TO / FROM_LOOP_MIN_NEEDED_FROM     \
1a097b
+		      ? : 1);						      \
1a097b
+      else								      \
1a097b
+	*inptrp -= ((outbuf - outerr) / FROM_LOOP_MIN_NEEDED_TO)	      \
1a097b
+		   * FROM_LOOP_MIN_NEEDED_FROM;				      \
1a097b
+    }									      \
1a097b
   else									      \
1a097b
-    *inptrp -= ((outbuf - outerr) / MIN_NEEDED_TO) * MIN_NEEDED_FROM
1a097b
+    {									      \
1a097b
+      if (TO_LOOP_MIN_NEEDED_FROM % TO_LOOP_MIN_NEEDED_TO == 0)		      \
1a097b
+	*inptrp -= (outbuf - outerr)					      \
1a097b
+		   * (TO_LOOP_MIN_NEEDED_FROM / TO_LOOP_MIN_NEEDED_TO);	      \
1a097b
+      else if (TO_LOOP_MIN_NEEDED_TO % TO_LOOP_MIN_NEEDED_FROM == 0)	      \
1a097b
+	*inptrp -= (outbuf - outerr)					      \
1a097b
+		   / (TO_LOOP_MIN_NEEDED_TO / TO_LOOP_MIN_NEEDED_FROM ? : 1); \
1a097b
+      else								      \
1a097b
+	*inptrp -= ((outbuf - outerr) / TO_LOOP_MIN_NEEDED_TO)		      \
1a097b
+		   * TO_LOOP_MIN_NEEDED_FROM;				      \
1a097b
+    }
1a097b
 # endif
1a097b
 #endif
1a097b
 
1a097b
@@ -220,21 +323,25 @@ gconv_init (struct __gconv_step *step)
1a097b
   /* Determine which direction.  */
1a097b
   if (strcmp (step->__from_name, CHARSET_NAME) == 0)
1a097b
     {
1a097b
-      step->__data = &from_object;
1a097b
+      step->__data = FROM_DIRECTION_VAL;
1a097b
+
1a097b
+      step->__min_needed_from = FROM_LOOP_MIN_NEEDED_FROM;
1a097b
+      step->__max_needed_from = FROM_LOOP_MAX_NEEDED_FROM;
1a097b
+      step->__min_needed_to = FROM_LOOP_MIN_NEEDED_TO;
1a097b
+      step->__max_needed_to = FROM_LOOP_MAX_NEEDED_TO;
1a097b
 
1a097b
-      step->__min_needed_from = MIN_NEEDED_FROM;
1a097b
-      step->__max_needed_from = MAX_NEEDED_FROM;
1a097b
-      step->__min_needed_to = MIN_NEEDED_TO;
1a097b
-      step->__max_needed_to = MAX_NEEDED_TO;
1a097b
+#ifdef FROM_ONEBYTE
1a097b
+      step->__btowc_fct = FROM_ONEBYTE;
1a097b
+#endif
1a097b
     }
1a097b
   else if (__builtin_expect (strcmp (step->__to_name, CHARSET_NAME), 0) == 0)
1a097b
     {
1a097b
-      step->__data = &to_object;
1a097b
+      step->__data = TO_DIRECTION_VAL;
1a097b
 
1a097b
-      step->__min_needed_from = MIN_NEEDED_TO;
1a097b
-      step->__max_needed_from = MAX_NEEDED_TO;
1a097b
-      step->__min_needed_to = MIN_NEEDED_FROM;
1a097b
-      step->__max_needed_to = MAX_NEEDED_FROM;
1a097b
+      step->__min_needed_from = TO_LOOP_MIN_NEEDED_FROM;
1a097b
+      step->__max_needed_from = TO_LOOP_MAX_NEEDED_FROM;
1a097b
+      step->__min_needed_to = TO_LOOP_MIN_NEEDED_TO;
1a097b
+      step->__max_needed_to = TO_LOOP_MAX_NEEDED_TO;
1a097b
     }
1a097b
   else
1a097b
     return __GCONV_NOCONV;
1a097b
@@ -288,10 +395,17 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 {
1a097b
   struct __gconv_step *next_step = step + 1;
1a097b
   struct __gconv_step_data *next_data = data + 1;
1a097b
-  __gconv_fct fct;
1a097b
+  __gconv_fct fct = NULL;
1a097b
   int status;
1a097b
 
1a097b
-  fct = (data->__flags & __GCONV_IS_LAST) ? NULL : next_step->__fct;
1a097b
+  if ((data->__flags & __GCONV_IS_LAST) == 0)
1a097b
+    {
1a097b
+      fct = next_step->__fct;
1a097b
+#ifdef PTR_DEMANGLE
1a097b
+      if (next_step->__shlib_handle != NULL)
1a097b
+	PTR_DEMANGLE (fct);
1a097b
+#endif
1a097b
+    }
1a097b
 
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
@@ -398,27 +512,45 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 	 actually converted.  */
1a097b
       size_t lirreversible = 0;
1a097b
       size_t *lirreversiblep = irreversible ? &lirreversible : NULL;
1a097b
-#if defined _STRING_ARCH_unaligned \
1a097b
-    || MIN_NEEDED_FROM == 1 || MAX_NEEDED_FROM % MIN_NEEDED_FROM != 0 \
1a097b
-    || MIN_NEEDED_TO == 1 || MAX_NEEDED_TO % MIN_NEEDED_TO != 0
1a097b
-# define unaligned 0
1a097b
-#else
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
+	 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
+	 We use && instead of || to combine the subexpression for the FROM
1a097b
+	 encoding and for the TO encoding, because usually one of them is
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
+   && (((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
+	    && FROM_LOOP_MAX_NEEDED_TO % FROM_LOOP_MIN_NEEDED_TO == 0))	      \
1a097b
+       || ((TO_LOOP_MIN_NEEDED_FROM != 1				      \
1a097b
+	    && TO_LOOP_MAX_NEEDED_FROM % TO_LOOP_MIN_NEEDED_FROM == 0)	      \
1a097b
+	   && (TO_LOOP_MIN_NEEDED_TO != 1				      \
1a097b
+	       && TO_LOOP_MAX_NEEDED_TO % TO_LOOP_MIN_NEEDED_TO == 0))))
1a097b
+#if POSSIBLY_UNALIGNED
1a097b
       int unaligned;
1a097b
 # define GEN_unaligned(name) GEN_unaligned2 (name)
1a097b
 # define GEN_unaligned2(name) name##_unaligned
1a097b
+#else
1a097b
+# define unaligned 0
1a097b
 #endif
1a097b
 
1a097b
 #ifdef PREPARE_LOOP
1a097b
       PREPARE_LOOP
1a097b
 #endif
1a097b
 
1a097b
-#if MAX_NEEDED_FROM > 1 || MAX_NEEDED_TO > 1
1a097b
+#if FROM_LOOP_MAX_NEEDED_FROM > 1 || TO_LOOP_MAX_NEEDED_FROM > 1
1a097b
       /* If the function is used to implement the mb*towc*() or wc*tomb*()
1a097b
 	 functions we must test whether any bytes from the last call are
1a097b
 	 stored in the `state' object.  */
1a097b
-      if (((MAX_NEEDED_FROM > 1 && MAX_NEEDED_TO > 1)
1a097b
-	   || (MAX_NEEDED_FROM > 1 && FROM_DIRECTION)
1a097b
-	   || (MAX_NEEDED_TO > 1 && !FROM_DIRECTION))
1a097b
+      if (((FROM_LOOP_MAX_NEEDED_FROM > 1 && TO_LOOP_MAX_NEEDED_FROM > 1)
1a097b
+	   || (FROM_LOOP_MAX_NEEDED_FROM > 1 && FROM_DIRECTION)
1a097b
+	   || (TO_LOOP_MAX_NEEDED_FROM > 1 && !FROM_DIRECTION))
1a097b
 	  && consume_incomplete && (data->__statep->__count & 7) != 0)
1a097b
 	{
1a097b
 	  /* Yep, we have some bytes left over.  Process them now.
1a097b
@@ -426,18 +558,20 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
              error handler.  */
1a097b
 	  assert (outbufstart == NULL);
1a097b
 
1a097b
-# if MAX_NEEDED_FROM > 1
1a097b
-	  if (MAX_NEEDED_TO == 1 || FROM_DIRECTION)
1a097b
+# if FROM_LOOP_MAX_NEEDED_FROM > 1
1a097b
+	  if (TO_LOOP_MAX_NEEDED_FROM == 1 || FROM_DIRECTION)
1a097b
 	    status = SINGLE(FROM_LOOP) (step, data, inptrp, inend, &outbuf,
1a097b
 					outend, lirreversiblep
1a097b
 					EXTRA_LOOP_ARGS);
1a097b
 # endif
1a097b
-# if MAX_NEEDED_FROM > 1 && MAX_NEEDED_TO > 1 && !ONE_DIRECTION
1a097b
+# if !ONE_DIRECTION
1a097b
+#  if FROM_LOOP_MAX_NEEDED_FROM > 1 && TO_LOOP_MAX_NEEDED_FROM > 1
1a097b
 	  else
1a097b
-# endif
1a097b
-# if MAX_NEEDED_TO > 1 && !ONE_DIRECTION
1a097b
+#  endif
1a097b
+#  if TO_LOOP_MAX_NEEDED_FROM > 1
1a097b
 	    status = SINGLE(TO_LOOP) (step, data, inptrp, inend, &outbuf,
1a097b
 				      outend, lirreversiblep EXTRA_LOOP_ARGS);
1a097b
+#  endif
1a097b
 # endif
1a097b
 
1a097b
 	  if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK)
1a097b
@@ -445,22 +579,16 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 	}
1a097b
 #endif
1a097b
 
1a097b
-#if !defined _STRING_ARCH_unaligned \
1a097b
-    && MIN_NEEDED_FROM != 1 && MAX_NEEDED_FROM % MIN_NEEDED_FROM == 0 \
1a097b
-    && MIN_NEEDED_TO != 1 && MAX_NEEDED_TO % MIN_NEEDED_TO == 0
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
-	 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
-      unaligned = ((FROM_DIRECTION
1a097b
-		    && ((uintptr_t) inptr % MIN_NEEDED_FROM != 0
1a097b
-			|| ((data->__flags & __GCONV_IS_LAST)
1a097b
-			    && (uintptr_t) outbuf % MIN_NEEDED_TO != 0)))
1a097b
-		   || (!FROM_DIRECTION
1a097b
-		       && (((data->__flags & __GCONV_IS_LAST)
1a097b
-			    && (uintptr_t) outbuf % MIN_NEEDED_FROM != 0)
1a097b
-			   || (uintptr_t) inptr % MIN_NEEDED_TO != 0)));
1a097b
+#if POSSIBLY_UNALIGNED
1a097b
+      unaligned =
1a097b
+	((FROM_DIRECTION
1a097b
+	  && ((uintptr_t) inptr % FROM_LOOP_MIN_NEEDED_FROM != 0
1a097b
+	      || ((data->__flags & __GCONV_IS_LAST)
1a097b
+		  && (uintptr_t) outbuf % FROM_LOOP_MIN_NEEDED_TO != 0)))
1a097b
+	 || (!FROM_DIRECTION
1a097b
+	     && (((data->__flags & __GCONV_IS_LAST)
1a097b
+		  && (uintptr_t) outbuf % TO_LOOP_MIN_NEEDED_TO != 0)
1a097b
+		 || (uintptr_t) inptr % TO_LOOP_MIN_NEEDED_FROM != 0)));
1a097b
 #endif
1a097b
 
1a097b
       while (1)
1a097b
@@ -487,9 +615,7 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 		status = TO_LOOP (step, data, inptrp, inend, &outbuf, outend,
1a097b
 				  lirreversiblep EXTRA_LOOP_ARGS);
1a097b
 	    }
1a097b
-#if !defined _STRING_ARCH_unaligned \
1a097b
-    && MIN_NEEDED_FROM != 1 && MAX_NEEDED_FROM % MIN_NEEDED_FROM == 0 \
1a097b
-    && MIN_NEEDED_TO != 1 && MAX_NEEDED_TO % MIN_NEEDED_TO == 0
1a097b
+#if POSSIBLY_UNALIGNED
1a097b
 	  else
1a097b
 	    {
1a097b
 	      if (FROM_DIRECTION)
1a097b
@@ -556,8 +682,8 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 #ifdef RESET_INPUT_BUFFER
1a097b
 		      RESET_INPUT_BUFFER;
1a097b
 #else
1a097b
-		      /* We have a problem with the in on of the functions
1a097b
-			 below.  Undo the conversion upto the error point.  */
1a097b
+		      /* We have a problem in one of the functions below.
1a097b
+			 Undo the conversion upto the error point.  */
1a097b
 		      size_t nstatus;
1a097b
 
1a097b
 		      /* Reload the pointers.  */
1a097b
@@ -584,9 +710,7 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 					       lirreversiblep
1a097b
 					       EXTRA_LOOP_ARGS);
1a097b
 			}
1a097b
-# if !defined _STRING_ARCH_unaligned \
1a097b
-     && MIN_NEEDED_FROM != 1 && MAX_NEEDED_FROM % MIN_NEEDED_FROM == 0 \
1a097b
-     && MIN_NEEDED_TO != 1 && MAX_NEEDED_TO % MIN_NEEDED_TO == 0
1a097b
+# if POSSIBLY_UNALIGNED
1a097b
 		      else
1a097b
 			{
1a097b
 			  if (FROM_DIRECTION)
1a097b
@@ -645,10 +769,10 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 
1a097b
       /* If we are supposed to consume all character store now all of the
1a097b
 	 remaining characters in the `state' object.  */
1a097b
-#if MAX_NEEDED_FROM > 1 || MAX_NEEDED_TO > 1
1a097b
-      if (((MAX_NEEDED_FROM > 1 && MAX_NEEDED_TO > 1)
1a097b
-	   || (MAX_NEEDED_FROM > 1 && FROM_DIRECTION)
1a097b
-	   || (MAX_NEEDED_TO > 1 && !FROM_DIRECTION))
1a097b
+#if FROM_LOOP_MAX_NEEDED_FROM > 1 || TO_LOOP_MAX_NEEDED_FROM > 1
1a097b
+      if (((FROM_LOOP_MAX_NEEDED_FROM > 1 && TO_LOOP_MAX_NEEDED_FROM > 1)
1a097b
+	   || (FROM_LOOP_MAX_NEEDED_FROM > 1 && FROM_DIRECTION)
1a097b
+	   || (TO_LOOP_MAX_NEEDED_FROM > 1 && !FROM_DIRECTION))
1a097b
 	  && __builtin_expect (consume_incomplete, 0)
1a097b
 	  && status == __GCONV_INCOMPLETE_INPUT)
1a097b
 	{
1a097b
@@ -657,12 +781,11 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 
1a097b
 	  STORE_REST
1a097b
 # else
1a097b
-	  size_t cnt;
1a097b
-
1a097b
 	  /* Make sure the remaining bytes fit into the state objects
1a097b
              buffer.  */
1a097b
 	  assert (inend - *inptrp < 4);
1a097b
 
1a097b
+	  size_t cnt;
1a097b
 	  for (cnt = 0; *inptrp < inend; ++cnt)
1a097b
 	    data->__statep->__value.__wchb[cnt] = *(*inptrp)++;
1a097b
 	  data->__statep->__count &= ~7;
1a097b
@@ -670,6 +793,8 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 # endif
1a097b
 	}
1a097b
 #endif
1a097b
+#undef unaligned
1a097b
+#undef POSSIBLY_UNALIGNED
1a097b
     }
1a097b
 
1a097b
   return status;
1a097b
@@ -682,15 +807,24 @@ FUNCTION_NAME (struct __gconv_step *step
1a097b
 #undef MIN_NEEDED_TO
1a097b
 #undef MAX_NEEDED_FROM
1a097b
 #undef MAX_NEEDED_TO
1a097b
-#undef DEFINE_DIRECTION_OBJECTS
1a097b
+#undef FROM_LOOP_MIN_NEEDED_FROM
1a097b
+#undef FROM_LOOP_MAX_NEEDED_FROM
1a097b
+#undef FROM_LOOP_MIN_NEEDED_TO
1a097b
+#undef FROM_LOOP_MAX_NEEDED_TO
1a097b
+#undef TO_LOOP_MIN_NEEDED_FROM
1a097b
+#undef TO_LOOP_MAX_NEEDED_FROM
1a097b
+#undef TO_LOOP_MIN_NEEDED_TO
1a097b
+#undef TO_LOOP_MAX_NEEDED_TO
1a097b
 #undef FROM_DIRECTION
1a097b
 #undef EMIT_SHIFT_TO_INIT
1a097b
 #undef FROM_LOOP
1a097b
 #undef TO_LOOP
1a097b
+#undef ONE_DIRECTION
1a097b
 #undef SAVE_RESET_STATE
1a097b
 #undef RESET_INPUT_BUFFER
1a097b
 #undef FUNCTION_NAME
1a097b
 #undef PREPARE_LOOP
1a097b
 #undef END_LOOP
1a097b
-#undef ONE_DIRECTION
1a097b
+#undef EXTRA_LOOP_ARGS
1a097b
 #undef STORE_REST
1a097b
+#undef FROM_ONEBYTE
1a097b
diff -up saplocales-2.2.5/Makefile-sap saplocales-2.2.5/Makefile
1a097b
--- saplocales-2.2.5/Makefile-sap	2009-02-18 15:34:56.000000000 -0800
1a097b
+++ saplocales-2.2.5/Makefile	2009-02-18 15:51:43.000000000 -0800
1a097b
@@ -20,13 +20,16 @@ gconv/NAGAMASA.so      \
1a097b
 gconv/SILKROAD.so      \
1a097b
 gconv/SAPSJIS.so
1a097b
 
1a097b
+# Uncomment when building for glibc 2.6 and newer
1a097b
+# NEWFLAGS = -DFOR_GLIBC_2_6_AND_LATER
1a097b
+
1a097b
 CFLAGS = \
1a097b
 -O \
1a097b
 -Wall -Winline -Wstrict-prototypes -Wwrite-strings \
1a097b
 -fno-strength-reduce -fPIC \
1a097b
 -D_LIBC_REENTRANT -DPIC -DSHARED -D_GNU_SOURCE=1 -D_REENTRANT=1 \
1a097b
 -include compiler.h \
1a097b
--I.
1a097b
+-I. -Iiconv $(NEWFLAGS)
1a097b
 
1a097b
 LDFLAGS= -shared
1a097b
 
1a097b
diff -up saplocales-2.2.5/NAGAMASA.c-sap saplocales-2.2.5/NAGAMASA.c
1a097b
--- saplocales-2.2.5/NAGAMASA.c-sap	2009-02-18 15:15:18.000000000 -0800
1a097b
+++ saplocales-2.2.5/NAGAMASA.c	2009-02-18 15:16:01.000000000 -0800
1a097b
@@ -3679,7 +3679,8 @@ static const char from_ucs4_double[0x1eb
1a097b
           }                                                                   \
1a097b
       }									      \
1a097b
 									      \
1a097b
-    *((uint32_t *) outptr)++ = ch;					      \
1a097b
+    put32 (outptr, ch);							      \
1a097b
+    outptr += 4;							      \
1a097b
   }
1a097b
 #include <iconv/loop.c>
1a097b
 
1a097b
@@ -3691,7 +3692,7 @@ static const char from_ucs4_double[0x1eb
1a097b
 #define LOOPFCT			TO_LOOP
1a097b
 #define BODY \
1a097b
   {									      \
1a097b
-    uint32_t ch = *((uint32_t *) inptr);				      \
1a097b
+    uint32_t ch = get32 (inptr);					      \
1a097b
     const char *cp;							      \
1a097b
 									      \
1a097b
     if (ch <= 0xff)							      \
1a097b
diff -up saplocales-2.2.5/SAPSJIS.c-sap saplocales-2.2.5/SAPSJIS.c
1a097b
--- saplocales-2.2.5/SAPSJIS.c-sap	2009-02-18 15:17:37.000000000 -0800
1a097b
+++ saplocales-2.2.5/SAPSJIS.c	2009-02-18 15:19:04.000000000 -0800
1a097b
@@ -4492,7 +4492,7 @@ static const char from_ucs4_extra[0x100]
1a097b
     if (__builtin_expect (cp[0], '\1') == '\0' && ch != 0)		      \
1a097b
       {									      \
1a097b
 	/* Illegal character.  */					      \
1a097b
-	STANDARD_ERR_HANDLER (4);					      \
1a097b
+	STANDARD_TO_LOOP_ERR_HANDLER (4);				      \
1a097b
       }									      \
1a097b
     else								      \
1a097b
       {									      \
1a097b
diff -up saplocales-2.2.5/SAPUNI.c-sap saplocales-2.2.5/SAPUNI.c
1a097b
--- saplocales-2.2.5/SAPUNI.c-sap	2009-02-18 15:11:52.000000000 -0800
1a097b
+++ saplocales-2.2.5/SAPUNI.c	2009-02-18 15:12:44.000000000 -0800
1a097b
@@ -3679,7 +3679,8 @@ static const char from_ucs4_double[0x1eb
1a097b
           }                                                                   \
1a097b
       }									      \
1a097b
 									      \
1a097b
-    *((uint32_t *) outptr)++ = ch;					      \
1a097b
+    put32 (outptr, ch);							      \
1a097b
+    outptr += 4;							      \
1a097b
   }
1a097b
 #include <iconv/loop.c>
1a097b
 
1a097b
@@ -3691,7 +3692,7 @@ static const char from_ucs4_double[0x1eb
1a097b
 #define LOOPFCT			TO_LOOP
1a097b
 #define BODY \
1a097b
   {									      \
1a097b
-    uint32_t ch = *((uint32_t *) inptr);				      \
1a097b
+    uint32_t ch = get32 (inptr);					      \
1a097b
     const char *cp;							      \
1a097b
 									      \
1a097b
     if (ch <= 0xff)							      \
1a097b
diff -up saplocales-2.2.5/SILKROAD.c-sap saplocales-2.2.5/SILKROAD.c
1a097b
--- saplocales-2.2.5/SILKROAD.c-sap	2009-02-18 15:16:09.000000000 -0800
1a097b
+++ saplocales-2.2.5/SILKROAD.c	2009-02-18 15:16:45.000000000 -0800
1a097b
@@ -3679,7 +3679,8 @@ static const char from_ucs4_double[0x1eb
1a097b
           }                                                                   \
1a097b
       }									      \
1a097b
 									      \
1a097b
-    *((uint32_t *) outptr)++ = ch;					      \
1a097b
+    put32 (outptr, ch);							      \
1a097b
+    outptr += 4;							      \
1a097b
   }
1a097b
 #include <iconv/loop.c>
1a097b
 
1a097b
@@ -3691,7 +3692,7 @@ static const char from_ucs4_double[0x1eb
1a097b
 #define LOOPFCT			TO_LOOP
1a097b
 #define BODY \
1a097b
   {									      \
1a097b
-    uint32_t ch = *((uint32_t *) inptr);				      \
1a097b
+    uint32_t ch = get32 (inptr);					      \
1a097b
     const char *cp;							      \
1a097b
 									      \
1a097b
     if (ch <= 0xff)							      \
1a097b
diff -up saplocales-2.2.5/TRANSSIBERIAN.c-sap saplocales-2.2.5/TRANSSIBERIAN.c
1a097b
--- saplocales-2.2.5/TRANSSIBERIAN.c-sap	2009-02-18 15:13:00.000000000 -0800
1a097b
+++ saplocales-2.2.5/TRANSSIBERIAN.c	2009-02-18 15:13:46.000000000 -0800
1a097b
@@ -3679,7 +3679,8 @@ static const char from_ucs4_double[0x1eb
1a097b
           }                                                                   \
1a097b
       }									      \
1a097b
 									      \
1a097b
-    *((uint32_t *) outptr)++ = ch;					      \
1a097b
+    put32 (outptr, ch);							      \
1a097b
+    outptr += 4;							      \
1a097b
   }
1a097b
 #include <iconv/loop.c>
1a097b
 
1a097b
@@ -3691,7 +3692,7 @@ static const char from_ucs4_double[0x1eb
1a097b
 #define LOOPFCT			TO_LOOP
1a097b
 #define BODY \
1a097b
   {									      \
1a097b
-    uint32_t ch = *((uint32_t *) inptr);				      \
1a097b
+    uint32_t ch = get32 (inptr);					      \
1a097b
     const char *cp;							      \
1a097b
 									      \
1a097b
     if (ch <= 0xff)							      \
1a097b
diff -up saplocales-2.2.5/transsiberian.src-sap saplocales-2.2.5/transsiberian.src
1a097b
--- saplocales-2.2.5/transsiberian.src-sap	2009-02-18 17:44:55.000000000 -0800
1a097b
+++ saplocales-2.2.5/transsiberian.src	2009-02-18 17:45:15.000000000 -0800
1a097b
@@ -9230,7 +9230,7 @@ order_end
1a097b
 END LC_COLLATE
1a097b
 
1a097b
 LC_MONETARY
1a097b
-int_curr_symbol	"<U0052><U0055><U0052><U0020>"
1a097b
+int_curr_symbol	"<U0052><U0055><U0042><U0020>"
1a097b
 currency_symbol	"<U00C0><U00C3><U00B1><U002E>"
1a097b
 mon_decimal_point	"<U002E>"
1a097b
 mon_thousands_sep	"<U0020>"
1a097b
diff -up saplocales-2.2.5/tr_TR-sap saplocales-2.2.5/tr_TR
1a097b
--- saplocales-2.2.5/tr_TR-sap	2009-02-18 15:22:43.000000000 -0800
1a097b
+++ saplocales-2.2.5/tr_TR	2009-02-18 15:23:14.000000000 -0800
1a097b
@@ -3430,8 +3430,8 @@ nostr	"<U0068><U0061><U0079><U0131>
1a097b
 END LC_MESSAGES
1a097b
 
1a097b
 LC_MONETARY
1a097b
-int_curr_symbol           "<U0054><U0052><U004C><U0020>"
1a097b
-currency_symbol           "<U0054><U004C>"
1a097b
+int_curr_symbol           "<U0054><U0052><U0059><U0020>"
1a097b
+currency_symbol           "<U0059><U0054><U004C>"
1a097b
 mon_decimal_point         "<U002C>"
1a097b
 mon_thousands_sep         "<U002E>"
1a097b
 mon_grouping              3