static U_CHAR *skip_to_end_of_comment ();
static U_CHAR *skip_quoted_string ();
static U_CHAR *skip_paren_group ();
+static void quote_string ();
static char *check_precompiled ();
/* static struct macrodef create_definition (); [moved below] */
if (string)
{
- buf = (char *) alloca (3 + strlen (string));
- sprintf (buf, "\"%s\"", string);
+ buf = (char *) alloca (3 + 2 * strlen (string));
+ quote_string (buf, string);
}
else
buf = "\"\"";
return bp;
}
+/* Place into DST a quoted string representing the string SRC. */
+static void
+quote_string (dst, src)
+ char *dst, *src;
+{
+ char c;
+
+ for (*dst++ = '\"'; ; *dst++ = c)
+ switch ((c = *src++))
+ {
+ case '\n':
+ c = 'n';
+ /* fall through */
+ case '\"':
+ case '\\':
+ *dst++ = '\\';
+ break;
+
+ case '\0':
+ *dst++ = '\"';
+ *dst = '\0';
+ return;
+ }
+}
+
/* Skip across a group of balanced parens, starting from IP->bufp.
IP->bufp is updated. Use this with IP->bufp pointing at an open-paren.