51 double w32strtod(
const char *,
char **);
68 double w32strtod(
const char *val,
char **ptr)
71 string *sval =
new string(val);
72 string *snan =
new string(
"NaN");
76 if (stricmp(sval->c_str(), snan->c_str()) != 0)
77 return (strtod(val, ptr));
81 *ptr = (
char *) val + strlen(val);
82 return (std::numeric_limits < double >::quiet_NaN());
104 oss +=
"Error parsing the text on line ";
108 oss +=
"Parse error.";
112 oss += (string)
" at or near: " + context + (
string)
"\n" + msg
115 oss += (string)
"\n" + msg + (
string)
"\n";
121 parse_error(
const char *msg,
const int line_num,
const char *context)
131 oss +=
"Error parsing the text on line ";
135 oss +=
"Parse error.";
139 oss += (string)
" at or near: " + context + (
string)
"\n" + msg
142 oss += (string)
"\n" + msg + (
string)
"\n";
150 parse_error(
const string & msg,
const int line_num,
const char *context)
155 void save_str(
char *dst,
const char *src,
const int line_num)
157 if (strlen(src) >=
ID_MAX)
159 +
string(
"' is too long (it should be no longer than ")
162 strncpy(dst, src,
ID_MAX);
166 void save_str(
string & dst,
const char *src,
const int)
175 DBG(cerr <<
"is_keyword: " << keyword <<
" = " <<
id << endl);
176 return id == keyword;
182 long v = strtol(val, &ptr, 0);
184 if ((v == 0 && val == ptr) || *ptr !=
'\0') {
188 DBG(cerr <<
"v: " << v << endl);
208 long v = strtol(val, &ptr, 0);
210 if ((v == 0 && val == ptr) || *ptr !=
'\0') {
224 unsigned long v = strtol(val, &ptr, 0);
226 if ((v == 0 && val == ptr) || *ptr !=
'\0') {
241 long v = strtol(val, &ptr, 0);
244 if ((v == 0 && val == ptr) || *ptr !=
'\0') {
251 if (errno == ERANGE) {
270 while (c && isspace(*c)) {
273 if (c && (*c ==
'-')) {
279 unsigned long v = strtoul(val, &ptr, 0);
281 if ((v == 0 && val == ptr) || *ptr !=
'\0') {
288 if (errno == ERANGE) {
311 double v = w32strtod(val, &ptr);
313 double v = strtod(val, &ptr);
316 DBG(cerr <<
"v: " << v <<
", ptr: " << ptr
317 <<
", errno: " << errno <<
", val==ptr: " << (val == ptr) << endl);
319 if (errno == ERANGE || (v == 0.0 && val == ptr) || *ptr !=
'\0')
322 if ((v == 0.0 && (val == ptr || errno == HUGE_VAL || errno == ERANGE))
328 DBG(cerr <<
"fabs(" << val <<
") = " << fabs(v) << endl);
329 double abs_val = fabs(v);
339 DBG(cerr <<
"val: " << val << endl);
344 double v = w32strtod(val, &ptr);
346 double v = strtod(val, &ptr);
349 DBG(cerr <<
"v: " << v <<
", ptr: " << ptr
350 <<
", errno: " << errno <<
", val==ptr: " << (val == ptr) << endl);
353 if (errno == ERANGE || (v == 0.0 && val == ptr) || *ptr !=
'\0')
356 if ((v == 0.0 && (val == ptr || errno == HUGE_VAL || errno == ERANGE))
361 DBG(cerr <<
"fabs(" << val <<
") = " << fabs(v) << endl);
362 double abs_val = fabs(v);
int check_float64(const char *val)
int check_int32(const char *val)
int check_int16(const char *val)
Is the value a valid integer?
string prune_spaces(const string &name)
#define unknown_error
Unknown error.
void set_status(int val=0)
int check_byte(const char *val)
Is the value a valid byte?
void append_long_to_string(long val, int base, string &str_val)
void set_error(Error *obj)
string long_to_string(long val, int base)
int check_url(const char *)
Is the value a valid URL?
void parse_error(parser_arg *arg, const char *msg, const int line_num, const char *context)
Pass parameters by reference to a parser.
bool is_keyword(string id, const string &keyword)
int check_uint32(const char *val)
A class for error processing.
int check_uint16(const char *val)
void save_str(char *dst, const char *src, const int line_num)
Save a string to a temporary variable during the parse.
int check_float32(const char *val)
Is the value a valid float?