-void CYStringify(std::ostringstream &str, const char *data, size_t size, bool c) {
- bool single;
- if (c)
- single = false;
+enum CYStringType {
+ CYStringTypeSingle,
+ CYStringTypeDouble,
+ CYStringTypeTemplate,
+};
+
+void CYStringify(std::ostringstream &str, const char *data, size_t size, CYStringifyMode mode) {
+ if (size == 0) {
+ str << "\"\"";
+ return;
+ }
+
+ unsigned quot(0), apos(0), tick(0), line(0);
+ for (const char *value(data), *end(data + size); value != end; ++value)
+ switch (*value) {
+ case '"': ++quot; break;
+ case '\'': ++apos; break;
+ case '`': ++tick; break;
+ case '$': ++tick; break;
+ case '\n': ++line; break;
+ }
+
+ bool split;
+ if (mode != CYStringifyModeCycript)
+ split = false;