static duk_hstring *do_lookup(duk_heap *heap, duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t *out_strhash) { duk_hstring *res; DUK_ASSERT(out_strhash); *out_strhash = duk_heap_hashstring(heap, str, (duk_size_t) blen); /* FIXME: change blen to duk_size_t */ res = find_matching_string(heap, heap->st, heap->st_size, str, blen, *out_strhash); return res; }
svn_error_t * svn_time_from_cstring(apr_time_t *when, const char *data, apr_pool_t *pool) { apr_time_exp_t exploded_time; apr_status_t apr_err; char wday[4], month[4]; char *c; /* Open-code parsing of the new timestamp format, as this is a hot path for reading the entries file. This format looks like: "2001-08-31T04:24:14.966996Z" */ exploded_time.tm_year = strtol(data, &c, 10); if (*c++ != '-') goto fail; exploded_time.tm_mon = strtol(c, &c, 10); if (*c++ != '-') goto fail; exploded_time.tm_mday = strtol(c, &c, 10); if (*c++ != 'T') goto fail; exploded_time.tm_hour = strtol(c, &c, 10); if (*c++ != ':') goto fail; exploded_time.tm_min = strtol(c, &c, 10); if (*c++ != ':') goto fail; exploded_time.tm_sec = strtol(c, &c, 10); if (*c++ != '.') goto fail; exploded_time.tm_usec = strtol(c, &c, 10); if (*c++ != 'Z') goto fail; exploded_time.tm_year -= 1900; exploded_time.tm_mon -= 1; exploded_time.tm_wday = 0; exploded_time.tm_yday = 0; exploded_time.tm_isdst = 0; exploded_time.tm_gmtoff = 0; apr_err = apr_time_exp_gmt_get(when, &exploded_time); if (apr_err == APR_SUCCESS) return SVN_NO_ERROR; return svn_error_create(SVN_ERR_BAD_DATE, NULL, NULL); fail: /* Try the compatibility option. This does not need to be fast, as this format is no longer generated and the client will convert an old-format entries file the first time it reads it. */ if (sscanf(data, OLD_TIMESTAMP_FORMAT, wday, &exploded_time.tm_mday, month, &exploded_time.tm_year, &exploded_time.tm_hour, &exploded_time.tm_min, &exploded_time.tm_sec, &exploded_time.tm_usec, &exploded_time.tm_yday, &exploded_time.tm_isdst, &exploded_time.tm_gmtoff) == 11) { exploded_time.tm_year -= 1900; exploded_time.tm_yday -= 1; /* Using hard coded limits for the arrays - they are going away soon in any case. */ exploded_time.tm_wday = find_matching_string(wday, 7, apr_day_snames); exploded_time.tm_mon = find_matching_string(month, 12, apr_month_snames); apr_err = apr_time_exp_gmt_get(when, &exploded_time); if (apr_err != APR_SUCCESS) return svn_error_create(SVN_ERR_BAD_DATE, NULL, NULL); return SVN_NO_ERROR; } /* Timestamp is something we do not recognize. */ else return svn_error_create(SVN_ERR_BAD_DATE, NULL, NULL); }