lemongraph 0.0.1
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.
- checksums.yaml +7 -0
- data/.yardopts +8 -0
- data/LICENSE +674 -0
- data/README.md +6 -0
- data/ext/lemon-1.3.1/AUTHORS +26 -0
- data/ext/lemon-1.3.1/CMakeLists.txt +371 -0
- data/ext/lemon-1.3.1/INSTALL +167 -0
- data/ext/lemon-1.3.1/LICENSE +32 -0
- data/ext/lemon-1.3.1/NEWS +337 -0
- data/ext/lemon-1.3.1/README +50 -0
- data/ext/lemon-1.3.1/cmake/FindCOIN.cmake +110 -0
- data/ext/lemon-1.3.1/cmake/FindGLPK.cmake +55 -0
- data/ext/lemon-1.3.1/cmake/FindGhostscript.cmake +10 -0
- data/ext/lemon-1.3.1/cmake/FindILOG.cmake +102 -0
- data/ext/lemon-1.3.1/cmake/FindSOPLEX.cmake +23 -0
- data/ext/lemon-1.3.1/cmake/LEMONConfig.cmake.in +13 -0
- data/ext/lemon-1.3.1/cmake/nsis/lemon.ico +0 -0
- data/ext/lemon-1.3.1/cmake/nsis/uninstall.ico +0 -0
- data/ext/lemon-1.3.1/cmake/version.cmake +1 -0
- data/ext/lemon-1.3.1/cmake/version.cmake.in +1 -0
- data/ext/lemon-1.3.1/contrib/CMakeLists.txt +19 -0
- data/ext/lemon-1.3.1/lemon/CMakeLists.txt +91 -0
- data/ext/lemon-1.3.1/lemon/adaptors.h +3638 -0
- data/ext/lemon-1.3.1/lemon/arg_parser.cc +474 -0
- data/ext/lemon-1.3.1/lemon/arg_parser.h +440 -0
- data/ext/lemon-1.3.1/lemon/assert.h +214 -0
- data/ext/lemon-1.3.1/lemon/base.cc +37 -0
- data/ext/lemon-1.3.1/lemon/bellman_ford.h +1116 -0
- data/ext/lemon-1.3.1/lemon/bfs.h +1754 -0
- data/ext/lemon-1.3.1/lemon/bin_heap.h +347 -0
- data/ext/lemon-1.3.1/lemon/binomial_heap.h +445 -0
- data/ext/lemon-1.3.1/lemon/bits/alteration_notifier.h +472 -0
- data/ext/lemon-1.3.1/lemon/bits/array_map.h +351 -0
- data/ext/lemon-1.3.1/lemon/bits/bezier.h +174 -0
- data/ext/lemon-1.3.1/lemon/bits/default_map.h +182 -0
- data/ext/lemon-1.3.1/lemon/bits/edge_set_extender.h +627 -0
- data/ext/lemon-1.3.1/lemon/bits/enable_if.h +131 -0
- data/ext/lemon-1.3.1/lemon/bits/graph_adaptor_extender.h +401 -0
- data/ext/lemon-1.3.1/lemon/bits/graph_extender.h +1332 -0
- data/ext/lemon-1.3.1/lemon/bits/lock.h +65 -0
- data/ext/lemon-1.3.1/lemon/bits/map_extender.h +332 -0
- data/ext/lemon-1.3.1/lemon/bits/path_dump.h +177 -0
- data/ext/lemon-1.3.1/lemon/bits/solver_bits.h +194 -0
- data/ext/lemon-1.3.1/lemon/bits/traits.h +388 -0
- data/ext/lemon-1.3.1/lemon/bits/variant.h +494 -0
- data/ext/lemon-1.3.1/lemon/bits/vector_map.h +244 -0
- data/ext/lemon-1.3.1/lemon/bits/windows.cc +166 -0
- data/ext/lemon-1.3.1/lemon/bits/windows.h +44 -0
- data/ext/lemon-1.3.1/lemon/bucket_heap.h +594 -0
- data/ext/lemon-1.3.1/lemon/capacity_scaling.h +1014 -0
- data/ext/lemon-1.3.1/lemon/cbc.cc +460 -0
- data/ext/lemon-1.3.1/lemon/cbc.h +129 -0
- data/ext/lemon-1.3.1/lemon/christofides_tsp.h +254 -0
- data/ext/lemon-1.3.1/lemon/circulation.h +807 -0
- data/ext/lemon-1.3.1/lemon/clp.cc +464 -0
- data/ext/lemon-1.3.1/lemon/clp.h +164 -0
- data/ext/lemon-1.3.1/lemon/color.cc +44 -0
- data/ext/lemon-1.3.1/lemon/color.h +204 -0
- data/ext/lemon-1.3.1/lemon/concept_check.h +77 -0
- data/ext/lemon-1.3.1/lemon/concepts/bpgraph.h +1029 -0
- data/ext/lemon-1.3.1/lemon/concepts/digraph.h +491 -0
- data/ext/lemon-1.3.1/lemon/concepts/graph.h +788 -0
- data/ext/lemon-1.3.1/lemon/concepts/graph_components.h +2134 -0
- data/ext/lemon-1.3.1/lemon/concepts/heap.h +324 -0
- data/ext/lemon-1.3.1/lemon/concepts/maps.h +223 -0
- data/ext/lemon-1.3.1/lemon/concepts/path.h +312 -0
- data/ext/lemon-1.3.1/lemon/config.h.in +22 -0
- data/ext/lemon-1.3.1/lemon/connectivity.h +1688 -0
- data/ext/lemon-1.3.1/lemon/core.h +2506 -0
- data/ext/lemon-1.3.1/lemon/cost_scaling.h +1607 -0
- data/ext/lemon-1.3.1/lemon/counter.h +249 -0
- data/ext/lemon-1.3.1/lemon/cplex.cc +994 -0
- data/ext/lemon-1.3.1/lemon/cplex.h +292 -0
- data/ext/lemon-1.3.1/lemon/cycle_canceling.h +1230 -0
- data/ext/lemon-1.3.1/lemon/dfs.h +1637 -0
- data/ext/lemon-1.3.1/lemon/dheap.h +352 -0
- data/ext/lemon-1.3.1/lemon/dijkstra.h +1303 -0
- data/ext/lemon-1.3.1/lemon/dim2.h +726 -0
- data/ext/lemon-1.3.1/lemon/dimacs.h +448 -0
- data/ext/lemon-1.3.1/lemon/edge_set.h +1420 -0
- data/ext/lemon-1.3.1/lemon/edmonds_karp.h +556 -0
- data/ext/lemon-1.3.1/lemon/elevator.h +982 -0
- data/ext/lemon-1.3.1/lemon/error.h +276 -0
- data/ext/lemon-1.3.1/lemon/euler.h +287 -0
- data/ext/lemon-1.3.1/lemon/fib_heap.h +475 -0
- data/ext/lemon-1.3.1/lemon/fractional_matching.h +2139 -0
- data/ext/lemon-1.3.1/lemon/full_graph.h +1082 -0
- data/ext/lemon-1.3.1/lemon/glpk.cc +1012 -0
- data/ext/lemon-1.3.1/lemon/glpk.h +263 -0
- data/ext/lemon-1.3.1/lemon/gomory_hu.h +568 -0
- data/ext/lemon-1.3.1/lemon/graph_to_eps.h +1186 -0
- data/ext/lemon-1.3.1/lemon/greedy_tsp.h +251 -0
- data/ext/lemon-1.3.1/lemon/grid_graph.h +699 -0
- data/ext/lemon-1.3.1/lemon/grosso_locatelli_pullan_mc.h +840 -0
- data/ext/lemon-1.3.1/lemon/hao_orlin.h +1015 -0
- data/ext/lemon-1.3.1/lemon/hartmann_orlin_mmc.h +654 -0
- data/ext/lemon-1.3.1/lemon/howard_mmc.h +651 -0
- data/ext/lemon-1.3.1/lemon/hypercube_graph.h +459 -0
- data/ext/lemon-1.3.1/lemon/insertion_tsp.h +533 -0
- data/ext/lemon-1.3.1/lemon/karp_mmc.h +590 -0
- data/ext/lemon-1.3.1/lemon/kruskal.h +324 -0
- data/ext/lemon-1.3.1/lemon/lemon.pc.in +10 -0
- data/ext/lemon-1.3.1/lemon/lgf_reader.h +3854 -0
- data/ext/lemon-1.3.1/lemon/lgf_writer.h +2687 -0
- data/ext/lemon-1.3.1/lemon/list_graph.h +2510 -0
- data/ext/lemon-1.3.1/lemon/lp.h +95 -0
- data/ext/lemon-1.3.1/lemon/lp_base.cc +30 -0
- data/ext/lemon-1.3.1/lemon/lp_base.h +2147 -0
- data/ext/lemon-1.3.1/lemon/lp_skeleton.cc +143 -0
- data/ext/lemon-1.3.1/lemon/lp_skeleton.h +234 -0
- data/ext/lemon-1.3.1/lemon/maps.h +4057 -0
- data/ext/lemon-1.3.1/lemon/matching.h +3505 -0
- data/ext/lemon-1.3.1/lemon/math.h +77 -0
- data/ext/lemon-1.3.1/lemon/max_cardinality_search.h +794 -0
- data/ext/lemon-1.3.1/lemon/min_cost_arborescence.h +808 -0
- data/ext/lemon-1.3.1/lemon/nagamochi_ibaraki.h +702 -0
- data/ext/lemon-1.3.1/lemon/nauty_reader.h +113 -0
- data/ext/lemon-1.3.1/lemon/nearest_neighbor_tsp.h +238 -0
- data/ext/lemon-1.3.1/lemon/network_simplex.h +1659 -0
- data/ext/lemon-1.3.1/lemon/opt2_tsp.h +367 -0
- data/ext/lemon-1.3.1/lemon/pairing_heap.h +474 -0
- data/ext/lemon-1.3.1/lemon/path.h +1164 -0
- data/ext/lemon-1.3.1/lemon/planarity.h +2754 -0
- data/ext/lemon-1.3.1/lemon/preflow.h +985 -0
- data/ext/lemon-1.3.1/lemon/quad_heap.h +343 -0
- data/ext/lemon-1.3.1/lemon/radix_heap.h +438 -0
- data/ext/lemon-1.3.1/lemon/radix_sort.h +487 -0
- data/ext/lemon-1.3.1/lemon/random.cc +29 -0
- data/ext/lemon-1.3.1/lemon/random.h +1005 -0
- data/ext/lemon-1.3.1/lemon/smart_graph.h +1344 -0
- data/ext/lemon-1.3.1/lemon/soplex.cc +465 -0
- data/ext/lemon-1.3.1/lemon/soplex.h +158 -0
- data/ext/lemon-1.3.1/lemon/static_graph.h +476 -0
- data/ext/lemon-1.3.1/lemon/suurballe.h +776 -0
- data/ext/lemon-1.3.1/lemon/time_measure.h +610 -0
- data/ext/lemon-1.3.1/lemon/tolerance.h +242 -0
- data/ext/lemon-1.3.1/lemon/unionfind.h +1824 -0
- data/ext/lemon-1.3.1/scripts/unify-sources.sh +390 -0
- data/ext/lemon-1.3.1/scripts/valgrind-wrapper.sh +22 -0
- data/ext/lemongraph/arc_map.cc +1007 -0
- data/ext/lemongraph/digraph.cc +282 -0
- data/ext/lemongraph/digraph_arc.cc +153 -0
- data/ext/lemongraph/digraph_node.cc +277 -0
- data/ext/lemongraph/edge_map.cc +770 -0
- data/ext/lemongraph/extconf.rb +53 -0
- data/ext/lemongraph/graph.cc +351 -0
- data/ext/lemongraph/graph_arc.cc +95 -0
- data/ext/lemongraph/graph_edge.cc +153 -0
- data/ext/lemongraph/graph_item.cc +76 -0
- data/ext/lemongraph/graph_node.cc +321 -0
- data/ext/lemongraph/lemongraph.cc +260 -0
- data/ext/lemongraph/lemongraph.hh +295 -0
- data/ext/lemongraph/lemongraph.map +6 -0
- data/ext/lemongraph/lemongraph_export.hh +31 -0
- data/ext/lemongraph/node_map.cc +1011 -0
- data/lemongraph.gemspec +176 -0
- data/lib/lemongraph/graphviz.rb +240 -0
- data/lib/lemongraph/version.rb +4 -0
- data/lib/lemongraph.rb +21 -0
- data/samples/lemondeps.rb +38 -0
- metadata +202 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# This file is a part of LEMON, a generic C++ optimization library.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2003-2009
|
|
6
|
+
# Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
|
7
|
+
# (Egervary Research Group on Combinatorial Optimization, EGRES).
|
|
8
|
+
#
|
|
9
|
+
# Permission to use, modify and distribute this software is granted
|
|
10
|
+
# provided that this copyright notice appears in all copies. For
|
|
11
|
+
# precise terms see the accompanying LICENSE file.
|
|
12
|
+
#
|
|
13
|
+
# This software is provided "AS IS" with no warranty of any kind,
|
|
14
|
+
# express or implied, and with no claim as to its suitability for any
|
|
15
|
+
# purpose.
|
|
16
|
+
|
|
17
|
+
YEAR=`date +%Y`
|
|
18
|
+
HGROOT=`hg root`
|
|
19
|
+
|
|
20
|
+
function hg_year() {
|
|
21
|
+
if [ -n "$(hg st $1)" ]; then
|
|
22
|
+
echo $YEAR
|
|
23
|
+
else
|
|
24
|
+
hg log -l 1 --template='{date|isodate}\n' $1 |
|
|
25
|
+
cut -d '-' -f 1
|
|
26
|
+
fi
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# file enumaration modes
|
|
30
|
+
|
|
31
|
+
function all_files() {
|
|
32
|
+
hg status -a -m -c |
|
|
33
|
+
cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' |
|
|
34
|
+
while read file; do echo $HGROOT/$file; done
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function modified_files() {
|
|
38
|
+
hg status -a -m |
|
|
39
|
+
cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' |
|
|
40
|
+
while read file; do echo $HGROOT/$file; done
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function changed_files() {
|
|
44
|
+
{
|
|
45
|
+
if [ -n "$HG_PARENT1" ]
|
|
46
|
+
then
|
|
47
|
+
hg status --rev $HG_PARENT1:$HG_NODE -a -m
|
|
48
|
+
fi
|
|
49
|
+
if [ -n "$HG_PARENT2" ]
|
|
50
|
+
then
|
|
51
|
+
hg status --rev $HG_PARENT2:$HG_NODE -a -m
|
|
52
|
+
fi
|
|
53
|
+
} | cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' |
|
|
54
|
+
sort | uniq |
|
|
55
|
+
while read file; do echo $HGROOT/$file; done
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function given_files() {
|
|
59
|
+
for file in $GIVEN_FILES
|
|
60
|
+
do
|
|
61
|
+
echo $file
|
|
62
|
+
done
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# actions
|
|
66
|
+
|
|
67
|
+
function update_action() {
|
|
68
|
+
if ! diff -q $1 $2 >/dev/null
|
|
69
|
+
then
|
|
70
|
+
echo -n " [$3 updated]"
|
|
71
|
+
rm $2
|
|
72
|
+
mv $1 $2
|
|
73
|
+
CHANGED=YES
|
|
74
|
+
fi
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function update_warning() {
|
|
78
|
+
echo -n " [$2 warning]"
|
|
79
|
+
WARNED=YES
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function update_init() {
|
|
83
|
+
echo Update source files...
|
|
84
|
+
TOTAL_FILES=0
|
|
85
|
+
CHANGED_FILES=0
|
|
86
|
+
WARNED_FILES=0
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function update_done() {
|
|
90
|
+
echo $CHANGED_FILES out of $TOTAL_FILES files has been changed.
|
|
91
|
+
echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings.
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function update_begin() {
|
|
95
|
+
((TOTAL_FILES++))
|
|
96
|
+
CHANGED=NO
|
|
97
|
+
WARNED=NO
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function update_end() {
|
|
101
|
+
if [ $CHANGED == YES ]
|
|
102
|
+
then
|
|
103
|
+
((++CHANGED_FILES))
|
|
104
|
+
fi
|
|
105
|
+
if [ $WARNED == YES ]
|
|
106
|
+
then
|
|
107
|
+
((++WARNED_FILES))
|
|
108
|
+
fi
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function check_action() {
|
|
112
|
+
if [ "$3" == 'tabs' ]
|
|
113
|
+
then
|
|
114
|
+
if echo $2 | grep -q -v -E 'Makefile\.am$'
|
|
115
|
+
then
|
|
116
|
+
PATTERN=$(echo -e '\t')
|
|
117
|
+
else
|
|
118
|
+
PATTERN=' '
|
|
119
|
+
fi
|
|
120
|
+
elif [ "$3" == 'trailing spaces' ]
|
|
121
|
+
then
|
|
122
|
+
PATTERN='\ +$'
|
|
123
|
+
else
|
|
124
|
+
PATTERN='*'
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
if ! diff -q $1 $2 >/dev/null
|
|
128
|
+
then
|
|
129
|
+
if [ "$PATTERN" == '*' ]
|
|
130
|
+
then
|
|
131
|
+
diff $1 $2 | grep '^[0-9]' | sed "s|^\(.*\)c.*$|$2:\1: check failed: $3|g" |
|
|
132
|
+
sed "s/:\([0-9]*\),\([0-9]*\):\(.*\)$/:\1:\3 (until line \2)/g"
|
|
133
|
+
else
|
|
134
|
+
grep -n -E "$PATTERN" $2 | sed "s|^\([0-9]*\):.*$|$2:\1: check failed: $3|g"
|
|
135
|
+
fi
|
|
136
|
+
FAILED=YES
|
|
137
|
+
fi
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function check_warning() {
|
|
141
|
+
if [ "$2" == 'long lines' ]
|
|
142
|
+
then
|
|
143
|
+
grep -n -E '.{81,}' $1 | sed "s|^\([0-9]*\):.*$|$1:\1: warning: $2|g"
|
|
144
|
+
else
|
|
145
|
+
echo "$1: warning: $2"
|
|
146
|
+
fi
|
|
147
|
+
WARNED=YES
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function check_init() {
|
|
151
|
+
echo Check source files...
|
|
152
|
+
FAILED_FILES=0
|
|
153
|
+
WARNED_FILES=0
|
|
154
|
+
TOTAL_FILES=0
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function check_done() {
|
|
158
|
+
echo $FAILED_FILES out of $TOTAL_FILES files has been failed.
|
|
159
|
+
echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings.
|
|
160
|
+
|
|
161
|
+
if [ $WARNED_FILES -gt 0 -o $FAILED_FILES -gt 0 ]
|
|
162
|
+
then
|
|
163
|
+
if [ "$WARNING" == 'INTERACTIVE' ]
|
|
164
|
+
then
|
|
165
|
+
echo -n "Are the files with errors/warnings acceptable? (yes/no) "
|
|
166
|
+
while read answer
|
|
167
|
+
do
|
|
168
|
+
if [ "$answer" == 'yes' ]
|
|
169
|
+
then
|
|
170
|
+
return 0
|
|
171
|
+
elif [ "$answer" == 'no' ]
|
|
172
|
+
then
|
|
173
|
+
return 1
|
|
174
|
+
fi
|
|
175
|
+
echo -n "Are the files with errors/warnings acceptable? (yes/no) "
|
|
176
|
+
done
|
|
177
|
+
elif [ "$WARNING" == 'WERROR' ]
|
|
178
|
+
then
|
|
179
|
+
return 1
|
|
180
|
+
fi
|
|
181
|
+
fi
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function check_begin() {
|
|
185
|
+
((TOTAL_FILES++))
|
|
186
|
+
FAILED=NO
|
|
187
|
+
WARNED=NO
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function check_end() {
|
|
191
|
+
if [ $FAILED == YES ]
|
|
192
|
+
then
|
|
193
|
+
((++FAILED_FILES))
|
|
194
|
+
fi
|
|
195
|
+
if [ $WARNED == YES ]
|
|
196
|
+
then
|
|
197
|
+
((++WARNED_FILES))
|
|
198
|
+
fi
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
# checks
|
|
204
|
+
|
|
205
|
+
function header_check() {
|
|
206
|
+
if echo $1 | grep -q -E 'Makefile\.am$'
|
|
207
|
+
then
|
|
208
|
+
return
|
|
209
|
+
fi
|
|
210
|
+
|
|
211
|
+
TMP_FILE=`mktemp`
|
|
212
|
+
|
|
213
|
+
(echo "/* -*- mode: C++; indent-tabs-mode: nil; -*-
|
|
214
|
+
*
|
|
215
|
+
* This file is a part of LEMON, a generic C++ optimization library.
|
|
216
|
+
*
|
|
217
|
+
* Copyright (C) 2003-"$(hg_year $1)"
|
|
218
|
+
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
|
219
|
+
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
|
220
|
+
*
|
|
221
|
+
* Permission to use, modify and distribute this software is granted
|
|
222
|
+
* provided that this copyright notice appears in all copies. For
|
|
223
|
+
* precise terms see the accompanying LICENSE file.
|
|
224
|
+
*
|
|
225
|
+
* This software is provided \"AS IS\" with no warranty of any kind,
|
|
226
|
+
* express or implied, and with no claim as to its suitability for any
|
|
227
|
+
* purpose.
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
230
|
+
"
|
|
231
|
+
awk 'BEGIN { pm=0; }
|
|
232
|
+
pm==3 { print }
|
|
233
|
+
/\/\* / && pm==0 { pm=1;}
|
|
234
|
+
/[^:blank:]/ && (pm==0 || pm==2) { pm=3; print;}
|
|
235
|
+
/\*\// && pm==1 { pm=2;}
|
|
236
|
+
' $1
|
|
237
|
+
) >$TMP_FILE
|
|
238
|
+
|
|
239
|
+
"$ACTION"_action "$TMP_FILE" "$1" header
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function tabs_check() {
|
|
243
|
+
if echo $1 | grep -q -v -E 'Makefile\.am$'
|
|
244
|
+
then
|
|
245
|
+
OLD_PATTERN=$(echo -e '\t')
|
|
246
|
+
NEW_PATTERN=' '
|
|
247
|
+
else
|
|
248
|
+
OLD_PATTERN=' '
|
|
249
|
+
NEW_PATTERN=$(echo -e '\t')
|
|
250
|
+
fi
|
|
251
|
+
TMP_FILE=`mktemp`
|
|
252
|
+
cat $1 | sed -e "s/$OLD_PATTERN/$NEW_PATTERN/g" >$TMP_FILE
|
|
253
|
+
|
|
254
|
+
"$ACTION"_action "$TMP_FILE" "$1" 'tabs'
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function spaces_check() {
|
|
258
|
+
TMP_FILE=`mktemp`
|
|
259
|
+
cat $1 | sed -e 's/ \+$//g' >$TMP_FILE
|
|
260
|
+
|
|
261
|
+
"$ACTION"_action "$TMP_FILE" "$1" 'trailing spaces'
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function long_lines_check() {
|
|
265
|
+
if cat $1 | grep -q -E '.{81,}'
|
|
266
|
+
then
|
|
267
|
+
"$ACTION"_warning $1 'long lines'
|
|
268
|
+
fi
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
# process the file
|
|
272
|
+
|
|
273
|
+
function process_file() {
|
|
274
|
+
if [ "$ACTION" == 'update' ]
|
|
275
|
+
then
|
|
276
|
+
echo -n " $ACTION $1..."
|
|
277
|
+
else
|
|
278
|
+
echo " $ACTION $1..."
|
|
279
|
+
fi
|
|
280
|
+
|
|
281
|
+
CHECKING="header tabs spaces long_lines"
|
|
282
|
+
|
|
283
|
+
"$ACTION"_begin $1
|
|
284
|
+
for check in $CHECKING
|
|
285
|
+
do
|
|
286
|
+
"$check"_check $1
|
|
287
|
+
done
|
|
288
|
+
"$ACTION"_end $1
|
|
289
|
+
if [ "$ACTION" == 'update' ]
|
|
290
|
+
then
|
|
291
|
+
echo
|
|
292
|
+
fi
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function process_all {
|
|
296
|
+
"$ACTION"_init
|
|
297
|
+
while read file
|
|
298
|
+
do
|
|
299
|
+
process_file $file
|
|
300
|
+
done < <($FILES)
|
|
301
|
+
"$ACTION"_done
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
while [ $# -gt 0 ]
|
|
305
|
+
do
|
|
306
|
+
|
|
307
|
+
if [ "$1" == '--help' ] || [ "$1" == '-h' ]
|
|
308
|
+
then
|
|
309
|
+
echo -n \
|
|
310
|
+
"Usage:
|
|
311
|
+
$0 [OPTIONS] [files]
|
|
312
|
+
Options:
|
|
313
|
+
--dry-run|-n
|
|
314
|
+
Check the files, but do not modify them.
|
|
315
|
+
--interactive|-i
|
|
316
|
+
If --dry-run is specified and the checker emits warnings,
|
|
317
|
+
then the user is asked if the warnings should be considered
|
|
318
|
+
errors.
|
|
319
|
+
--werror|-w
|
|
320
|
+
Make all warnings into errors.
|
|
321
|
+
--all|-a
|
|
322
|
+
Check all source files in the repository.
|
|
323
|
+
--modified|-m
|
|
324
|
+
Check only the modified (and new) source files. This option is
|
|
325
|
+
useful to check the modification before making a commit.
|
|
326
|
+
--changed|-c
|
|
327
|
+
Check only the changed source files compared to the parent(s) of
|
|
328
|
+
the current hg node. This option is useful as hg hook script.
|
|
329
|
+
To automatically check all your changes before making a commit,
|
|
330
|
+
add the following section to the appropriate .hg/hgrc file.
|
|
331
|
+
|
|
332
|
+
[hooks]
|
|
333
|
+
pretxncommit.checksources = scripts/unify-sources.sh -c -n -i
|
|
334
|
+
|
|
335
|
+
--help|-h
|
|
336
|
+
Print this help message.
|
|
337
|
+
files
|
|
338
|
+
The files to check/unify. If no file names are given, the modified
|
|
339
|
+
source files will be checked/unified (just like using the
|
|
340
|
+
--modified|-m option).
|
|
341
|
+
"
|
|
342
|
+
exit 0
|
|
343
|
+
elif [ "$1" == '--dry-run' ] || [ "$1" == '-n' ]
|
|
344
|
+
then
|
|
345
|
+
[ -n "$ACTION" ] && echo "Conflicting action options" >&2 && exit 1
|
|
346
|
+
ACTION=check
|
|
347
|
+
elif [ "$1" == "--all" ] || [ "$1" == '-a' ]
|
|
348
|
+
then
|
|
349
|
+
[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1
|
|
350
|
+
FILES=all_files
|
|
351
|
+
elif [ "$1" == "--changed" ] || [ "$1" == '-c' ]
|
|
352
|
+
then
|
|
353
|
+
[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1
|
|
354
|
+
FILES=changed_files
|
|
355
|
+
elif [ "$1" == "--modified" ] || [ "$1" == '-m' ]
|
|
356
|
+
then
|
|
357
|
+
[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1
|
|
358
|
+
FILES=modified_files
|
|
359
|
+
elif [ "$1" == "--interactive" ] || [ "$1" == "-i" ]
|
|
360
|
+
then
|
|
361
|
+
[ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1
|
|
362
|
+
WARNING='INTERACTIVE'
|
|
363
|
+
elif [ "$1" == "--werror" ] || [ "$1" == "-w" ]
|
|
364
|
+
then
|
|
365
|
+
[ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1
|
|
366
|
+
WARNING='WERROR'
|
|
367
|
+
elif [ $(echo x$1 | cut -c 2) == '-' ]
|
|
368
|
+
then
|
|
369
|
+
echo "Invalid option $1" >&2 && exit 1
|
|
370
|
+
else
|
|
371
|
+
[ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1
|
|
372
|
+
GIVEN_FILES=$@
|
|
373
|
+
FILES=given_files
|
|
374
|
+
break
|
|
375
|
+
fi
|
|
376
|
+
|
|
377
|
+
shift
|
|
378
|
+
done
|
|
379
|
+
|
|
380
|
+
if [ -z $FILES ]
|
|
381
|
+
then
|
|
382
|
+
FILES=modified_files
|
|
383
|
+
fi
|
|
384
|
+
|
|
385
|
+
if [ -z $ACTION ]
|
|
386
|
+
then
|
|
387
|
+
ACTION=update
|
|
388
|
+
fi
|
|
389
|
+
|
|
390
|
+
process_all
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# Run in valgrind, with leak checking enabled
|
|
4
|
+
|
|
5
|
+
valgrind -q --leak-check=full "$@" 2> .valgrind-log
|
|
6
|
+
|
|
7
|
+
# Save the test result
|
|
8
|
+
|
|
9
|
+
result="$?"
|
|
10
|
+
|
|
11
|
+
# Valgrind should generate no error messages
|
|
12
|
+
|
|
13
|
+
log_contents="`cat .valgrind-log`"
|
|
14
|
+
|
|
15
|
+
if [ "$log_contents" != "" ]; then
|
|
16
|
+
cat .valgrind-log >&2
|
|
17
|
+
result=1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
rm -f .valgrind-log
|
|
21
|
+
|
|
22
|
+
exit $result
|