hash_string_buffer(hash, str, len);
if (result & HASH_SOURCE_CODE_FOUND_DATE) {
+ cc_log("Found __DATE__ in %s", path);
+
// Make sure that the hash sum changes if the (potential) expansion of
// __DATE__ changes.
time_t t = time(NULL);
struct tm now;
- localtime_r(&t, &now);
- cc_log("Found __DATE__ in %s", path);
hash_delimiter(hash, "date");
+ if (!localtime_r(&t, &now)) {
+ return HASH_SOURCE_CODE_ERROR;
+ }
hash_int(hash, now.tm_year);
hash_int(hash, now.tm_mon);
hash_int(hash, now.tm_mday);
localtime_r(const time_t* timep, struct tm* result)
{
struct tm* tm = localtime(timep);
- *result = *tm;
- return result;
+ if (tm) {
+ *result = *tm;
+ return result;
+ } else {
+ memset(result, 0, sizeof(*result));
+ return NULL;
+ }
}
#endif