@knowvah/dot-engine 2.12.1 → 2.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/dist/api/builder.d.ts +7 -1
  2. package/dist/api/builder.d.ts.map +1 -1
  3. package/dist/api.js +14 -7
  4. package/dist/api.js.map +2 -2
  5. package/dist/common/compass-port.d.ts.map +1 -1
  6. package/dist/common/edge-label-init.d.ts +26 -1
  7. package/dist/common/edge-label-init.d.ts.map +1 -1
  8. package/dist/common/graph-init.d.ts.map +1 -1
  9. package/dist/common/htmltable-label.d.ts.map +1 -1
  10. package/dist/common/htmltable-lex.d.ts +3 -1
  11. package/dist/common/htmltable-lex.d.ts.map +1 -1
  12. package/dist/common/htmltable-parse-image.d.ts +23 -0
  13. package/dist/common/htmltable-parse-image.d.ts.map +1 -0
  14. package/dist/common/htmltable-parse-state.d.ts +4 -0
  15. package/dist/common/htmltable-parse-state.d.ts.map +1 -1
  16. package/dist/common/htmltable-parse.d.ts +33 -2
  17. package/dist/common/htmltable-parse.d.ts.map +1 -1
  18. package/dist/common/nodeinit.d.ts +16 -2
  19. package/dist/common/nodeinit.d.ts.map +1 -1
  20. package/dist/common/poly-inside.d.ts.map +1 -1
  21. package/dist/common/splines-geom.d.ts +2 -1
  22. package/dist/common/splines-geom.d.ts.map +1 -1
  23. package/dist/common/splines-path-begin.d.ts.map +1 -1
  24. package/dist/common/splines-path-end.d.ts.map +1 -1
  25. package/dist/common/splines-routespl.d.ts +3 -0
  26. package/dist/common/splines-routespl.d.ts.map +1 -1
  27. package/dist/gvc/context.d.ts +8 -0
  28. package/dist/gvc/context.d.ts.map +1 -1
  29. package/dist/gvc/emit-gates.d.ts +5 -10
  30. package/dist/gvc/emit-gates.d.ts.map +1 -1
  31. package/dist/gvc/emit-xdot.d.ts +7 -6
  32. package/dist/gvc/emit-xdot.d.ts.map +1 -1
  33. package/dist/gvc/job.d.ts +5 -2
  34. package/dist/gvc/job.d.ts.map +1 -1
  35. package/dist/gvc/viewport.d.ts +10 -5
  36. package/dist/gvc/viewport.d.ts.map +1 -1
  37. package/dist/index.js +21565 -21326
  38. package/dist/index.js.map +4 -4
  39. package/dist/layout/dot/classify.d.ts.map +1 -1
  40. package/dist/layout/dot/edge-route-chain-views.d.ts +35 -0
  41. package/dist/layout/dot/edge-route-chain-views.d.ts.map +1 -0
  42. package/dist/layout/dot/edge-route-chain.d.ts +20 -16
  43. package/dist/layout/dot/edge-route-chain.d.ts.map +1 -1
  44. package/dist/layout/dot/edge-route-faithful.d.ts.map +1 -1
  45. package/dist/layout/dot/edge-route.d.ts +7 -3
  46. package/dist/layout/dot/edge-route.d.ts.map +1 -1
  47. package/dist/layout/dot/fastgr.d.ts +5 -3
  48. package/dist/layout/dot/fastgr.d.ts.map +1 -1
  49. package/dist/layout/dot/flat-adj-record.d.ts +22 -0
  50. package/dist/layout/dot/flat-adj-record.d.ts.map +1 -0
  51. package/dist/layout/dot/flat.d.ts +22 -7
  52. package/dist/layout/dot/flat.d.ts.map +1 -1
  53. package/dist/layout/dot/init.d.ts +49 -9
  54. package/dist/layout/dot/init.d.ts.map +1 -1
  55. package/dist/layout/dot/mincross-build.d.ts +6 -0
  56. package/dist/layout/dot/mincross-build.d.ts.map +1 -1
  57. package/dist/layout/dot/mincross-flat.d.ts +10 -1
  58. package/dist/layout/dot/mincross-flat.d.ts.map +1 -1
  59. package/dist/layout/dot/mincross.d.ts +6 -1
  60. package/dist/layout/dot/mincross.d.ts.map +1 -1
  61. package/dist/layout/dot/ns-subtree.d.ts +9 -6
  62. package/dist/layout/dot/ns-subtree.d.ts.map +1 -1
  63. package/dist/layout/dot/pack-components.d.ts +4 -3
  64. package/dist/layout/dot/pack-components.d.ts.map +1 -1
  65. package/dist/layout/dot/position-aux.d.ts +69 -21
  66. package/dist/layout/dot/position-aux.d.ts.map +1 -1
  67. package/dist/layout/dot/position-bbox.d.ts.map +1 -1
  68. package/dist/layout/dot/position-ycoords.d.ts.map +1 -1
  69. package/dist/layout/dot/position.d.ts.map +1 -1
  70. package/dist/layout/dot/rank-dot2.d.ts +7 -25
  71. package/dist/layout/dot/rank-dot2.d.ts.map +1 -1
  72. package/dist/layout/dot/self-loop.d.ts +11 -4
  73. package/dist/layout/dot/self-loop.d.ts.map +1 -1
  74. package/dist/layout/dot/splines-clone.d.ts +2 -1
  75. package/dist/layout/dot/splines-clone.d.ts.map +1 -1
  76. package/dist/layout/dot/splines-flat-labeled.d.ts.map +1 -1
  77. package/dist/layout/dot/splines-flat-multi.d.ts +11 -3
  78. package/dist/layout/dot/splines-flat-multi.d.ts.map +1 -1
  79. package/dist/layout/dot/splines-flat.d.ts +18 -0
  80. package/dist/layout/dot/splines-flat.d.ts.map +1 -1
  81. package/dist/layout/dot/splines-groups.d.ts.map +1 -1
  82. package/dist/layout/dot/splines-route.d.ts +6 -3
  83. package/dist/layout/dot/splines-route.d.ts.map +1 -1
  84. package/dist/layout/dot/straight-edges.d.ts.map +1 -1
  85. package/dist/layout/fdp/ports.d.ts.map +1 -1
  86. package/dist/layout/fdp/tlayout.d.ts +3 -0
  87. package/dist/layout/fdp/tlayout.d.ts.map +1 -1
  88. package/dist/layout/neato/__fixtures__/hier-imds.d.ts +5 -4
  89. package/dist/layout/neato/__fixtures__/hier-imds.d.ts.map +1 -1
  90. package/dist/layout/neato/__fixtures__/hier-majorization.d.ts +6 -5
  91. package/dist/layout/neato/__fixtures__/hier-majorization.d.ts.map +1 -1
  92. package/dist/layout/neato/conjgrad-mkernel.d.ts.map +1 -1
  93. package/dist/layout/neato/conjgrad.d.ts +7 -6
  94. package/dist/layout/neato/conjgrad.d.ts.map +1 -1
  95. package/dist/layout/neato/matrix-ops-dense.d.ts +1 -6
  96. package/dist/layout/neato/matrix-ops-dense.d.ts.map +1 -1
  97. package/dist/layout/neato/matrix-ops.d.ts +0 -6
  98. package/dist/layout/neato/matrix-ops.d.ts.map +1 -1
  99. package/dist/layout/neato/quad-prog-vpsc.d.ts.map +1 -1
  100. package/dist/layout/neato/sgd.d.ts.map +1 -1
  101. package/dist/model/cgraph-ops.d.ts +10 -2
  102. package/dist/model/cgraph-ops.d.ts.map +1 -1
  103. package/dist/model/edge.d.ts +7 -2
  104. package/dist/model/edge.d.ts.map +1 -1
  105. package/dist/model/edgeInfo.d.ts +17 -2
  106. package/dist/model/edgeInfo.d.ts.map +1 -1
  107. package/dist/model/graph.d.ts +4 -3
  108. package/dist/model/graph.d.ts.map +1 -1
  109. package/dist/model/lazy-attrs.d.ts.map +1 -1
  110. package/dist/model/rankEntry.d.ts +3 -1
  111. package/dist/model/rankEntry.d.ts.map +1 -1
  112. package/dist/ortho/index.d.ts +0 -1
  113. package/dist/ortho/index.d.ts.map +1 -1
  114. package/dist/ortho/partition.d.ts +2 -4
  115. package/dist/ortho/partition.d.ts.map +1 -1
  116. package/dist/parser/builder.d.ts.map +1 -1
  117. package/dist/pathplan/route.d.ts +93 -0
  118. package/dist/pathplan/route.d.ts.map +1 -1
  119. package/dist/render/dot/agwrite.d.ts +26 -10
  120. package/dist/render/dot/agwrite.d.ts.map +1 -1
  121. package/dist/render/dot/attrs.d.ts +15 -4
  122. package/dist/render/dot/attrs.d.ts.map +1 -1
  123. package/dist/render/dot/types.d.ts +7 -2
  124. package/dist/render/dot/types.d.ts.map +1 -1
  125. package/dist/render/dot/write-back.d.ts +14 -0
  126. package/dist/render/dot/write-back.d.ts.map +1 -1
  127. package/dist/render/dot/xdot-ops.d.ts +20 -29
  128. package/dist/render/dot/xdot-ops.d.ts.map +1 -1
  129. package/dist/render/dot.d.ts +4 -2
  130. package/dist/render/dot.d.ts.map +1 -1
  131. package/dist/render/json-cluster-edge.d.ts +17 -4
  132. package/dist/render/json-cluster-edge.d.ts.map +1 -1
  133. package/dist/render/json-nonfinite.d.ts +17 -0
  134. package/dist/render/json-nonfinite.d.ts.map +1 -0
  135. package/dist/render/json.d.ts +4 -0
  136. package/dist/render/json.d.ts.map +1 -1
  137. package/dist/render/map.d.ts +3 -0
  138. package/dist/render/map.d.ts.map +1 -1
  139. package/dist/render/svg-graph.d.ts.map +1 -1
  140. package/dist/render/svg-id.d.ts +10 -1
  141. package/dist/render/svg-id.d.ts.map +1 -1
  142. package/dist/render/svg.d.ts +3 -1
  143. package/dist/render/svg.d.ts.map +1 -1
  144. package/dist/render.js +21517 -21278
  145. package/dist/render.js.map +4 -4
  146. package/dist/util/bsd-qsort.d.ts.map +1 -1
  147. package/dist/util/overflow.d.ts +37 -0
  148. package/dist/util/overflow.d.ts.map +1 -0
  149. package/dist/xdot/parse.d.ts.map +1 -1
  150. package/dist/xdot/strtod.d.ts +23 -0
  151. package/dist/xdot/strtod.d.ts.map +1 -0
  152. package/package.json +3 -2
  153. package/src/api/builder.ts +8 -2
  154. package/src/common/compass-port.ts +36 -20
  155. package/src/common/edge-label-init.ts +43 -17
  156. package/src/common/graph-init.ts +11 -1
  157. package/src/common/htmltable-label.ts +9 -4
  158. package/src/common/htmltable-lex.ts +5 -2
  159. package/src/common/htmltable-parse-image.ts +69 -0
  160. package/src/common/htmltable-parse-state.ts +6 -0
  161. package/src/common/htmltable-parse.ts +34 -44
  162. package/src/common/nodeinit.ts +28 -8
  163. package/src/common/poly-inside.ts +11 -5
  164. package/src/common/splines-geom.ts +24 -6
  165. package/src/common/splines-path-begin.ts +4 -3
  166. package/src/common/splines-path-end.ts +4 -3
  167. package/src/common/splines-routespl.ts +32 -0
  168. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.1 +19 -19
  169. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.2 +19 -19
  170. package/src/gvc/__fixtures__/rerender/abom-shift-pack.dot.plain.nofree.3 +19 -19
  171. package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.2 +18 -18
  172. package/src/gvc/__fixtures__/rerender/abom-shift-parity.dot.plain.nofree.3 +12 -12
  173. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.1 +20 -20
  174. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.2 +31 -31
  175. package/src/gvc/__fixtures__/rerender/flat-rev-stale.dot.plain.nofree.3 +33 -33
  176. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.1 +10 -10
  177. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.2 +28 -28
  178. package/src/gvc/__fixtures__/rerender/multi-edge.dot.plain.nofree.3 +28 -28
  179. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.1 +21 -28
  180. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.2 +100 -102
  181. package/src/gvc/__fixtures__/rerender/multi-edge.dot.svg.nofree.3 +137 -139
  182. package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.1 +1 -1
  183. package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.2 +1 -1
  184. package/src/gvc/__fixtures__/rerender/nestedclust.dot.dot.nofree.3 +1 -1
  185. package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.1 +3 -3
  186. package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.2 +3 -3
  187. package/src/gvc/__fixtures__/rerender/nestedclust.dot.xdot.nofree.3 +3 -3
  188. package/src/gvc/__fixtures__/rerender/regen.sh +6 -0
  189. package/src/gvc/context.ts +8 -0
  190. package/src/gvc/device.ts +6 -6
  191. package/src/gvc/emit-gates.ts +6 -15
  192. package/src/gvc/emit-xdot.ts +10 -11
  193. package/src/gvc/job.ts +5 -2
  194. package/src/gvc/viewport.ts +13 -7
  195. package/src/layout/dot/__fixtures__/flat-adj-aux-syms.native-16.1.json +1210 -0
  196. package/src/layout/dot/classify.ts +5 -2
  197. package/src/layout/dot/edge-route-chain-views.ts +120 -0
  198. package/src/layout/dot/edge-route-chain.ts +103 -117
  199. package/src/layout/dot/edge-route-faithful.ts +20 -5
  200. package/src/layout/dot/edge-route.ts +44 -49
  201. package/src/layout/dot/fastgr.ts +9 -3
  202. package/src/layout/dot/flat-adj-record.ts +68 -0
  203. package/src/layout/dot/flat.ts +38 -17
  204. package/src/layout/dot/init.ts +59 -13
  205. package/src/layout/dot/mincross-build.ts +14 -1
  206. package/src/layout/dot/mincross-flat.ts +15 -5
  207. package/src/layout/dot/mincross.ts +6 -2
  208. package/src/layout/dot/ns-subtree.ts +11 -7
  209. package/src/layout/dot/pack-components.ts +6 -4
  210. package/src/layout/dot/position-aux.ts +122 -42
  211. package/src/layout/dot/position-bbox.ts +14 -1
  212. package/src/layout/dot/position-ycoords.ts +7 -1
  213. package/src/layout/dot/position.ts +4 -1
  214. package/src/layout/dot/rank-dot2.ts +13 -94
  215. package/src/layout/dot/self-loop.ts +29 -11
  216. package/src/layout/dot/splines-clone.ts +8 -2
  217. package/src/layout/dot/splines-flat-labeled.ts +3 -2
  218. package/src/layout/dot/splines-flat-multi.ts +12 -4
  219. package/src/layout/dot/splines-flat.ts +9 -19
  220. package/src/layout/dot/splines-groups.ts +5 -3
  221. package/src/layout/dot/splines-route.ts +10 -11
  222. package/src/layout/dot/straight-edges.ts +5 -3
  223. package/src/layout/fdp/ports.ts +6 -2
  224. package/src/layout/fdp/tlayout.ts +6 -5
  225. package/src/layout/neato/__fixtures__/conjgrad-d.json +1 -0
  226. package/src/layout/neato/__fixtures__/dim/hier-big-dim3.dot +141 -141
  227. package/src/layout/neato/__fixtures__/dim/hier-big-dim3.xdot +339 -339
  228. package/src/layout/neato/__fixtures__/dim/hier-big-dim4.dot +140 -140
  229. package/src/layout/neato/__fixtures__/dim/hier-big-dim4.xdot +323 -323
  230. package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.dot +141 -141
  231. package/src/layout/neato/__fixtures__/dim/hier-big-subset-dim3.xdot +339 -339
  232. package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.dot +251 -251
  233. package/src/layout/neato/__fixtures__/dim/hier-big110-dim3.xdot +535 -535
  234. package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.dot +14 -14
  235. package/src/layout/neato/__fixtures__/dim/hier-circuit-dim3.xdot +32 -32
  236. package/src/layout/neato/__fixtures__/dim/hier-dim4.dot +8 -8
  237. package/src/layout/neato/__fixtures__/dim/hier-dim4.xdot +14 -14
  238. package/src/layout/neato/__fixtures__/dim/hier-len-dim3.dot +17 -17
  239. package/src/layout/neato/__fixtures__/dim/hier-len-dim3.xdot +35 -35
  240. package/src/layout/neato/__fixtures__/dim/hier-noedge-big.dot +2 -2
  241. package/src/layout/neato/__fixtures__/dim/hier-noedge-big.xdot +2 -2
  242. package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.dot +11 -11
  243. package/src/layout/neato/__fixtures__/dim/hier-ring-dim3.xdot +21 -21
  244. package/src/layout/neato/__fixtures__/dim/hier-star-dim3.dot +14 -14
  245. package/src/layout/neato/__fixtures__/dim/hier-star-dim3.xdot +26 -26
  246. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.dot +13 -13
  247. package/src/layout/neato/__fixtures__/dim/hier-stresswt1-dim4.xdot +30 -30
  248. package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.dot +10 -10
  249. package/src/layout/neato/__fixtures__/dim/hier-subset-dim3.xdot +19 -19
  250. package/src/layout/neato/__fixtures__/dim/smart-units.json +1 -1
  251. package/src/layout/neato/__fixtures__/hier/cases/dirnone.plain +10 -10
  252. package/src/layout/neato/__fixtures__/hier/cases/tdist.plain +12 -12
  253. package/src/layout/neato/__fixtures__/hier/hier-probe.plain +1 -1
  254. package/src/layout/neato/__fixtures__/hier/hier-probe.xdot +19 -19
  255. package/src/layout/neato/__fixtures__/hier-imds.ts +14 -13
  256. package/src/layout/neato/__fixtures__/hier-majorization.ts +24 -23
  257. package/src/layout/neato/__fixtures__/ipsep/ipsep-grid.xdot +20 -20
  258. package/src/layout/neato/__fixtures__/ipsep/ipsep-k6.xdot +8 -8
  259. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand-len.xdot +34 -34
  260. package/src/layout/neato/__fixtures__/ipsep/ipsep-rand.xdot +32 -32
  261. package/src/layout/neato/__fixtures__/ipsep/ipsep-tree.xdot +18 -18
  262. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep-len.xdot +13 -13
  263. package/src/layout/neato/__fixtures__/ipsep/kd-ipsep.xdot +12 -12
  264. package/src/layout/neato/__fixtures__/models/hier-circuit.xdot +33 -33
  265. package/src/layout/neato/__fixtures__/models/hier-default.xdot +30 -30
  266. package/src/layout/neato/__fixtures__/models/hier-mds-nolen.xdot +30 -30
  267. package/src/layout/neato/__fixtures__/models/hier-pin-disc-circuit.xdot +35 -35
  268. package/src/layout/neato/__fixtures__/models/hier-shortpath.xdot +30 -30
  269. package/src/layout/neato/conjgrad-mkernel.ts +6 -2
  270. package/src/layout/neato/conjgrad.ts +38 -35
  271. package/src/layout/neato/matrix-ops-dense.ts +2 -20
  272. package/src/layout/neato/matrix-ops.ts +0 -20
  273. package/src/layout/neato/quad-prog-vpsc.ts +7 -5
  274. package/src/layout/neato/sgd.ts +2 -1
  275. package/src/layout/neato/smart-ini-x.ts +15 -15
  276. package/src/layout/neato/stress-subspace.ts +5 -5
  277. package/src/layout/sfdp/__fixtures__/dim/dim3-dimen3.dot +6 -6
  278. package/src/layout/sfdp/__fixtures__/dim/dim3.dot +6 -6
  279. package/src/layout/sfdp/__fixtures__/dim/dim4-dimen4.dot +6 -6
  280. package/src/layout/sfdp/__fixtures__/dim/overlap-prism-dim3.dot +6 -6
  281. package/src/layout/sfdp/__fixtures__/dim/regen.sh +2 -0
  282. package/src/model/cgraph-ops.ts +4 -3
  283. package/src/model/edge.ts +11 -4
  284. package/src/model/edgeInfo.ts +18 -2
  285. package/src/model/graph.ts +4 -3
  286. package/src/model/lazy-attrs.ts +3 -1
  287. package/src/model/rankEntry.ts +3 -1
  288. package/src/ortho/index.ts +0 -1
  289. package/src/ortho/partition.ts +10 -22
  290. package/src/parser/builder.ts +12 -3
  291. package/src/pathplan/route.ts +14 -4
  292. package/src/render/dot/agwrite.ts +45 -18
  293. package/src/render/dot/attrs.ts +18 -7
  294. package/src/render/dot/types.ts +7 -2
  295. package/src/render/dot/write-back.ts +27 -3
  296. package/src/render/dot/xdot-ops.ts +25 -56
  297. package/src/render/dot.ts +7 -5
  298. package/src/render/json-cluster-edge.ts +42 -5
  299. package/src/render/json-nonfinite.ts +51 -0
  300. package/src/render/json.ts +23 -26
  301. package/src/render/map.ts +3 -0
  302. package/src/render/svg-graph.ts +3 -15
  303. package/src/render/svg-id.ts +11 -2
  304. package/src/render/svg.ts +4 -1
  305. package/src/util/bsd-qsort.ts +2 -1
  306. package/src/util/overflow.ts +74 -0
  307. package/src/xdot/parse.ts +9 -19
  308. package/src/xdot/strtod.ts +167 -0
@@ -10,7 +10,6 @@
10
10
  import type {
11
11
  HtmlCell,
12
12
  HtmlCellContent,
13
- HtmlImage,
14
13
  HtmlLabel,
15
14
  HtmlRow,
16
15
  HtmlTable,
@@ -22,8 +21,9 @@ import type {
22
21
  import { HtmlParseError } from './htmltable-types.js';
23
22
  import { StderrLines } from './htmltable-attr-warn.js';
24
23
  import type { ParseState } from './htmltable-parse-state.js';
25
- import { consume, emitEof, emitWarnings, peek } from './htmltable-parse-state.js';
26
- import { htmlErrorAtToken, tokenizeDeferred } from './htmltable-lex.js';
24
+ import { consume, consumedTag, emitEof, emitWarnings, peek } from './htmltable-parse-state.js';
25
+ import { HtmlLexError, htmlErrorAtToken, tokenizeDeferred } from './htmltable-lex.js';
26
+ import { scanCellImage } from './htmltable-parse-image.js';
27
27
  import type { FontState } from './htmltable-parse-font.js';
28
28
  import {
29
29
  fontItemProps, inlineFontState, isInlineTag, mergeFontState, tableFont, wrapperFont,
@@ -38,7 +38,7 @@ import {
38
38
  } from './htmltable-parse-attrs.js';
39
39
 
40
40
  /** bison's default message for an unexpected token. @see lib/common/htmlparse.y */
41
- const MSG_SYNTAX_ERROR = 'syntax error';
41
+ export const MSG_SYNTAX_ERROR = 'syntax error';
42
42
  /** @see lib/common/htmlparse.y:288 (table rule) */
43
43
  const MSG_TEXT_BEFORE_TABLE = 'Syntax error: non-space string used before <TABLE>';
44
44
  /** @see lib/common/htmlparse.y:298 (table rule) */
@@ -50,17 +50,25 @@ const nonSpace = (text: string): boolean => /[^ ]/.test(text);
50
50
  /** Text in `ctx->xb` that no token carried, which the table rule's nonSpace also reads. */
51
51
  const heldNonSpace = (tbl: Token | undefined): boolean => tbl?.type === 'open' && nonSpace(tbl.heldText ?? '');
52
52
 
53
+ /**
54
+ * `e` as C prints it once `ctx->error` is set: htmlerror and the expat path
55
+ * print nothing more (a silent HtmlParseError); only lexerror still does.
56
+ * @see lib/common/htmllex.c:htmlerror
57
+ */
58
+ const guarded = (s: ParseState, e: HtmlParseError): HtmlParseError =>
59
+ s.error === true && !(e instanceof HtmlLexError && e.unguarded) ? new HtmlParseError(e.tag) : e;
60
+
53
61
  /**
54
62
  * The parse failure C reports through `htmlerror` when the lexer last returned
55
63
  * `tok`. At end of input the deferred lexical error is what C would hit next.
56
64
  * A token without a recorded chunk yields a plain, silent HtmlParseError.
57
65
  * @see lib/common/htmllex.c:htmlerror
58
66
  */
59
- const parseError = (s: ParseState, tok: Token | undefined, message: string): HtmlParseError => {
67
+ export const parseError = (s: ParseState, tok: Token | undefined, message: string): HtmlParseError => {
60
68
  // The lexer already ran for the token the error is reported at.
61
69
  if (tok !== undefined) emitWarnings(s, tok);
62
70
  else emitEof(s);
63
- return (tok === undefined ? s.pending : htmlErrorAtToken(message, tok)) ?? new HtmlParseError(message);
71
+ return guarded(s, (tok === undefined ? s.pending : htmlErrorAtToken(message, tok)) ?? new HtmlParseError(message));
64
72
  };
65
73
 
66
74
  // ---------------------------------------------------------------------------
@@ -73,7 +81,7 @@ const parseError = (s: ParseState, tok: Token | undefined, message: string): Htm
73
81
  * syntax error at that token.
74
82
  * @see lib/common/htmlparse.y:br, image
75
83
  */
76
- const consumeClose = (s: ParseState, tag: string): void => {
84
+ export const consumeClose = (s: ParseState, tag: string): void => {
77
85
  const nxt = peek(s);
78
86
  if (nxt === undefined) return;
79
87
  if (nxt.type === 'close' && nxt.tag === tag) {
@@ -172,7 +180,7 @@ const fontTableWrapper = (s: ParseState): OpenToken | undefined => {
172
180
  };
173
181
 
174
182
  /** Consume strings; true when any is non-space (the table rule's nonSpace check). */
175
- const skipStrings = (s: ParseState): boolean => {
183
+ export const skipStrings = (s: ParseState): boolean => {
176
184
  let found = false;
177
185
  for (let t = peek(s); t?.type === 'text'; t = peek(s)) {
178
186
  consume(s);
@@ -210,29 +218,18 @@ const parseFontTable = (s: ParseState, open: OpenToken, fontStack: FontState[]):
210
218
  const rejectTableAfterTag = (s: ParseState, start: number): void => {
211
219
  const nxt = peek(s);
212
220
  if (nxt?.type !== 'open' || nxt.tag !== 'TABLE') return;
213
- if (s.tokens.slice(start, s.pos).some((t) => t.type !== 'text')) {
214
- throw parseError(s, nxt, MSG_SYNTAX_ERROR);
215
- }
221
+ if (consumedTag(s, start)) throw parseError(s, nxt, MSG_SYNTAX_ERROR);
216
222
  };
217
223
 
218
224
  // ---------------------------------------------------------------------------
219
225
  // Cell content helpers — mirrors htmlparse.y cell rule
220
226
  // ---------------------------------------------------------------------------
221
227
 
222
- const parseImgContent = (s: ParseState, t: OpenToken): HtmlImage => {
223
- consume(s);
224
- const img: HtmlImage = {
225
- kind: 'image',
226
- src: t.attrs['src'] ?? '',
227
- scale: t.attrs['scale'],
228
- };
229
- consumeClose(s, 'IMG');
230
- return img;
231
- };
232
-
233
228
  /** What a cell holds so far: C's cell has exactly one child. */
234
- interface CellScan {
229
+ export interface CellScan {
235
230
  kind: 'none' | 'text' | 'table' | 'fonttable' | 'image';
231
+ /** Index of the cell's first token. */
232
+ start: number;
236
233
  /** Non-space text before the nested table (checked when the table opens). */
237
234
  textNonSpace: boolean;
238
235
  /** Non-space text after the nested table (checked when the run ends). */
@@ -243,7 +240,6 @@ interface CellScan {
243
240
  const scanCellTable = (
244
241
  s: ParseState, t: Token, fontStack: FontState[], st: CellScan,
245
242
  ): HtmlCellContent[] => {
246
- if (st.kind === 'image' || st.kind === 'table') throw parseError(s, t, MSG_SYNTAX_ERROR);
247
243
  if (st.textNonSpace || heldNonSpace(t)) throw parseError(s, t, MSG_TEXT_BEFORE_TABLE);
248
244
  const tbl = parseTable(s, fontStack);
249
245
  st.kind = 'table';
@@ -269,18 +265,12 @@ const scanAfterTable = (s: ParseState, t: Token, st: CellScan): HtmlCellContent[
269
265
  return [];
270
266
  };
271
267
 
272
- /** `image` as the cell's only child. */
273
- const scanCellImage = (s: ParseState, t: OpenToken, st: CellScan): HtmlCellContent[] => {
274
- if (st.kind !== 'none') throw parseError(s, t, MSG_SYNTAX_ERROR);
275
- st.kind = 'image';
276
- return [parseImgContent(s, t)];
277
- };
278
-
279
268
  /** One step of `cell: T_cell (fonttable | fonttext | image) T_end_cell`. */
280
269
  const scanCellItem = (
281
270
  s: ParseState, t: Token, fontStack: FontState[], st: CellScan,
282
271
  ): HtmlCellContent[] => {
283
- if (st.kind === 'fonttable') throw parseError(s, t, MSG_SYNTAX_ERROR);
272
+ // After an image only the cell's close may come: its opt_space took the strings.
273
+ if (st.kind === 'fonttable' || st.kind === 'image') throw parseError(s, t, MSG_SYNTAX_ERROR);
284
274
  if (st.kind === 'table') return scanAfterTable(s, t, st);
285
275
  const wrapper = st.kind === 'none' ? fontTableWrapper(s) : undefined;
286
276
  if (wrapper !== undefined) {
@@ -289,7 +279,6 @@ const scanCellItem = (
289
279
  }
290
280
  if (t.type === 'open' && t.tag === 'TABLE') return scanCellTable(s, t, fontStack, st);
291
281
  if (t.type === 'open' && t.tag === 'IMG') return scanCellImage(s, t, st);
292
- if (st.kind === 'image') throw parseError(s, t, MSG_SYNTAX_ERROR);
293
282
  return scanCellText(s, t, fontStack, st);
294
283
  };
295
284
 
@@ -303,19 +292,18 @@ const endsCell = (s: ParseState, t: Token, st: CellScan): boolean => {
303
292
 
304
293
  const parseCellContent = (s: ParseState, fontStack: FontState[]): HtmlCellContent[] => {
305
294
  const content: HtmlCellContent[] = [];
306
- const st: CellScan = { kind: 'none', textNonSpace: false, afterNonSpace: false };
295
+ const st: CellScan = { kind: 'none', start: s.pos, textNonSpace: false, afterNonSpace: false };
307
296
  for (let t = peek(s); t !== undefined; t = peek(s)) {
308
297
  if (endsCell(s, t, st)) break;
309
298
  content.push(...scanCellItem(s, t, fontStack, st));
310
299
  }
311
300
  const nxt = peek(s);
312
301
  if (nxt?.type === 'close' && nxt.tag === 'TD') consume(s);
313
- // C models a cell child as a single object; the `TD table TD` rule discards
314
- // whitespace around a nested table, so a table IS the cell's sole content.
315
- // @see lib/common/htmltable.h:htmlcell_t.child
316
- const tbl = content.find((c) => c.kind === 'table');
317
- if (tbl !== undefined) return [tbl];
318
- return content;
302
+ // C models a cell child as a single object; the table and image rules take
303
+ // the strings around them (opt_space), so a table or image IS the cell's
304
+ // sole content. @see lib/common/htmltable.h:htmlcell_t.child
305
+ const sole = content.find((c) => c.kind === 'table' || c.kind === 'image');
306
+ return sole !== undefined ? [sole] : content;
319
307
  };
320
308
 
321
309
  /** @see lib/common/htmlparse.y:cell rule / lib/common/htmllex.c:mkCell */
@@ -547,10 +535,12 @@ const parseTokens = (s: ParseState): HtmlLabel => {
547
535
  return parseTextLabel(s, fontStack);
548
536
  };
549
537
 
550
- /** A parsed label and `ctx->warn`, which `make_html_label` ORs into its rv. */
538
+ /** A parsed label with `ctx->warn` and `ctx->error`, from which `clearHTMLlexer` makes parseHTML's rv. */
551
539
  export interface ParsedHtmlLabel {
552
540
  label: HtmlLabel;
553
541
  warn: boolean;
542
+ /** htmlerror printed but the parse went on: rv 3 with a label. */
543
+ error: boolean;
554
544
  }
555
545
 
556
546
  /**
@@ -566,11 +556,11 @@ export const parseHtmlLabelRv = (src: string, stderr: StderrLines): ParsedHtmlLa
566
556
  const s: ParseState = { tokens, pos: 0, pending: error, stderr, emitted: new WeakSet(), warn: false, eof };
567
557
  try {
568
558
  const label = parseTokens(s);
569
- if (error !== undefined) throw error;
570
- return { label, warn: s.warn === true };
559
+ if (error !== undefined) throw guarded(s, error);
560
+ return { label, warn: s.warn === true, error: s.error === true };
571
561
  } catch (e) {
572
562
  // Running off the truncated stream means C's lexer would have hit the error.
573
- if (error !== undefined && s.pos >= tokens.length) { emitEof(s); throw error; }
563
+ if (error !== undefined && s.pos >= tokens.length) { emitEof(s); throw guarded(s, error); }
574
564
  throw e;
575
565
  }
576
566
  };
@@ -160,11 +160,28 @@ export function polySizeParamsFromNode(
160
160
  }
161
161
 
162
162
  /**
163
- * Create ND_xlabel when the xlabel attr is non-empty and set NODE_XLABEL.
163
+ * Which of common_init_node's guarded symbols are bound. C tests N_xlabel
164
+ * before reading it (`N_xlabel && (str = agxget(n, N_xlabel)) && str[0]`), and
165
+ * make_flat_adj_edges' setState nulls it for the aux layout, so an aux node's
166
+ * copied `xlabel` is never read.
167
+ * @see lib/common/utils.c:common_init_node (443)
168
+ * @see lib/dotgen/dotsplines.c:setState
169
+ */
170
+ export interface NodeInitSyms {
171
+ readonly nodeXlabel: boolean;
172
+ }
173
+
174
+ /** N_xlabel bound, as graph_init leaves it. @see lib/common/input.c:graph_init */
175
+ export const BOUND_NODE_INIT_SYMS: NodeInitSyms = { nodeXlabel: true };
176
+
177
+ /**
178
+ * Create ND_xlabel when N_xlabel is bound and the xlabel attr is non-empty,
179
+ * and set NODE_XLABEL.
164
180
  * @see lib/common/utils.c:443-447
165
181
  * @see lib/common/utils.c:447 — GD_has_labels scoped to agraphof(n) root
166
182
  */
167
- function initNodeXLabel(n: Node, g: Graph, measurer: TextMeasurer): void {
183
+ function initNodeXLabel(n: Node, g: Graph, measurer: TextMeasurer, syms: NodeInitSyms): void {
184
+ if (!syms.nodeXlabel) return; // utils.c:443 — the `N_xlabel &&` guard
168
185
  const str = nodeAttr(n, g, 'xlabel');
169
186
  if (!str || str.length === 0) return;
170
187
  const font = readFontAttrs(n, g);
@@ -228,7 +245,7 @@ function initPointSize(n: Node, g: Graph, shape: ShapeDesc & { polygon: PolygonT
228
245
  * has no polygon descriptor to size against.
229
246
  * @see lib/common/utils.c:common_init_node
230
247
  */
231
- function initNodeFromLabel(n: Node, g: Graph, measurer: TextMeasurer): boolean {
248
+ function initNodeFromLabel(n: Node, g: Graph, measurer: TextMeasurer, syms: NodeInitSyms): boolean {
232
249
  const shape = bindShape(nodeAttr(n, g, 'shape') ?? 'ellipse', nodeAttr(n, g, 'shapefile'));
233
250
  n.info.shape = shape;
234
251
  if (shape.kind === ShapeKind.SH_RECORD) {
@@ -237,12 +254,12 @@ function initNodeFromLabel(n: Node, g: Graph, measurer: TextMeasurer): boolean {
237
254
  // only selects make_label's is_record flag and initfn=record_init — it is
238
255
  // NOT a reason to skip the xlabel (utils.c:441/443/453).
239
256
  recordMakeLabel(n, g, measurer);
240
- initNodeXLabel(n, g, measurer);
257
+ initNodeXLabel(n, g, measurer, syms);
241
258
  recordInit(n, g, measurer); // initfn: sets lw/rw/ht from the field tree
242
259
  return true;
243
260
  }
244
261
  buildNodeLabel(n, g, measurer);
245
- initNodeXLabel(n, g, measurer);
262
+ initNodeXLabel(n, g, measurer, syms);
246
263
  // Layout-time poly_init warnings (once per layout; render-time polyInit is silent).
247
264
  if (shape.kind !== ShapeKind.SH_POINT) warnPolyInitImages(n, g);
248
265
  const poly = shape.polygon;
@@ -330,13 +347,16 @@ function initNodeDefaults(n: Node, g: Graph): void {
330
347
 
331
348
  /**
332
349
  * Initialise per-node geometry: shape-aware, label-driven sizing when a
333
- * text measurer is available; width/height attr defaults otherwise.
350
+ * text measurer is available; width/height attr defaults otherwise. `syms`
351
+ * stands for the global symbol state common_init_node reads.
334
352
  * @see lib/common/utils.c:common_init_node
335
353
  * @see lib/common/utils.c:gv_nodesize
336
354
  */
337
- export function commonInitNode(n: Node, g: Graph): void {
355
+ export function commonInitNode(
356
+ n: Node, g: Graph, syms: NodeInitSyms = BOUND_NODE_INIT_SYMS,
357
+ ): void {
338
358
  const measurer = layoutMeasurer(g);
339
- if (measurer !== undefined && initNodeFromLabel(n, g, measurer)) return;
359
+ if (measurer !== undefined && initNodeFromLabel(n, g, measurer, syms)) return;
340
360
  initNodeDefaults(n, g);
341
361
  }
342
362
 
@@ -20,6 +20,7 @@ import type { PolygonT } from './types.js';
20
20
  import type { InsideContext } from './splines-geom.js';
21
21
  import { polygonOutlineRing } from './poly-sizing.js';
22
22
  import { ccwrotatepf } from '../model/geom.js';
23
+ import { fdivOverflow } from '../util/overflow.js';
23
24
 
24
25
  /** Test if p0 and p1 are on the same side of the line L0-L1. @see shapes.c:same_side */
25
26
  export function sameSide(p0: Point, p1: Point, L0: Point, L1: Point): boolean {
@@ -60,7 +61,12 @@ function insideDims(n: Node, xsize: number, ysize: number):
60
61
  return { w, h, ow: 72 * n.info.outline_width || w, oh: 72 * n.info.outline_height || h };
61
62
  }
62
63
 
63
- /** @see lib/common/shapes.c:poly_inside (scale setup) */
64
+ /**
65
+ * C assigns `scalex = n_width` and then lets `fdiv_overflow` overwrite it
66
+ * with `n_width / xsize` when that quotient is finite (likewise `scaley`):
67
+ * `fdivOverflow(w, xsize) ?? w`.
68
+ * @see lib/common/shapes.c:poly_inside (scale setup, 2465-2469)
69
+ */
64
70
  function insideScale(n: Node, poly: PolygonT): InsideScale {
65
71
  // C swaps the node extents for flipped (LR/RL) layouts. @see poly_inside (GD_flip)
66
72
  const flip = n.root.info.flip === true;
@@ -74,8 +80,8 @@ function insideScale(n: Node, poly: PolygonT): InsideScale {
74
80
  const xsize = flip ? h : w;
75
81
  const ysize = flip ? w : h;
76
82
  return {
77
- scalex: xsize !== 0 ? w / xsize : w,
78
- scaley: ysize !== 0 ? h / ysize : h,
83
+ scalex: fdivOverflow(w, xsize) ?? w,
84
+ scaley: fdivOverflow(h, ysize) ?? h,
79
85
  boxURx: w / 2,
80
86
  boxURy: h / 2,
81
87
  };
@@ -85,8 +91,8 @@ function insideScale(n: Node, poly: PolygonT): InsideScale {
85
91
  const ysize = flip ? lwrw : n.info.ht;
86
92
  const { w, h, ow, oh } = insideDims(n, xsize, ysize);
87
93
  return {
88
- scalex: xsize !== 0 ? w / xsize : w,
89
- scaley: ysize !== 0 ? h / ysize : h,
94
+ scalex: fdivOverflow(w, xsize) ?? w,
95
+ scaley: fdivOverflow(h, ysize) ?? h,
90
96
  boxURx: ow / 2,
91
97
  boxURy: oh / 2,
92
98
  };
@@ -91,21 +91,39 @@ function expandByPoints(bb: Box, cp: Point[]): void {
91
91
  }
92
92
 
93
93
  /**
94
- * Expands bb to contain the cubic Bezier segment cp by adaptively refining the
95
- * segment to its true curve extent (not the control hull).
96
- * @see lib/common/emit.c:update_bb_bz
94
+ * How many times update_bb_bz attempts refinement of the control points.
95
+ * @see lib/common/emit.c:update_bb_bz (ATTEMPTS)
97
96
  */
98
- export function updateBbBz(bb: Box, cp: Point[]): void {
97
+ const UPDATE_BB_BZ_ATTEMPTS = 10;
98
+
99
+ /**
100
+ * Expands bb by the segment cp, halving it until it is sufficiently refined.
101
+ * A segment still unrefined when `recurse` reaches 0 leaves bb as it is
102
+ * (graphviz 16.1.1, upstream issue 2780: huge coordinates never refine).
103
+ * @see lib/common/emit.c:update_bb_bz_core
104
+ */
105
+ function updateBbBzCore(bb: Box, cp: Point[], recurse: number): void {
99
106
  if (!anyOutside(bb, cp)) return;
100
107
  if (checkControlPoints(cp)) {
101
108
  expandByPoints(bb, cp);
102
109
  return;
103
110
  }
111
+ if (recurse === 0) return;
104
112
  const left: Point[] = [];
105
113
  const right: Point[] = [];
106
114
  evalBezier(cp, 0.5, left, right);
107
- updateBbBz(bb, left);
108
- updateBbBz(bb, right);
115
+ updateBbBzCore(bb, left, recurse - 1);
116
+ updateBbBzCore(bb, right, recurse - 1);
117
+ }
118
+
119
+ /**
120
+ * Expands bb to contain the cubic Bezier segment cp by adaptively refining the
121
+ * segment to its true curve extent (not the control hull). Refinement stops
122
+ * after UPDATE_BB_BZ_ATTEMPTS levels (upstream issue 2780).
123
+ * @see lib/common/emit.c:update_bb_bz
124
+ */
125
+ export function updateBbBz(bb: Box, cp: Point[]): void {
126
+ updateBbBzCore(bb, cp, UPDATE_BB_BZ_ATTEMPTS);
109
127
  }
110
128
 
111
129
  // ---------------------------------------------------------------------------
@@ -35,9 +35,10 @@ class BeginRegSide {
35
35
  static topLeft(ctx: BeginCtx): void {
36
36
  const { P, n, endp, ranksep } = ctx;
37
37
  const b = endp.nb;
38
+ // C: GD_ranksep is int (types.h:335), so /2 truncates
38
39
  endp.boxes[0] = {
39
40
  ll: { x: b.ll.x - 1, y: P.start.p.y },
40
- ur: { x: b.ur.x, y: n.info.coord.y + n.info.ht / 2 + ranksep / 2 },
41
+ ur: { x: b.ur.x, y: n.info.coord.y + n.info.ht / 2 + Math.trunc(ranksep / 2) },
41
42
  };
42
43
  endp.boxes[1] = {
43
44
  ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 },
@@ -50,7 +51,7 @@ class BeginRegSide {
50
51
  const b = endp.nb;
51
52
  endp.boxes[0] = {
52
53
  ll: { x: b.ll.x, y: P.start.p.y },
53
- ur: { x: b.ur.x + 1, y: n.info.coord.y + n.info.ht / 2 + ranksep / 2 },
54
+ ur: { x: b.ur.x + 1, y: n.info.coord.y + n.info.ht / 2 + Math.trunc(ranksep / 2) },
54
55
  };
55
56
  endp.boxes[1] = {
56
57
  ll: { x: n.info.coord.x + n.info.rw + (FUDGE - 2), y: n.info.coord.y - n.info.ht / 2 },
@@ -121,7 +122,7 @@ class BeginFlatSide {
121
122
  const { P, n, endp, ranksep } = ctx;
122
123
  if (endp.sidemask === TOP) {
123
124
  endp.boxes[0] = {
124
- ll: { x: P.start.p.x, y: n.info.coord.y - n.info.ht / 2 - ranksep / 2 },
125
+ ll: { x: P.start.p.x, y: n.info.coord.y - n.info.ht / 2 - Math.trunc(ranksep / 2) },
125
126
  ur: { x: b.ur.x + 1, y: n.info.coord.y - n.info.ht / 2 },
126
127
  };
127
128
  endp.boxes[1] = {
@@ -45,8 +45,9 @@ class EndRegSide {
45
45
  const { P, n, e, endp, ranksep } = ctx;
46
46
  const b = endp.nb;
47
47
  if (P.end.p.x < n.info.coord.x) {
48
+ // C: GD_ranksep is int (types.h:335), so /2 truncates
48
49
  endp.boxes[0] = {
49
- ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 - ranksep / 2 },
50
+ ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 - Math.trunc(ranksep / 2) },
50
51
  ur: { x: b.ur.x, y: P.end.p.y },
51
52
  };
52
53
  endp.boxes[1] = {
@@ -55,7 +56,7 @@ class EndRegSide {
55
56
  };
56
57
  } else {
57
58
  endp.boxes[0] = {
58
- ll: { x: b.ll.x, y: n.info.coord.y - n.info.ht / 2 - ranksep / 2 },
59
+ ll: { x: b.ll.x, y: n.info.coord.y - n.info.ht / 2 - Math.trunc(ranksep / 2) },
59
60
  ur: { x: b.ur.x + 1, y: P.end.p.y },
60
61
  };
61
62
  endp.boxes[1] = {
@@ -121,7 +122,7 @@ class EndFlatSide {
121
122
  const { P, n, endp, ranksep } = ctx;
122
123
  if (endp.sidemask === TOP) {
123
124
  endp.boxes[0] = {
124
- ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 - ranksep / 2 },
125
+ ll: { x: b.ll.x - 1, y: n.info.coord.y - n.info.ht / 2 - Math.trunc(ranksep / 2) },
125
126
  ur: { x: P.end.p.x, y: n.info.coord.y - n.info.ht / 2 },
126
127
  };
127
128
  endp.boxes[1] = {
@@ -16,6 +16,7 @@ import type { Poly } from '../pathplan/types.js';
16
16
  import { INIT_DELTA, LOOP_TRIES, ROUTESPL_FUDGE } from './splines-constants.js';
17
17
  import { fma } from './fma.js';
18
18
  import { agerrorf } from './agerr.js';
19
+ import { gfmt5 } from '../render/dot/xdot-ops.js';
19
20
 
20
21
  // ---------------------------------------------------------------------------
21
22
  // Stage-dump hook (diagnosis only; null in production — same pattern as
@@ -158,15 +159,46 @@ function clampPoint(p: Point, box: Box): void {
158
159
  // checkPath
159
160
  // ---------------------------------------------------------------------------
160
161
 
162
+ /** One port line of printpath: `(%.5g, %.5g), tangent angle: %.5g, %s`. */
163
+ function portText(port: Path['start']): string {
164
+ const constrained = port.constrained ? 'constrained' : 'not constrained';
165
+ return `(${gfmt5(port.p.x)}, ${gfmt5(port.p.y)}), tangent angle: ${gfmt5(port.theta)}, ${constrained}`;
166
+ }
167
+
168
+ /**
169
+ * Dump a path: its box count, each box, and both ports. C writes these with
170
+ * plain `fprintf(stderr)`, not agerr, so they go straight to `console.error`
171
+ * (the channel of the `Error:` line checkpath prints just before them) and a
172
+ * caller-set `agseterrf` function does not receive them.
173
+ * @see lib/common/routespl.c:printpath
174
+ */
175
+ function printPath(pp: Path): void {
176
+ console.error(`${pp.nbox} boxes:`);
177
+ for (let bi = 0; bi < pp.nbox; bi++) {
178
+ const { ll, ur } = pp.boxes[bi];
179
+ console.error(`${bi} (${gfmt5(ll.x)}, ${gfmt5(ll.y)}), (${gfmt5(ur.x)}, ${gfmt5(ur.y)})`);
180
+ }
181
+ console.error(`start port: ${portText(pp.start)}`);
182
+ console.error(`end port: ${portText(pp.end)}`);
183
+ }
184
+
161
185
  /**
162
186
  * Repairs minor errors in the box path (gaps, slight overlaps).
163
187
  * Returns true on hard failure; false on success.
164
188
  * Mutates boxes[] and pp in place.
165
189
  *
190
+ * A path with no box left after the degenerate-box filter is a hard failure
191
+ * that reports the path (graphviz 16.1.1, upstream 2773, 2774, 2776, 2778).
192
+ *
166
193
  * @see lib/common/routespl.c:checkpath
167
194
  */
168
195
  export function checkPath(boxn: number, boxes: Box[], pp: Path): boolean {
169
196
  const bn = removeDegenerateBoxes(boxes, boxn);
197
+ if (bn === 0) {
198
+ agerrorf('in checkpath, all bounding boxes are below threshold');
199
+ printPath(pp);
200
+ return true;
201
+ }
170
202
  if (boxes[0].ll.x > boxes[0].ur.x || boxes[0].ll.y > boxes[0].ur.y) return true;
171
203
 
172
204
  for (let bi = 0; bi + 1 < bn; bi++) {
@@ -1,20 +1,20 @@
1
- graph 1 6.9028 3.9
2
- node a 0.375 2.9167 0.75 0.5 a solid ellipse black lightgrey
3
- node b 2.7917 2.9167 0.75 0.5 b solid ellipse black lightgrey
4
- node e 1.7917 2.9167 0.75 0.5 e solid ellipse black lightgrey
5
- node c 1.5833 1.9167 0.75 0.5 c solid ellipse black lightgrey
6
- node d 1.5833 0.91667 0.75 0.5 d solid ellipse black lightgrey
7
- node p 4.375 1.25 0.75 0.5 p solid ellipse black lightgrey
8
- node q 6.5278 1.25 0.75 0.5 q solid ellipse black lightgrey
9
- node r 5.5278 1.25 0.75 0.5 r solid ellipse black lightgrey
10
- node s 4.375 0.25 0.75 0.5 s solid ellipse black lightgrey
11
- edge a a 7 0.67726 3.0714 0.84528 3.1003 1 3.0487 1 2.9167 1 2.828 0.93016 2.7756 0.83336 2.7595 solid black
12
- edge a b 7 0.58237 3.1304 0.79801 3.336 1.1565 3.6331 1.5347 3.7556 1.9178 3.8796 2.2934 3.5533 2.5327 3.2721 x 1.5833 3.7833 solid black
13
- edge a e 4 0.75464 2.9167 0.90709 2.9167 1.0856 2.9167 1.2512 2.9167 zz 1.0833 3.075 solid black
14
- edge a c 4 0.60798 2.7153 0.7835 2.5741 1.0273 2.378 1.2272 2.2171 y 1.5694 0.66667 solid black
15
- edge b c 4 2.5587 2.7153 2.3832 2.5741 2.1394 2.378 1.9395 2.2171 solid black
16
- edge c d 4 1.5833 1.6625 1.5833 1.5612 1.5833 1.4406 1.5833 1.3269 solid black
17
- edge p q 7 4.5164 1.4864 4.713 1.7816 5.0905 2.2316 5.4931 2.0889 5.7783 1.9878 6.0422 1.7709 6.2322 1.583 k 5.4444 2.1167 solid black
18
- edge p r 4 4.7525 1.25 4.8301 1.25 4.9132 1.25 4.9951 1.25 m 4.9514 1.4083 solid black
19
- edge p s 4 4.375 0.99579 4.375 0.89454 4.375 0.77398 4.375 0.66022 solid black
1
+ graph 1 6.8472 3.9
2
+ node a 2.4722 2.9167 0.75 0.5 a solid ellipse black lightgrey
3
+ node b 1.375 2.9167 0.75 0.5 b solid ellipse black lightgrey
4
+ node e 0.375 2.9167 0.75 0.5 e solid ellipse black lightgrey
5
+ node c 1.9167 1.9167 0.75 0.5 c solid ellipse black lightgrey
6
+ node d 1.9167 0.91667 0.75 0.5 d solid ellipse black lightgrey
7
+ node p 6.4722 1.25 0.75 0.5 p solid ellipse black lightgrey
8
+ node q 5.375 1.25 0.75 0.5 q solid ellipse black lightgrey
9
+ node r 4.375 1.25 0.75 0.5 r solid ellipse black lightgrey
10
+ node s 6.4722 0.25 0.75 0.5 s solid ellipse black lightgrey
11
+ edge a a 7 2.7745 3.0714 2.9425 3.1003 3.0972 3.0487 3.0972 2.9167 3.0972 2.828 3.0274 2.7756 2.9306 2.7595 solid black
12
+ edge a b 4 2.0939 2.9167 2.0353 2.9167 1.9738 2.9167 1.9124 2.9167 x 1.9236 3.075 solid black
13
+ edge a e 7 2.2964 3.1413 2.1207 3.3457 1.8304 3.6335 1.503 3.7556 1.1535 3.8858 0.81939 3.5617 0.60677 3.2792 zz 1.4167 3.7833 solid black
14
+ edge a c 4 2.3434 2.6773 2.2782 2.5632 2.1974 2.4218 2.1238 2.293 y 0.36111 0.66667 solid black
15
+ edge b c 4 1.5006 2.6773 1.5642 2.5632 1.6429 2.4218 1.7148 2.293 solid black
16
+ edge c d 4 1.9167 1.6625 1.9167 1.5612 1.9167 1.4406 1.9167 1.3269 solid black
17
+ edge p q 4 6.0939 1.25 6.0353 1.25 5.9738 1.25 5.9124 1.25 k 5.9236 1.4083 solid black
18
+ edge p r 7 6.2939 1.4747 6.1159 1.6791 5.8221 1.967 5.4923 2.0889 5.1466 2.2166 4.8177 1.8973 4.6074 1.6165 m 5.4167 2.1167 solid black
19
+ edge p s 4 6.4722 0.99579 6.4722 0.89454 6.4722 0.77398 6.4722 0.66022 solid black
20
20
  stop
@@ -1,20 +1,20 @@
1
- graph 1 11.667 7.3796
2
- node a 6.875 3.75 0.75 0.5 a solid ellipse black lightgrey
3
- node b 9.2917 3.75 0.75 0.5 b solid ellipse black lightgrey
4
- node e 8.2917 3.75 0.75 0.5 e solid ellipse black lightgrey
5
- node c 10.292 3.75 0.75 0.5 c solid ellipse black lightgrey
6
- node d 11.292 3.75 0.75 0.5 d solid ellipse black lightgrey
7
- node p 0.375 0.25 0.75 0.5 p solid ellipse black lightgrey
8
- node q 3.375 0.25 0.75 0.5 q solid ellipse black lightgrey
9
- node r 2.375 0.25 0.75 0.5 r solid ellipse black lightgrey
10
- node s 1.375 0.25 0.75 0.5 s solid ellipse black lightgrey
11
- edge a a 14 8.3856 6.5714 8.5536 6.6003 8.7083 6.5487 8.7083 6.4167 8.7083 6.328 8.6385 6.2756 8.5417 6.2595 7.2284 3.8429 7.3754 3.8493 7.5 3.8184 7.5 3.75 7.5 3.7083 7.4537 3.6806 7.3843 3.6667 solid black
12
- edge a b 14 8.2907 6.6304 8.5063 6.836 8.8648 7.1331 9.2431 7.2556 9.6262 7.3796 10.002 7.0533 10.241 6.7721 7.127 3.9419 7.4155 4.1484 7.9111 4.4641 8.3958 4.5889 8.6953 4.666 8.9431 4.3861 9.1016 4.1292 x 8.4444 4.6167 solid black
13
- edge a e 8 8.463 6.4167 8.6154 6.4167 8.794 6.4167 8.9595 6.4167 7.2546 3.75 7.4071 3.75 7.5856 3.75 7.7512 3.75 zz 7.5833 3.9083 solid black
14
- edge a c 11 8.3163 6.2153 8.4918 6.0741 8.7356 5.878 8.9355 5.7171 7.0681 3.9673 7.2662 4.1725 7.5951 4.4665 7.9514 4.5889 8.6535 4.8302 9.4687 4.3684 9.928 4.0395 y 8 4.6167 solid black
15
- edge b c 8 10.267 6.2153 10.092 6.0741 9.8477 5.878 9.6478 5.7171 9.6706 3.75 9.6984 3.75 9.7262 3.75 9.754 3.75 solid black
16
- edge c d 8 9.2917 5.1625 9.2917 5.0612 9.2917 4.9406 9.2917 4.8269 10.671 3.75 10.698 3.75 10.726 3.75 10.754 3.75 solid black
17
- edge p q 14 5.8219 1.4864 6.0186 1.7816 6.3961 2.2316 6.7986 2.0889 7.0838 1.9878 7.3478 1.7709 7.5377 1.583 0.61898 0.44548 0.8937 0.65196 1.3626 0.96449 1.8264 1.0889 2.291 1.2135 2.7694 0.86813 3.0692 0.58337 k 1.875 1.1167 solid black
18
- edge p r 8 6.058 1.25 6.1356 1.25 6.2188 1.25 6.3007 1.25 0.75589 0.25 1.0617 0.25 1.4949 0.25 1.8363 0.25 m 1.375 0.40833 solid black
19
- edge p s 8 5.6806 0.99579 5.6806 0.89454 5.6806 0.77398 5.6806 0.66022 0.75391 0.25 0.78171 0.25 0.80951 0.25 0.83731 0.25 solid black
1
+ graph 1 10.444 7.2886
2
+ node a 9.8194 3.6528 0.75 0.5 a solid ellipse black lightgrey
3
+ node b 8.7222 3.6528 0.75 0.5 b solid ellipse black lightgrey
4
+ node e 5.7222 3.6528 0.75 0.5 e solid ellipse black lightgrey
5
+ node c 7.7222 3.6528 0.75 0.5 c solid ellipse black lightgrey
6
+ node d 6.7222 3.6528 0.75 0.5 d solid ellipse black lightgrey
7
+ node p 3.4722 0.25 0.75 0.5 p solid ellipse black lightgrey
8
+ node q 2.375 0.25 0.75 0.5 q solid ellipse black lightgrey
9
+ node r 1.375 0.25 0.75 0.5 r solid ellipse black lightgrey
10
+ node s 0.375 0.25 0.75 0.5 s solid ellipse black lightgrey
11
+ edge a a 14 8.4828 6.4742 8.6508 6.5031 8.8056 6.4515 8.8056 6.3194 8.8056 6.2307 8.7357 6.1783 8.6389 6.1623 10.173 3.7457 10.32 3.7521 10.444 3.7211 10.444 3.6528 10.444 3.6111 10.398 3.5833 10.329 3.5695 solid black
12
+ edge a b 8 9.4411 3.6528 9.3825 3.6528 9.321 3.6528 9.2596 3.6528 7.6208 6.3194 7.6821 6.3194 7.7436 6.3194 7.8023 6.3194 x 9.2708 3.8111 solid black
13
+ edge a e 17 9.6983 3.895 9.5826 4.0965 9.3874 4.3693 9.128 4.4917 8.5321 4.7727 6.8438 4.1212 6.2222 3.9028 6.2005 3.8951 6.1785 3.8868 6.1564 3.8779 6.3151 6.682 6.5277 6.9645 6.8619 7.2886 7.2113 7.1583 7.5387 7.0363 7.8291 6.7484 8.0047 6.544 zz 9.0417 4.5194 solid black
14
+ edge a c 11 9.6172 3.8703 9.4101 4.0756 9.0674 4.3696 8.7014 4.4917 8.3867 4.5966 8.1083 4.299 7.9296 4.0297 7.8321 5.6957 7.9057 5.8246 7.9865 5.9659 8.0517 6.0801 y 8.6528 4.5194 solid black
15
+ edge b c 8 8.3437 3.6528 8.3159 3.6528 8.2881 3.6528 8.2603 3.6528 7.4231 5.6957 7.3513 5.8246 7.2725 5.9659 7.209 6.0801 solid black
16
+ edge c d 8 7.3437 3.6528 7.3159 3.6528 7.2881 3.6528 7.2603 3.6528 7.625 4.7297 7.625 4.8434 7.625 4.964 7.625 5.0652 solid black
17
+ edge p q 8 3.0939 0.25 3.0353 0.25 2.9738 0.25 2.9124 0.25 6.2874 1.25 6.3488 1.25 6.4103 1.25 6.4689 1.25 k 2.9236 0.40833 solid black
18
+ edge p r 14 3.2939 0.47465 3.1159 0.6791 2.8221 0.967 2.4923 1.0889 2.1466 1.2166 1.8177 0.89726 1.6074 0.61649 4.9824 1.6165 5.1927 1.8973 5.5216 2.2166 5.8673 2.0889 6.1971 1.967 6.4909 1.6791 6.6689 1.4747 m 2.4167 1.1167 solid black
19
+ edge p s 14 3.2509 0.45635 3.1169 0.5668 2.9363 0.6918 2.75 0.75 2.0076 0.98191 1.7339 1.0074 1 0.75 0.88822 0.71079 0.78157 0.64225 0.68904 0.56825 6.8472 0.66022 6.8472 0.77398 6.8472 0.89454 6.8472 0.99579 solid black
20
20
  stop