From 5e5dcbc29506a0b40d7c99a12bf2830290289582 Mon Sep 17 00:00:00 2001 From: zimoch Date: Wed, 13 Nov 2013 09:33:12 +0000 Subject: [PATCH] be more relaxed for strings without quotes check number of macros --- dbLoadTemplate | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dbLoadTemplate b/dbLoadTemplate index 78d09a0..88d8215 100755 --- a/dbLoadTemplate +++ b/dbLoadTemplate @@ -1,6 +1,6 @@ #!/usr/bin/env perl -# $Header: /cvs/G/EPICS/App/scripts/dbLoadTemplate,v 1.8 2013/04/15 15:20:42 zimoch Exp $ +# $Header: /cvs/G/EPICS/App/scripts/dbLoadTemplate,v 1.9 2013/11/13 09:33:12 zimoch Exp $ use strict; @@ -26,7 +26,7 @@ sub nextToken { die "unexpected end of file in $ARGV\n"; } } - $input =~ s/^\s*($WORD|$STRING|$NOWORD|$SUBST)\s*(#.*\n?)?//; + $input =~ s/^\s*($STRING|$SUBST|$WORD|$NOWORD)\s*(#.*\n?)?//; $1 ne $QUOTECHAR or die "unterminated string in $ARGV line $.\n"; #print STDERR "nextToken from $ARGV line $. is $1\n"; $1; @@ -98,7 +98,7 @@ sub parseRecord { } last if $_ eq "}"; push @fields, expect "(", "$WORD field name"; - push @fields, expect ",", "$STRING quoted field value"; + push @fields, expect ",", "$STRING|$SUBST quoted field value"; expect ")"; } handleRecord $rtype,$name,@fields; @@ -124,7 +124,7 @@ sub parseTemplate { sub parseSubst { # print STDERR "parseSubst $ARGV line $.\n"; my $filename; - eval { $filename = expect "file","$WORD file name" }; + eval { $filename = expect "file","$STRING|$WORD file name" }; if ($@) { $@ =~ /end of file/ or die $@; return 0; @@ -145,6 +145,11 @@ sub parseSubst { expect "=", "$STRING|$SUBST value for $macro"; $subst{$macro} = $_; } + my $n; + $n = scalar (keys %subst); + if ($n > 100) { + print STDERR "Warning: more than 100 marcos ($n in your case) is not supported\n"; + } eval {parseTemplate $filename} or die "$@called from $ARGV line $.\n"; expect "{|} '{' or '}'"; } while $_ eq "{"; @@ -159,6 +164,11 @@ sub parseSubst { last if $_ eq '}'; push @macros, $_; }; + my $n; + $n = scalar (@macros); + if ($n > 100) { + print STDERR "Warning: more than 100 marcos ($n in your case) is not supported\n"; + } while (1) { local %subst; expect "{|} '{' or '}'";