summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2009-11-05 16:39:30 -0800
committerBob Gilligan <gilligan@vyatta.com>2009-11-05 16:39:30 -0800
commit5edd540c79f349cbe5f377f5b0e8ed16dcf7cf99 (patch)
tree5c9446f66f58349ccad57e694f902b3e3846128e
parentd1936f6f6328143199d2a2f665ca92292c00709f (diff)
downloadvyatta-cfg-5edd540c79f349cbe5f377f5b0e8ed16dcf7cf99.tar.gz
vyatta-cfg-5edd540c79f349cbe5f377f5b0e8ed16dcf7cf99.zip
Allow inline comments in config template fields.
Also change priority.pl script to display inline comments found in "priority:" fields if they are present.
-rw-r--r--scripts/priority.pl31
-rw-r--r--src/cli_def.l1
2 files changed, 22 insertions, 10 deletions
diff --git a/scripts/priority.pl b/scripts/priority.pl
index 59239bf..39f6220 100644
--- a/scripts/priority.pl
+++ b/scripts/priority.pl
@@ -2,16 +2,29 @@
my %pri;
- # first check if this file exists, and if so ensure this is a config file.
+# Look at all node.def files in the configuration template tree
my @files = `find /opt/vyatta/share/vyatta-cfg -name 'node.def'`;
foreach my $f (@files) {
my $result = `grep 'priority:' $f`;
- if (defined $result && length($result) != 0) {
- my @r = split " ", $result;
- if (defined $r[1]) {
- #stuff in hash here
- push @{$pri{$r[1]}},$f;
- }
+ if (defined $result && length($result) != 0) {
+ my @r = split " ", $result;
+ if (defined $r[1]) {
+ # Strip off trailing "/node.def\n" from file pathname
+ my $line = substr($f, 0, -10);
+
+ # Strip off leading "/opt/vyatta/share/vyatta-cfg/templates/"
+ $line = substr($line, 39);
+
+ # See if there is a comment in entry
+ my ($entry, $comment) = split /#/, $result;
+ if (defined $comment) {
+ $comment =~ s/\n//;
+ $line = $line . " #" . $comment;
+ }
+
+ # stuff resulting line into hash
+ push @{$pri{$r[1]}}, $line;
+ }
}
}
@@ -21,8 +34,6 @@ foreach my $f (@files) {
foreach my $key ( sort { $a <=> $b } keys %pri ) {
my @a = @{$pri{$key}};
foreach my $val (@a) {
- my $loc = substr($val,0,-10);
- my $loc = substr($loc,39);
- print $key," ",$loc,"\n";
+ print $key," ",$val,"\n";
}
}
diff --git a/src/cli_def.l b/src/cli_def.l
index d73f1c4..721e5f0 100644
--- a/src/cli_def.l
+++ b/src/cli_def.l
@@ -271,6 +271,7 @@ RE_ACT_FIELD (help|syntax|commit|delete|update|activate|create|begin|end|comp_he
#[^\n]*\n {
/* comment */
++yy_cli_def_lineno;
+ return EOL;
}
\n {