1 From 5fee50c54a370fdfb5241bd4c4c16281a741762e Mon Sep 17 00:00:00 2001
2 From: Ricardo Mones <ricardo@mones.org>
3 Date: Sat, 23 Apr 2022 19:26:16 +0200
4 Subject: [PATCH] Fix building perl plugin since perl v5.35.2
6 Using XSRETURN_* macros in expressions is now deprecated:
7 https://github.com/Perl/perl5/commit/7169efc77525df70484a824bff4ceebd1fafc760
9 src/plugins/perl/perl_plugin.c | 243 +++++++++++++++++++++++++--------
10 1 file changed, 188 insertions(+), 55 deletions(-)
12 diff --git a/src/plugins/perl/perl_plugin.c b/src/plugins/perl/perl_plugin.c
13 index f9597b342..cc33aee57 100644
14 --- a/src/plugins/perl/perl_plugin.c
15 +++ b/src/plugins/perl/perl_plugin.c
16 @@ -577,76 +577,182 @@ static XS(XS_ClawsMail_filter_init)
20 - msginfo->size ? XSRETURN_UV(msginfo->size) : XSRETURN_UNDEF;
21 + if (msginfo->size) {
22 + XSRETURN_UV(msginfo->size);
28 - msginfo->date ? XSRETURN_PV(msginfo->date) : XSRETURN_UNDEF;
29 + if (msginfo->date) {
30 + XSRETURN_PV(msginfo->date);
36 - msginfo->from ? XSRETURN_PV(msginfo->from) : XSRETURN_UNDEF;
37 + if (msginfo->from) {
38 + XSRETURN_PV(msginfo->from);
44 - msginfo->to ? XSRETURN_PV(msginfo->to) : XSRETURN_UNDEF;
46 + XSRETURN_PV(msginfo->to);
52 - msginfo->cc ? XSRETURN_PV(msginfo->cc) : XSRETURN_UNDEF;
54 + XSRETURN_PV(msginfo->cc);
60 - msginfo->newsgroups ? XSRETURN_PV(msginfo->newsgroups) : XSRETURN_UNDEF;
61 + if (msginfo->newsgroups) {
62 + XSRETURN_PV(msginfo->newsgroups);
68 - msginfo->subject ? XSRETURN_PV(msginfo->subject) : XSRETURN_UNDEF;
69 + if (msginfo->subject) {
70 + XSRETURN_PV(msginfo->subject);
76 - msginfo->msgid ? XSRETURN_PV(msginfo->msgid) : XSRETURN_UNDEF;
77 + if (msginfo->msgid) {
78 + XSRETURN_PV(msginfo->msgid);
84 - msginfo->inreplyto ? XSRETURN_PV(msginfo->inreplyto) : XSRETURN_UNDEF;
85 + if (msginfo->inreplyto) {
86 + XSRETURN_PV(msginfo->inreplyto);
92 - msginfo->xref ? XSRETURN_PV(msginfo->xref) : XSRETURN_UNDEF;
93 + if (msginfo->xref) {
94 + XSRETURN_PV(msginfo->xref);
100 xface = procmsg_msginfo_get_avatar(msginfo, AVATAR_XFACE);
101 - xface ? XSRETURN_PV(xface) : XSRETURN_UNDEF;
103 + XSRETURN_PV(xface);
109 - (msginfo->extradata && msginfo->extradata->dispositionnotificationto) ?
110 - XSRETURN_PV(msginfo->extradata->dispositionnotificationto) : XSRETURN_UNDEF;
111 + if (msginfo->extradata && msginfo->extradata->dispositionnotificationto) {
112 + XSRETURN_PV(msginfo->extradata->dispositionnotificationto);
118 - (msginfo->extradata && msginfo->extradata->returnreceiptto) ?
119 - XSRETURN_PV(msginfo->extradata->returnreceiptto) : XSRETURN_UNDEF;
120 + if (msginfo->extradata && msginfo->extradata->returnreceiptto) {
121 + XSRETURN_PV(msginfo->extradata->returnreceiptto);
127 EXTEND(SP, g_slist_length(msginfo->references));
129 for(walk = msginfo->references; walk != NULL; walk = g_slist_next(walk))
130 XST_mPV(ii++,walk->data ? (gchar*) walk->data: "");
131 - ii ? XSRETURN(ii) : XSRETURN_UNDEF;
139 - msginfo->score ? XSRETURN_IV(msginfo->score) : XSRETURN_UNDEF;
140 + if (msginfo->score) {
141 + XSRETURN_IV(msginfo->score);
147 - msginfo->plaintext_file ?
148 - XSRETURN_PV(msginfo->plaintext_file) : XSRETURN_UNDEF;
149 + if (msginfo->plaintext_file) {
150 + XSRETURN_PV(msginfo->plaintext_file);
156 - msginfo->hidden ? XSRETURN_IV(msginfo->hidden) : XSRETURN_UNDEF;
157 + if (msginfo->hidden) {
158 + XSRETURN_IV(msginfo->hidden);
164 if((charp = procmsg_get_message_file_path(msginfo)) != NULL) {
165 strncpy2(buf,charp,sizeof(buf));
174 - (msginfo->extradata && msginfo->extradata->partial_recv) ?
175 - XSRETURN_PV(msginfo->extradata->partial_recv) : XSRETURN_UNDEF;
176 + if (msginfo->extradata && msginfo->extradata->partial_recv) {
177 + XSRETURN_PV(msginfo->extradata->partial_recv);
183 - msginfo->total_size ? XSRETURN_IV(msginfo->total_size) : XSRETURN_UNDEF;
184 + if (msginfo->total_size) {
185 + XSRETURN_IV(msginfo->total_size);
191 - (msginfo->extradata && msginfo->extradata->account_server) ?
192 - XSRETURN_PV(msginfo->extradata->account_server) : XSRETURN_UNDEF;
193 + if (msginfo->extradata && msginfo->extradata->account_server) {
194 + XSRETURN_PV(msginfo->extradata->account_server);
200 - (msginfo->extradata && msginfo->extradata->account_login) ?
201 - XSRETURN_PV(msginfo->extradata->account_login) : XSRETURN_UNDEF;
202 + if (msginfo->extradata && msginfo->extradata->account_login) {
203 + XSRETURN_PV(msginfo->extradata->account_login);
209 - msginfo->planned_download ?
210 - XSRETURN_IV(msginfo->planned_download) : XSRETURN_UNDEF;
211 + if (msginfo->planned_download) {
212 + XSRETURN_IV(msginfo->planned_download);
220 - if(manual_filtering)
221 + if(manual_filtering) {
229 g_warning("Perl plugin: wrong argument to ClawsMail::C::init");
231 @@ -664,8 +770,9 @@ static XS(XS_ClawsMail_open_mail_file)
234 file = procmsg_get_message_file_path(msginfo);
239 if((message_file = claws_fopen(file, "rb")) == NULL) {
240 FILE_OP_ERROR(file, "claws_fopen");
241 g_warning("Perl plugin: file open error in ClawsMail::C::open_mail_file");
242 @@ -718,8 +825,9 @@ static XS(XS_ClawsMail_get_next_header)
252 /* ClawsMail::C::get_next_body_line */
253 @@ -736,10 +844,12 @@ static XS(XS_ClawsMail_get_next_body_line)
254 g_warning("Perl plugin: message file not open. Use ClawsMail::C::open_message_file first");
257 - if(claws_fgets(buf, sizeof(buf), message_file) != NULL)
258 + if(claws_fgets(buf, sizeof(buf), message_file) != NULL) {
268 @@ -772,57 +882,65 @@ static XS(XS_ClawsMail_check_flag)
269 filter_log_write(LOG_MATCH,"marked");
277 if(MSG_IS_UNREAD(msginfo->flags)) {
278 filter_log_write(LOG_MATCH,"unread");
286 if(MSG_IS_DELETED(msginfo->flags)) {
287 filter_log_write(LOG_MATCH,"deleted");
295 if(MSG_IS_NEW(msginfo->flags)) {
296 filter_log_write(LOG_MATCH,"new");
304 if(MSG_IS_REPLIED(msginfo->flags)) {
305 filter_log_write(LOG_MATCH,"replied");
313 if(MSG_IS_FORWARDED(msginfo->flags)) {
314 filter_log_write(LOG_MATCH,"forwarded");
322 if(MSG_IS_LOCKED(msginfo->flags)) {
323 filter_log_write(LOG_MATCH,"locked");
331 if(MSG_IS_IGNORE_THREAD(msginfo->flags)) {
332 filter_log_write(LOG_MATCH,"ignore_thread");
340 g_warning("Perl plugin: unknown argument to ClawsMail::C::check_flag");
342 @@ -845,8 +963,9 @@ static XS(XS_ClawsMail_colorlabel)
343 filter_log_write(LOG_MATCH,"colorlabel");
352 /* ClawsMail::C::age_greater(int) */
353 @@ -866,8 +985,9 @@ static XS(XS_ClawsMail_age_greater)
354 filter_log_write(LOG_MATCH,"age_greater");
363 /* ClawsMail::C::age_lower(int) */
364 @@ -887,8 +1007,9 @@ static XS(XS_ClawsMail_age_lower)
365 filter_log_write(LOG_MATCH,"age_lower");
374 /* ClawsMail::C::tagged() */
375 @@ -900,7 +1021,12 @@ static XS(XS_ClawsMail_tagged)
379 - return msginfo->tags ? XSRETURN_YES : XSRETURN_NO;
380 + if (msginfo->tags) {
388 /* ClawsMail::C::get_tags() */
389 @@ -1032,10 +1158,12 @@ static XS(XS_ClawsMail_make_sure_folder_exists)
391 identifier = SvPV_nolen(ST(0));
392 item = folder_get_item_from_identifier(identifier);
404 @@ -1066,8 +1194,9 @@ static XS(XS_ClawsMail_addr_in_addressbook)
405 filter_log_write(LOG_MATCH,"addr_in_addressbook");
415 @@ -1348,8 +1477,9 @@ static XS(XS_ClawsMail_forward)
425 /* ClawsMail::C::redirect(int,char*) */
426 @@ -1373,8 +1503,9 @@ static XS(XS_ClawsMail_redirect)
427 account = account_find_from_id(account_id);
428 compose = compose_redirect(account, msginfo, TRUE);
430 - if (compose->account->protocol == A_NNTP)
431 + if (compose->account->protocol == A_NNTP) {
435 compose_entry_append(compose, dest, COMPOSE_TO, PREF_NONE);
437 @@ -1389,8 +1520,9 @@ static XS(XS_ClawsMail_redirect)
448 @@ -1472,8 +1604,9 @@ static XS(XS_ClawsMail_get_attribute_value)
449 attribute_value = get_attribute_value(addr,attr,bookname);
452 - if(attribute_value)
453 + if(attribute_value) {
454 XSRETURN_PV(attribute_value);