42 #ifdef ALPHANUM_LOCALE
65 #ifdef ALPHANUM_LOCALE
67 bool alphanum_isdigit(
int c)
76 bool alphanum_isdigit(
const char c)
78 return c >=
'0' && c <=
'9';
97 int alphanum_impl(
const char* l,
const char* r)
110 while ((l_char = *l) && (r_char = *r))
113 const bool l_digit = alphanum_isdigit(l_char), r_digit = alphanum_isdigit(r_char);
115 if (l_digit && r_digit)
127 const int diff = l_char - r_char;
138 #ifdef ALPHANUM_LOCALE
141 unsigned long l_int = strtoul(l, &end, 0);
145 unsigned long r_int = strtoul(r, &end, 0);
149 unsigned long l_int = 0;
150 while (*l && alphanum_isdigit(*l))
153 l_int = l_int * 10 + *l -
'0';
158 unsigned long r_int = 0;
159 while (*r && alphanum_isdigit(*r))
162 r_int = r_int * 10 + *r -
'0';
168 const long diff = l_int - r_int;
194 template <
typename lT,
typename rT>
198 std::clog <<
"alphanum_comp<" <<
typeid(
left).name() <<
"," <<
typeid(
right).name()
199 <<
"> " <<
left <<
"," <<
right << std::endl;
201 std::ostringstream l;
203 std::ostringstream r;
205 return alphanum_impl(l.str().c_str(), r.str().c_str());
216 inline int alphanum_comp<std::string>(
const std::string& l,
const std::string& r)
219 std::clog <<
"alphanum_comp<std::string,std::string> " << l <<
"," << r << std::endl;
221 return alphanum_impl(l.c_str(), r.c_str());
242 std::clog <<
"alphanum_comp<char*,char*> " << l <<
"," << r << std::endl;
244 return alphanum_impl(l, r);
252 std::clog <<
"alphanum_comp<const char*,const char*> " << l <<
"," << r << std::endl;
254 return alphanum_impl(l, r);
262 std::clog <<
"alphanum_comp<char*,const char*> " << l <<
"," << r << std::endl;
264 return alphanum_impl(l, r);
272 std::clog <<
"alphanum_comp<const char*,char*> " << l <<
"," << r << std::endl;
274 return alphanum_impl(l, r);
281 std::clog <<
"alphanum_comp<std::string,char*> " << l <<
"," << r << std::endl;
283 return alphanum_impl(l.c_str(), r);
290 std::clog <<
"alphanum_comp<char*,std::string> " << l <<
"," << r << std::endl;
292 return alphanum_impl(l, r.c_str());
299 std::clog <<
"alphanum_comp<std::string,const char*> " << l <<
"," << r << std::endl;
301 return alphanum_impl(l.c_str(), r);
308 std::clog <<
"alphanum_comp<const char*,std::string> " << l <<
"," << r << std::endl;
310 return alphanum_impl(l, r.c_str());