Changeset 3511 for trunk/lang/tcl/src/RpUnitsTclInterface.cc
- Timestamp:
- Mar 16, 2013 9:31:43 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lang/tcl/src/RpUnitsTclInterface.cc
r3177 r3511 38 38 */ 39 39 40 #include <algorithm> 41 #include <functional> 42 #include <cctype> 43 44 // Trim from start 45 static inline std::string <rim(std::string &s) 46 { 47 s.erase(s.begin(), 48 std::find_if(s.begin(), s.end(), 49 std::not1(std::ptr_fun<int, int>(std::isspace)))); 50 return s; 51 } 52 53 // Trim from end 54 static inline std::string &rtrim(std::string &s) 55 { 56 s.erase(std::find_if(s.rbegin(), s.rend(), 57 std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); 58 return s; 59 } 60 61 // Trim from both ends 62 static inline std::string &trim(std::string &s) 63 { 64 return ltrim(rtrim(s)); 65 } 66 40 67 extern "C" int 41 68 RpUnits_Init(Tcl_Interp *interp) … … 71 98 * provided in -context option. 72 99 */ 100 73 101 74 102 int … … 208 236 // or if we should use those provided in -context option 209 237 238 239 // Trim away white space from the value. 240 trim(inValue); 241 210 242 double value; 211 value = strtod(inValue.c_str(), &endptr);243 value = strtod(inValue.c_str(), &endptr); 212 244 if (endptr == inValue.c_str()) { 213 245 // there was no numeric value that could be pulled from inValue
Note: See TracChangeset
for help on using the changeset viewer.