| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
""" |
| 4 |
validate formatting of C/C++ files |
| 5 |
|
| 6 |
This script is deliberately a fairly simple-stupid translation of what would |
| 7 |
otherwise be some steps described in awkward YAML in |
| 8 |
../.gitlab-ci.yml:lint_clang_format. |
| 9 |
""" |
| 10 |
|
| 11 |
import difflib |
| 12 |
import subprocess |
| 13 |
import sys |
| 14 |
from pathlib import Path |
| 15 |
|
| 16 |
# TODO: files that are not yet compliant |
| 17 |
EXCLUDE = ( |
| 18 |
"cmd/dot/dot.c", |
| 19 |
"cmd/dot/dot_builtins.cpp", |
| 20 |
"cmd/edgepaint/edgepaintmain.c", |
| 21 |
"cmd/gvedit/csettings.h", |
| 22 |
"cmd/gvedit/imageviewer.cpp", |
| 23 |
"cmd/gvedit/imageviewer.h", |
| 24 |
"cmd/gvedit/mdichild.h", |
| 25 |
"cmd/gvmap/cluster.c", |
| 26 |
"cmd/gvmap/country_graph_coloring.c", |
| 27 |
"cmd/gvmap/country_graph_coloring.h", |
| 28 |
"cmd/gvmap/gvmap.c", |
| 29 |
"cmd/gvmap/make_map.c", |
| 30 |
"cmd/gvmap/make_map.h", |
| 31 |
"cmd/gvmap/power.c", |
| 32 |
"cmd/mingle/minglemain.cpp", |
| 33 |
"cmd/smyrna/arcball.c", |
| 34 |
"cmd/smyrna/arcball.h", |
| 35 |
"cmd/smyrna/draw.c", |
| 36 |
"cmd/smyrna/draw.h", |
| 37 |
"cmd/smyrna/glexpose.c", |
| 38 |
"cmd/smyrna/glmotion.c", |
| 39 |
"cmd/smyrna/glmotion.h", |
| 40 |
"cmd/smyrna/gltemplate.c", |
| 41 |
"cmd/smyrna/gltemplate.h", |
| 42 |
"cmd/smyrna/glutrender.c", |
| 43 |
"cmd/smyrna/gui/appmouse.c", |
| 44 |
"cmd/smyrna/gui/appmouse.h", |
| 45 |
"cmd/smyrna/gui/callbacks.c", |
| 46 |
"cmd/smyrna/gui/datalistcallbacks.c", |
| 47 |
"cmd/smyrna/gui/frmobjectui.c", |
| 48 |
"cmd/smyrna/gui/glcompui.c", |
| 49 |
"cmd/smyrna/gui/glcompui.h", |
| 50 |
"cmd/smyrna/gui/gui.c", |
| 51 |
"cmd/smyrna/gui/gui.h", |
| 52 |
"cmd/smyrna/gui/menucallbacks.c", |
| 53 |
"cmd/smyrna/gui/toolboxcallbacks.c", |
| 54 |
"cmd/smyrna/gui/topviewsettings.c", |
| 55 |
"cmd/smyrna/gvprpipe.c", |
| 56 |
"cmd/smyrna/hier.c", |
| 57 |
"cmd/smyrna/hier.h", |
| 58 |
"cmd/smyrna/hotkeymap.c", |
| 59 |
"cmd/smyrna/hotkeymap.h", |
| 60 |
"cmd/smyrna/polytess.c", |
| 61 |
"cmd/smyrna/polytess.h", |
| 62 |
"cmd/smyrna/selectionfuncs.c", |
| 63 |
"cmd/smyrna/selectionfuncs.h", |
| 64 |
"cmd/smyrna/smyrna_utils.c", |
| 65 |
"cmd/smyrna/smyrna_utils.h", |
| 66 |
"cmd/smyrna/smyrnadefs.h", |
| 67 |
"cmd/smyrna/topfisheyeview.c", |
| 68 |
"cmd/smyrna/topfisheyeview.h", |
| 69 |
"cmd/smyrna/topviewfuncs.c", |
| 70 |
"cmd/smyrna/topviewfuncs.h", |
| 71 |
"cmd/smyrna/tvnodes.c", |
| 72 |
"cmd/smyrna/tvnodes.h", |
| 73 |
"cmd/smyrna/viewport.c", |
| 74 |
"cmd/smyrna/viewport.h", |
| 75 |
"cmd/smyrna/viewportcamera.c", |
| 76 |
"cmd/smyrna/viewportcamera.h", |
| 77 |
"cmd/tools/acyclic.c", |
| 78 |
"cmd/tools/bcomps.c", |
| 79 |
"cmd/tools/colortbl.h", |
| 80 |
"cmd/tools/colxlate.c", |
| 81 |
"cmd/tools/convert.h", |
| 82 |
"cmd/tools/cvtgxl.c", |
| 83 |
"cmd/tools/dijkstra.c", |
| 84 |
"cmd/tools/gc.c", |
| 85 |
"cmd/tools/gml2gv.h", |
| 86 |
"cmd/tools/graph_generator.c", |
| 87 |
"cmd/tools/graphml2gv.c", |
| 88 |
"cmd/tools/gv2gml.c", |
| 89 |
"cmd/tools/gv2gxl.c", |
| 90 |
"cmd/tools/gvcolor.c", |
| 91 |
"cmd/tools/gvgen.c", |
| 92 |
"cmd/tools/gvpack.cpp", |
| 93 |
"cmd/tools/gxl2gv.c", |
| 94 |
"cmd/tools/matrix_market.h", |
| 95 |
"cmd/tools/mm2gv.c", |
| 96 |
"cmd/tools/mmio.c", |
| 97 |
"cmd/tools/mmio.h", |
| 98 |
"cmd/tools/sccmap.c", |
| 99 |
"cmd/tools/tred.c", |
| 100 |
"cmd/tools/unflatten.c", |
| 101 |
"contrib/prune/prune.c", |
| 102 |
"doc/libgraph/agmemread.c", |
| 103 |
"doc/libgraph/sccmap.c", |
| 104 |
"lib/ast/ast.h", |
| 105 |
"lib/ast/chresc.c", |
| 106 |
"lib/ast/chrtoi.c", |
| 107 |
"lib/ast/error.c", |
| 108 |
"lib/ast/error.h", |
| 109 |
"lib/ast/fmtesc.c", |
| 110 |
"lib/ast/stresc.c", |
| 111 |
"lib/ast/strmatch.c", |
| 112 |
"lib/cdt/dtclose.c", |
| 113 |
"lib/cdt/dtdisc.c", |
| 114 |
"lib/cdt/dtextract.c", |
| 115 |
"lib/cdt/dtflatten.c", |
| 116 |
"lib/cdt/dthash.c", |
| 117 |
"lib/cdt/dthdr.h", |
| 118 |
"lib/cdt/dtmethod.c", |
| 119 |
"lib/cdt/dtopen.c", |
| 120 |
"lib/cdt/dtrenew.c", |
| 121 |
"lib/cdt/dtrestore.c", |
| 122 |
"lib/cdt/dtsize.c", |
| 123 |
"lib/cdt/dtstrhash.c", |
| 124 |
"lib/cdt/dttree.c", |
| 125 |
"lib/cdt/dtview.c", |
| 126 |
"lib/cgraph/apply.c", |
| 127 |
"lib/cgraph/attr.c", |
| 128 |
"lib/cgraph/cghdr.h", |
| 129 |
"lib/cgraph/edge.c", |
| 130 |
"lib/cgraph/graph.c", |
| 131 |
"lib/cgraph/id.c", |
| 132 |
"lib/cgraph/imap.c", |
| 133 |
"lib/cgraph/ingraphs.c", |
| 134 |
"lib/cgraph/ingraphs.h", |
| 135 |
"lib/cgraph/io.c", |
| 136 |
"lib/cgraph/node.c", |
| 137 |
"lib/cgraph/obj.c", |
| 138 |
"lib/cgraph/rec.c", |
| 139 |
"lib/cgraph/refstr.c", |
| 140 |
"lib/cgraph/subg.c", |
| 141 |
"lib/cgraph/utils.c", |
| 142 |
"lib/cgraph/write.c", |
| 143 |
"lib/circogen/block.c", |
| 144 |
"lib/circogen/block.h", |
| 145 |
"lib/circogen/blockpath.c", |
| 146 |
"lib/circogen/blockpath.h", |
| 147 |
"lib/circogen/blocktree.c", |
| 148 |
"lib/circogen/blocktree.h", |
| 149 |
"lib/circogen/circo.h", |
| 150 |
"lib/circogen/circpos.c", |
| 151 |
"lib/circogen/circpos.h", |
| 152 |
"lib/circogen/circular.c", |
| 153 |
"lib/circogen/circular.h", |
| 154 |
"lib/circogen/circularinit.c", |
| 155 |
"lib/circogen/edgelist.c", |
| 156 |
"lib/circogen/edgelist.h", |
| 157 |
"lib/circogen/nodelist.c", |
| 158 |
"lib/circogen/nodelist.h", |
| 159 |
"lib/common/args.c", |
| 160 |
"lib/common/arith.h", |
| 161 |
"lib/common/arrows.c", |
| 162 |
"lib/common/color.h", |
| 163 |
"lib/common/colorprocs.h", |
| 164 |
"lib/common/colxlate.c", |
| 165 |
"lib/common/const.h", |
| 166 |
"lib/common/emit.c", |
| 167 |
"lib/common/geom.c", |
| 168 |
"lib/common/geom.h", |
| 169 |
"lib/common/geomprocs.h", |
| 170 |
"lib/common/globals.c", |
| 171 |
"lib/common/globals.h", |
| 172 |
"lib/common/htmllex.c", |
| 173 |
"lib/common/htmllex.h", |
| 174 |
"lib/common/htmltable.c", |
| 175 |
"lib/common/htmltable.h", |
| 176 |
"lib/common/input.c", |
| 177 |
"lib/common/labels.c", |
| 178 |
"lib/common/macros.h", |
| 179 |
"lib/common/ns.c", |
| 180 |
"lib/common/output.c", |
| 181 |
"lib/common/pointset.c", |
| 182 |
"lib/common/pointset.h", |
| 183 |
"lib/common/postproc.c", |
| 184 |
"lib/common/ps_font_equiv.h", |
| 185 |
"lib/common/psusershape.c", |
| 186 |
"lib/common/render.h", |
| 187 |
"lib/common/routespl.c", |
| 188 |
"lib/common/shapes.c", |
| 189 |
"lib/common/splines.c", |
| 190 |
"lib/common/taper.c", |
| 191 |
"lib/common/textspan.c", |
| 192 |
"lib/common/textspan.h", |
| 193 |
"lib/common/types.h", |
| 194 |
"lib/common/usershape.h", |
| 195 |
"lib/common/utils.c", |
| 196 |
"lib/dotgen/acyclic.c", |
| 197 |
"lib/dotgen/class1.c", |
| 198 |
"lib/dotgen/class2.c", |
| 199 |
"lib/dotgen/cluster.c", |
| 200 |
"lib/dotgen/compound.c", |
| 201 |
"lib/dotgen/conc.c", |
| 202 |
"lib/dotgen/decomp.c", |
| 203 |
"lib/dotgen/dot.h", |
| 204 |
"lib/dotgen/dotinit.c", |
| 205 |
"lib/dotgen/dotprocs.h", |
| 206 |
"lib/dotgen/fastgr.c", |
| 207 |
"lib/dotgen/flat.c", |
| 208 |
"lib/dotgen/mincross.c", |
| 209 |
"lib/dotgen/position.c", |
| 210 |
"lib/dotgen/rank.c", |
| 211 |
"lib/dotgen/sameport.c", |
| 212 |
"lib/edgepaint/edge_distinct_coloring.c", |
| 213 |
"lib/edgepaint/furtherest_point.c", |
| 214 |
"lib/edgepaint/furtherest_point.h", |
| 215 |
"lib/edgepaint/intersection.c", |
| 216 |
"lib/edgepaint/intersection.h", |
| 217 |
"lib/edgepaint/lab.c", |
| 218 |
"lib/edgepaint/lab.h", |
| 219 |
"lib/edgepaint/lab_gamut.c", |
| 220 |
"lib/edgepaint/node_distinct_coloring.c", |
| 221 |
"lib/expr/excc.c", |
| 222 |
"lib/expr/excontext.c", |
| 223 |
"lib/expr/exdata.c", |
| 224 |
"lib/expr/exerror.c", |
| 225 |
"lib/expr/exeval.c", |
| 226 |
"lib/expr/exexpr.c", |
| 227 |
"lib/expr/exgram.h", |
| 228 |
"lib/expr/exlib.h", |
| 229 |
"lib/expr/exnospace.c", |
| 230 |
"lib/expr/exopen.c", |
| 231 |
"lib/expr/expr.h", |
| 232 |
"lib/expr/extoken.c", |
| 233 |
"lib/expr/extype.c", |
| 234 |
"lib/expr/exzero.c", |
| 235 |
"lib/fdpgen/clusteredges.c", |
| 236 |
"lib/fdpgen/clusteredges.h", |
| 237 |
"lib/fdpgen/comp.c", |
| 238 |
"lib/fdpgen/comp.h", |
| 239 |
"lib/fdpgen/dbg.c", |
| 240 |
"lib/fdpgen/dbg.h", |
| 241 |
"lib/fdpgen/fdp.h", |
| 242 |
"lib/fdpgen/fdpinit.c", |
| 243 |
"lib/fdpgen/grid.c", |
| 244 |
"lib/fdpgen/grid.h", |
| 245 |
"lib/fdpgen/layout.c", |
| 246 |
"lib/fdpgen/tlayout.h", |
| 247 |
"lib/fdpgen/xlayout.c", |
| 248 |
"lib/fdpgen/xlayout.h", |
| 249 |
"lib/glcomp/glcompbutton.c", |
| 250 |
"lib/glcomp/glcompbutton.h", |
| 251 |
"lib/glcomp/glcompdefs.h", |
| 252 |
"lib/glcomp/glcompfont.c", |
| 253 |
"lib/glcomp/glcompfont.h", |
| 254 |
"lib/glcomp/glcompimage.c", |
| 255 |
"lib/glcomp/glcompimage.h", |
| 256 |
"lib/glcomp/glcomplabel.c", |
| 257 |
"lib/glcomp/glcompmouse.c", |
| 258 |
"lib/glcomp/glcompmouse.h", |
| 259 |
"lib/glcomp/glcomppanel.c", |
| 260 |
"lib/glcomp/glcompset.c", |
| 261 |
"lib/glcomp/glcompset.h", |
| 262 |
"lib/glcomp/glcomptextpng.c", |
| 263 |
"lib/glcomp/glcomptexture.c", |
| 264 |
"lib/glcomp/glcomptexture.h", |
| 265 |
"lib/glcomp/glpangofont.c", |
| 266 |
"lib/glcomp/glutils.c", |
| 267 |
"lib/glcomp/glutils.h", |
| 268 |
"lib/gvc/gvc.c", |
| 269 |
"lib/gvc/gvc.h", |
| 270 |
"lib/gvc/gvcext.h", |
| 271 |
"lib/gvc/gvcint.h", |
| 272 |
"lib/gvc/gvcjob.h", |
| 273 |
"lib/gvc/gvconfig.c", |
| 274 |
"lib/gvc/gvconfig.h", |
| 275 |
"lib/gvc/gvcontext.c", |
| 276 |
"lib/gvc/gvcproc.h", |
| 277 |
"lib/gvc/gvdevice.c", |
| 278 |
"lib/gvc/gvevent.c", |
| 279 |
"lib/gvc/gvio.h", |
| 280 |
"lib/gvc/gvjobs.c", |
| 281 |
"lib/gvc/gvlayout.c", |
| 282 |
"lib/gvc/gvloadimage.c", |
| 283 |
"lib/gvc/gvplugin.c", |
| 284 |
"lib/gvc/gvplugin.h", |
| 285 |
"lib/gvc/gvplugin_device.h", |
| 286 |
"lib/gvc/gvplugin_layout.h", |
| 287 |
"lib/gvc/gvplugin_loadimage.h", |
| 288 |
"lib/gvc/gvplugin_render.h", |
| 289 |
"lib/gvc/gvplugin_textlayout.h", |
| 290 |
"lib/gvc/gvrender.c", |
| 291 |
"lib/gvc/gvtextlayout.c", |
| 292 |
"lib/gvc/gvtool_tred.c", |
| 293 |
"lib/gvpr/actions.h", |
| 294 |
"lib/gvpr/compile.h", |
| 295 |
"lib/gvpr/gdefs.h", |
| 296 |
"lib/gvpr/gprstate.c", |
| 297 |
"lib/gvpr/gprstate.h", |
| 298 |
"lib/gvpr/gvpr.h", |
| 299 |
"lib/gvpr/parse.h", |
| 300 |
"lib/gvpr/trie.c", |
| 301 |
"lib/gvpr/trieFA.h", |
| 302 |
"lib/label/index.c", |
| 303 |
"lib/label/index.h", |
| 304 |
"lib/label/node.c", |
| 305 |
"lib/label/node.h", |
| 306 |
"lib/label/rectangle.c", |
| 307 |
"lib/label/split.q.c", |
| 308 |
"lib/label/split.q.h", |
| 309 |
"lib/label/xlabels.h", |
| 310 |
"lib/mingle/agglomerative_bundling.cpp", |
| 311 |
"lib/mingle/edge_bundling.cpp", |
| 312 |
"lib/mingle/edge_bundling.h", |
| 313 |
"lib/mingle/ink.cpp", |
| 314 |
"lib/mingle/ink.h", |
| 315 |
"lib/mingle/nearest_neighbor_graph.cpp", |
| 316 |
"lib/mingle/nearest_neighbor_graph_ann.cpp", |
| 317 |
"lib/neatogen/adjust.c", |
| 318 |
"lib/neatogen/adjust.h", |
| 319 |
"lib/neatogen/call_tri.c", |
| 320 |
"lib/neatogen/call_tri.h", |
| 321 |
"lib/neatogen/circuit.c", |
| 322 |
"lib/neatogen/closest.c", |
| 323 |
"lib/neatogen/compute_hierarchy.c", |
| 324 |
"lib/neatogen/conjgrad.c", |
| 325 |
"lib/neatogen/conjgrad.h", |
| 326 |
"lib/neatogen/constrained_majorization.c", |
| 327 |
"lib/neatogen/constrained_majorization_ipsep.c", |
| 328 |
"lib/neatogen/constraint.c", |
| 329 |
"lib/neatogen/defs.h", |
| 330 |
"lib/neatogen/delaunay.c", |
| 331 |
"lib/neatogen/delaunay.h", |
| 332 |
"lib/neatogen/digcola.h", |
| 333 |
"lib/neatogen/dijkstra.c", |
| 334 |
"lib/neatogen/edges.c", |
| 335 |
"lib/neatogen/edges.h", |
| 336 |
"lib/neatogen/embed_graph.c", |
| 337 |
"lib/neatogen/fPQ.h", |
| 338 |
"lib/neatogen/geometry.c", |
| 339 |
"lib/neatogen/geometry.h", |
| 340 |
"lib/neatogen/heap.c", |
| 341 |
"lib/neatogen/hedges.c", |
| 342 |
"lib/neatogen/hedges.h", |
| 343 |
"lib/neatogen/info.c", |
| 344 |
"lib/neatogen/kkutils.c", |
| 345 |
"lib/neatogen/kkutils.h", |
| 346 |
"lib/neatogen/legal.c", |
| 347 |
"lib/neatogen/lu.c", |
| 348 |
"lib/neatogen/matinv.c", |
| 349 |
"lib/neatogen/matrix_ops.c", |
| 350 |
"lib/neatogen/matrix_ops.h", |
| 351 |
"lib/neatogen/multispline.c", |
| 352 |
"lib/neatogen/multispline.h", |
| 353 |
"lib/neatogen/neato.h", |
| 354 |
"lib/neatogen/neatoinit.c", |
| 355 |
"lib/neatogen/neatoprocs.h", |
| 356 |
"lib/neatogen/neatosplines.c", |
| 357 |
"lib/neatogen/opt_arrangement.c", |
| 358 |
"lib/neatogen/overlap.c", |
| 359 |
"lib/neatogen/overlap.h", |
| 360 |
"lib/neatogen/pca.c", |
| 361 |
"lib/neatogen/poly.c", |
| 362 |
"lib/neatogen/poly.h", |
| 363 |
"lib/neatogen/quad_prog_solve.c", |
| 364 |
"lib/neatogen/quad_prog_solver.h", |
| 365 |
"lib/neatogen/quad_prog_vpsc.c", |
| 366 |
"lib/neatogen/quad_prog_vpsc.h", |
| 367 |
"lib/neatogen/randomkit.c", |
| 368 |
"lib/neatogen/randomkit.h", |
| 369 |
"lib/neatogen/sgd.h", |
| 370 |
"lib/neatogen/site.c", |
| 371 |
"lib/neatogen/smart_ini_x.c", |
| 372 |
"lib/neatogen/sparsegraph.h", |
| 373 |
"lib/neatogen/stress.c", |
| 374 |
"lib/neatogen/stress.h", |
| 375 |
"lib/neatogen/stuff.c", |
| 376 |
"lib/neatogen/voronoi.c", |
| 377 |
"lib/ortho/fPQ.c", |
| 378 |
"lib/ortho/fPQ.h", |
| 379 |
"lib/ortho/maze.c", |
| 380 |
"lib/ortho/maze.h", |
| 381 |
"lib/ortho/ortho.c", |
| 382 |
"lib/ortho/partition.c", |
| 383 |
"lib/ortho/rawgraph.c", |
| 384 |
"lib/ortho/rawgraph.h", |
| 385 |
"lib/ortho/sgraph.c", |
| 386 |
"lib/ortho/sgraph.h", |
| 387 |
"lib/ortho/structures.h", |
| 388 |
"lib/ortho/trap.h", |
| 389 |
"lib/ortho/trapezoid.c", |
| 390 |
"lib/osage/osage.h", |
| 391 |
"lib/osage/osageinit.c", |
| 392 |
"lib/pack/pack.h", |
| 393 |
"lib/patchwork/patchwork.c", |
| 394 |
"lib/patchwork/patchwork.h", |
| 395 |
"lib/patchwork/patchworkinit.c", |
| 396 |
"lib/patchwork/tree_map.c", |
| 397 |
"lib/patchwork/tree_map.h", |
| 398 |
"lib/pathplan/cvt.c", |
| 399 |
"lib/pathplan/pathgeom.h", |
| 400 |
"lib/pathplan/pathplan.h", |
| 401 |
"lib/pathplan/route.c", |
| 402 |
"lib/pathplan/shortest.c", |
| 403 |
"lib/pathplan/shortestpth.c", |
| 404 |
"lib/pathplan/solvers.c", |
| 405 |
"lib/pathplan/solvers.h", |
| 406 |
"lib/pathplan/triang.c", |
| 407 |
"lib/pathplan/util.c", |
| 408 |
"lib/pathplan/vis.h", |
| 409 |
"lib/pathplan/visibility.c", |
| 410 |
"lib/pathplan/vispath.h", |
| 411 |
"lib/rbtree/red_black_tree.c", |
| 412 |
"lib/rbtree/red_black_tree.h", |
| 413 |
"lib/rbtree/test_red_black_tree.c", |
| 414 |
"lib/sfdpgen/Multilevel.c", |
| 415 |
"lib/sfdpgen/post_process.c", |
| 416 |
"lib/sfdpgen/post_process.h", |
| 417 |
"lib/sfdpgen/sfdp.h", |
| 418 |
"lib/sfdpgen/sfdpinit.c", |
| 419 |
"lib/sfdpgen/sparse_solve.c", |
| 420 |
"lib/sfdpgen/spring_electrical.c", |
| 421 |
"lib/sfdpgen/spring_electrical.h", |
| 422 |
"lib/sfio/Sfio_f/_sfslen.c", |
| 423 |
"lib/sfio/sfcvt.c", |
| 424 |
"lib/sfio/sfextern.c", |
| 425 |
"lib/sfio/sfhdr.h", |
| 426 |
"lib/sfio/sfio.h", |
| 427 |
"lib/sfio/sftable.c", |
| 428 |
"lib/sfio/sfprint.c", |
| 429 |
"lib/sfio/sfvscanf.c", |
| 430 |
"lib/sparse/DotIO.c", |
| 431 |
"lib/sparse/DotIO.h", |
| 432 |
"lib/sparse/QuadTree.c", |
| 433 |
"lib/sparse/QuadTree.h", |
| 434 |
"lib/sparse/SparseMatrix.c", |
| 435 |
"lib/sparse/SparseMatrix.h", |
| 436 |
"lib/sparse/clustering.c", |
| 437 |
"lib/sparse/clustering.h", |
| 438 |
"lib/sparse/color_palette.c", |
| 439 |
"lib/sparse/color_palette.h", |
| 440 |
"lib/sparse/general.c", |
| 441 |
"lib/sparse/general.h", |
| 442 |
"lib/sparse/mq.c", |
| 443 |
"lib/sparse/mq.h", |
| 444 |
"lib/topfish/hierarchy.c", |
| 445 |
"lib/topfish/hierarchy.h", |
| 446 |
"lib/topfish/rescale_layout.c", |
| 447 |
"lib/twopigen/circle.c", |
| 448 |
"lib/twopigen/circle.h", |
| 449 |
"lib/twopigen/twopiinit.c", |
| 450 |
"lib/vpsc/block.cpp", |
| 451 |
"lib/vpsc/block.h", |
| 452 |
"lib/vpsc/blocks.cpp", |
| 453 |
"lib/vpsc/blocks.h", |
| 454 |
"lib/vpsc/constraint.cpp", |
| 455 |
"lib/vpsc/constraint.h", |
| 456 |
"lib/vpsc/csolve_VPSC.cpp", |
| 457 |
"lib/vpsc/csolve_VPSC.h", |
| 458 |
"lib/vpsc/generate-constraints.cpp", |
| 459 |
"lib/vpsc/generate-constraints.h", |
| 460 |
"lib/vpsc/solve_VPSC.cpp", |
| 461 |
"lib/vpsc/solve_VPSC.h", |
| 462 |
"lib/vpsc/variable.cpp", |
| 463 |
"lib/vpsc/variable.h", |
| 464 |
"macosx/GVApplicationDelegate.h", |
| 465 |
"macosx/GVApplicationDelegate.m", |
| 466 |
"macosx/GVAttributeInspectorController.h", |
| 467 |
"macosx/GVAttributeInspectorController.m", |
| 468 |
"macosx/GVAttributeSchema.h", |
| 469 |
"macosx/GVAttributeSchema.m", |
| 470 |
"macosx/GVDocument.h", |
| 471 |
"macosx/GVDocument.m", |
| 472 |
"macosx/GVExportViewController.h", |
| 473 |
"macosx/GVExportViewController.m", |
| 474 |
"macosx/GVFileNotificationCenter.h", |
| 475 |
"macosx/GVFileNotificationCenter.m", |
| 476 |
"macosx/GVGraphArguments.h", |
| 477 |
"macosx/GVGraphArguments.m", |
| 478 |
"macosx/GVGraphDefaultAttributes.h", |
| 479 |
"macosx/GVGraphDefaultAttributes.m", |
| 480 |
"macosx/GVWindowController.h", |
| 481 |
"macosx/GVWindowController.m", |
| 482 |
"macosx/GVZGraph.h", |
| 483 |
"macosx/GVZGraph.m", |
| 484 |
"macosx/main.m", |
| 485 |
"plugin.demo/xgtk/src/callbacks.c", |
| 486 |
"plugin.demo/xgtk/src/callbacks.h", |
| 487 |
"plugin.demo/xgtk/src/gvdevice_xgtk.c", |
| 488 |
"plugin.demo/xgtk/src/gvplugin_xgtk.c", |
| 489 |
"plugin.demo/xgtk/src/interface.c", |
| 490 |
"plugin.demo/xgtk/src/interface.h", |
| 491 |
"plugin.demo/xgtk/src/support.c", |
| 492 |
"plugin.demo/xgtk/src/support.h", |
| 493 |
"plugin/core/gvloadimage_core.c", |
| 494 |
"plugin/core/gvplugin_core.c", |
| 495 |
"plugin/core/gvrender_core_dot.c", |
| 496 |
"plugin/core/gvrender_core_fig.c", |
| 497 |
"plugin/core/gvrender_core_json.c", |
| 498 |
"plugin/core/gvrender_core_map.c", |
| 499 |
"plugin/core/gvrender_core_pic.c", |
| 500 |
"plugin/core/gvrender_core_pov.c", |
| 501 |
"plugin/core/gvrender_core_ps.c", |
| 502 |
"plugin/core/gvrender_core_svg.c", |
| 503 |
"plugin/core/gvrender_core_tk.c", |
| 504 |
"plugin/devil/gvdevice_devil.c", |
| 505 |
"plugin/dot_layout/gvlayout_dot_layout.c", |
| 506 |
"plugin/dot_layout/gvplugin_dot_layout.c", |
| 507 |
"plugin/gd/gvdevice_gd.c", |
| 508 |
"plugin/gd/gvloadimage_gd.c", |
| 509 |
"plugin/gd/gvplugin_gd.c", |
| 510 |
"plugin/gd/gvrender_gd.c", |
| 511 |
"plugin/gd/gvrender_gd_vrml.c", |
| 512 |
"plugin/gd/gvtextlayout_gd.c", |
| 513 |
"plugin/gdiplus/gvdevice_gdiplus.cpp", |
| 514 |
"plugin/gdiplus/gvloadimage_gdiplus.cpp", |
| 515 |
"plugin/gdiplus/gvplugin_gdiplus.cpp", |
| 516 |
"plugin/gdiplus/gvplugin_gdiplus.h", |
| 517 |
"plugin/gdiplus/gvrender_gdiplus.cpp", |
| 518 |
"plugin/gdiplus/gvtextlayout_gdiplus.cpp", |
| 519 |
"plugin/gdk/gvdevice_gdk.c", |
| 520 |
"plugin/gdk/gvloadimage_gdk.c", |
| 521 |
"plugin/gs/gvloadimage_gs.c", |
| 522 |
"plugin/lasi/gvrender_lasi.cpp", |
| 523 |
"plugin/pango/gvgetfontlist.h", |
| 524 |
"plugin/pango/gvloadimage_pango.c", |
| 525 |
"plugin/pango/gvplugin_pango.c", |
| 526 |
"plugin/pango/gvrender_pango.c", |
| 527 |
"plugin/pango/gvtextlayout_pango.c", |
| 528 |
"plugin/poppler/gvloadimage_poppler.c", |
| 529 |
"plugin/quartz/GVTextLayout.h", |
| 530 |
"plugin/quartz/GVTextLayout.m", |
| 531 |
"plugin/quartz/gvdevice_quartz.c", |
| 532 |
"plugin/quartz/gvloadimage_quartz.c", |
| 533 |
"plugin/quartz/gvplugin_quartz.c", |
| 534 |
"plugin/quartz/gvplugin_quartz.h", |
| 535 |
"plugin/quartz/gvrender_quartz.c", |
| 536 |
"plugin/quartz/gvtextlayout_quartz.c", |
| 537 |
"plugin/rsvg/gvloadimage_rsvg.c", |
| 538 |
"plugin/rsvg/gvplugin_rsvg.c", |
| 539 |
"plugin/webp/gvdevice_webp.c", |
| 540 |
"plugin/webp/gvloadimage_webp.c", |
| 541 |
"plugin/webp/gvplugin_webp.c", |
| 542 |
"tclpkg/gv/gv_builtins.c", |
| 543 |
"tclpkg/gv/gv_dummy_init.c", |
| 544 |
"tclpkg/gv/gv_java_init.c", |
| 545 |
"tclpkg/gv/gv_php_init.c", |
| 546 |
"tclpkg/gv/gv_tcl_init.c", |
| 547 |
"tclpkg/tcldot/no_builtins.c", |
| 548 |
"tclpkg/tcldot/tcldot-id.c", |
| 549 |
"tclpkg/tcldot/tcldot-io.c", |
| 550 |
"tclpkg/tcldot/tcldot-util.c", |
| 551 |
"tclpkg/tcldot/tcldot.h", |
| 552 |
"tclpkg/tcldot/tcldot_builtins.cpp", |
| 553 |
"tclpkg/tclpathplan/find_ints.c", |
| 554 |
"tclpkg/tclpathplan/intersect.c", |
| 555 |
"tclpkg/tclpathplan/makecw.c", |
| 556 |
"tclpkg/tclpathplan/simple.h", |
| 557 |
"tclpkg/tclpathplan/tclpathplan.c", |
| 558 |
"tclpkg/tclstubs/tclStubLib.c", |
| 559 |
"windows/include/unistd/unistd.h", |
| 560 |
) |
| 561 |
|
| 562 |
root = Path(__file__).parents[1] |
| 563 |
|
| 564 |
# ensure developers cannot move/delete a file without being prompted to update |
| 565 |
# the above list |
| 566 |
for source in EXCLUDE: |
| 567 |
assert ( |
| 568 |
root / source |
| 569 |
).exists(), f"{source} not found; ci/clang_format.py needs updating?" |
| 570 |
|
| 571 |
# find all C/C++ in the repository |
| 572 |
sources = subprocess.check_output( |
| 573 |
[ |
| 574 |
"git", |
| 575 |
"ls-files", |
| 576 |
"-z", |
| 577 |
"--", |
| 578 |
"**/*.c", |
| 579 |
"**/*.h", |
| 580 |
"**/*.hpp", |
| 581 |
"**/*.cpp", |
| 582 |
"**/*.C", |
| 583 |
"**/*.c++", |
| 584 |
"**/*.cxx", |
| 585 |
"**/*.cc", |
| 586 |
"**/*.m", |
| 587 |
], |
| 588 |
text=True, |
| 589 |
) |
| 590 |
|
| 591 |
ret = 0 |
| 592 |
for source in sources.split("\x00")[:-1]: |
| 593 |
print(f"checking {source}...") |
| 594 |
|
| 595 |
original = Path(source).read_text(encoding="utf-8") |
| 596 |
|
| 597 |
# ask `clang-format` to style the file |
| 598 |
reformatted = subprocess.check_output( |
| 599 |
["clang-format-19", "--style=file", "--", source], |
| 600 |
cwd=root, |
| 601 |
text=True, |
| 602 |
) |
| 603 |
|
| 604 |
if source in EXCLUDE: |
| 605 |
# ensure developers cannot make a file compliant without being prompted to |
| 606 |
# remove it from the exclude list |
| 607 |
assert ( |
| 608 |
original != reformatted |
| 609 |
), f"{source} is on the exclude list but is compliant" |
| 610 |
continue |
| 611 |
|
| 612 |
# were the before and after contents different? |
| 613 |
diff = list( |
| 614 |
difflib.unified_diff( |
| 615 |
original.splitlines(keepends=True), |
| 616 |
reformatted.splitlines(keepends=True), |
| 617 |
fromfile=source, |
| 618 |
tofile=source, |
| 619 |
) |
| 620 |
) |
| 621 |
if diff: |
| 622 |
print(f"{source} incorrectly formatted:\n{''.join(diff)}", end="") |
| 623 |
ret = -1 |
| 624 |
|
| 625 |
sys.exit(ret) |