Fix perl context. I really have no clue how this works, but it works.

FossilOrigin-Name: 808322f63ddc7af32b994c9101b241ca9caabfc9c0ddef55fcb2f07d54251b8a
This commit is contained in:
nekobit 2022-08-08 19:03:20 +00:00
parent 1edf678d90
commit ec3dbcb60b
5 changed files with 19 additions and 19 deletions

View File

@ -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,

View File

@ -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

View File

@ -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();

View File

@ -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 */

View File

@ -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;
}