adlint 2.0.6 → 2.0.10

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.
data/ChangeLog CHANGED
@@ -1,3 +1,38 @@
1
+ Thu Sep 6 15:54:41 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
2
+
3
+ * release.ga : 2.0.10
4
+ - Revise value domain management in order not to over-thin value
5
+ domains of the controlling variables in complexly compounded
6
+ controlling expression.
7
+ - Support environment variable substitution in the traits file.
8
+
9
+ Thu Sep 6 11:52:08 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
10
+
11
+ * release.rc : 2.0.9
12
+ - Support environment variable substitution in the traits file.
13
+
14
+ Thu Sep 6 11:36:26 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
15
+
16
+ * lib/adlint/prelude.rb : Support environment variable substitution in
17
+ the traits file.
18
+
19
+ Wed Sep 5 16:40:17 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
20
+
21
+ * release.rc : 2.0.7
22
+ - Revise value domain management in order not to over-thin value
23
+ domains of the controlling variables in complexly compounded
24
+ controlling expression.
25
+
26
+ Wed Sep 5 16:11:42 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
27
+
28
+ * lib/adlint/c/branch.rb : Revise value domain management in order not
29
+ to over-thin value domains of the controlling variables in complexly
30
+ compounded controlling expression.
31
+
32
+ * lib/adlint/c/ctrlexpr.rb : Add #complexly_compounded? predicate
33
+ method.
34
+ * lib/adlint/c/syntax.rb : Ditto.
35
+
1
36
  Thu Aug 30 09:56:15 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
2
37
 
3
38
  * release.ga : 2.0.6
data/NEWS CHANGED
@@ -21,6 +21,18 @@
21
21
 
22
22
  ++
23
23
 
24
+ === \AdLint 2.0.10 is released (2012-09-06)
25
+
26
+ ==== Changes since the 2.0.6 release
27
+
28
+ * Revise value domain management in order not to over-thin value domains of the
29
+ controlling variables in complexly compounded controlling expression
30
+ * Support environment variable substitution in the traits file
31
+
32
+ See the file
33
+ {ChangeLog}[http://adlint.sourceforge.net/pmwiki/upload.d/Main/ChangeLog]
34
+ for more details.
35
+
24
36
  === \AdLint 2.0.6 is released (2012-08-30)
25
37
 
26
38
  ==== Changes since the 2.0.2 release
@@ -30,10 +42,6 @@
30
42
  * Revise variable cross-reference extraction in order to output only about the
31
43
  outmost-variable when its element or member is accessed
32
44
 
33
- See the file
34
- {ChangeLog}[http://adlint.sourceforge.net/pmwiki/upload.d/Main/ChangeLog]
35
- for more details.
36
-
37
45
  === \AdLint 2.0.2 is released (2012-08-28)
38
46
 
39
47
  ==== Changes since the 2.0.0 release
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "2.0.6"
52
+ version: "2.0.10"
53
53
 
54
54
  message_definition:
55
55
  W0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "2.0.6"
52
+ version: "2.0.10"
53
53
 
54
54
  message_definition:
55
55
  W0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "2.0.6"
52
+ version: "2.0.10"
53
53
 
54
54
  message_definition:
55
55
  X0001:
@@ -49,7 +49,7 @@
49
49
  # - "ERR:X99"
50
50
  # format: "Your custom message for the error of E9999."
51
51
 
52
- version: "2.0.6"
52
+ version: "2.0.10"
53
53
 
54
54
  message_definition:
55
55
  X0001:
@@ -82,13 +82,24 @@ module C #:nodoc:
82
82
  environment.enter_versioning_group if first?
83
83
  environment.begin_versioning
84
84
 
85
- @controlling_expression = ControllingExpression.new(interpreter, self)
86
- if ensure_condition(@controlling_expression, expression)
85
+ @controlling_expression =
86
+ ControllingExpression.new(interpreter, self, expression)
87
+ if ensure_condition(@controlling_expression)
87
88
  @break_event = BreakEvent.catch { yield(self) }
88
89
  end
89
90
 
90
91
  ensure
91
- environment.end_versioning(break_with_return?)
92
+ if @controlling_expression.complexly_compounded?
93
+ # NOTE: Give up value domain thinning of the controlling variables,
94
+ # because the controlling expression is too complex to manage
95
+ # value domains correctly.
96
+ # TODO: Study about introducing inter-value-constraints to correctly
97
+ # manage value domains of controlling variables related with each
98
+ # other.
99
+ environment.end_versioning(false)
100
+ else
101
+ environment.end_versioning(break_with_return?)
102
+ end
92
103
  environment.leave_versioning_group(!@group.complete?) if final?
93
104
 
94
105
  if final? && @group.complete?
@@ -119,12 +130,12 @@ module C #:nodoc:
119
130
  end
120
131
 
121
132
  private
122
- def ensure_condition(controlling_expression, expression)
133
+ def ensure_condition(controlling_expression)
123
134
  case
124
135
  when narrowing?
125
- controlling_expression.ensure_true_by_narrowing(expression).commit!
136
+ controlling_expression.ensure_true_by_narrowing.commit!
126
137
  when widening?
127
- controlling_expression.ensure_true_by_widening(expression).commit!
138
+ controlling_expression.ensure_true_by_widening.commit!
128
139
  end
129
140
  @group.all_controlling_variables_value_exist?
130
141
  end
@@ -55,15 +55,20 @@ module C #:nodoc:
55
55
  # <-- StrictObjectDerivation
56
56
  # <-- DelayedObjectDerivation
57
57
  class ControllingExpression
58
- def initialize(interpreter, branch)
58
+ include SyntaxNodeCollector
59
+
60
+ def initialize(interpreter, branch, expression = nil)
59
61
  @interpreter = interpreter
60
62
  @branch = branch
63
+ @expression = expression
61
64
  @manipulators = []
62
65
  end
63
66
 
64
- def ensure_true_by_narrowing(expression = nil)
65
- if expression
66
- new_manip = ValueDomainNarrower.new(@interpreter, expression)
67
+ def ensure_true_by_narrowing(other_expr = nil)
68
+ target_expr = other_expr ? other_expr : @expression
69
+
70
+ if target_expr
71
+ new_manip = ValueDomainNarrower.new(@interpreter, target_expr)
67
72
  begin
68
73
  if @branch.implicit_condition?
69
74
  @interpreter._quiet = true
@@ -83,9 +88,11 @@ module C #:nodoc:
83
88
  new_manip
84
89
  end
85
90
 
86
- def ensure_true_by_widening(expression = nil)
87
- if expression
88
- new_manip = ValueDomainWidener.new(@interpreter, expression)
91
+ def ensure_true_by_widening(other_expr = nil)
92
+ target_expr = other_expr ? other_expr : @expression
93
+
94
+ if target_expr
95
+ new_manip = ValueDomainWidener.new(@interpreter, target_expr)
89
96
  begin
90
97
  if @branch.implicit_condition?
91
98
  @interpreter._quiet = true
@@ -120,6 +127,12 @@ module C #:nodoc:
120
127
  def restore_affected_variables
121
128
  @manipulators.each { |manip| manip.restore! }
122
129
  end
130
+
131
+ def complexly_compounded?
132
+ # NOTE: This method determines whether the controlling expression is too
133
+ # complex to thinning value domains of controlling variables.
134
+ @expression && !collect_logical_and_expressions(@expression).empty?
135
+ end
123
136
  end
124
137
 
125
138
  class ValueDomainManipulator < SyntaxTreeVisitor
@@ -324,6 +324,17 @@ module C #:nodoc:
324
324
  end
325
325
  module_function :collect_additive_expressions
326
326
 
327
+ def collect_logical_and_expressions(node)
328
+ if node
329
+ LogicalAndExpressionCollector.new.tap { |collector|
330
+ node.accept(collector)
331
+ }.logical_and_expressions
332
+ else
333
+ []
334
+ end
335
+ end
336
+ module_function :collect_logical_and_expressions
337
+
327
338
  def collect_generic_labeled_statements(node)
328
339
  if node
329
340
  GenericLabeledStatementCollector.new.tap { |collector|
@@ -5065,6 +5076,19 @@ module C #:nodoc:
5065
5076
  end
5066
5077
  end
5067
5078
 
5079
+ class LogicalAndExpressionCollector < SyntaxTreeVisitor
5080
+ def initialize
5081
+ @logical_and_expressions = []
5082
+ end
5083
+
5084
+ attr_reader :logical_and_expressions
5085
+
5086
+ def visit_logical_and_expression(node)
5087
+ super
5088
+ @logical_and_expressions.push(node)
5089
+ end
5090
+ end
5091
+
5068
5092
  class GenericLabeledStatementCollector < SyntaxTreeVisitor
5069
5093
  def initialize
5070
5094
  @generic_labeled_statements = []
data/lib/adlint/exam.rb CHANGED
@@ -118,7 +118,7 @@ module AdLint #:nodoc:
118
118
 
119
119
  private
120
120
  def module_name
121
- @name.sub(/\A./) { |str| str.upcase }.gsub(/_(.)/) { |*| $1.upcase }
121
+ @name.sub(/\A./) { |str| str.upcase }.gsub(/_(.)/) { $1.upcase }
122
122
  end
123
123
  end
124
124
 
@@ -299,6 +299,37 @@ class SuffixArray < Array
299
299
  end
300
300
  end
301
301
 
302
+ # NOTE: To support environment variable substitution in YAML file.
303
+ #
304
+ # Syntax of embedding environment variable is below;
305
+ # env_var_specifier : '$' env_var_name
306
+ # | '$' '{' env_var_name '}'
307
+ # env_var_name : [A-Za-z_][0-9A-Za-z_]*
308
+ #
309
+ # Examples of environment variable as any scalar value;
310
+ # string_item_1: $VAR
311
+ # boolean_item: $VAR
312
+ # decimal_item: $VAR
313
+ #
314
+ # Examples of embedding environment variable in string;
315
+ # string_item_1: "foo${VAR}baz"
316
+ #
317
+ class Psych::TreeBuilder < Psych::Handler
318
+ alias :_orig_scalar :scalar
319
+ def scalar(value, anchor, tag, plain, quoted, style)
320
+ _orig_scalar(substitute_environment_variables(value),
321
+ anchor, tag, plain, quoted, style)
322
+ end
323
+
324
+ private
325
+ def substitute_environment_variables(string)
326
+ string.gsub(/(?<!\\)\${?([a-z_][0-9a-z_]*)}?/i) do
327
+ (value = ENV[$1]) ? value : ""
328
+ end
329
+ end
330
+ end
331
+
332
+
302
333
  if $0 == __FILE__
303
334
  h1 = Hash.lazy_new(1)
304
335
  p h1[0]
data/lib/adlint/util.rb CHANGED
@@ -568,9 +568,7 @@ module AdLint #:nodoc:
568
568
  module PackageResolver
569
569
  def package_name_of(class_or_module)
570
570
  if class_or_module.name =~ /\AAdLint::Exam::(.*?)::/
571
- $1.sub(/\A./) { |str| str.downcase }.gsub(/[A-Z]/) { |str|
572
- "_#{str.downcase}"
573
- }
571
+ $1.sub(/\A./) { |s| s.downcase }.gsub(/[A-Z]/) { |s| "_#{s.downcase}" }
574
572
  else
575
573
  "core"
576
574
  end
@@ -33,8 +33,8 @@ module AdLint #:nodoc:
33
33
 
34
34
  MAJOR_VERSION = 2
35
35
  MINOR_VERSION = 0
36
- PATCH_VERSION = 6
37
- RELEASE_DATE = "2012-08-30"
36
+ PATCH_VERSION = 10
37
+ RELEASE_DATE = "2012-09-06"
38
38
 
39
39
  TRAITS_SCHEMA_VERSION = "2.0.0"
40
40
 
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 2.0.6 開発者ガイド</title>
3
+ <title>AdLint 2.0.10 開発者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 2.0.6 開発者ガイド">
5
+ <meta name="description" content="AdLint 2.0.10 開発者ガイド">
6
6
  <meta name="generator" content="makeinfo 4.13">
7
7
  <link title="Top" rel="top" href="#Top">
8
8
  <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
@@ -44,7 +44,7 @@ td { border: 1px solid black; }
44
44
  --></style>
45
45
  </head>
46
46
  <body>
47
- <h1 class="settitle">AdLint 2.0.6 開発者ガイド</h1>
47
+ <h1 class="settitle">AdLint 2.0.10 開発者ガイド</h1>
48
48
  <div class="contents">
49
49
  <h2>Table of Contents</h2>
50
50
  <ul>
@@ -2,7 +2,7 @@
2
2
  @setfilename developers_guide_ja.info
3
3
  @documentlanguage ja
4
4
  @documentencoding utf-8
5
- @settitle AdLint 2.0.6 開発者ガイド
5
+ @settitle AdLint 2.0.10 開発者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
@@ -1,8 +1,8 @@
1
1
  <html lang="en">
2
2
  <head>
3
- <title>AdLint 2.0.6 User's Guide</title>
3
+ <title>AdLint 2.0.10 User's Guide</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 2.0.6 User's Guide">
5
+ <meta name="description" content="AdLint 2.0.10 User's Guide">
6
6
  <meta name="generator" content="makeinfo 4.13">
7
7
  <link title="Top" rel="top" href="#Top">
8
8
  <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
@@ -44,7 +44,7 @@ td { border: 1px solid black; }
44
44
  --></style>
45
45
  </head>
46
46
  <body>
47
- <h1 class="settitle">AdLint 2.0.6 User's Guide</h1>
47
+ <h1 class="settitle">AdLint 2.0.10 User's Guide</h1>
48
48
  <div class="node">
49
49
  <a name="Top"></a>
50
50
  <p><hr>
@@ -999,6 +999,20 @@ generate the template of traits file for the project, <samp><span class="file">G
999
999
  % ls adlint
1000
1000
  GNUmakefile adlint_all.sh adlint_files.txt adlint_traits.yml
1001
1001
  adlint_all.bat adlint_cinit.h adlint_pinit.h
1002
+ </pre>
1003
+
1004
+ <p>You can specify environment variable as items in the traits file to be
1005
+ described.
1006
+
1007
+ <p>For example, specify the environment variable <code>ENV_VAR</code> as the item
1008
+ <code>item</code> like below;
1009
+
1010
+ <pre class="verbatim"> item: $ENV_VAR
1011
+ </pre>
1012
+
1013
+ <p>And embed environment variables in a string value like below;
1014
+
1015
+ <pre class="verbatim"> item: "prefix${ENV_VAR}suffix"
1002
1016
  </pre>
1003
1017
 
1004
1018
  <div class="node">
@@ -2,7 +2,7 @@
2
2
  @setfilename users_guide_en.info
3
3
  @documentlanguage en
4
4
  @documentencoding utf-8
5
- @settitle AdLint 2.0.6 User's Guide
5
+ @settitle AdLint 2.0.10 User's Guide
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
@@ -867,6 +867,22 @@ GNUmakefile adlint_all.sh adlint_files.txt adlint_traits.yml
867
867
  adlint_all.bat adlint_cinit.h adlint_pinit.h
868
868
  @end verbatim
869
869
 
870
+ You can specify environment variable as items in the traits file to be
871
+ described.
872
+
873
+ For example, specify the environment variable @code{ENV_VAR} as the item
874
+ @code{item} like below;
875
+
876
+ @verbatim
877
+ item: $ENV_VAR
878
+ @end verbatim
879
+
880
+ And embed environment variables in a string value like below;
881
+
882
+ @verbatim
883
+ item: "prefix${ENV_VAR}suffix"
884
+ @end verbatim
885
+
870
886
 
871
887
  @node Global Traits
872
888
  @subsection Global Traits
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 2.0.6 利用者ガイド</title>
3
+ <title>AdLint 2.0.10 利用者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 2.0.6 利用者ガイド">
5
+ <meta name="description" content="AdLint 2.0.10 利用者ガイド">
6
6
  <meta name="generator" content="makeinfo 4.13">
7
7
  <link title="Top" rel="top" href="#Top">
8
8
  <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
@@ -44,7 +44,7 @@ td { border: 1px solid black; }
44
44
  --></style>
45
45
  </head>
46
46
  <body>
47
- <h1 class="settitle">AdLint 2.0.6 利用者ガイド</h1>
47
+ <h1 class="settitle">AdLint 2.0.10 利用者ガイド</h1>
48
48
  <div class="node">
49
49
  <a name="Top"></a>
50
50
  <p><hr>
@@ -1044,15 +1044,29 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#Input">Input</a>
1044
1044
  <a href="http://yaml.org/">YAML 形式</a>の設定ファイル(<a href="#Traits-Sample">サンプル</a>)
1045
1045
  に記述します。
1046
1046
 
1047
- <p>下記のように解析対象プロジェクトのルートディレクトリで <a href="#AdLintize-Command"><samp><span class="command">adlintize</span></samp></a> コマンドを実行すると、そのプロジェクト用の特性ファイルの雛
1048
- 形、および、解析手順を自動化する <samp><span class="file">GNUmakefile</span></samp> やシェルスクリプトなどを生
1049
- 成することができます。
1047
+ <p>下記のように解析対象プロジェクトのルートディレクトリで <a href="#AdLintize-Command"><samp><span class="command">adlintize</span></samp></a> コマンドを実行すると、そのプロジェクト用の特性ファイル
1048
+ <samp><span class="file">adlint_traits.yml</span></samp> の雛形、および、解析手順を自動化する
1049
+ <samp><span class="file">GNUmakefile</span></samp> やシェルスクリプトなどを生成することができます。
1050
1050
 
1051
1051
  <pre class="verbatim">% cd project
1052
1052
  % adlintize -o adlint
1053
1053
  % ls adlint
1054
1054
  GNUmakefile adlint_all.sh adlint_files.txt adlint_traits.yml
1055
1055
  adlint_all.bat adlint_cinit.h adlint_pinit.h
1056
+ </pre>
1057
+
1058
+ <p>後述の特性ファイルの各設定項目には、環境変数を指定することもできます。
1059
+
1060
+ <p>例えば、設定項目 <code>item</code> に、環境変数 <code>ENV_VAR</code> の値を指定する場合は下
1061
+ 記のように記述します。
1062
+
1063
+ <pre class="verbatim"> item: $ENV_VAR
1064
+ </pre>
1065
+
1066
+ <p>また、文字列形式の設定項目に、環境変数の値を埋め込んだ文字列を指定する場合は下
1067
+ 記のように記述します。
1068
+
1069
+ <pre class="verbatim"> item: "prefix${ENV_VAR}suffix"
1056
1070
  </pre>
1057
1071
 
1058
1072
  <div class="node">
@@ -2,7 +2,7 @@
2
2
  @setfilename users_guide_ja.info
3
3
  @documentlanguage ja
4
4
  @documentencoding utf-8
5
- @settitle AdLint 2.0.6 利用者ガイド
5
+ @settitle AdLint 2.0.10 利用者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
@@ -904,9 +904,9 @@ Command, @command{adlint_sma}}、@ref{AdLint CMA Command, @command{adlint_cma}}
904
904
  に記述します。
905
905
 
906
906
  下記のように解析対象プロジェクトのルートディレクトリで @ref{AdLintize Command,
907
- @command{adlintize}} コマンドを実行すると、そのプロジェクト用の特性ファイルの雛
908
- 形、および、解析手順を自動化する @file{GNUmakefile} やシェルスクリプトなどを生
909
- 成することができます。
907
+ @command{adlintize}} コマンドを実行すると、そのプロジェクト用の特性ファイル
908
+ @file{adlint_traits.yml} の雛形、および、解析手順を自動化する
909
+ @file{GNUmakefile} やシェルスクリプトなどを生成することができます。
910
910
 
911
911
  @verbatim
912
912
  % cd project
@@ -916,6 +916,22 @@ GNUmakefile adlint_all.sh adlint_files.txt adlint_traits.yml
916
916
  adlint_all.bat adlint_cinit.h adlint_pinit.h
917
917
  @end verbatim
918
918
 
919
+ 後述の特性ファイルの各設定項目には、環境変数を指定することもできます。
920
+
921
+ 例えば、設定項目 @code{item} に、環境変数 @code{ENV_VAR} の値を指定する場合は下
922
+ 記のように記述します。
923
+
924
+ @verbatim
925
+ item: $ENV_VAR
926
+ @end verbatim
927
+
928
+ また、文字列形式の設定項目に、環境変数の値を埋め込んだ文字列を指定する場合は下
929
+ 記のように記述します。
930
+
931
+ @verbatim
932
+ item: "prefix${ENV_VAR}suffix"
933
+ @end verbatim
934
+
919
935
 
920
936
  @node Global Traits
921
937
  @subsection グローバル特性
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-30 00:00:00.000000000 Z
12
+ date: 2012-09-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'AdLint is a source code static analyzer.
15
15