From a083b3b5f884975c04d1cd3d2f6d7d97109f5e0a Mon Sep 17 00:00:00 2001 From: Will Budic Date: Tue, 13 May 2025 19:24:57 +1000 Subject: [PATCH] dev --- ...pan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh | 6 ++-- system/modules/CNFGlobalFile.pm | 9 ++--- system/modules/CNFParser.pm | 33 ++++++++++--------- tests/testTreeToHTML.pl | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/install_cpan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh b/install_cpan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh index 4fdf907..57f4116 100755 --- a/install_cpan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh +++ b/install_cpan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh @@ -22,15 +22,15 @@ sudo perl -MCPAN -e 'CPAN::install(local::lib)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(LWP)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Text::Levenshtein::XS)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Term::Term:)' -sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Term::ReadKey)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Term::Screen)' +sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Term::ReadKey)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Exception::Class)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Syntax::Keyword::Try)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(JSON::XS)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(DBI)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(DBD::SQLite)' -# sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(DBD::Pg)' -# sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(DBD::mysql)' +sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(DBD::Pg)' +sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(DBD::mysql)' sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(CGI::Session)' sudo apt install libanyevent-perl libclass-refresh-perl libcompiler-lexer-perl \ diff --git a/system/modules/CNFGlobalFile.pm b/system/modules/CNFGlobalFile.pm index 944cade..3e8f715 100644 --- a/system/modules/CNFGlobalFile.pm +++ b/system/modules/CNFGlobalFile.pm @@ -16,12 +16,9 @@ sub new ($class, $path) { sub content($self) { return _load($self) -> {content} ; } -sub changed($self){ - if(exists $self->{last_modified}){ - my @cur = stat($self->{path}); - return $cur[9] != $self->{last_modified} ? 1 : 0 - } - return 1; +sub changed($self){ return 1 if not $self->{last_modified}; #We return changed if doesn't exist. + my @stats = stat($self->{path}); + return $self->{last_modified} != $stats[9] } sub binary($self){ _binary($self, *STDOUT) diff --git a/system/modules/CNFParser.pm b/system/modules/CNFParser.pm index 125f0e4..6feddcf 100644 --- a/system/modules/CNFParser.pm +++ b/system/modules/CNFParser.pm @@ -226,7 +226,7 @@ package PropertyValueStyle { if(!$p){ $p = $itm; }else{ - $itm =~ s/^\s*(['"])(.*)\g{1}$/$2/g if $itm; $itm =~ s/\s*$//; + $itm =~ s/^\s*(['"])(.*)\g{1}$/$2/g if $itm; $itm =~ s/\s*$//; $self->{$p}=$itm; undef $p; } @@ -503,11 +503,11 @@ sub doInstruction { my ($self,$e,$t,$v) = @_; } }elsif($t eq 'FILE'){#@TODO Test case this $self->doLoadDataFile($e,$v); - }elsif($t eq 'INCLUDE'){ - my $isMetaConst = $v =~ s/$meta_const//s; + }elsif($t eq 'INCLUDE'){ if (!$v){ - $v=$e + $v=$e }else{ + my $isMetaConst = $v =~ s/$meta_const//s; if ($isMetaConst){ $self -> {$e} = $v; }else{ @@ -521,7 +521,7 @@ sub doInstruction { my ($self,$e,$t,$v) = @_; } $includes[@includes] = {script=>$v,local=>$CUR_SCRIPT,loaded=>0, prc_last=>$prc_last}; }elsif($t eq 'TREE'){ - my $tree = 0; + my $tree = 0; if( !$v ){ $v = $e; $e = CNFMeta::ANN(); @@ -789,12 +789,11 @@ sub doDATAInstructions_{ my ($self,$e,$v,$t,$d)=@_; sub parse { my ($self, $cnf_file, $content, $del_keys) = @_; my @tags; - $cnf_file = $cnf_file -> {path} if ref($cnf_file) eq 'CNFGlobalFile'; - - # We control from here the constances, as we need to unlock them if a previous parse was run. + # We control from here the constances, as we need to unlock them if a previous parse was run. unlock_hash(%$self); if(not $content){ + $cnf_file = $cnf_file -> {path} if ref($cnf_file) eq 'CNFGlobalFile'; open(my $fh, "<:perlio", $cnf_file ) or die "Can't open $cnf_file -> $!"; read $fh, $content, -s $fh; close $fh; @@ -1010,8 +1009,12 @@ sub parse { my ($self, $cnf_file, $content, $del_keys) = @_; # Do scripted includes first. As these might set properties imported and processed used by the main script. if(@includes){ $includes[@includes] = {script=>$CUR_SCRIPT,loaded=>1, prc_last=>0} if not includeContains($CUR_SCRIPT); #<- to prevent circular includes. - foreach (@includes){ - $self -> doInclude($_) if $_ && not $_->{prc_last} and not $_->{loaded} and $_->{local} eq $CUR_SCRIPT; + my $hook = $self->{INCLUDES_LISTENER}; + foreach my $include (@includes){ + if ($include && not $include->{prc_last} and not $include->{loaded} and $include->{local} eq $CUR_SCRIPT){ + $hook -> ($CUR_SCRIPT,$include->{script}) if $hook; + $self -> doInclude($include); #<- These might include new includes, not worried about to hook on, as would be to deep. + } } } # Do those autonumbering list anons, and for pre instruction processing prepare if have it. @@ -1073,17 +1076,17 @@ sub parse { my ($self, $cnf_file, $content, $del_keys) = @_; $anechoic ->{$struct->name()} = $struct->process($self, $struct->script()); $self->log("Processed -> ".$struct->name()) if $self->{DEBUG} } - $splice[@splice] = $idx - @splice; + $splice[@splice] = $idx - @splice; }elsif($type eq 'InstructedDataItem' && $priority > 0 && $priority < 5){ my $t = $struct->{ins}; if($t eq 'PLUGIN'){ instructPlugin($self, $struct); - $splice[@splice] = $idx - @splice; + $splice[@splice] = $idx - @splice; } } } } - + foreach my $i(@splice){ splice(@items, $i, 1) } #Now only what is left instructed data items or plugins, and nodes that have assigned last priority, if any. @@ -1157,11 +1160,11 @@ sub doInclude { my ($self, $prp_file) = @_; $IS_IN_INCLUDE_MODE = 0; $CUR_SCRIPT = $cur_script; }else{ - $self->error("Include content is blank for include -> ".$prp_file->{script}) + $self->error("Include content is blank for -> ".$prp_file->{script}) } }else{ $prp_file->{loaded} = 0; - $self->error("Script include not available for include -> ".$prp_file->{script}); + $self->error("Script include not available for -> ".$prp_file->{script}); CNFParserException->throw("Can't open include ".$prp_file->{script}." -> $!") if $self->{STRICT}; } } diff --git a/tests/testTreeToHTML.pl b/tests/testTreeToHTML.pl index 47e7ddf..addb562 100644 --- a/tests/testTreeToHTML.pl +++ b/tests/testTreeToHTML.pl @@ -3,7 +3,7 @@ use warnings; use strict; use Syntax::Keyword::Try; use lib "tests"; -use lib "/home/will/dev_new/PerlCNF/system/modules"; +use lib "system/modules"; require TestManager; -- 2.34.1