From ec3dbcb60bdb0ac584c98b98f0c1fd794a1dbb8f Mon Sep 17 00:00:00 2001 From: nekobit Date: Mon, 8 Aug 2022 19:03:20 +0000 Subject: [PATCH] Fix perl context. I really have no clue how this works, but it works. FossilOrigin-Name: 808322f63ddc7af32b994c9101b241ca9caabfc9c0ddef55fcb2f07d54251b8a --- perl/status.pm | 3 +-- perl/string_helpers.pm | 5 +++-- src/global_perl.c | 5 +++-- src/global_perl.h | 10 +++++----- src/main.c | 15 +++++++-------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/perl/status.pm b/perl/status.pm index b4249a3..f0d8388 100644 --- a/perl/status.pm +++ b/perl/status.pm @@ -1,7 +1,6 @@ package status; use strict; use warnings; -use HTML::Escape 'escape_html'; use string_helpers qw( reltime_to_str greentextify emojify format_username localize_mentions ); use icons qw( get_icon visibility_to_icon ); use attachments 'generate_attachment'; @@ -30,7 +29,7 @@ sub generate_status make_emoji => \&generate_emoji, greentextify => \&greentextify, emojify => \&emojify, - escape => \&escape_html, + escape => undef, fix_mentions => \&localize_mentions, format_username => \&format_username, make_postbox => \&generate_postbox, diff --git a/perl/string_helpers.pm b/perl/string_helpers.pm index 62be6ee..bbef6e8 100644 --- a/perl/string_helpers.pm +++ b/perl/string_helpers.pm @@ -1,7 +1,6 @@ package string_helpers; use strict; use warnings; -use HTML::Escape 'escape_html'; use Exporter 'import'; our @EXPORT = qw( reltime_to_str greentextify emojify format_username get_mentions_from_content localize_mentions ); @@ -47,7 +46,9 @@ sub emojify sub format_username { my $account = shift; - emojify(escape_html($account->{display_name}), $account->{emojis}); + + #TODO ESCAPE DISPLAY NAME + emojify($account->{display_name}, $account->{emojis}); } sub localize_mentions diff --git a/src/global_perl.c b/src/global_perl.c index 94f34cc..6de0585 100644 --- a/src/global_perl.c +++ b/src/global_perl.c @@ -34,10 +34,11 @@ #include "../templates/content_notifs.ctt" #include "../templates/content_lists.ctt" +PerlInterpreter* my_perl; HV* template_files; -pthread_mutex_t perl_mutex = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t perllock_mutex = PTHREAD_MUTEX_INITIALIZER; -void init_template_files() +void init_template_files(pTHX) { template_files = newHV(); diff --git a/src/global_perl.h b/src/global_perl.h index f6cfb85..f8eafac 100644 --- a/src/global_perl.h +++ b/src/global_perl.h @@ -28,16 +28,16 @@ #define hvstores_ref(hv, key, val) hv_stores((hv), key, \ ((val) ? newRV_inc((SV* const)(val)) : &PL_sv_undef)) -static PerlInterpreter* perl; +extern PerlInterpreter* my_perl; extern HV* template_files; -extern pthread_mutex_t perl_mutex; +extern pthread_mutex_t perllock_mutex; -#define perl_lock() do { pthread_mutex_lock(&perl_mutex); } while (0) -#define perl_unlock() do { pthread_mutex_unlock(&perl_mutex); } while (0) +#define perl_lock() do { pthread_mutex_lock(&perllock_mutex); } while (0) +#define perl_unlock() do { pthread_mutex_unlock(&perllock_mutex); } while (0) #define ARG_UNDEFINED() do { XPUSHs(&PL_sv_undef); } while (0) -void init_template_files(); +void init_template_files(pTHX); void cleanup_template_files(); #endif /* GLOBAL_PERL_H */ diff --git a/src/main.c b/src/main.c index c4ee17b..5442d7d 100644 --- a/src/main.c +++ b/src/main.c @@ -213,16 +213,16 @@ int main(int argc, char **argv, char **env) // Initialize Perl PERL_SYS_INIT3(&argc, &argv, &env); - perl = perl_alloc(); - perl_construct(perl); + my_perl = perl_alloc(); + perl_construct(my_perl); //char* perl_argv[] = { "", "-e", data_main_pl, NULL }; char* perl_argv[] = { "", "-I", "perl/", "perl/main.pl", NULL }; - perl_parse(perl, xs_init, (sizeof(perl_argv) / sizeof(perl_argv[0])) - 1, perl_argv, (char**)NULL); + perl_parse(my_perl, xs_init, (sizeof(perl_argv) / sizeof(perl_argv[0])) - 1, perl_argv, (char**)NULL); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; - perl_run(perl); + perl_run(my_perl); - init_template_files(); + init_template_files(aTHX); // Initiate mastodont library mastodont_t api; @@ -249,10 +249,9 @@ int main(int argc, char **argv, char **env) mastodont_cleanup(&api); cleanup_template_files(); - - perl_destruct(perl); - perl_free(perl); + perl_destruct(my_perl); + perl_free(my_perl); PERL_SYS_TERM(); return 0; }