patch by Jeffrey Yasskin for porting to Ubuntu Hardy.  Everything was accepted except there were some bug fixes needed in <locale> for the __nolocale_* series.  For the apple branch I ended up using templates instead of the var_args solution because it seemed both safer and more efficient.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@104516 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/system_error.cpp b/src/system_error.cpp
index 2e12aa8..3c1f000 100644
--- a/src/system_error.cpp
+++ b/src/system_error.cpp
@@ -64,9 +64,11 @@
 string
 __generic_error_category::message(int ev) const
 {
-    if (ev <= ELAST)
-        return __do_message::message(ev);
-    return string("unspecified generic_category error");
+#ifdef ELAST
+    if (ev > ELAST)
+      return string("unspecified generic_category error");
+#endif
+    return __do_message::message(ev);
 }
 
 const error_category&
@@ -94,17 +96,21 @@
 string
 __system_error_category::message(int ev) const
 {
-    if (ev <= ELAST)
-        return __do_message::message(ev);
-    return string("unspecified system_category error");
+#ifdef ELAST
+    if (ev > ELAST)
+      return string("unspecified system_category error");
+#endif
+    return __do_message::message(ev);
 }
 
 error_condition
 __system_error_category::default_error_condition(int ev) const
 {
-    if (ev <= ELAST)
-        return error_condition(ev, generic_category());
-    return error_condition(ev, system_category());
+#ifdef ELAST
+    if (ev > ELAST)
+      return error_condition(ev, system_category());
+#endif
+    return error_condition(ev, generic_category());
 }
 
 const error_category&