Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend #2

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions tred_refactored/btred
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,6 @@ EOL
require TrEd::File;
import TrEd::File;

#load back-ends
@backends = @{ TrEd::File::init_backends($extra_backends) };

# these are for macros
$stdout = \*STDOUT;
$stderr = \*STDERR;
Expand Down Expand Up @@ -1788,7 +1785,11 @@ sub _new_status {
sub loadFile {
my ( $file, $backends ) = @_;
my @warnings;

push @backends, TredMacro::Backends();
_make_uniq(\@backends);
my $bck = ref($backends) ? $backends : \@backends;

my $status = _new_status(
ok => 0,
filename => $file,
Expand Down Expand Up @@ -2620,6 +2621,7 @@ EOF
_msg($@) if $@;
}
}
delete @INC{qw{ TrEd/MacroAPI/Default.pm TrEd/MacroAPI/Extended.pm }};
$TrEd::Macros::safeCompartment = undef;
}

Expand Down Expand Up @@ -2780,7 +2782,8 @@ sub loadMacros {

require TrEd::MacroAPI::Default;#this loads TredMacro API
# not sure why, we don't need it here...
#TredMacro->import;

#TredMacro->import;
#TredMacro::init_tredmacro_bindings();

# set minor modes and this stuff, can't do it at compile time, since there is no grp...
Expand All @@ -2798,6 +2801,7 @@ sub loadMacros {
my ( $extensions, $pre_installed, $preinst_dir ) = prepareExtensions();
init_extensions($extensions);
init_extensions( $pre_installed, $preinst_dir );
@backends = @{ TrEd::File::init_backends($extra_backends) };
_msg("Reading extension macros...\n") unless $quiet;

for my $ext_contrib ( get_extension_macro_paths($extensions),
Expand Down
6 changes: 4 additions & 2 deletions tred_refactored/tredlib/Filelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ sub _lazy_load {
}

@{ $self->list_ref() } = <$fh>;
close $fh
or croak("Cannot open $self->{load}: $!\n");
if ($load ne '-') {
close $fh
or croak("Cannot close $self->{load}: $!\n");
}

if ($load =~ /\.fl$/) {
my $fl_name = decode('UTF-8', shift @{ $self->list_ref });
Expand Down
8 changes: 6 additions & 2 deletions tred_refactored/tredlib/TrEd/Macros.pm
Original file line number Diff line number Diff line change
Expand Up @@ -921,12 +921,16 @@ sub initialize_macros {
# which should in this way be made visible
# to macros
my $result = 2; #hm? strange init, return value never actually used
no warnings;

# Needed to load default macros after cleanup.
require TrEd::MacroAPI::Default;

if ( not $macrosEvaluated ) {
my $utf = ($useEncoding) ? "use utf8;\n" : q{};
my $macros = q{};
$macros .= 'use strict;' if $strict;
$macros .= "use warnings; no warnings 'redefine';" if $warnings;
$macros .= 'use warnings;' if $warnings;
$macros .= 'no warnings "redefine";';
$macros
.= "{\n"
. $utf
Expand Down
2 changes: 1 addition & 1 deletion tred_refactored/tredlib/TrEd/Stylesheet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ sub get_stylesheet_patterns {
$hint = $s->{hint};
$context = $s->{context};
$context = '.*' unless ( wantarray or $context =~ /\S/ );
chomp $context;
chomp $context if length $context;
@$patterns = defined( $s->{patterns} ) ? @{ $s->{patterns} } : ();
}
else {
Expand Down
2 changes: 1 addition & 1 deletion tred_refactored/tredlib/contrib/support/arrows.inc
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ instruction in L<http://ufal.ms.mff.cuni.cz/tred/ar01s10.html>).
$dx ||= 0;
$dy ||= 0;

if ( $node == $target ) {
if ( $node == ($target // -1) ) {

# same node
push @{ $props{-coords} }, <<"COORDS";
Expand Down