#define NILsym NIL(Agsym_t*)
#define NILstr NIL(char*)
-#define MAX_OUTPUTLINE 80
+#define MAX_OUTPUTLINE 128
#define SUCCESS 0
#define FAILURE -1
#define LOCALNAMEPREFIX '%'
<qstring>["] BEGIN(INITIAL); endstr(); return (T_qatom);
<qstring>[\\]["] addstr ("\"");
<qstring>[\\][\n] line_num++; /* ignore escaped newlines */
-<qstring>([^"\\]*|[\\].) addstr(yytext);
+<qstring>([^"\\]*|[\\]) addstr(yytext);
[<] BEGIN(hstring); html_nest = 1; beginstr();
<hstring>[>] html_nest--; if (html_nest) addstr(yytext); else {BEGIN(INITIAL); endstr_html(); return (T_qatom);}
<hstring>[<] html_nest++; addstr(yytext);
}
#endif
+#define is_number_char(c) (isdigit(c) || ((c) == '.'))
+
/* _agstrcanon:
* Canonicalize ordinary strings.
* Assumes buf is large enough to hold output.
int cnt = 0;
int needs_quotes = FALSE;
int maybe_num;
+ int backslash_pending = FALSE;
static const char *tokenlist[] /* must agree with scan.l */
= { "node", "edge", "strict", "graph", "digraph", "subgraph",
NIL(char *)
p = buf;
*p++ = '\"';
uc = *(unsigned char *) s++;
- maybe_num = (isdigit(uc) || (uc == '.'));
+ maybe_num = is_number_char(uc);
while (uc) {
if (uc == '\"') {
*p++ = '\\';
} else {
if (!ISALNUM(uc))
needs_quotes = TRUE;
- else if (maybe_num && (!isdigit(uc) && (uc != '.')))
+ else if (maybe_num && !is_number_char(uc))
needs_quotes = TRUE;
}
*p++ = (char) uc;
uc = *(unsigned char *) s++;
cnt++;
- if (cnt >= MAX_OUTPUTLINE) {
- *p++ = '\\';
- *p++ = '\n';
- needs_quotes = TRUE;
+
+ if (uc && backslash_pending && !((is_number_char(p[-1]) || isalpha(p[-1])) && (is_number_char(uc) || isalpha(uc)))) {
+ *p++ = '\\';
+ *p++ = '\n';
+ needs_quotes = TRUE;
+ backslash_pending = FALSE;
cnt = 0;
+ } else if (uc && (cnt >= MAX_OUTPUTLINE)) {
+ if (!((is_number_char(p[-1]) || isalpha(p[-1])) && (is_number_char(uc) || isalpha(uc)))) {
+ *p++ = '\\';
+ *p++ = '\n';
+ needs_quotes = TRUE;
+ cnt = 0;
+ } else {
+ backslash_pending = TRUE;
+ }
}
}
*p++ = '\"';