adlint 2.6.14 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -3
- data/ChangeLog +511 -0
- data/INSTALL +1 -1
- data/MANIFEST +57 -37
- data/NEWS +36 -7
- data/README +2 -2
- data/Rakefile +6 -6
- data/TODO +1 -1
- data/bin/adlint +25 -16
- data/bin/adlint_chk +22 -12
- data/bin/adlint_cma +17 -12
- data/bin/adlint_sma +22 -12
- data/bin/adlintize +98 -17
- data/etc/conf.d/fallback/cinit.erb +1 -1
- data/etc/conf.d/fallback/traits.erb +37 -37
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
- data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
- data/etc/conf.d/noarch/pinit.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
- data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
- data/etc/mesg.d/core/en_US/messages.yml +2 -2
- data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
- data/features/code_check/W0018.feature +197 -0
- data/features/code_check/W0019.feature +79 -0
- data/features/code_check/W0021.feature +81 -0
- data/features/code_check/W0023.feature +203 -0
- data/features/code_check/W0024.feature +226 -0
- data/features/code_check/W0025.feature +5 -0
- data/features/code_check/W0088.feature +2 -2
- data/features/code_check/W0109.feature +2 -2
- data/features/code_check/W0477.feature +0 -3
- data/features/code_check/W0478.feature +0 -1
- data/features/code_check/W0582.feature +3 -3
- data/features/code_check/W0583.feature +4 -7
- data/features/code_check/W0646.feature +0 -1
- data/features/code_check/W0695.feature +0 -1
- data/features/code_check/W0705.feature +8 -0
- data/features/code_check/W0723.feature +0 -1
- data/features/code_check/W0745.feature +1 -0
- data/features/code_check/W0781.feature +1 -0
- data/features/code_check/W1057.feature +141 -0
- data/features/code_check/W1058.feature +93 -0
- data/features/code_check/W1059.feature +86 -0
- data/features/code_check/W1060.feature +77 -0
- data/features/code_check/W1061.feature +143 -0
- data/features/code_check/W1062.feature +162 -0
- data/features/code_check/W1063.feature +123 -0
- data/features/code_check/W1064.feature +83 -0
- data/features/code_check/W1065.feature +82 -0
- data/features/code_check/W9003.feature +2 -0
- data/features/step_definitions/code_check_steps.rb +1 -0
- data/features/support/env.rb +16 -13
- data/lib/adlint.rb +7 -4
- data/lib/adlint/analyzer.rb +131 -157
- data/lib/adlint/annot.rb +149 -0
- data/lib/adlint/cc1.rb +57 -0
- data/lib/adlint/{c → cc1}/branch.rb +74 -62
- data/lib/adlint/{c → cc1}/builtin.rb +21 -21
- data/lib/adlint/{c → cc1}/const.rb +119 -117
- data/lib/adlint/{c → cc1}/conv.rb +76 -78
- data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
- data/lib/adlint/cc1/domain.rb +8103 -0
- data/lib/adlint/{c → cc1}/enum.rb +3 -3
- data/lib/adlint/{c → cc1}/environ.rb +21 -21
- data/lib/adlint/{c → cc1}/expr.rb +232 -218
- data/lib/adlint/{c → cc1}/format.rb +305 -342
- data/lib/adlint/{c → cc1}/interp.rb +269 -220
- data/lib/adlint/cc1/lexer.rb +246 -0
- data/lib/adlint/{c → cc1}/mediator.rb +78 -84
- data/lib/adlint/{c → cc1}/object.rb +261 -264
- data/lib/adlint/{c → cc1}/operator.rb +7 -7
- data/lib/adlint/{c → cc1}/option.rb +4 -3
- data/lib/adlint/{c → cc1}/parser.rb +274 -506
- data/lib/adlint/{c → cc1}/parser.y +69 -301
- data/lib/adlint/cc1/phase.rb +138 -0
- data/lib/adlint/{c → cc1}/resolver.rb +66 -78
- data/lib/adlint/{c → cc1}/scanner.rb +57 -49
- data/lib/adlint/{c → cc1}/scope.rb +3 -3
- data/lib/adlint/{c → cc1}/seqp.rb +13 -5
- data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
- data/lib/adlint/{c → cc1}/type.rb +1498 -1479
- data/lib/adlint/{c → cc1}/util.rb +20 -12
- data/lib/adlint/{c → cc1}/value.rb +699 -642
- data/lib/adlint/code.rb +163 -164
- data/lib/adlint/cpp.rb +2 -2
- data/lib/adlint/cpp/asm.rb +13 -14
- data/lib/adlint/cpp/constexpr.rb +42 -38
- data/lib/adlint/cpp/constexpr.y +44 -40
- data/lib/adlint/cpp/eval.rb +435 -435
- data/lib/adlint/cpp/lexer.rb +343 -340
- data/lib/adlint/cpp/macro.rb +188 -190
- data/lib/adlint/cpp/phase.rb +66 -45
- data/lib/adlint/cpp/scanner.rb +14 -17
- data/lib/adlint/cpp/source.rb +49 -55
- data/lib/adlint/cpp/subst.rb +65 -65
- data/lib/adlint/cpp/syntax.rb +155 -275
- data/lib/adlint/cpp/util.rb +22 -19
- data/lib/adlint/driver.rb +86 -93
- data/lib/adlint/error.rb +33 -52
- data/lib/adlint/exam.rb +158 -24
- data/lib/adlint/exam/c_builtin.rb +7 -7
- data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
- data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
- data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
- data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
- data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
- data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
- data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
- data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
- data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
- data/lib/adlint/lang.rb +25 -25
- data/lib/adlint/ld.rb +2 -2
- data/lib/adlint/ld/object.rb +220 -188
- data/lib/adlint/ld/phase.rb +94 -63
- data/lib/adlint/ld/typedef.rb +22 -11
- data/lib/adlint/ld/util.rb +43 -35
- data/lib/adlint/lexer.rb +59 -56
- data/lib/adlint/location.rb +140 -0
- data/lib/adlint/memo.rb +157 -0
- data/lib/adlint/message.rb +207 -156
- data/lib/adlint/metric.rb +139 -217
- data/lib/adlint/monitor.rb +45 -43
- data/lib/adlint/phase.rb +56 -29
- data/lib/adlint/prelude.rb +66 -54
- data/lib/adlint/report.rb +253 -332
- data/lib/adlint/source.rb +26 -27
- data/lib/adlint/supp.rb +131 -0
- data/lib/adlint/symbol.rb +14 -16
- data/lib/adlint/token.rb +19 -91
- data/lib/adlint/traits.rb +242 -226
- data/lib/adlint/util.rb +116 -205
- data/lib/adlint/version.rb +8 -8
- data/share/HEADER +2 -2
- data/share/doc/developers_guide_ja.html +148 -19
- data/share/doc/developers_guide_ja.texi +141 -11
- data/share/doc/samples/GNUmakefile +1 -1
- data/share/doc/samples/adlint_traits.yml +45 -36
- data/share/doc/users_guide_en.html +1321 -1252
- data/share/doc/users_guide_en.texi +475 -408
- data/share/doc/users_guide_ja.html +1932 -1878
- data/share/doc/users_guide_ja.texi +324 -273
- data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
- data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
- data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
- data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
- data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
- data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
- data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
- data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
- data/spec/conf.d/default_traits.yml +38 -37
- data/spec/conf.d/empty_cinit.h +1 -1
- data/spec/conf.d/empty_pinit.h +1 -1
- data/spec/conf.d/project/foo.c +0 -0
- data/spec/spec_helper.rb +2 -2
- metadata +60 -40
- data/lib/adlint/c/domain.rb +0 -7931
- data/lib/adlint/c/lexer.rb +0 -252
- data/lib/adlint/c/phase.rb +0 -135
- data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
- data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
- data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
- data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
data/lib/adlint/monitor.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Progress monitoring mechanism.
|
2
2
|
#
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
5
5
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
6
6
|
#
|
7
7
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
12
12
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
13
13
|
# / __ |/ /_/ / /___/ / /| / / /
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
15
15
|
#
|
16
16
|
# This file is part of AdLint.
|
17
17
|
#
|
@@ -36,56 +36,55 @@ require "adlint/report"
|
|
36
36
|
module AdLint #:nodoc:
|
37
37
|
|
38
38
|
module MonitorUtil
|
39
|
+
# NOTE: Host class must respond to #monitor.
|
40
|
+
|
39
41
|
def monitored_region(title, total = 1)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
monitor.start(title, total)
|
43
|
+
retval = yield(monitor)
|
44
|
+
monitor.finish
|
45
|
+
retval
|
44
46
|
rescue Error
|
45
|
-
|
47
|
+
monitor.abort
|
46
48
|
raise
|
47
49
|
rescue => ex
|
48
|
-
|
49
|
-
raise InternalError.new(ex,
|
50
|
+
monitor.abort
|
51
|
+
raise InternalError.new(ex, monitor.location)
|
50
52
|
end
|
51
|
-
module_function :monitored_region
|
52
53
|
|
53
|
-
def checkpoint(
|
54
|
-
case
|
54
|
+
def checkpoint(loc_or_num)
|
55
|
+
case loc_or_num
|
55
56
|
when Location
|
56
|
-
|
57
|
+
monitor.location = loc_or_num
|
57
58
|
when Numeric
|
58
|
-
|
59
|
+
monitor.progress = loc_or_num
|
59
60
|
end
|
60
61
|
end
|
61
|
-
module_function :checkpoint
|
62
62
|
end
|
63
63
|
|
64
64
|
class ProgressMonitor
|
65
|
-
|
65
|
+
def initialize(fpath, phase_num, verbose)
|
66
|
+
@fpath = fpath
|
67
|
+
@phase_num = phase_num
|
68
|
+
@verbose = verbose
|
69
|
+
@start_time = Time.now
|
70
|
+
@cur_phase = 0
|
71
|
+
end
|
66
72
|
|
67
73
|
attr_reader :location
|
68
74
|
attr_reader :progress
|
69
75
|
|
70
|
-
def reset(fpath, phase_num)
|
71
|
-
@fpath = fpath
|
72
|
-
@phase_num = phase_num
|
73
|
-
@current_phase = 0
|
74
|
-
@start_time = Time.now
|
75
|
-
end
|
76
|
-
|
77
76
|
def start(title, total = 1)
|
78
|
-
@total
|
79
|
-
@title
|
77
|
+
@total = total
|
78
|
+
@title = title
|
80
79
|
@location = nil
|
81
80
|
@progress = 0
|
82
|
-
@
|
81
|
+
@cur_phase += 1
|
83
82
|
draw
|
84
83
|
end
|
85
84
|
|
86
85
|
def finish
|
87
86
|
@progress = @total
|
88
|
-
if @
|
87
|
+
if @cur_phase == @phase_num
|
89
88
|
draw_finished
|
90
89
|
else
|
91
90
|
draw
|
@@ -96,39 +95,42 @@ module AdLint #:nodoc:
|
|
96
95
|
draw_aborted
|
97
96
|
end
|
98
97
|
|
99
|
-
def location=(
|
100
|
-
@location =
|
101
|
-
if false &&
|
102
|
-
self.progress = location.line_no
|
98
|
+
def location=(loc)
|
99
|
+
@location = loc
|
100
|
+
if false && @fpath.identical?(@location.fpath)
|
101
|
+
self.progress = @location.line_no
|
103
102
|
end
|
104
103
|
end
|
105
104
|
|
106
|
-
def progress=(
|
107
|
-
@progress =
|
105
|
+
def progress=(val)
|
106
|
+
@progress = val
|
108
107
|
draw
|
109
108
|
end
|
110
109
|
|
111
110
|
private
|
112
111
|
def draw
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
if @verbose
|
113
|
+
draw_bar(@fpath, @title)
|
114
|
+
print " %3d%%" % (total_progress * 100).to_i
|
115
|
+
end
|
116
116
|
end
|
117
117
|
|
118
118
|
def draw_finished
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
if @verbose
|
120
|
+
draw_bar(@fpath, "fin")
|
121
|
+
puts " %.3fs" % (Time.now - @start_time)
|
122
|
+
end
|
122
123
|
end
|
123
124
|
|
124
125
|
def draw_aborted
|
125
|
-
|
126
|
-
|
127
|
-
|
126
|
+
if @verbose
|
127
|
+
draw_bar(@fpath, @title)
|
128
|
+
puts " %.3fs!" % (Time.now - @start_time)
|
129
|
+
end
|
128
130
|
end
|
129
131
|
|
130
132
|
def total_progress
|
131
|
-
phase_start
|
133
|
+
phase_start = (@cur_phase - 1).to_f / @phase_num
|
132
134
|
phase_progress = @progress.to_f / @total / @phase_num
|
133
135
|
phase_start + phase_progress
|
134
136
|
end
|
data/lib/adlint/phase.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Base of analysis phase classes.
|
2
2
|
#
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
5
5
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
6
6
|
#
|
7
7
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
12
12
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
13
13
|
# / __ |/ /_/ / /___/ / /| / / /
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
15
15
|
#
|
16
16
|
# This file is part of AdLint.
|
17
17
|
#
|
@@ -44,22 +44,22 @@ module AdLint #:nodoc:
|
|
44
44
|
# Constructs an analysis pass.
|
45
45
|
#
|
46
46
|
# === PARAMETER
|
47
|
-
#
|
48
|
-
def initialize(
|
49
|
-
@
|
50
|
-
@
|
47
|
+
# _phase_ctxt_:: PhaseContext -- Analysis context.
|
48
|
+
def initialize(phase_ctxt, pkg_name, phase_name)
|
49
|
+
@phase_ctxt = phase_ctxt
|
50
|
+
@pkg_name = pkg_name
|
51
51
|
@phase_name = phase_name
|
52
52
|
end
|
53
53
|
|
54
54
|
# === DESCRIPTION
|
55
55
|
# Executes the analysis.
|
56
56
|
def execute
|
57
|
-
monitored_region(@phase_name) do |
|
58
|
-
do_execute(@
|
59
|
-
register_examinations
|
57
|
+
monitored_region(@phase_name) do |mon|
|
58
|
+
do_execute(@phase_ctxt, mon)
|
59
|
+
register_examinations(@phase_ctxt)
|
60
60
|
end
|
61
61
|
rescue Error => ex
|
62
|
-
|
62
|
+
report.write_message(FatalErrorMessage.new(message_catalog, ex))
|
63
63
|
raise
|
64
64
|
end
|
65
65
|
|
@@ -68,47 +68,74 @@ module AdLint #:nodoc:
|
|
68
68
|
# Executes the analysis.
|
69
69
|
#
|
70
70
|
# Subclasses must implement this method.
|
71
|
-
def do_execute(
|
71
|
+
def do_execute(phase_ctxt, monitor)
|
72
72
|
subclass_responsibility
|
73
73
|
end
|
74
74
|
|
75
|
-
def register_examinations
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
75
|
+
def register_examinations(phase_ctxt)
|
76
|
+
key = context_key_of("examinations")
|
77
|
+
phase_ctxt[key] ||= []
|
78
|
+
traits.exam_packages.each do |exam_pkg|
|
79
|
+
exam_pkg.catalog.examination_classes.each do |exam_class|
|
80
|
+
next unless exam_class.registrant_phase_class == self.class
|
81
|
+
if exam_class.required?(phase_ctxt)
|
82
|
+
phase_ctxt[key].push(exam_class.new(phase_ctxt))
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
88
|
def examinations
|
88
|
-
@
|
89
|
+
@phase_ctxt[context_key_of("examinations")] || []
|
89
90
|
end
|
90
91
|
|
91
92
|
def context_key_of(str)
|
92
|
-
"#{@
|
93
|
+
"#{@pkg_name}_#{str}".to_sym
|
93
94
|
end
|
95
|
+
|
96
|
+
extend Forwardable
|
97
|
+
|
98
|
+
def_delegator :@phase_ctxt, :traits
|
99
|
+
private :traits
|
100
|
+
|
101
|
+
def_delegator :@phase_ctxt, :report
|
102
|
+
private :report
|
103
|
+
|
104
|
+
def_delegator :@phase_ctxt, :message_catalog
|
105
|
+
private :message_catalog
|
106
|
+
|
107
|
+
def_delegator :@phase_ctxt, :monitor
|
108
|
+
private :monitor
|
109
|
+
|
110
|
+
def_delegator :@phase_ctxt, :logger
|
111
|
+
private :logger
|
94
112
|
end
|
95
113
|
|
96
114
|
class PhaseContext < Hash
|
97
|
-
def initialize(report,
|
115
|
+
def initialize(analyzer, report, monitor)
|
98
116
|
super()
|
99
|
-
@
|
100
|
-
@
|
117
|
+
@analyzer = analyzer
|
118
|
+
@report = report
|
119
|
+
@monitor = monitor
|
101
120
|
end
|
102
121
|
|
103
122
|
attr_reader :report
|
104
|
-
attr_reader :
|
123
|
+
attr_reader :monitor
|
105
124
|
|
106
|
-
|
107
|
-
|
108
|
-
|
125
|
+
extend Forwardable
|
126
|
+
|
127
|
+
def_delegator :@analyzer, :traits
|
128
|
+
def_delegator :@analyzer, :message_catalog
|
129
|
+
def_delegator :@analyzer, :logger
|
109
130
|
|
110
|
-
|
111
|
-
|
131
|
+
def_delegator :@report, :msg_fpath
|
132
|
+
def_delegator :@report, :met_fpath
|
133
|
+
def_delegator :@report, :log_fpath
|
134
|
+
|
135
|
+
def flush_deferred_report!
|
136
|
+
if supps = self[:suppressors]
|
137
|
+
@report.flush_deferred_messages(supps)
|
138
|
+
end
|
112
139
|
end
|
113
140
|
end
|
114
141
|
|
data/lib/adlint/prelude.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Global ruby extensions preloaded before execution.
|
2
2
|
#
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
5
5
|
# License:: GPLv3+: GNU General Public License version 3 or later
|
6
6
|
#
|
7
7
|
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
12
12
|
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
13
13
|
# / __ |/ /_/ / /___/ / /| / / /
|
14
|
-
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
15
15
|
#
|
16
16
|
# This file is part of AdLint.
|
17
17
|
#
|
@@ -29,6 +29,8 @@
|
|
29
29
|
#
|
30
30
|
#++
|
31
31
|
|
32
|
+
require "adlint/memo"
|
33
|
+
|
32
34
|
module Kernel
|
33
35
|
private
|
34
36
|
def subclass_responsibility
|
@@ -40,32 +42,20 @@ module Kernel
|
|
40
42
|
raise "NOTREACHED"
|
41
43
|
end
|
42
44
|
module_function :__NOTREACHED__
|
43
|
-
|
44
|
-
def print_elapsed_time(io)
|
45
|
-
tms = Process.times
|
46
|
-
io.print " %.3fs user, %.3fs system, " % [tms.utime, tms.stime]
|
47
|
-
total = tms.utime + tms.stime
|
48
|
-
h = total / 3600
|
49
|
-
m = total / 60 % 60
|
50
|
-
s = (total % 60).floor
|
51
|
-
io.puts "%02d:%02d:%02d.%02d total" % [h, m, s, ((total % 60) - s) * 100]
|
52
|
-
end
|
53
|
-
|
54
|
-
def verbose=(verbose)
|
55
|
-
# NOTE: The meaning of this verbose flag is not same as one of $VERBOSE.
|
56
|
-
@@verbose = verbose
|
57
|
-
end
|
58
|
-
|
59
|
-
def verbose?
|
60
|
-
@@verbose
|
61
|
-
end
|
62
45
|
end
|
63
46
|
|
64
47
|
class Module
|
48
|
+
include ::AdLint::Memoizable
|
49
|
+
|
65
50
|
# NOTE: Module.private_constant is added in Ruby 1.9.3-p0.
|
66
51
|
unless public_instance_methods.include?(:private_constant)
|
67
52
|
def private_constant(*) end
|
68
53
|
end
|
54
|
+
|
55
|
+
def outer_module
|
56
|
+
eval self.name.sub(/(.*)::.*\z/, "\\1")
|
57
|
+
end
|
58
|
+
memoize :outer_module
|
69
59
|
end
|
70
60
|
|
71
61
|
class Encoding
|
@@ -94,9 +84,9 @@ class LazyInstantiation
|
|
94
84
|
|
95
85
|
undef_method(*(Object.new.public_methods - [:__id__, :object_id, :__send__]))
|
96
86
|
|
97
|
-
def method_missing(
|
87
|
+
def method_missing(name, *args)
|
98
88
|
@receiver ||= @klass.new(*@args, &@block)
|
99
|
-
@receiver.__send__(
|
89
|
+
@receiver.__send__(name, *args)
|
100
90
|
end
|
101
91
|
end
|
102
92
|
|
@@ -130,19 +120,46 @@ class Pathname
|
|
130
120
|
def components
|
131
121
|
self.each_filename.to_a
|
132
122
|
end
|
123
|
+
memoize :components
|
124
|
+
|
125
|
+
def real_components
|
126
|
+
self.realpath.each_filename.to_a
|
127
|
+
end
|
128
|
+
memoize :real_components
|
129
|
+
|
130
|
+
memoize :realpath
|
131
|
+
memoize :cleanpath
|
133
132
|
|
134
133
|
def strip(num = 0)
|
135
134
|
comps = self.components
|
136
|
-
if num >= 0 && num < comps.size
|
137
|
-
comps = comps.slice(num..-1)
|
138
|
-
end
|
139
|
-
|
135
|
+
comps = comps.slice(num..-1) if num >= 0 && num < comps.size
|
140
136
|
Pathname.new(comps.reduce { |stripped, comp| File.join(stripped, comp) })
|
141
137
|
end
|
142
138
|
|
143
139
|
def add_ext(ext_str)
|
144
140
|
Pathname.new(self.to_s + ext_str)
|
145
141
|
end
|
142
|
+
|
143
|
+
def identical?(rhs)
|
144
|
+
case rhs
|
145
|
+
when Pathname
|
146
|
+
self.cleanpath == rhs.cleanpath
|
147
|
+
when String
|
148
|
+
self.cleanpath == Pathname.new(rhs).cleanpath
|
149
|
+
else
|
150
|
+
false
|
151
|
+
end
|
152
|
+
end
|
153
|
+
memoize :identical?
|
154
|
+
|
155
|
+
def under?(parent_dpath)
|
156
|
+
lhs_comps, rhs_comps = self.real_components, parent_dpath.real_components
|
157
|
+
if rhs_comps.size < lhs_comps.size
|
158
|
+
rhs_comps.zip(lhs_comps).all? { |rhs, lhs| lhs == rhs }
|
159
|
+
else
|
160
|
+
false
|
161
|
+
end
|
162
|
+
end
|
146
163
|
end
|
147
164
|
|
148
165
|
class String
|
@@ -165,8 +182,8 @@ class String
|
|
165
182
|
end
|
166
183
|
|
167
184
|
class Substring < String
|
168
|
-
def initialize(str,
|
169
|
-
@range =
|
185
|
+
def initialize(str, idx, len)
|
186
|
+
@range = idx...(idx + len)
|
170
187
|
super(str.slice(@range))
|
171
188
|
end
|
172
189
|
|
@@ -174,8 +191,8 @@ class Substring < String
|
|
174
191
|
end
|
175
192
|
|
176
193
|
class SubstringPair < Array
|
177
|
-
def initialize(lhs_suffix, rhs_suffix,
|
178
|
-
super([lhs_suffix.prefix(
|
194
|
+
def initialize(lhs_suffix, rhs_suffix, len)
|
195
|
+
super([lhs_suffix.prefix(len), rhs_suffix.prefix(len)])
|
179
196
|
end
|
180
197
|
|
181
198
|
def lhs
|
@@ -191,12 +208,12 @@ class Suffix
|
|
191
208
|
include Comparable
|
192
209
|
|
193
210
|
def self.of(str)
|
194
|
-
str.length.times.map { |
|
211
|
+
str.length.times.map { |idx| new(str, idx) }
|
195
212
|
end
|
196
213
|
|
197
|
-
def initialize(owner,
|
214
|
+
def initialize(owner, idx)
|
198
215
|
@owner = owner
|
199
|
-
@index =
|
216
|
+
@index = idx
|
200
217
|
end
|
201
218
|
private_class_method :new
|
202
219
|
|
@@ -216,8 +233,8 @@ class Suffix
|
|
216
233
|
to_s.chars.zip(rhs.to_s.chars).take_while { |lch, rch| lch == rch }.size
|
217
234
|
end
|
218
235
|
|
219
|
-
def prefix(
|
220
|
-
Substring.new(@owner, @index,
|
236
|
+
def prefix(len)
|
237
|
+
Substring.new(@owner, @index, len)
|
221
238
|
end
|
222
239
|
|
223
240
|
def <=>(rhs)
|
@@ -251,13 +268,12 @@ class SuffixArray < Array
|
|
251
268
|
end
|
252
269
|
|
253
270
|
def longest_common_substrings
|
254
|
-
|
271
|
+
len = self.longest_common_prefix_length
|
255
272
|
|
256
|
-
return [] if
|
273
|
+
return [] if len == 0
|
257
274
|
|
258
|
-
self.each_index.reduce([]) { |result,
|
259
|
-
self[
|
260
|
-
result + create_substring_pairs(index, length) : result
|
275
|
+
self.each_index.reduce([]) { |result, idx|
|
276
|
+
self[idx][1] == len ? result + create_substring_pairs(idx, len) : result
|
261
277
|
}
|
262
278
|
end
|
263
279
|
|
@@ -267,31 +283,27 @@ class SuffixArray < Array
|
|
267
283
|
|
268
284
|
private
|
269
285
|
def update_height_of_each_suffixes!
|
270
|
-
(1...self.size).each do |
|
271
|
-
self[
|
286
|
+
(1...self.size).each do |idx|
|
287
|
+
self[idx][1] = self[idx - 1][0].common_prefix_length(self[idx][0])
|
272
288
|
end
|
273
289
|
end
|
274
290
|
|
275
|
-
def create_substring_pairs(
|
276
|
-
base_suffix = self[
|
291
|
+
def create_substring_pairs(idx, len)
|
292
|
+
base_suffix = self[idx][0]
|
277
293
|
|
278
294
|
if base_suffix.lhs?
|
279
|
-
create_entry = lambda { |lhs, rhs,
|
280
|
-
SubstringPair.new(lhs, rhs, len)
|
281
|
-
}
|
295
|
+
create_entry = lambda { |lhs, rhs, l| SubstringPair.new(lhs, rhs, l) }
|
282
296
|
else
|
283
|
-
create_entry = lambda { |rhs, lhs,
|
284
|
-
SubstringPair.new(lhs, rhs, len)
|
285
|
-
}
|
297
|
+
create_entry = lambda { |rhs, lhs, l| SubstringPair.new(lhs, rhs, l) }
|
286
298
|
end
|
287
299
|
|
288
300
|
result = []
|
289
301
|
|
290
|
-
(0...
|
291
|
-
break unless self[i + 1][1] ==
|
302
|
+
(0...idx).reverse_each do |i|
|
303
|
+
break unless self[i + 1][1] == len
|
292
304
|
|
293
305
|
unless base_suffix.same_owner?(self[i][0])
|
294
|
-
result.push(create_entry[base_suffix, self[i][0],
|
306
|
+
result.push(create_entry[base_suffix, self[i][0], len])
|
295
307
|
end
|
296
308
|
end
|
297
309
|
|