]> granicus.if.org Git - graphviz/commitdiff
updated patch from yuri@rawbw.com
authorellson <devnull@localhost>
Tue, 5 Aug 2008 19:56:43 +0000 (19:56 +0000)
committerellson <devnull@localhost>
Tue, 5 Aug 2008 19:56:43 +0000 (19:56 +0000)
lib/graph/graphio.c

index 79bc538d360b7af7a21490f563a09cccf042d807..28a525dfa75bbf8be4942ea4280ca2c4768d3dbc 100644 (file)
@@ -92,6 +92,12 @@ int agerrors(void)
     return AG.syntax_errors;
 }
 
+static int
+_is_number_char(char c)
+{
+    return (isdigit(c) || c == '.' || c == '-');
+}
+
 /* _agstrcanon:
  * Canonicalize an ordinary string if necessary.
  */
@@ -110,7 +116,7 @@ _agstrcanon (char* arg, char* buf)
        return "\"\"";
     *p++ = '\"';
     uc = *(unsigned char *) s++;
-    maybe_num = (isdigit(uc) || (uc == '.'));
+    maybe_num = _is_number_char(uc);
     while (uc) {
        if (uc == '\"') {
            *p++ = '\\';
@@ -118,20 +124,19 @@ _agstrcanon (char* arg, char* buf)
        } else {
            if (!ISALNUM(uc))
                has_special = TRUE;
-           else if (maybe_num && (!isdigit(uc) && (uc != '.')))
+           else if (maybe_num && !_is_number_char(uc))
                has_special = TRUE;
        }
        *p++ = (char) uc;
        uc = *(unsigned char *) s++;
        cnt++;
-        if (backslash_pending && !((isdigit(p[-1]) || (p[-1] == '.') || isalpha(p[-1])) && (isdigit(uc) || (uc == '.') || isalpha(uc)))) {
+        if (uc && backslash_pending && !((_is_number_char(p[-1]) || isalpha(p[-1])) && (_is_number_char(uc) || isalpha(uc)))) {
             *p++ = '\\';
             *p++ = '\n';
             has_special = TRUE;
             backslash_pending = FALSE;
-        }
-       if (cnt % SMALLBUF == 0) {
-            if (!((isdigit(p[-1]) || (p[-1] == '.') || isalpha(p[-1])) && (isdigit(uc) || (uc == '.') || isalpha(uc)))) {
+        } else if (uc && cnt % SMALLBUF == 0) {
+            if (!((_is_number_char(p[-1]) || isalpha(p[-1])) && (_is_number_char(uc) || isalpha(uc)))) {
                *p++ = '\\';
                *p++ = '\n';
                has_special = TRUE;