EV-Etcd
view release on metacpan or search on metacpan
SSize_t n;
while ((n = PerlIO_read(fp, buf, sizeof buf)) > 0)
sv_catpvn(sv, buf, n);
int failed = n < 0 || PerlIO_error(fp);
PerlIO_close(fp);
if (failed)
croak("EV::Etcd: cannot read %s '%s'", opt, path);
return sv;
}
/* 0 for off (non-positive or NaN), else whole milliseconds capped at a day */
static int seconds_to_ms(NV seconds) {
if (!(seconds > 0))
return 0;
if (seconds >= 86400)
return 86400000;
return seconds < 0.001 ? 1 : (int)(seconds * 1000);
}
/* A mortal copy: magic on a later option could change or free the original */
static char *option_pv(pTHX_ SV *val, STRLEN *len) {
s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
s++; if (s < send && (*s == 'I' || *s == 'i')) {
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
s++;
}
sawinf = 1;
} else if (*s == 'N' || *s == 'n') {
/* XXX TODO: There are signaling NaNs and quiet NaNs. */
s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++;
sawnan = 1;
} else
return 0;
if (sawinf) {
numtype &= IS_NUMBER_NEG; /* Keep track of sign */
numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
( run in 3.727 seconds using v1.01-cache-2.11-cpan-60884a8df76 )