From baa6e3bf844c3cf036cb0b080ddd6109e5f9a9fb Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Mon, 29 Sep 2014 11:19:28 +0200
Subject: gcc2 fixes.


diff --git a/source/acinclude.m4 b/source/acinclude.m4
index 179c1c8..51f131f 100644
--- a/source/acinclude.m4
+++ b/source/acinclude.m4
@@ -470,6 +470,9 @@ AC_DEFUN([AC_CHECK_STRICT_COMPILE],
         if test "$GCC" = yes
         then
             case "${host}" in
+            *-*-haiku*)
+                CFLAGS="$CFLAGS -std=c9x"
+                ;;
             *)
                 # Do not use -ansi. It limits us to C90, and it breaks some platforms.
                 # We use -std=c99 to disable the gnu99 defaults and its associated warnings
diff --git a/source/common/unicode/bytestrie.h b/source/common/unicode/bytestrie.h
index 9c77827..367a0ae 100644
--- a/source/common/unicode/bytestrie.h
+++ b/source/common/unicode/bytestrie.h
@@ -338,6 +338,9 @@ public:
         // but the code looks more confusing that way.)
         UVector32 *stack_;
     };
+#if __GNUC__ == 2
+	friend class Iterator;
+#endif
 
 private:
     friend class BytesTrieBuilder;
diff --git a/source/common/unicode/bytestriebuilder.h b/source/common/unicode/bytestriebuilder.h
index d00ab9b..afbf59b 100644
--- a/source/common/unicode/bytestriebuilder.h
+++ b/source/common/unicode/bytestriebuilder.h
@@ -152,6 +152,9 @@ private:
     private:
         const char *s;
     };
+#if __GNUC__ == 2
+	friend class BTLinearMatchNode;
+#endif
 
     virtual Node *createLinearMatchNode(int32_t i, int32_t byteIndex, int32_t length,
                                         Node *nextNode) const;
diff --git a/source/common/unicode/platform.h b/source/common/unicode/platform.h
index 07dce8a..fbb4ae1 100644
--- a/source/common/unicode/platform.h
+++ b/source/common/unicode/platform.h
@@ -698,7 +698,7 @@
     /* Use the predefined value. */
 #elif defined(U_STATIC_IMPLEMENTATION)
 #   define U_EXPORT
-#elif defined(__GNUC__)
+#elif defined(__GNUC__) && __GNUC__ > 2
 #   define U_EXPORT __attribute__((visibility("default")))
 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
    || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 
diff --git a/source/common/unicode/stringtriebuilder.h b/source/common/unicode/stringtriebuilder.h
index 04447e5..b0ad961 100644
--- a/source/common/unicode/stringtriebuilder.h
+++ b/source/common/unicode/stringtriebuilder.h
@@ -258,6 +258,9 @@ protected:
     protected:
         int32_t value;
     };
+#if __GNUC__ == 2
+	friend class FinalValueNode;
+#endif
 
     /**
      * @internal 
@@ -289,6 +292,9 @@ protected:
     protected:
         Node *next;
     };
+#if __GNUC__ == 2
+	friend class IntermediateValueNode;
+#endif
 
     /**
      * @internal 
@@ -346,6 +352,9 @@ protected:
         int32_t values[kMaxBranchLinearSubNodeLength];
         UChar units[kMaxBranchLinearSubNodeLength];
     };
+#if __GNUC__ == 2
+	friend class ListBranchNode;
+#endif
 
     /**
      * @internal 
@@ -364,6 +373,9 @@ protected:
         Node *lessThan;
         Node *greaterOrEqual;
     };
+#if __GNUC__ == 2
+	friend class SplitBranchNode;
+#endif
 
     // Branch head node, for writing the actual node lead unit.
     /** @internal */
@@ -379,6 +391,9 @@ protected:
         int32_t length;
         Node *next;  // A branch sub-node.
     };
+#if __GNUC__ == 2
+	friend class BranchHeadNode;
+#endif
 #endif  /* U_HIDE_INTERNAL_API */
 
     /** @internal */
diff --git a/source/common/unicode/ucharstrie.h b/source/common/unicode/ucharstrie.h
index 0575a97..ec54589 100644
--- a/source/common/unicode/ucharstrie.h
+++ b/source/common/unicode/ucharstrie.h
@@ -356,9 +356,12 @@ public:
         // but the code looks more confusing that way.)
         UVector32 *stack_;
     };
+#if __GNUC__ == 2
+	friend class Iterator;
+#endif
 
-private:
     friend class UCharsTrieBuilder;
+private:
 
     /**
      * Constructs a UCharsTrie reader instance.
diff --git a/source/common/unicode/ucharstriebuilder.h b/source/common/unicode/ucharstriebuilder.h
index 35e353d..b128745 100644
--- a/source/common/unicode/ucharstriebuilder.h
+++ b/source/common/unicode/ucharstriebuilder.h
@@ -156,6 +156,9 @@ private:
     private:
         const UChar *s;
     };
+#if __GNUC__ == 2
+    friend class UCTLinearMatchNode;
+#endif
 
     virtual Node *createLinearMatchNode(int32_t i, int32_t unitIndex, int32_t length,
                                         Node *nextNode) const;
diff --git a/source/config/mh-haiku b/source/config/mh-haiku
index ccf956e..55a3ed2 100644
--- a/source/config/mh-haiku
+++ b/source/config/mh-haiku
@@ -18,7 +18,7 @@ LIBCPPFLAGS =
 THREADSCPPFLAGS =
 
 #
-CPPFLAGS += -D__STDC_ISO_10646__ -DU_CHARSET_IS_UTF8=1
+CPPFLAGS += -DU_CHARSET_IS_UTF8=1
 
 ## Compiler switch to embed a runtime search path
 LD_RPATH=
diff --git a/source/i18n/alphaindex.cpp b/source/i18n/alphaindex.cpp
index 0bea1dc..ca6c388 100644
--- a/source/i18n/alphaindex.cpp
+++ b/source/i18n/alphaindex.cpp
@@ -954,8 +954,8 @@ static int32_t U_CALLCONV
 collatorComparator(const void *context, const void *left, const void *right) {
     const UElement *leftElement = static_cast<const UElement *>(left);
     const UElement *rightElement = static_cast<const UElement *>(right);
-    const UnicodeString *leftString  = static_cast<const UnicodeString *>(leftElement->pointer);
-    const UnicodeString *rightString = static_cast<const UnicodeString *>(rightElement->pointer);
+    const UnicodeString *leftString  = (const UnicodeString *)(leftElement->pointer);
+    const UnicodeString *rightString = (const UnicodeString *)(rightElement->pointer);
 
     if (leftString == rightString) {
         // Catches case where both are NULL
@@ -979,8 +979,8 @@ static int32_t U_CALLCONV
 recordCompareFn(const void *context, const void *left, const void *right) {
     const UElement *leftElement = static_cast<const UElement *>(left);
     const UElement *rightElement = static_cast<const UElement *>(right);
-    const AlphabeticIndex::Record *leftRec  = static_cast<const AlphabeticIndex::Record *>(leftElement->pointer);
-    const AlphabeticIndex::Record *rightRec = static_cast<const AlphabeticIndex::Record *>(rightElement->pointer);
+    const AlphabeticIndex::Record *leftRec  = (const AlphabeticIndex::Record *)(leftElement->pointer);
+    const AlphabeticIndex::Record *rightRec = (const AlphabeticIndex::Record *)(rightElement->pointer);
     const Collator *col = static_cast<const Collator *>(context);
     UErrorCode errorCode = U_ZERO_ERROR;
     return col->compare(leftRec->name_, rightRec->name_, errorCode);
diff --git a/source/i18n/currfmt.h b/source/i18n/currfmt.h
index b3f23e5..7763215 100644
--- a/source/i18n/currfmt.h
+++ b/source/i18n/currfmt.h
@@ -58,7 +58,9 @@ class CurrencyFormat : public MeasureFormat {
     virtual Format* clone() const;
 
 
+#if __GNUC__ != 2
     using MeasureFormat::format;
+#endif
 
     /**
      * Override Format API.
diff --git a/source/i18n/digitlst.cpp b/source/i18n/digitlst.cpp
index b0e6010..d10a976 100644
--- a/source/i18n/digitlst.cpp
+++ b/source/i18n/digitlst.cpp
@@ -38,7 +38,9 @@
 #include <limits.h>
 #include <string.h>
 #include <stdio.h>
+#if __GNUC__ != 2
 #include <limits>
+#endif
 
 // ***************************************************************************
 // class DigitList
@@ -437,11 +439,15 @@ DigitList::getDouble() const
             tDouble /= -1;
         }
     } else if (isInfinite()) {
+#if __GNUC__ == 2
+        tDouble = DBL_MAX;
+#else
         if (std::numeric_limits<double>::has_infinity) {
             tDouble = std::numeric_limits<double>::infinity();
         } else {
             tDouble = std::numeric_limits<double>::max();
         }
+#endif
         if (!isPositive()) {
             tDouble = -tDouble; //this was incorrectly "-fDouble" originally.
         } 
diff --git a/source/i18n/digitlst.h b/source/i18n/digitlst.h
index 7e98d2b..2698367 100644
--- a/source/i18n/digitlst.h
+++ b/source/i18n/digitlst.h
@@ -413,7 +413,7 @@ private:
 
  public:
 
-#if U_OVERRIDE_CXX_ALLOCATION
+#if U_OVERRIDE_CXX_ALLOCATION && __GNUC__ != 2
     using UMemory::operator new;
     using UMemory::operator delete;
 #else
diff --git a/source/i18n/reldtfmt.h b/source/i18n/reldtfmt.h
index 67539e0..2227096 100644
--- a/source/i18n/reldtfmt.h
+++ b/source/i18n/reldtfmt.h
@@ -81,7 +81,9 @@ public:
     virtual UBool operator==(const Format& other) const;
 
 
+#if __GNUC__ != 2
     using DateFormat::format;
+#endif
 
     /**
      * Format a date or time, which is the standard millis since 24:00 GMT, Jan
diff --git a/source/i18n/sortkey.cpp b/source/i18n/sortkey.cpp
index baf3254..838ea82 100644
--- a/source/i18n/sortkey.cpp
+++ b/source/i18n/sortkey.cpp
@@ -172,7 +172,7 @@ Collator::EComparisonResult
 CollationKey::compareTo(const CollationKey& target) const
 {
     UErrorCode errorCode = U_ZERO_ERROR;
-    return static_cast<Collator::EComparisonResult>(compareTo(target, errorCode));
+    return (Collator::EComparisonResult)(compareTo(target, errorCode));
 }
 
 // Bitwise comparison for the collation keys.
diff --git a/source/i18n/unicode/choicfmt.h b/source/i18n/unicode/choicfmt.h
index cfd5206..d2b7f66 100644
--- a/source/i18n/unicode/choicfmt.h
+++ b/source/i18n/unicode/choicfmt.h
@@ -355,7 +355,22 @@ public:
     virtual const UnicodeString* getFormats(int32_t& count) const;
 
 
+#if __GNUC__ == 2
+    virtual UnicodeString& format (double number,
+                                   icu::UnicodeString& appendTo) const {
+        return NumberFormat::format(number, appendTo);
+    }
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+		FieldPosition& p, UErrorCode& e) const {
+		return NumberFormat::format(f, s, p, e);
+	}
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+		UErrorCode& e) const {
+		return NumberFormat::format(f, s, e);
+	}
+#else
     using NumberFormat::format;
+#endif
 
     /**
      * Formats a double number using this object's choices.
@@ -421,7 +436,13 @@ public:
                                   FieldPosition& pos,
                                   UErrorCode& success) const;
 
+#if __GNUC__ == 2
+	void parse(UnicodeString& s, Formattable& f, UErrorCode& e) const {
+		NumberFormat::parse(s, f, e);
+	}
+#else
    using NumberFormat::parse;
+#endif
 
    /**
     * Looks for the longest match of any message string on the input text and,
diff --git a/source/i18n/unicode/compactdecimalformat.h b/source/i18n/unicode/compactdecimalformat.h
index bd8fdba..be2e580 100644
--- a/source/i18n/unicode/compactdecimalformat.h
+++ b/source/i18n/unicode/compactdecimalformat.h
@@ -104,7 +104,13 @@ public:
     virtual UBool operator==(const Format& other) const;
 
 
+#if __GNUC__ == 2
+	UnicodeString& format(double n, UnicodeString& s) const {
+		return DecimalFormat::format(n, s);
+	}
+#else
     using DecimalFormat::format;
+#endif
 
     /**
      * Format a double or long number using base-10 representation.
diff --git a/source/i18n/unicode/datefmt.h b/source/i18n/unicode/datefmt.h
index ce967a5..59d735d 100644
--- a/source/i18n/unicode/datefmt.h
+++ b/source/i18n/unicode/datefmt.h
@@ -221,7 +221,13 @@ public:
     virtual UBool operator==(const Format&) const;
 
 
+#if __GNUC__ == 2
+	UnicodeString& format(const Formattable& f, UnicodeString& s, UErrorCode& e) const {
+		return Format::format(f, s, e);
+	}
+#else
     using Format::format;
+#endif
 
     /**
      * Format an object to produce a string. This method handles Formattable
diff --git a/source/i18n/unicode/decimfmt.h b/source/i18n/unicode/decimfmt.h
index 75249a4..bc046b9 100644
--- a/source/i18n/unicode/decimfmt.h
+++ b/source/i18n/unicode/decimfmt.h
@@ -919,7 +919,35 @@ public:
     virtual UBool operator==(const Format& other) const;
 
 
+#if __GNUC__ == 2
+    virtual UnicodeString& format (double number,
+                                   icu::UnicodeString& appendTo) const {
+        return NumberFormat::format(number, appendTo);
+    }
+
+    virtual UnicodeString& format (double number,
+                                   icu::UnicodeString& appendTo,
+                                   UErrorCode& status) const {
+        return NumberFormat::format(number, appendTo, status);
+    }
+
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+			FieldPositionIterator* i, UErrorCode& e) const {
+		return NumberFormat::format(f, s, i, e);
+	}
+	
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+			FieldPosition& p, UErrorCode& e) const {
+		return NumberFormat::format(f, s, p, e);
+	}
+
+	UnicodeString& format(const Formattable& f, UnicodeString& s, UErrorCode& e)
+		const {
+		return NumberFormat::format(f, s, e);
+	}
+#else
     using NumberFormat::format;
+#endif
 
     /**
      * Format a double or long number using base-10 representation.
@@ -1132,7 +1160,15 @@ public:
                                   FieldPosition& pos,
                                   UErrorCode& status) const;
 
+#if __GNUC__ == 2
+    void parse(const UnicodeString& text,
+                       Formattable& result,
+                       UErrorCode& status) const {
+        NumberFormat::parse(text, result, status);
+    }
+#else
    using NumberFormat::parse;
+#endif
 
    /**
     * Parse the given string using this object's choices. The method
diff --git a/source/i18n/unicode/dtitvfmt.h b/source/i18n/unicode/dtitvfmt.h
index fb27eec..07ae7cd 100644
--- a/source/i18n/unicode/dtitvfmt.h
+++ b/source/i18n/unicode/dtitvfmt.h
@@ -373,7 +373,9 @@ public:
     UBool operator!=(const Format& other) const;
 
 
+#if __GNUC__ != 2
     using Format::format;
+#endif
 
     /**
      * Format an object to produce a string. This method handles Formattable
diff --git a/source/i18n/unicode/measfmt.h b/source/i18n/unicode/measfmt.h
index 91e08ef..6d480f0 100644
--- a/source/i18n/unicode/measfmt.h
+++ b/source/i18n/unicode/measfmt.h
@@ -94,8 +94,25 @@ class DateFormat;
  */
 class U_I18N_API MeasureFormat : public Format {
  public:
+#if __GNUC__ == 2
+	void parseObject (const UnicodeString& s, Formattable& f, UErrorCode& e) 
+		const {
+		Format::parseObject(s, f, e);
+	}
+
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+		FieldPositionIterator* i, UErrorCode& e) const {
+		return Format::format(f, s, i, e);
+	}
+
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+		UErrorCode& e) const {
+		return Format::format(f, s, e);
+	}
+#else
     using Format::parseObject;
     using Format::format;
+#endif
 
 #ifndef U_HIDE_DRAFT_API
     /**
diff --git a/source/i18n/unicode/msgfmt.h b/source/i18n/unicode/msgfmt.h
index 5de91e4..8f9f995 100644
--- a/source/i18n/unicode/msgfmt.h
+++ b/source/i18n/unicode/msgfmt.h
@@ -622,7 +622,17 @@ public:
     virtual const Format** getFormats(int32_t& count) const;
 
 
+#if __GNUC__ == 2
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+		FieldPositionIterator* i, UErrorCode& e) const {
+		return Format::format(f, s, i, e);
+	}
+	UnicodeString& format(const Formattable& f, UnicodeString& s, UErrorCode& e) {
+		return Format::format(f, s, e);
+	}
+#else
     using Format::format;
+#endif
 
     /**
      * Formats the given array of arguments into a user-readable string.
@@ -884,6 +894,9 @@ private:
         PluralRules* rules;
         UPluralType type;
     };
+#if __GNUC__ == 2
+	friend class PluralSelectorProvider;
+#endif
 
     /**
      * A MessageFormat formats an array of arguments.  Each argument
diff --git a/source/i18n/unicode/numfmt.h b/source/i18n/unicode/numfmt.h
index e7dc33e..9b989ca 100644
--- a/source/i18n/unicode/numfmt.h
+++ b/source/i18n/unicode/numfmt.h
@@ -235,7 +235,15 @@ public:
     virtual UBool operator==(const Format& other) const;
 
 
+#if __GNUC__ == 2
+    virtual UnicodeString& format (const Formattable& obj,
+                                   UnicodeString& appendTo,
+                                   UErrorCode & status) const {
+        return Format::format(obj, appendTo, status);
+    }
+#else
     using Format::format;
+#endif
 
     /**
      * Format an object to produce a string.  This method handles
diff --git a/source/i18n/unicode/plurfmt.h b/source/i18n/unicode/plurfmt.h
index f7099d8..bedaf01 100644
--- a/source/i18n/unicode/plurfmt.h
+++ b/source/i18n/unicode/plurfmt.h
@@ -313,7 +313,14 @@ public:
     void applyPattern(const UnicodeString& pattern, UErrorCode& status);
 
 
+#if __GNUC__ == 2
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+		FieldPositionIterator* i, UErrorCode& e) const {
+		return Format::format(f, s, i, e);
+	}
+#else
     using Format::format;
+#endif
 
     /**
      * Formats a plural message for a given number.
diff --git a/source/i18n/unicode/rbnf.h b/source/i18n/unicode/rbnf.h
index 398454b..5c7bb00 100644
--- a/source/i18n/unicode/rbnf.h
+++ b/source/i18n/unicode/rbnf.h
@@ -741,7 +741,23 @@ public:
                           const Locale& locale = Locale::getDefault());
 
 
+#if __GNUC__ == 2
+  UnicodeString& format(const Formattable& f, UnicodeString& s, UErrorCode& e)
+	const {
+		return NumberFormat::format(f, s, e);
+  }
+
+  UnicodeString& format(double n, UnicodeString& s) const {
+	return NumberFormat::format(n, s);
+  }
+
+  UnicodeString& format(int64_t n, UnicodeString& s, FieldPosition& p,
+	UErrorCode& e) const {
+	return NumberFormat::format(n, s, p, e);
+  }
+#else
   using NumberFormat::format;
+#endif
 
   /**
    * Formats the specified 32-bit number using the default ruleset.
@@ -827,7 +843,13 @@ public:
                                 FieldPosition& pos,
                                 UErrorCode& status) const;
 
+#if __GNUC__ == 2
+  void parse(const UnicodeString& s, Formattable& f, UErrorCode& e) const {
+	return NumberFormat::parse(s, f, e);
+  }
+#else
   using NumberFormat::parse;
+#endif
 
   /**
    * Parses the specfied string, beginning at the specified position, according
diff --git a/source/i18n/unicode/selfmt.h b/source/i18n/unicode/selfmt.h
index 635144b..fbc89f6 100644
--- a/source/i18n/unicode/selfmt.h
+++ b/source/i18n/unicode/selfmt.h
@@ -219,7 +219,9 @@ public:
     void applyPattern(const UnicodeString& pattern, UErrorCode& status);
 
 
+#if __GNUC__ != 2
     using Format::format;
+#endif
 
     /**
      * Selects the phrase for  the given keyword
diff --git a/source/i18n/unicode/smpdtfmt.h b/source/i18n/unicode/smpdtfmt.h
index d41fb59..34ea328 100644
--- a/source/i18n/unicode/smpdtfmt.h
+++ b/source/i18n/unicode/smpdtfmt.h
@@ -868,7 +868,27 @@ public:
     virtual UBool operator==(const Format& other) const;
 
 
+#if __GNUC__ == 2
+	UnicodeString& format(const Formattable& f, UnicodeString& s,
+		FieldPositionIterator* i, UErrorCode& e) const {
+		return DateFormat::format(f, s, i, e);
+	}
+	UnicodeString& format(const Formattable& f, UnicodeString& s, FieldPosition& p,
+		UErrorCode& e) const {
+		return DateFormat::format(f, s, p, e);
+	}
+	UnicodeString& format(const Formattable& f, UnicodeString& s, UErrorCode& e) const {
+		return Format::format(f, s, e);
+	}
+	UnicodeString& format(const UDate& d, UnicodeString& s, FieldPosition& f) const {
+		return DateFormat::format(d, s, f);
+	}
+	UnicodeString& format(const UDate& d, UnicodeString& s) const {
+		return DateFormat::format(d, s);
+	}
+#else
     using DateFormat::format;
+#endif
 
     /**
      * Format a date or time, which is the standard millis since 24:00 GMT, Jan
@@ -913,7 +933,16 @@ public:
                                     FieldPositionIterator* posIter,
                                     UErrorCode& status) const;
 
+#if __GNUC__ == 2
+	UDate parse(const UnicodeString& s, UErrorCode& e) const {
+		return DateFormat::parse(s, e);
+	}
+	UDate parse (const UnicodeString& s, ParsePosition& p) const {
+		return DateFormat::parse(s, p);
+	}
+#else
     using DateFormat::parse;
+#endif
 
     /**
      * Parse a date/time string beginning at the given parse position. For
diff --git a/source/i18n/unicode/tblcoll.h b/source/i18n/unicode/tblcoll.h
index 6d6e4b9..b044c9c 100644
--- a/source/i18n/unicode/tblcoll.h
+++ b/source/i18n/unicode/tblcoll.h
@@ -254,7 +254,22 @@ public:
                                          const CharacterIterator& source) const;
 
     // Make deprecated versions of Collator::compare() visible.
+#if __GNUC__ == 2
+	EComparisonResult compare(const UChar* source, int sourceLength,
+		const UChar* target, int targetLength) const {
+		return Collator::compare(source, sourceLength, target, targetLength);
+	}
+	EComparisonResult compare(const UnicodeString& s1, const UnicodeString& s2,
+		int i) const {
+		return Collator::compare(s1, s2, i);
+	}
+	EComparisonResult compare(const UnicodeString& s1, const UnicodeString& s2)
+		const {
+		return Collator::compare(s1, s2);
+	}
+#else
     using Collator::compare;
+#endif
 
     /**
     * The comparison function compares the character data stored in two
diff --git a/source/i18n/unicode/tzfmt.h b/source/i18n/unicode/tzfmt.h
index 24f0e49..969e08a 100644
--- a/source/i18n/unicode/tzfmt.h
+++ b/source/i18n/unicode/tzfmt.h
@@ -520,7 +520,14 @@ public:
      */
     UnicodeString& formatOffsetShortLocalizedGMT(int32_t offset, UnicodeString& result, UErrorCode& status) const;
 
+#if __GNUC__ == 2
+	UnicodeString& format(const Formattable& data, UnicodeString& string,
+		FieldPositionIterator* iterator, UErrorCode& error) const {
+		return Format::format(data, string, iterator, error);
+	}
+#else
     using Format::format;
+#endif
 
     /**
      * Returns the display name of the time zone at the given date for the style.
diff --git a/source/layout/LETableReference.h b/source/layout/LETableReference.h
index f7eb79b..8ea8700 100644
--- a/source/layout/LETableReference.h
+++ b/source/layout/LETableReference.h
@@ -304,7 +304,11 @@ LE_TRACE_TR("INFO: new RTAO")
 
   le_uint32 getCount() const { return fCount; }
 
+#if __GNUC__ == 2
+  const T *getAlias() const { return LETableReference::getAlias(); }
+#else
   using LETableReference::getAlias;
+#endif
 
   const T *getAlias(le_uint32 i, LEErrorCode &success) const {
     return ((const T*)(((const char*)getAlias())+getOffsetFor(i, success)));
diff --git a/source/test/intltest/apicoll.cpp b/source/test/intltest/apicoll.cpp
index 9d87bf0..4798867 100644
--- a/source/test/intltest/apicoll.cpp
+++ b/source/test/intltest/apicoll.cpp
@@ -1987,7 +1987,22 @@ class TestCollator  : public Collator
 public:
     virtual Collator* clone(void) const;
 
+#if __GNUC__ == 2
+	EComparisonResult compare (const UnicodeString& s1, const UnicodeString& s2)
+		const {
+		return Collator::compare(s1, s2);
+	}
+	EComparisonResult compare (const UnicodeString& s1, const UnicodeString& s2,
+			int32_t i) const {
+		return Collator::compare(s1, s2, i);
+	}
+	EComparisonResult compare (const UChar* s1, int32_t l1, const UChar* s2,
+		int32_t l2) const {
+		return Collator::compare(s1, l1, s2, l2);
+	}
+#else
     using Collator::compare;
+#endif
 
     virtual UCollationResult compare(const UnicodeString& source, 
                                       const UnicodeString& target,
diff --git a/source/test/iotest/stream.cpp b/source/test/iotest/stream.cpp
index a821636..083b4ab 100644
--- a/source/test/iotest/stream.cpp
+++ b/source/test/iotest/stream.cpp
@@ -131,7 +131,7 @@ static void U_CALLCONV TestStream(void)
 #endif
     UnicodeString ustr("string");
 
-    outFormatStream << "1234567890" << setw(10) << left << ustr << " " << "0123456789";
+    outFormatStream << "1234567890" << setw(10) << ios::left << ustr << " " << "0123456789";
 
 #ifdef USE_SSTREAM
     tempStr = outFormatStream.str();
diff --git a/source/tools/toolutil/udbgutil.cpp b/source/tools/toolutil/udbgutil.cpp
index efad363..5676e6d 100644
--- a/source/tools/toolutil/udbgutil.cpp
+++ b/source/tools/toolutil/udbgutil.cpp
@@ -639,7 +639,9 @@ U_CAPI void udbg_knownIssue_close(void *ptr) {
 #include <set>
 #include <map>
 #include <string>
+#if __GNUC__ != 2
 #include <ostream>
+#endif
 #include <iostream>
 
 class KnownIssues {
-- 
1.8.3.4


From 3bb3350e14d91e05c87c01d2707b626d863e3ba0 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 2 Oct 2014 14:54:39 +0200
Subject: Force definition of U_DISABLE_RENAMING

We build ICU with this flag disabled, but somehow this isn't added tothe
header, and later on trying to build haiku without the flag would fail.
So we just change the default value to keep things simpler.

diff --git a/source/common/unicode/uconfig.h b/source/common/unicode/uconfig.h
index ed073b6..4950c5e 100644
--- a/source/common/unicode/uconfig.h
+++ b/source/common/unicode/uconfig.h
@@ -87,7 +87,7 @@
  * @internal
  */
 #ifndef U_DISABLE_RENAMING
-#define U_DISABLE_RENAMING 0
+#define U_DISABLE_RENAMING 1
 #endif
 
 /**
-- 
1.8.3.4


From 3343d5fa455ccf69c3db877d3134dd4f32ac9af7 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Fri, 3 Oct 2014 11:07:01 +0200
Subject: Don't call tzset and tzname on Haiku

While they exist, they are implemented using ICU, and trying to use them
within ICU results in a deadlock.

diff --git a/source/common/putilimp.h b/source/common/putilimp.h
index d2c1c66..a3e361f 100644
--- a/source/common/putilimp.h
+++ b/source/common/putilimp.h
@@ -105,7 +105,7 @@ typedef size_t uintptr_t;
     /* Use the predefined value. */
 #elif U_PLATFORM_USES_ONLY_WIN32_API
 #   define U_TZSET _tzset
-#elif U_PLATFORM == U_PF_OS400
+#elif U_PLATFORM == U_PF_OS400 || defined(__HAIKU__)
    /* not defined */
 #else
 #   define U_TZSET tzset
@@ -140,7 +140,7 @@ typedef size_t uintptr_t;
     /* Use the predefined value. */
 #elif U_PLATFORM_USES_ONLY_WIN32_API
 #   define U_TZNAME _tzname
-#elif U_PLATFORM == U_PF_OS400
+#elif U_PLATFORM == U_PF_OS400 || defined(__HAIKU__)
    /* not defined */
 #else
 #   define U_TZNAME tzname
diff --git a/source/configure.ac b/source/configure.ac
index b30c8d0..89902b4 100644
--- a/source/configure.ac
+++ b/source/configure.ac
@@ -790,50 +790,26 @@ else
 fi
 AC_SUBST(U_HAVE_POPEN)
 
-AC_CHECK_FUNC(tzset)
+#AC_CHECK_FUNC(tzset)
 U_HAVE_TZSET=0
-if test x$ac_cv_func_tzset = xyes
-then
-    U_TZSET=tzset
-    U_HAVE_TZSET=1
-else
-    AC_CHECK_FUNC(_tzset)
-    if test x$ac_cv_func__tzset = xyes
-    then
-        U_TZSET=_tzset
-        U_HAVE_TZSET=1
-    else
-      CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_TZSET=0"
-    fi
-fi
+#if test x$ac_cv_func_tzset = xyes
+#then
+#    U_TZSET=tzset
+#    U_HAVE_TZSET=1
+#else
+#    AC_CHECK_FUNC(_tzset)
+#    if test x$ac_cv_func__tzset = xyes
+#    then
+#        U_TZSET=_tzset
+#        U_HAVE_TZSET=1
+#    else
+#      CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_TZSET=0"
+#    fi
+#fi
 AC_SUBST(U_HAVE_TZSET)
 AC_SUBST(U_TZSET)
 
 U_HAVE_TZNAME=0
-AC_CACHE_CHECK(for tzname,ac_cv_var_tzname,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#ifndef __USE_POSIX
-#define __USE_POSIX
-#endif
-#include <stdlib.h>
-#include <time.h>
-#ifndef tzname /* For SGI.  */
-extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
-#endif]], [atoi(*tzname);])],[ac_cv_var_tzname=yes],[ac_cv_var_tzname=no])])
-if test $ac_cv_var_tzname = yes; then
-  U_TZNAME=tzname
-  U_HAVE_TZNAME=1
-else
-  AC_CACHE_CHECK(for _tzname,ac_cv_var__tzname,
-  [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
-  #include <time.h>
-  extern char *_tzname[];]], [atoi(*_tzname);])],[ac_cv_var__tzname=yes],[ac_cv_var__tzname=no])])
-    if test $ac_cv_var__tzname = yes; then
-      U_TZNAME=_tzname
-      U_HAVE_TZNAME=1
-    else
-     CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DU_HAVE_TZNAME=0"
-    fi
-fi
 AC_SUBST(U_HAVE_TZNAME)
 AC_SUBST(U_TZNAME)
 
-- 
1.8.3.4


From 675a0667bee53b6d00de939af2ed82282dec7e6d Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Mon, 6 Oct 2014 13:28:09 +0200
Subject: more gcc2 fixes for ICU 54.


diff --git a/source/common/norm2allmodes.h b/source/common/norm2allmodes.h
index 64c84a2..aca1e08 100644
--- a/source/common/norm2allmodes.h
+++ b/source/common/norm2allmodes.h
@@ -193,7 +193,9 @@ private:
               ReorderingBuffer &buffer, UErrorCode &errorCode) const {
         impl.decompose(src, limit, &buffer, errorCode);
     }
+#if __GNUC__ != 2
     using Normalizer2WithImpl::normalize;  // Avoid warning about hiding base class function.
+#endif
     virtual void
     normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
                        UnicodeString &safeMiddle,
@@ -204,7 +206,9 @@ private:
     spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &errorCode) const {
         return impl.decompose(src, limit, NULL, errorCode);
     }
+#if __GNUC__ != 2
     using Normalizer2WithImpl::spanQuickCheckYes;  // Avoid warning about hiding base class function.
+#endif
     virtual UNormalizationCheckResult getQuickCheck(UChar32 c) const {
         return impl.isDecompYes(impl.getNorm16(c)) ? UNORM_YES : UNORM_NO;
     }
@@ -225,7 +229,9 @@ private:
               ReorderingBuffer &buffer, UErrorCode &errorCode) const {
         impl.compose(src, limit, onlyContiguous, TRUE, buffer, errorCode);
     }
+#if __GNUC__ != 2
     using Normalizer2WithImpl::normalize;  // Avoid warning about hiding base class function.
+#endif
     virtual void
     normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
                        UnicodeString &safeMiddle,
@@ -268,7 +274,9 @@ private:
     spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &) const {
         return impl.composeQuickCheck(src, limit, onlyContiguous, NULL);
     }
+#if __GNUC__ != 2
     using Normalizer2WithImpl::spanQuickCheckYes;  // Avoid warning about hiding base class function.
+#endif
     virtual UNormalizationCheckResult getQuickCheck(UChar32 c) const {
         return impl.getCompQuickCheck(impl.getNorm16(c));
     }
@@ -296,7 +304,9 @@ private:
               ReorderingBuffer &buffer, UErrorCode &errorCode) const {
         impl.makeFCD(src, limit, &buffer, errorCode);
     }
+#if __GNUC__ != 2
     using Normalizer2WithImpl::normalize;  // Avoid warning about hiding base class function.
+#endif
     virtual void
     normalizeAndAppend(const UChar *src, const UChar *limit, UBool doNormalize,
                        UnicodeString &safeMiddle,
@@ -307,7 +317,9 @@ private:
     spanQuickCheckYes(const UChar *src, const UChar *limit, UErrorCode &errorCode) const {
         return impl.makeFCD(src, limit, NULL, errorCode);
     }
+#if __GNUC__ != 2
     using Normalizer2WithImpl::spanQuickCheckYes;  // Avoid warning about hiding base class function.
+#endif
     virtual UBool hasBoundaryBefore(UChar32 c) const { return impl.hasFCDBoundaryBefore(c); }
     virtual UBool hasBoundaryAfter(UChar32 c) const { return impl.hasFCDBoundaryAfter(c); }
     virtual UBool isInert(UChar32 c) const { return impl.isFCDInert(c); }
diff --git a/source/common/putilimp.h b/source/common/putilimp.h
index a3e361f..affb1a8 100644
--- a/source/common/putilimp.h
+++ b/source/common/putilimp.h
@@ -113,7 +113,7 @@ typedef size_t uintptr_t;
 
 #if defined(U_TIMEZONE) || defined(U_HAVE_TIMEZONE)
     /* Use the predefined value. */
-#elif U_PLATFORM == U_PF_ANDROID
+#elif U_PLATFORM == U_PF_ANDROID || defined(__HAIKU__)
 #   define U_TIMEZONE timezone
 #elif U_PLATFORM_IS_LINUX_BASED
 #   if defined(__UCLIBC__)
diff --git a/source/common/unicode/platform.h b/source/common/unicode/platform.h
index fbb4ae1..6e7c62f 100644
--- a/source/common/unicode/platform.h
+++ b/source/common/unicode/platform.h
@@ -149,7 +149,7 @@
 #   else
 #       define U_PLATFORM U_PF_DARWIN
 #   endif
-#elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)
+#elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__) || defined(__HAIKU__)
 #   define U_PLATFORM U_PF_BSD
 #elif defined(sun) || defined(__sun)
     /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
diff --git a/source/i18n/filteredbrk.cpp b/source/i18n/filteredbrk.cpp
index 43b2d53..70802e4 100644
--- a/source/i18n/filteredbrk.cpp
+++ b/source/i18n/filteredbrk.cpp
@@ -65,7 +65,13 @@ class U_I18N_API UStringSet : public UVector {
   inline UBool contains(const UnicodeString& s) {
     return contains((void*) &s);
   }
+#if __GNUC__ == 2
+  UBool contains(void* s) {
+	  return UVector::contains(s);
+  }
+#else
   using UVector::contains;
+#endif
   /**
    * Return the ith UnicodeString alias
    */
-- 
1.8.3.4


From 5c4615966fb385dd000fa9adca7156b4976b1955 Mon Sep 17 00:00:00 2001
From: Oliver Tappe <zooey@hirschkaefer.de>
Date: Fri, 14 Nov 2014 23:56:19 +0100
Subject: Restore missing parts for proper Haiku port.

* Actually set the platform to U_HAIKU for Haiku target.
* Use gcc to build icudt54l_dat.o for Haiku target.

diff --git a/source/configure.ac b/source/configure.ac
index 89902b4..9f3b893 100644
--- a/source/configure.ac
+++ b/source/configure.ac
@@ -626,7 +626,7 @@ AC_MSG_CHECKING([for genccode assembly])
 # Check to see if genccode can generate simple assembly.
 GENCCODE_ASSEMBLY=
 case "${host}" in
-*-linux*|*-kfreebsd*-gnu*|i*86-*-*bsd*|i*86-pc-gnu)
+*-linux*|*-kfreebsd*-gnu*|i*86-*-*bsd*|i*86-pc-gnu|*-haiku*)
     if test "$GCC" = yes; then
         # We're using gcc, and the simple -a gcc command line works for genccode
         GENCCODE_ASSEMBLY="-a gcc"
@@ -1227,6 +1227,7 @@ case "${host}" in
 	*-*-nto*)	platform=U_QNX ;;
 	*-dec-osf*) 	platform=U_OSF ;;
 	*-*-beos)		platform=U_BEOS ;;
+	*-*-haiku*)		platform=U_HAIKU ;;
 	*-*-irix*)		platform=U_IRIX ;;
 	*-ncr-*)		platform=U_MPRAS ;;
 	*) 		platform=U_UNKNOWN_PLATFORM ;;
-- 
1.8.3.4


From 93cbe09790e65f5c22ae8150a547789a027f6ba8 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Thu, 26 Mar 2015 18:39:42 +0000
Subject: gcc2 fixes for tztools.


diff --git a/source/tools/tzcode/private.h b/source/tools/tzcode/private.h
index 1a85c88..0ee3329 100644
--- a/source/tools/tzcode/private.h
+++ b/source/tools/tzcode/private.h
@@ -120,7 +120,7 @@
 */
 #ifndef HAVE_STDINT_H
 #define HAVE_STDINT_H \
-	(199901 <= __STDC_VERSION__ || \
+	(defined(__HAIKU__) || 199901 <= __STDC_VERSION__ || \
 	2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
 #endif /* !defined HAVE_STDINT_H */
 
-- 
1.8.3.4

