Commit bc17ef4e authored by Erwin Janssen's avatar Erwin Janssen

Modify `gvprintdouble()`

Use the name technique in `gvprintdouble` as in `xdot_fmt_num`. This
prevents strange characters in the SVG output when numbers get larger.

Updated the references files to reflect this change.
parent d4308b89
......@@ -526,14 +526,49 @@ int main (int argc, char *argv[])
}
#endif
/* gv_trim_zeros
* Trailing zeros are removed and decimal point, if possible.
* Add trailing space if addSpace is non-zero.
*/
static void gv_trim_zeros(char* buf, int addSpace)
{
char* dotp;
char* p;
if ((dotp = strchr(buf, '.'))) {
p = dotp + 1;
while (*p) p++; // find end of string
p--;
while (*p == '0') *p-- = '\0';
if (*p == '.') // If all decimals were zeros, remove ".".
*p = '\0';
else
p++;
}
else if (addSpace)
p = buf + strlen(buf);
if (addSpace) { /* p points to null byte */
*p++ = ' ';
*p = '\0';
}
}
void gvprintdouble(GVJ_t * job, double num)
{
char *buf;
size_t len;
// Prevents values like -0
if (num > -0.00000001 && num < 0.00000001)
{
num = 0;
}
buf = gvprintnum(&len, num);
gvwrite(job, buf, len);
}
char buf[50];
snprintf(buf, 50, "%.02f", num);
gv_trim_zeros(buf, 0);
gvwrite(job, buf, strlen(buf));
}
void gvprintpointf(GVJ_t * job, pointf p)
{
......
......@@ -13,8 +13,8 @@
<g id="node1" class="node">
<title>a</title>
<ellipse fill="none" stroke="black" cx="18" cy="-18" rx="18" ry="18"/>
<polyline fill="none" stroke="black" points="29.9052,-31.5 6.0948,-31.5 "/>
<polyline fill="none" stroke="black" points="29.9052,-4.5 6.0948,-4.5 "/>
<polyline fill="none" stroke="black" points="29.91,-31.5 6.09,-31.5 "/>
<polyline fill="none" stroke="black" points="29.91,-4.5 6.09,-4.5 "/>
</g>
</g>
</svg>
......@@ -12,8 +12,8 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<path fill="none" stroke="black" d="M54,-32.7273C54,-34.5331 41.8982,-36 27,-36 12.1018,-36 0,-34.5331 0,-32.7273 0,-32.7273 0,-3.2727 0,-3.2727 0,-1.4669 12.1018,0 27,0 41.8982,0 54,-1.4669 54,-3.2727 54,-3.2727 54,-32.7273 54,-32.7273"/>
<path fill="none" stroke="black" d="M54,-32.7273C54,-30.9214 41.8982,-29.4545 27,-29.4545 12.1018,-29.4545 0,-30.9214 0,-32.7273"/>
<path fill="none" stroke="black" d="M54,-32.73C54,-34.53 41.9,-36 27,-36 12.1,-36 0,-34.53 0,-32.73 0,-32.73 0,-3.27 0,-3.27 0,-1.47 12.1,0 27,0 41.9,0 54,-1.47 54,-3.27 54,-3.27 54,-32.73 54,-32.73"/>
<path fill="none" stroke="black" d="M54,-32.73C54,-30.92 41.9,-29.45 27,-29.45 12.1,-29.45 0,-30.92 0,-32.73"/>
</g>
</g>
</svg>
......@@ -12,8 +12,8 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="58,-14.5442 58,-29.4558 42.1838,-40 19.8162,-40 4,-29.4558 4,-14.5442 19.8162,-4 42.1838,-4 58,-14.5442"/>
<polygon fill="none" stroke="black" points="62,-12.4034 62,-31.5966 43.3949,-44 18.6051,-44 0,-31.5966 0,-12.4034 18.6051,0 43.3949,0 62,-12.4034"/>
<polygon fill="none" stroke="black" points="58,-14.54 58,-29.46 42.18,-40 19.82,-40 4,-29.46 4,-14.54 19.82,-4 42.18,-4 58,-14.54"/>
<polygon fill="none" stroke="black" points="62,-12.4 62,-31.6 43.39,-44 18.61,-44 0,-31.6 0,-12.4 18.61,0 43.39,0 62,-12.4"/>
</g>
</g>
</svg>
......@@ -8,11 +8,11 @@
viewBox="0.00 0.00 65.49 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">
<title>G</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 61.4869,-40 61.4869,4 -4,4"/>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 61.49,-40 61.49,4 -4,4"/>
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="31.426,-.0493 33.202,-.1479 34.9597,-.2953 36.6919,-.4913 38.3915,-.7353 40.0517,-1.0266 41.666,-1.3645 43.2281,-1.7479 44.732,-2.1759 46.1722,-2.6472 47.5435,-3.1606 48.8411,-3.7147 50.0607,-4.308 51.1984,-4.9388 52.2508,-5.6054 53.2152,-6.3059 54.089,-7.0385 54.8704,-7.8012 55.558,-8.5918 56.151,-9.4082 56.6489,-10.2481 57.052,-11.1093 57.3606,-11.9894 57.5759,-12.886 57.6992,-13.7965 57.7324,-14.7186 57.6776,-15.6497 57.5374,-16.5873 57.3145,-17.5287 57.0121,-18.4713 56.6334,-19.4127 56.182,-20.3503 55.6616,-21.2814 55.0759,-22.2035 54.4287,-23.114 53.7241,-24.0106 52.966,-24.8907 52.1582,-25.7519 51.3048,-26.5918 50.4093,-27.4082 49.4757,-28.1988 48.5074,-28.9615 47.5078,-29.6941 46.4803,-30.3946 45.4278,-31.0612 44.3533,-31.692 43.2595,-32.2853 42.1488,-32.8394 41.0235,-33.3528 39.8858,-33.8241 38.7373,-34.2521 37.58,-34.6355 36.4152,-34.9734 35.2443,-35.2647 34.0685,-35.5087 32.8889,-35.7047 31.7065,-35.8521 30.522,-35.9507 29.3364,-36 28.1505,-36 26.9649,-35.9507 25.7804,-35.8521 24.598,-35.7047 23.4184,-35.5087 22.2426,-35.2647 21.0717,-34.9734 19.9069,-34.6355 18.7495,-34.2521 17.6011,-33.8241 16.4633,-33.3528 15.3381,-32.8394 14.2274,-32.2853 13.1335,-31.692 12.0591,-31.0612 11.0066,-30.3946 9.9791,-29.6941 8.9795,-28.9615 8.0112,-28.1988 7.0775,-27.4082 6.1821,-26.5918 5.3286,-25.7519 4.5209,-24.8907 3.7628,-24.0106 3.0582,-23.114 2.411,-22.2035 1.8253,-21.2814 1.3048,-20.3503 .8534,-19.4127 .4748,-18.4713 .1724,-17.5287 -.0505,-16.5873 -.1907,-15.6497 -.2455,-14.7186 -.2123,-13.7965 -.089,-12.886 .1263,-11.9894 .4349,-11.1093 .8379,-10.2481 1.3359,-9.4082 1.9289,-8.5918 2.6165,-7.8012 3.3979,-7.0385 4.2717,-6.3059 5.2361,-5.6054 6.2885,-4.9388 7.4262,-4.308 8.6458,-3.7147 9.9434,-3.1606 11.3147,-2.6472 12.7549,-2.1759 14.2588,-1.7479 15.8209,-1.3645 17.4352,-1.0266 19.0954,-.7353 20.795,-.4913 22.5271,-.2953 24.2848,-.1479 26.0609,-.0493 27.848,0 29.6389,0 31.426,-.0493"/>
<polygon fill="none" stroke="black" points="31.43,-0.05 33.2,-0.15 34.96,-0.3 36.69,-0.49 38.39,-0.74 40.05,-1.03 41.67,-1.36 43.23,-1.75 44.73,-2.18 46.17,-2.65 47.54,-3.16 48.84,-3.71 50.06,-4.31 51.2,-4.94 52.25,-5.61 53.22,-6.31 54.09,-7.04 54.87,-7.8 55.56,-8.59 56.15,-9.41 56.65,-10.25 57.05,-11.11 57.36,-11.99 57.58,-12.89 57.7,-13.8 57.73,-14.72 57.68,-15.65 57.54,-16.59 57.31,-17.53 57.01,-18.47 56.63,-19.41 56.18,-20.35 55.66,-21.28 55.08,-22.2 54.43,-23.11 53.72,-24.01 52.97,-24.89 52.16,-25.75 51.3,-26.59 50.41,-27.41 49.48,-28.2 48.51,-28.96 47.51,-29.69 46.48,-30.39 45.43,-31.06 44.35,-31.69 43.26,-32.29 42.15,-32.84 41.02,-33.35 39.89,-33.82 38.74,-34.25 37.58,-34.64 36.42,-34.97 35.24,-35.26 34.07,-35.51 32.89,-35.7 31.71,-35.85 30.52,-35.95 29.34,-36 28.15,-36 26.96,-35.95 25.78,-35.85 24.6,-35.7 23.42,-35.51 22.24,-35.26 21.07,-34.97 19.91,-34.64 18.75,-34.25 17.6,-33.82 16.46,-33.35 15.34,-32.84 14.23,-32.29 13.13,-31.69 12.06,-31.06 11.01,-30.39 9.98,-29.69 8.98,-28.96 8.01,-28.2 7.08,-27.41 6.18,-26.59 5.33,-25.75 4.52,-24.89 3.76,-24.01 3.06,-23.11 2.41,-22.2 1.83,-21.28 1.3,-20.35 0.85,-19.41 0.47,-18.47 0.17,-17.53 -0.05,-16.59 -0.19,-15.65 -0.25,-14.72 -0.21,-13.8 -0.09,-12.89 0.13,-11.99 0.43,-11.11 0.84,-10.25 1.34,-9.41 1.93,-8.59 2.62,-7.8 3.4,-7.04 4.27,-6.31 5.24,-5.61 6.29,-4.94 7.43,-4.31 8.65,-3.71 9.94,-3.16 11.31,-2.65 12.75,-2.18 14.26,-1.75 15.82,-1.36 17.44,-1.03 19.1,-0.74 20.79,-0.49 22.53,-0.3 24.28,-0.15 26.06,-0.05 27.85,0 29.64,0 31.43,-0.05"/>
</g>
</g>
</svg>
......@@ -12,7 +12,7 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="54,-23.5623 27,-36 0,-23.5623 .0252,-3.4377 53.9748,-3.4377 54,-23.5623"/>
<polygon fill="none" stroke="black" points="54,-23.56 27,-36 0,-23.56 0.03,-3.44 53.97,-3.44 54,-23.56"/>
</g>
</g>
</svg>
......@@ -12,7 +12,7 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="0,-12.4377 27,0 54,-12.4377 53.9748,-32.5623 .0252,-32.5623 0,-12.4377"/>
<polygon fill="none" stroke="black" points="0,-12.44 27,0 54,-12.44 53.97,-32.56 0.03,-32.56 0,-12.44"/>
</g>
</g>
</svg>
......@@ -12,7 +12,7 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="11.2315,0 42.7685,0 54,-36 0,-36 11.2315,0"/>
<polygon fill="none" stroke="black" points="11.23,0 42.77,0 54,-36 0,-36 11.23,0"/>
</g>
</g>
</svg>
......@@ -12,7 +12,7 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="54,-10.5442 54,-25.4558 38.1838,-36 15.8162,-36 0,-25.4558 0,-10.5442 15.8162,0 38.1838,0 54,-10.5442"/>
<polygon fill="none" stroke="black" points="54,-10.54 54,-25.46 38.18,-36 15.82,-36 0,-25.46 0,-10.54 15.82,0 38.18,0 54,-10.54"/>
</g>
</g>
</svg>
......@@ -8,11 +8,11 @@
viewBox="0.00 0.00 63.98 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 40)">
<title>G</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 59.9847,-40 59.9847,4 -4,4"/>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-40 59.98,-40 59.98,4 -4,4"/>
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="55.977,-36 11.4597,-36 .0077,0 44.525,0 55.977,-36"/>
<polygon fill="none" stroke="black" points="55.98,-36 11.46,-36 0.01,0 44.53,0 55.98,-36"/>
</g>
</g>
</svg>
......@@ -12,7 +12,7 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="54,-23.5623 27,-36 0,-23.5623 10.3131,-3.4377 43.6869,-3.4377 54,-23.5623"/>
<polygon fill="none" stroke="black" points="54,-23.56 27,-36 0,-23.56 10.31,-3.44 43.69,-3.44 54,-23.56"/>
</g>
</g>
</svg>
......@@ -12,7 +12,7 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="54,-13.9946 48.6523,-29.2228 27,-36 5.3477,-29.2228 0,-13.9946 14.9839,-1.7826 39.0161,-1.7826 54,-13.9946"/>
<polygon fill="none" stroke="black" points="54,-13.99 48.65,-29.22 27,-36 5.35,-29.22 0,-13.99 14.98,-1.78 39.02,-1.78 54,-13.99"/>
</g>
</g>
</svg>
......@@ -6,13 +6,13 @@
<!-- Title: G Pages: 1 -->
<svg width="62pt" height="59pt"
viewBox="0.00 0.00 62.00 59.36" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 55.3571)">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 55.36)">
<title>G</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-55.3571 58,-55.3571 58,4 -4,4"/>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-55.36 58,-55.36 58,4 -4,4"/>
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="54,-31.7828 33.3738,-31.7828 27,-51.5368 20.6262,-31.7828 0,-31.7828 16.6869,-19.5742 10.3131,.1798 27,-12.0289 43.6869,.1798 37.3131,-19.5742 54,-31.7828"/>
<polygon fill="none" stroke="black" points="54,-31.78 33.37,-31.78 27,-51.54 20.63,-31.78 0,-31.78 16.69,-19.57 10.31,0.18 27,-12.03 43.69,0.18 37.31,-19.57 54,-31.78"/>
</g>
</g>
</svg>
......@@ -12,7 +12,7 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="42.7685,-36 11.2315,-36 0,0 54,0 42.7685,-36"/>
<polygon fill="none" stroke="black" points="42.77,-36 11.23,-36 0,0 54,0 42.77,-36"/>
</g>
</g>
</svg>
......@@ -12,9 +12,9 @@
<!-- a -->
<g id="node1" class="node">
<title>a</title>
<polygon fill="none" stroke="black" points="62,-18.5442 62,-33.4558 46.1838,-44 23.8162,-44 8,-33.4558 8,-18.5442 23.8162,-8 46.1838,-8 62,-18.5442"/>
<polygon fill="none" stroke="black" points="66,-16.4034 66,-35.5966 47.3949,-48 22.6051,-48 4,-35.5966 4,-16.4034 22.6051,-4 47.3949,-4 66,-16.4034"/>
<polygon fill="none" stroke="black" points="70,-14.2627 70,-37.7373 48.606,-52 21.394,-52 0,-37.7373 0,-14.2627 21.394,0 48.606,0 70,-14.2627"/>
<polygon fill="none" stroke="black" points="62,-18.54 62,-33.46 46.18,-44 23.82,-44 8,-33.46 8,-18.54 23.82,-8 46.18,-8 62,-18.54"/>
<polygon fill="none" stroke="black" points="66,-16.4 66,-35.6 47.39,-48 22.61,-48 4,-35.6 4,-16.4 22.61,-4 47.39,-4 66,-16.4"/>
<polygon fill="none" stroke="black" points="70,-14.26 70,-37.74 48.61,-52 21.39,-52 0,-37.74 0,-14.26 21.39,0 48.61,0 70,-14.26"/>
</g>
</g>
</svg>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment