Changeset 325 for cpp/frams/param


Ignore:
Timestamp:
02/05/15 00:26:20 (9 years ago)
Author:
Maciej Komosinski
Message:

More strict parsing of int and float numbers from string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.cpp

    r320 r325  
    3737static const char *strchrlimit(const char *t, int ch, const char *limit)
    3838{
    39         int n = (int)(limit - t);
    40         for (; (n > 0) && *t; t++, n--)
    41                 if (*t == ch) return t;
    42         return 0;
     39        if (limit<t) return NULL;
     40        return (const char*)memchr((const void*)t,ch,limit-t);
    4341}
    4442
     
    1000998                //                     ^ ^-t (after)           ^ ^_next_field
    1001999                //                     \_t (before)            \_field_end
    1002                 while (strchr(" \n\r\t", *t)) if (t < end) t++; else return fields_loaded;
     1000                while (isspace(*t)) if (t < end) t++; else return fields_loaded;
    10031001
    10041002                field_end = strchrlimit(t, ',', end); if (!field_end) field_end = end;
    10051003                next_field=field_end;
    1006                 while ((field_end>t) && strchr(" \t",field_end[-1])) field_end--;
     1004                while ((field_end>t) && isblank(field_end[-1])) field_end--;
    10071005                quote = strchrlimit(t, '\"', field_end);
    10081006                if (quote)
Note: See TracChangeset for help on using the changeset viewer.