summaryrefslogtreecommitdiff
path: root/Auxiliary/vim/extract-upper-case.pl
diff options
context:
space:
mode:
authorPatrick Boettcher <patrick.boettcher@posteo.de>2017-05-02 17:34:53 +0200
committerPatrick Boettcher <patrick.boettcher@posteo.de>2017-05-02 17:34:53 +0200
commit0d8273fa32bdeb7f8bd939864ba6d6ea147e642d (patch)
tree00e9c28c1716e4d35917f28ac2c3bfa9b0a015b8 /Auxiliary/vim/extract-upper-case.pl
parent3960038ea225bf23ad738f988e6ee3ddac71ccab (diff)
parente335771157a1361e250989a5f2d7540144409e78 (diff)
downloadcmake-0d8273fa32bdeb7f8bd939864ba6d6ea147e642d.tar.gz
Merge branch 'upstream-vim-cmake-syntax'
* upstream-vim-cmake-syntax: vim-cmake-syntax 2017-05-02 (15526199)
Diffstat (limited to 'Auxiliary/vim/extract-upper-case.pl')
-rwxr-xr-xAuxiliary/vim/extract-upper-case.pl27
1 files changed, 15 insertions, 12 deletions
diff --git a/Auxiliary/vim/extract-upper-case.pl b/Auxiliary/vim/extract-upper-case.pl
index e945d5211c..ea77cbb5c6 100755
--- a/Auxiliary/vim/extract-upper-case.pl
+++ b/Auxiliary/vim/extract-upper-case.pl
@@ -3,6 +3,9 @@
use strict;
use warnings;
+#my $cmake = "/home/pboettch/devel/upstream/cmake/build/bin/cmake";
+my $cmake = "cmake";
+
my @variables;
my @commands;
my @properties;
@@ -10,7 +13,7 @@ my @modules;
my %keywords; # command => keyword-list
# unwanted upper-cases
-my %unwanted = map { $_ => 1 } qw(VS CXX IDE NOTFOUND NO_ DFOO DBAR);
+my %unwanted = map { $_ => 1 } qw(VS CXX IDE NOTFOUND NO_ DFOO DBAR NEW);
# cannot remove ALL - exists for add_custom_command
# control-statements
@@ -24,9 +27,10 @@ my %deprecated = map { $_ => 1 } qw(build_name exec_program export_library_depen
push @modules, "ExternalProject";
# variables
-open(CMAKE, "cmake --help-variable-list|") or die "could not run cmake";
+open(CMAKE, "$cmake --help-variable-list|") or die "could not run cmake";
while (<CMAKE>) {
chomp;
+ next if /\</; # skip VARIABLES which contained <>-"templates"
push @variables, $_;
}
close(CMAKE);
@@ -35,17 +39,16 @@ close(CMAKE);
my %variables = map { $_ => 1 } @variables;
# commands
-open(CMAKE, "cmake --help-command-list|");
+open(CMAKE, "$cmake --help-command-list|");
while (my $cmd = <CMAKE>) {
chomp $cmd;
-
push @commands, $cmd;
}
close(CMAKE);
# now generate a keyword-list per command
foreach my $cmd (@commands) {
- my @word = extract_upper("cmake --help-command $cmd|");
+ my @word = extract_upper("$cmake --help-command $cmd|");
next if scalar @word == 0;
@@ -54,7 +57,7 @@ foreach my $cmd (@commands) {
# and now for modules
foreach my $mod (@modules) {
- my @word = extract_upper("cmake --help-module $mod|");
+ my @word = extract_upper("$cmake --help-module $mod|");
next if scalar @word == 0;
@@ -62,10 +65,10 @@ foreach my $mod (@modules) {
}
# and now for generator-expressions
-my @generator_expr = extract_upper("cmake --help-manual cmake-generator-expressions |");
+my @generator_expr = extract_upper("$cmake --help-manual cmake-generator-expressions |");
# properties
-open(CMAKE, "cmake --help-property-list|");
+open(CMAKE, "$cmake --help-property-list|");
while (<CMAKE>) {
chomp;
push @properties, $_;
@@ -88,7 +91,7 @@ while(<IN>)
! exists $deprecated{$_} } @commands;
print OUT " " x 12 , "\\ ", join(" ", @tmp), "\n";
} elsif ($1 eq "VARIABLE_LIST") {
- print OUT " " x 12 , "\\ ", join(" ", @variables), "\n";
+ print OUT " " x 12 , "\\ ", join(" ", sort keys %variables), "\n";
} elsif ($1 eq "MODULES") {
print OUT " " x 12 , "\\ ", join("\n", @modules), "\n";
} elsif ($1 eq "GENERATOR_EXPRESSIONS") {
@@ -101,9 +104,8 @@ while(<IN>)
print OUT " " x 12 , "\\ ", join(" ", sort keys %deprecated), "\n";
} elsif ($1 eq "KEYWORDS") {
foreach my $k (sort keys %keywords) {
- print OUT "syn keyword cmakeKW$k\n";
+ print OUT "syn keyword cmakeKW$k contained\n";
print OUT " " x 12, "\\ ", join(" ", @{$keywords{$k}}), "\n";
- print OUT " " x 12, "\\ contained\n";
print OUT "\n";
push @keyword_hi, "hi def link cmakeKW$k ModeMsg";
}
@@ -130,7 +132,8 @@ sub extract_upper
foreach my $w (m/\b([A-Z_]{2,})\b/g) {
next
if exists $variables{$w} or # skip if it is a variable
- exists $unwanted{$w}; # skip if not wanted
+ exists $unwanted{$w} or # skip if not wanted
+ grep(/$w/, @word); # skip if already in array
push @word, $w;
}