stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r653284 - /stdcxx/branches/4.2.x/tests/src/locale.cpp
Date Sun, 04 May 2008 23:59:17 GMT
Author: sebor
Date: Sun May  4 16:59:17 2008
New Revision: 653284

URL: http://svn.apache.org/viewvc?rev=653284&view=rev
Log:
2008-05-04  Martin Sebor  <sebor@roguewave.com>

	STDCXX-910
	* tests/src/locale.cpp (rw_localedef): Used __FILE__ to try to get
	the value of TOPDIR when the environment variable is unset or empty.
	(_rw_all_locales): Same.

Modified:
    stdcxx/branches/4.2.x/tests/src/locale.cpp

Modified: stdcxx/branches/4.2.x/tests/src/locale.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/locale.cpp?rev=653284&r1=653283&r2=653284&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/locale.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/locale.cpp Sun May  4 16:59:17 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 2001-2007 Rogue Wave Software, Inc.
+ * Copyright 2001-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -215,8 +215,22 @@
 
     // otherwise, try to create the locale database
 
+    // fallback for when TOPDIR is unset or empty
+    char topdir_path_buf [] = __FILE__;
+
     // use TOPDIR to determine the root of the source tree
-    const char* const topdir = getenv (TOPDIR);
+    const char* topdir = getenv (TOPDIR);
+    if (!topdir || !*topdir) {
+
+        // try to get TOPDIR from __FILE__
+        char* const slash = strrchr (topdir_path_buf, _RWSTD_PATH_SEP);
+
+        if (slash) {
+            slash [-1] = '\0';
+            topdir     = topdir_path_buf;
+        }
+    }
+
     if (!topdir || !*topdir) {
         rw_error (0, __FILE__, __LINE__,
                   "the environment variable %s is %s",
@@ -1097,8 +1111,22 @@
         _rw_lookup_table_t countries_map;
         _rw_lookup_table_t encodings_map;
 
+        // fallback for when TOPDIR is unset or empty
+        char topdir_path_buf [] = __FILE__;
+
         // use TOPDIR to determine the root of the source tree
-        const char* const topdir = getenv (TOPDIR);
+        const char* topdir = getenv (TOPDIR);
+        if (!topdir || !*topdir) {
+
+            // try to get TOPDIR from __FILE__
+            char* const slash = strrchr (topdir_path_buf, _RWSTD_PATH_SEP);
+
+            if (slash) {
+                slash [-1] = '\0';
+                topdir     = topdir_path_buf;
+            }
+        }
+
         if (!topdir || !*topdir) {
             rw_error (0, __FILE__, __LINE__,
                       "the environment variable %s is %s",



Mime
View raw message