stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r480734 - in /incubator/stdcxx/trunk/util: def.cpp def.h monetary.cpp
Date Wed, 29 Nov 2006 22:22:45 GMT
Author: sebor
Date: Wed Nov 29 14:22:44 2006
New Revision: 480734

URL: http://svn.apache.org/viewvc?view=rev&rev=480734
Log:
2006-11-29  Martin Sebor  <sebor@roguewave.com>

	* def.h (create_format): Removed redundant const qualifier from
	function formal arguments and removed their names.
	(mon_punct_out_): Removed data member.
	* def.cpp (Def): Invalidated mon_out_ char members by assigning
	CHAR_MAX as expected (and required by C) rather than -1.
	* monetary.cpp (create_format): Assigned CHAR_MAX instead of -1
	to indicate missing values.
	(write_monetary): Renamed mon_punct_out_ to punct and made local.

Modified:
    incubator/stdcxx/trunk/util/def.cpp
    incubator/stdcxx/trunk/util/def.h
    incubator/stdcxx/trunk/util/monetary.cpp

Modified: incubator/stdcxx/trunk/util/def.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/def.cpp?view=diff&rev=480734&r1=480733&r2=480734
==============================================================================
--- incubator/stdcxx/trunk/util/def.cpp (original)
+++ incubator/stdcxx/trunk/util/def.cpp Wed Nov 29 14:22:44 2006
@@ -555,25 +555,28 @@
     std::memset (&ctype_out_, 0, sizeof (ctype_out_));
     std::memset (&time_out_, 0, sizeof (time_out_));
 
-    mon_out_.frac_digits    [0] = -1;
-    mon_out_.frac_digits    [1] = -1;
-    mon_out_.p_cs_precedes  [0] = -1;
-    mon_out_.p_sep_by_space [0] = -1;
-    mon_out_.n_cs_precedes  [0] = -1;
-    mon_out_.n_sep_by_space [0] = -1;
-    mon_out_.p_sign_posn    [0] = -1;
-    mon_out_.n_sign_posn    [0] = -1;
-    mon_st_.mon_grouping += -1;
+    // invalidate format characters by setting each to CHAR_MAX
+    // as specified by the C function localeconv()
+    mon_out_.frac_digits    [0] = CHAR_MAX;
+    mon_out_.frac_digits    [1] = CHAR_MAX;
+    mon_out_.p_cs_precedes  [0] = CHAR_MAX;
+    mon_out_.p_sep_by_space [0] = CHAR_MAX;
+    mon_out_.n_cs_precedes  [0] = CHAR_MAX;
+    mon_out_.n_sep_by_space [0] = CHAR_MAX;
+    mon_out_.p_sign_posn    [0] = CHAR_MAX;
+    mon_out_.n_sign_posn    [0] = CHAR_MAX;
 
-    // c99 extension
-    mon_out_.p_cs_precedes  [1] = -1;
-    mon_out_.p_sep_by_space [1] = -1;
-    mon_out_.n_cs_precedes  [1] = -1;
-    mon_out_.n_sep_by_space [1] = -1;
-    mon_out_.p_sign_posn    [1] = -1;
-    mon_out_.n_sign_posn    [1] = -1;
+    mon_st_.mon_grouping += CHAR_MAX;
+
+    // invalidate int'l formats
+    mon_out_.p_cs_precedes  [1] = CHAR_MAX;
+    mon_out_.p_sep_by_space [1] = CHAR_MAX;
+    mon_out_.n_cs_precedes  [1] = CHAR_MAX;
+    mon_out_.n_sep_by_space [1] = CHAR_MAX;
+    mon_out_.p_sign_posn    [1] = CHAR_MAX;
+    mon_out_.n_sign_posn    [1] = CHAR_MAX;
     
-    num_st_.grouping += -1;
+    num_st_.grouping += CHAR_MAX;
 
     collate_out_.largest_ce     = 1;
     collate_out_.longest_weight = 1;

Modified: incubator/stdcxx/trunk/util/def.h
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/def.h?view=diff&rev=480734&r1=480733&r2=480734
==============================================================================
--- incubator/stdcxx/trunk/util/def.h (original)
+++ incubator/stdcxx/trunk/util/def.h Wed Nov 29 14:22:44 2006
@@ -216,9 +216,7 @@
     void process_monetary();
 
     // create the monetary formats
-    void create_format (char format[], const char sign_posn, 
-                        const char cs_precedes, const char sep_by_space,
-                        bool is_positive);
+    void create_format (char [4], char, char, char, bool);
 
     // process the numeric section of the locale definition file
     void process_numeric();
@@ -458,7 +456,6 @@
 
     // the structures used to hold the offsets for each locale category
     // and any non-pointer locale information
-    _RW::__rw_punct_t mon_punct_out_;
     _RW::__rw_punct_t num_punct_out_;
     _RW::__rw_ctype_t ctype_out_;
     _RW::__rw_time_t time_out_;

Modified: incubator/stdcxx/trunk/util/monetary.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/util/monetary.cpp?view=diff&rev=480734&r1=480733&r2=480734
==============================================================================
--- incubator/stdcxx/trunk/util/monetary.cpp (original)
+++ incubator/stdcxx/trunk/util/monetary.cpp Wed Nov 29 14:22:44 2006
@@ -41,7 +41,7 @@
 static const char lc_name[] = "LC_MONETARY";
 
 
-void Def::process_monetary()
+void Def::process_monetary ()
 {
     issue_diag (I_STAGE, false, 0, "processing %s section\n", lc_name);
 
@@ -236,24 +236,27 @@
                             maxval, next.name.c_str ());
             }
             else
-                *pcharint = char (val);
+                *pcharint = -1 == val ? CHAR_MAX : char (val);
         }
     }
 }
 
 
-void Def::create_format (char format[], const char sign_posn, 
-                         const char cs_precedes, const char sep_by_space,
+void Def::create_format (char format [4],
+                         char sign_posn, 
+                         char cs_precedes,
+                         char sep_by_space,
                          bool is_positive) 
 {
     switch (sign_posn) {
         // the international extension is not defined for this locale
-    case -1:
-        format[0] = -1;
-        format[1] = -1;
-        format[2] = -1;
-        format[3] = -1;
+    case CHAR_MAX:
+        format [0] = CHAR_MAX;
+        format [1] = CHAR_MAX;
+        format [2] = CHAR_MAX;
+        format [3] = CHAR_MAX;
         return;
+
     case 0:
         // if sign_posn is 0 then we change the sign to "()", if sign is 
         // not the empty string then issue a warning
@@ -405,39 +408,41 @@
     std::ofstream out (dir_name.c_str(), std::ios::binary);
     out.exceptions (std::ios::failbit | std::ios::badbit);
 
+    _RW::__rw_punct_t punct;
+
     // calculate the offsets for the mon_punct structure
-    mon_punct_out_.decimal_point_off [1] = 0;
+    punct.decimal_point_off [1] = 0;
 
-    mon_punct_out_.thousands_sep_off [1] = 
-          mon_punct_out_.decimal_point_off [1] 
+    punct.thousands_sep_off [1] =
+          punct.decimal_point_off [1] 
         + (mon_st_.wmon_decimal_point.size () + 1) * sizeof (wchar_t);
 
-    mon_punct_out_.decimal_point_off [0] = 
-          mon_punct_out_.thousands_sep_off [1]
+    punct.decimal_point_off [0] =
+          punct.thousands_sep_off [1]
         + (mon_st_.wmon_thousands_sep.size () + 1) * sizeof (wchar_t);
 
-    mon_punct_out_.thousands_sep_off [0] = 
-          mon_punct_out_.decimal_point_off [0]
+    punct.thousands_sep_off [0] =
+          punct.decimal_point_off [0]
         + mon_st_.mon_decimal_point.size () + 1;
 
-    mon_punct_out_.grouping_off =
-          mon_punct_out_.thousands_sep_off [0]
+    punct.grouping_off =
+          punct.thousands_sep_off [0]
         + mon_st_.mon_thousands_sep.size () + 1;
 
-    mon_punct_out_.punct_ext_off =
-          mon_punct_out_.grouping_off
+    punct.punct_ext_off =
+          punct.grouping_off
         + mon_st_.mon_grouping.size () + 1;
 
     // compute the alignment requirement of any offset member
-    const std::size_t align = sizeof mon_punct_out_.punct_ext_off;
+    const std::size_t align = sizeof punct.punct_ext_off;
 
     // align the offset of the extension struct on the required boundary
-    const std::size_t misalign = mon_punct_out_.punct_ext_off % align;
+    const std::size_t misalign = punct.punct_ext_off % align;
 
     // compute the amount of padding between the two structs
     const std::size_t pad = misalign ? align - misalign : 0;
 
-    mon_punct_out_.punct_ext_off += pad;
+    punct.punct_ext_off += pad;
 
     mon_out_.curr_symbol_off [1][1] = 0;
 
@@ -494,12 +499,12 @@
                 "    charmap_off = %u\n"
                 "}\n",
                 lc_name,
-                mon_punct_out_.decimal_point_off [0],
-                mon_punct_out_.decimal_point_off [1],
-                mon_punct_out_.thousands_sep_off [0],
-                mon_punct_out_.thousands_sep_off [1],
-                mon_punct_out_.grouping_off,
-                mon_punct_out_.punct_ext_off,
+                punct.decimal_point_off [0],
+                punct.decimal_point_off [1],
+                punct.thousands_sep_off [0],
+                punct.thousands_sep_off [1],
+                punct.grouping_off,
+                punct.punct_ext_off,
                 mon_out_.curr_symbol_off [0][0],
                 mon_out_.curr_symbol_off [0][1],
                 mon_out_.curr_symbol_off [1][0],
@@ -527,9 +532,9 @@
                    false);
         
     // write out the mon_punct structure
-    out.write ((char*)&mon_punct_out_, sizeof (mon_punct_out_));
+    out.write ((char*)&punct, sizeof punct);
         
-    // write out the strings in the mon_punct_out_ structure
+    // write out the strings in the punct structure
     out.write ((const char*)mon_st_.wmon_decimal_point.c_str(),
                (mon_st_.wmon_decimal_point.size() + 1) * sizeof(wchar_t));
     out.write ((const char*)mon_st_.wmon_thousands_sep.c_str(),



Mime
View raw message