From 617123b5d414b9b44159d1fe2a0bc57b0f272f08 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 11 Dec 2001 16:44:53 +0000 Subject: [PATCH] I always forget Perl 5.004 doesn't have PL_na .. so, now I've declared for 5.004, and changed all STRLEN n_a code to use PL_na instead. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2238 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/perl/common/Core.xs | 4 +--- src/perl/irc/Server.xs | 3 +-- src/perl/perl-common.c | 10 ++++++---- src/perl/perl-common.h | 1 + src/perl/perl-core.c | 4 +--- src/perl/perl-signals.c | 7 ++----- src/perl/perl-sources.c | 4 +--- src/perl/textui/Statusbar.xs | 3 +-- src/perl/ui/Formats.xs | 3 +-- src/perl/ui/Themes.xs | 17 ++++++----------- 10 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/perl/common/Core.xs b/src/perl/common/Core.xs index 7fbf0195..e5d8e948 100644 --- a/src/perl/common/Core.xs +++ b/src/perl/common/Core.xs @@ -22,8 +22,6 @@ PROTOTYPES: ENABLE void signal_emit(signal, ...) char *signal -PREINIT: - STRLEN n_a; CODE: void *p[SIGNAL_MAX_ARGUMENTS]; int n; @@ -31,7 +29,7 @@ CODE: memset(p, 0, sizeof(p)); for (n = 1; n < items && n < SIGNAL_MAX_ARGUMENTS+1; n++) { if (SvPOKp(ST(n))) - p[n-1] = SvPV(ST(n), n_a); + p[n-1] = SvPV(ST(n), PL_na); else if (irssi_is_ref_object(ST(n))) p[n-1] = irssi_ref_object(ST(n)); else diff --git a/src/perl/irc/Server.xs b/src/perl/irc/Server.xs index 3f1e5c23..0cbcad8e 100644 --- a/src/perl/irc/Server.xs +++ b/src/perl/irc/Server.xs @@ -25,7 +25,6 @@ static GSList *event_hash2list(HV *hv) { HE *he; GSList *list; - STRLEN n_a; if (hv == NULL) return NULL; @@ -35,7 +34,7 @@ static GSList *event_hash2list(HV *hv) while ((he = hv_iternext(hv)) != NULL) { I32 len; char *key = hv_iterkey(he, &len); - char *value = SvPV(HeVAL(he), n_a); + char *value = SvPV(HeVAL(he), PL_na); list = g_slist_append(list, g_strdup(key)); list = g_slist_append(list, g_strdup(value)); diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index 7000c4b1..76fa3f3f 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -47,14 +47,17 @@ typedef struct { PERL_OBJECT_FUNC fill_func; } PERL_OBJECT_REC; +#ifndef HAVE_PL_PERL +STRLEN PL_na; +#endif + static GHashTable *iobject_stashes, *plain_stashes; static GSList *use_protocols; /* returns the package who called us */ const char *perl_get_package(void) { - STRLEN n_a; - return SvPV(perl_eval_pv("caller", TRUE), n_a); + return SvPV(perl_eval_pv("caller", TRUE), PL_na); } /* Parses the package part from function name */ @@ -76,13 +79,12 @@ char *perl_function_get_package(const char *function) SV *perl_func_sv_inc(SV *func, const char *package) { - STRLEN n_a; char *name; if (SvPOK(func)) { /* prefix with package name */ name = g_strdup_printf("%s::%s", package, - (char *) SvPV(func, n_a)); + (char *) SvPV(func, PL_na)); func = new_pv(name); g_free(name); } else { diff --git a/src/perl/perl-common.h b/src/perl/perl-common.h index 7c3adfd1..9fa85f07 100644 --- a/src/perl/perl-common.h +++ b/src/perl/perl-common.h @@ -29,6 +29,7 @@ SV *perl_func_sv_inc(SV *func, const char *package); /* For compatibility with perl 5.004 and older */ #ifndef HAVE_PL_PERL # define PL_sv_undef sv_undef +extern STRLEN PL_na; #endif #define iobject_bless(object) \ diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c index d3e0a24a..7af06f89 100644 --- a/src/perl/perl-core.c +++ b/src/perl/perl-core.c @@ -234,9 +234,7 @@ static int perl_script_eval(PERL_SCRIPT_REC *script) error = NULL; if (SvTRUE(ERRSV)) { - STRLEN n_a; - - error = SvPV(ERRSV, n_a); + error = SvPV(ERRSV, PL_na); } else if (retcount > 0) { error = POPp; } diff --git a/src/perl/perl-signals.c b/src/perl/perl-signals.c index eb00f455..8df488cd 100644 --- a/src/perl/perl-signals.c +++ b/src/perl/perl-signals.c @@ -160,9 +160,7 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func, SPAGAIN; if (SvTRUE(ERRSV)) { - STRLEN n_a; - - signal_emit("script error", 2, script, SvPV(ERRSV, n_a)); + signal_emit("script error", 2, script, SvPV(ERRSV, PL_na)); rec = NULL; } @@ -335,14 +333,13 @@ static void perl_signal_remove_list_one(GSList **siglist, PERL_SIGNAL_REC *rec) static void perl_signal_remove_list(GSList **list, SV *func) { GSList *tmp; - STRLEN n_a; g_return_if_fail(list != NULL); for (tmp = *list; tmp != NULL; tmp = tmp->next) { PERL_SIGNAL_REC *rec = tmp->data; - if (sv_func_cmp(rec->func, func, n_a)) { + if (sv_func_cmp(rec->func, func, PL_na)) { perl_signal_remove_list_one(list, rec); break; } diff --git a/src/perl/perl-sources.c b/src/perl/perl-sources.c index 4a3fdea6..7718b871 100644 --- a/src/perl/perl-sources.c +++ b/src/perl/perl-sources.c @@ -77,10 +77,8 @@ static int perl_source_event(PERL_SOURCE_REC *rec) SPAGAIN; if (SvTRUE(ERRSV)) { - STRLEN n_a; - signal_emit("script error", 2, rec->script, - SvPV(ERRSV, n_a)); + SvPV(ERRSV, PL_na)); } perl_source_unref(rec); diff --git a/src/perl/textui/Statusbar.xs b/src/perl/textui/Statusbar.xs index 12901872..67b88e40 100644 --- a/src/perl/textui/Statusbar.xs +++ b/src/perl/textui/Statusbar.xs @@ -65,7 +65,6 @@ static void perl_statusbar_event(char *function, SBAR_ITEM_REC *item, SPAGAIN; if (SvTRUE(ERRSV)) { - STRLEN n_a; PERL_SCRIPT_REC *script; char *package; @@ -77,7 +76,7 @@ static void perl_statusbar_event(char *function, SBAR_ITEM_REC *item, /* make sure we don't get back here */ script_unregister_statusbars(script); } - signal_emit("script error", 2, script, SvPV(ERRSV, n_a)); + signal_emit("script error", 2, script, SvPV(ERRSV, PL_na)); } else { /* min_size and max_size can be changed, move them to SBAR_ITEM_REC */ hv = hvref(item_sv); diff --git a/src/perl/ui/Formats.xs b/src/perl/ui/Formats.xs index 84368d78..0ad8c86a 100644 --- a/src/perl/ui/Formats.xs +++ b/src/perl/ui/Formats.xs @@ -14,12 +14,11 @@ PREINIT: char **charargs; char *ret; int n; - STRLEN n_a; PPCODE: charargs = g_new0(char *, items-5+1); charargs[items-5] = NULL; for (n = 5; n < items; n++) { - charargs[n-5] = (char *)SvPV(ST(n), n_a); + charargs[n-5] = (char *)SvPV(ST(n), PL_na); } ret = format_get_text(module, window, server, target, formatnum, charargs); g_free(charargs); diff --git a/src/perl/ui/Themes.xs b/src/perl/ui/Themes.xs index eea5238f..28507ac1 100644 --- a/src/perl/ui/Themes.xs +++ b/src/perl/ui/Themes.xs @@ -91,7 +91,6 @@ void theme_register(formats) SV *formats PREINIT: - STRLEN n_a; AV *av; FORMAT_REC *formatrecs; char *key, *value; @@ -110,8 +109,8 @@ CODE: formatrecs[0].def = g_strdup("Perl script"); for (fpos = 1, n = 0; n < len; n++, fpos++) { - key = SvPV(*av_fetch(av, n, 0), n_a); n++; - value = SvPV(*av_fetch(av, n, 0), n_a); + key = SvPV(*av_fetch(av, n, 0), PL_na); n++; + value = SvPV(*av_fetch(av, n, 0), PL_na); formatrecs[fpos].tag = g_strdup(key); formatrecs[fpos].def = g_strdup(value); @@ -125,7 +124,6 @@ printformat(level, format, ...) int level char *format PREINIT: - STRLEN n_a; TEXT_DEST_REC dest; char *arglist[MAX_FORMAT_PARAMS+1]; int n; @@ -133,7 +131,7 @@ CODE: format_create_dest(&dest, NULL, NULL, level, NULL); memset(arglist, 0, sizeof(arglist)); for (n = 2; n < items && n < MAX_FORMAT_PARAMS+2; n++) { - arglist[n-2] = SvPV(ST(n), n_a); + arglist[n-2] = SvPV(ST(n), PL_na); } printformat_perl(&dest, format, arglist); @@ -149,7 +147,6 @@ printformat(server, target, level, format, ...) int level char *format PREINIT: - STRLEN n_a; TEXT_DEST_REC dest; char *arglist[MAX_FORMAT_PARAMS+1]; int n; @@ -157,7 +154,7 @@ CODE: format_create_dest(&dest, server, target, level, NULL); memset(arglist, 0, sizeof(arglist)); for (n = 4; n < items && n < MAX_FORMAT_PARAMS+4; n++) { - arglist[n-4] = SvPV(ST(n), n_a); + arglist[n-4] = SvPV(ST(n), PL_na); } printformat_perl(&dest, format, arglist); @@ -172,7 +169,6 @@ printformat(window, level, format, ...) int level char *format PREINIT: - STRLEN n_a; TEXT_DEST_REC dest; char *arglist[MAX_FORMAT_PARAMS+1]; int n; @@ -180,7 +176,7 @@ CODE: format_create_dest(&dest, NULL, NULL, level, window); memset(arglist, 0, sizeof(arglist)); for (n = 3; n < items && n < MAX_FORMAT_PARAMS+3; n++) { - arglist[n-3] = SvPV(ST(n), n_a); + arglist[n-3] = SvPV(ST(n), PL_na); } printformat_perl(&dest, format, arglist); @@ -195,7 +191,6 @@ printformat(item, level, format, ...) int level char *format PREINIT: - STRLEN n_a; TEXT_DEST_REC dest; char *arglist[MAX_FORMAT_PARAMS+1]; int n; @@ -203,7 +198,7 @@ CODE: format_create_dest(&dest, item->server, item->name, level, NULL); memset(arglist, 0, sizeof(arglist)); for (n = 3; n < items && n < MAX_FORMAT_PARAMS+3; n++) { - arglist[n-3] = SvPV(ST(n), n_a); + arglist[n-3] = SvPV(ST(n), PL_na); } printformat_perl(&dest, format, arglist);