}
/* }}} */
/* JavaScript *ify {{{ */
-void CYStringify(std::ostringstream &str, const char *data, size_t size) {
- unsigned quot(0), apos(0);
- for (const char *value(data), *end(data + size); value != end; ++value)
- if (*value == '"')
- ++quot;
- else if (*value == '\'')
- ++apos;
-
- bool single(quot > apos);
+void CYStringify(std::ostringstream &str, const char *data, size_t size, bool c) {
+ bool single;
+ if (c)
+ single = false;
+ else {
+ unsigned quot(0), apos(0);
+ for (const char *value(data), *end(data + size); value != end; ++value)
+ if (*value == '"')
+ ++quot;
+ else if (*value == '\'')
+ ++apos;
+
+ single = quot > apos;
+ }
str << (single ? '\'' : '"');
}
void CYNumerify(std::ostringstream &str, double value) {
+ if (std::isinf(value)) {
+ if (value < 0)
+ str << '-';
+ str << "Infinity";
+ return;
+ }
+
char string[32];
// XXX: I want this to print 1e3 rather than 1000
sprintf(string, "%.17g", value);
return haystack.size >= needle.size && strncmp(haystack.data, needle.data, needle.size) == 0;
}
-CYUTF8String CYPoolCode(CYPool &pool, std::istream &stream) {
+CYUTF8String CYPoolCode(CYPool &pool, std::streambuf &stream) {
CYLocalPool local;
CYDriver driver(local, stream);
_assert(!driver.Parse());