pidgin: 18b85ae6: Pass around a va_list instead of a point...
markdoliner at pidgin.im
markdoliner at pidgin.im
Wed Feb 10 04:06:00 EST 2010
-----------------------------------------------------------------
Revision: 18b85ae6ad8091af43d91826cf054e4569ba74aa
Ancestor: 2a6c0319124a6881d89d07208a717031b9b29aba
Author: markdoliner at pidgin.im
Date: 2010-02-10T09:04:15
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/18b85ae6ad8091af43d91826cf054e4569ba74aa
Modified files:
configure.ac libpurple/plugins/perl/perl-common.c
libpurple/plugins/perl/perl-common.h
libpurple/plugins/perl/perl-handlers.c
ChangeLog:
Pass around a va_list instead of a pointer to a va_list. Refs #7404
This gets rid of a compile warning for me on x86_64. I don't have
an i386 box to test on, but every bit of evidence I can find tells me
that it's totally fine to pass around a va_list. We do it in status.c
If this breaks compilation for you or you get a warning from perl-handlers.c
then pleaes let me know! Or just disapprove this
-------------- next part --------------
============================================================
--- configure.ac 3b0a16da4cf2caf3ab0d22804cf0205e33a27fb3
+++ configure.ac 866546c343b1a7ee049a39d5f96ac7dcf5a297a3
@@ -2393,30 +2393,6 @@ fi
AC_DEFINE(HAVE_TM_GMTOFF, 1, [Define if you have a tm_gmtoff member in struct tm])
fi
-AC_CACHE_CHECK([whether va_lists can be copied by value], ac_cv_va_val_copy,[
- AC_TRY_RUN([#include <stdarg.h>
-#include <stdlib.h>
- void f (int i, ...) {
- va_list args1, args2;
- va_start (args1, i);
- args2 = args1;
- if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
- exit (1);
- va_end (args1); va_end (args2);
- }
- int main() {
- f (0, 42);
- return 0;
- }],
- [ac_cv_va_val_copy=yes],
- [ac_cv_va_val_copy=no],
- [ac_cv_va_val_copy=yes])
-])
-
-if test "x$ac_cv_va_val_copy" = "xno"; then
- AC_DEFINE(VA_COPY_AS_ARRAY, 1, ['va_lists' cannot be copied as values])
-fi
-
dnl #######################################################################
dnl # Check for check
dnl #######################################################################
============================================================
--- libpurple/plugins/perl/perl-common.c f8b445f6b581da467f8f8a1f8f5351235c741665
+++ libpurple/plugins/perl/perl-common.c b3b68ed231487e7f0e54041909d497c23b7ca174
@@ -472,74 +472,74 @@ SV *
}
SV *
-purple_perl_sv_from_vargs(const PurpleValue *value, va_list *args, void ***copy_arg)
+purple_perl_sv_from_vargs(const PurpleValue *value, va_list args, void ***copy_arg)
{
if (purple_value_is_outgoing(value)) {
switch (purple_value_get_type(value)) {
case PURPLE_TYPE_SUBTYPE:
- if ((*copy_arg = va_arg(*args, void **)) == NULL)
+ if ((*copy_arg = va_arg(args, void **)) == NULL)
return &PL_sv_undef;
return purple_perl_sv_from_subtype(value, *(void **)*copy_arg);
case PURPLE_TYPE_BOOLEAN:
- if ((*copy_arg = (void *)va_arg(*args, gboolean *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, gboolean *)) == NULL)
return &PL_sv_undef;
return newSViv(*(gboolean *)*copy_arg);
case PURPLE_TYPE_INT:
- if ((*copy_arg = (void *)va_arg(*args, int *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, int *)) == NULL)
return &PL_sv_undef;
return newSViv(*(int *)*copy_arg);
case PURPLE_TYPE_UINT:
- if ((*copy_arg = (void *)va_arg(*args, unsigned int *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, unsigned int *)) == NULL)
return &PL_sv_undef;
return newSVuv(*(unsigned int *)*copy_arg);
case PURPLE_TYPE_LONG:
- if ((*copy_arg = (void *)va_arg(*args, long *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, long *)) == NULL)
return &PL_sv_undef;
return newSViv(*(long *)*copy_arg);
case PURPLE_TYPE_ULONG:
- if ((*copy_arg = (void *)va_arg(*args,
+ if ((*copy_arg = (void *)va_arg(args,
unsigned long *)) == NULL)
return &PL_sv_undef;
return newSVuv(*(unsigned long *)*copy_arg);
case PURPLE_TYPE_INT64:
- if ((*copy_arg = (void *)va_arg(*args, gint64 *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, gint64 *)) == NULL)
return &PL_sv_undef;
return newSViv(*(gint64 *)*copy_arg);
case PURPLE_TYPE_UINT64:
- if ((*copy_arg = (void *)va_arg(*args, guint64 *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, guint64 *)) == NULL)
return &PL_sv_undef;
return newSVuv(*(guint64 *)*copy_arg);
case PURPLE_TYPE_STRING:
- if ((*copy_arg = (void *)va_arg(*args, char **)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, char **)) == NULL)
return &PL_sv_undef;
return newSVGChar(*(char **)*copy_arg);
case PURPLE_TYPE_POINTER:
- if ((*copy_arg = va_arg(*args, void **)) == NULL)
+ if ((*copy_arg = va_arg(args, void **)) == NULL)
return &PL_sv_undef;
return newSViv((IV)*(void **)*copy_arg);
case PURPLE_TYPE_BOXED:
/* Uh.. I dunno. Try this? */
- if ((*copy_arg = va_arg(*args, void **)) == NULL)
+ if ((*copy_arg = va_arg(args, void **)) == NULL)
return &PL_sv_undef;
return sv_2mortal(purple_perl_bless_object(
@@ -553,40 +553,40 @@ purple_perl_sv_from_vargs(const PurpleVa
} else {
switch (purple_value_get_type(value)) {
case PURPLE_TYPE_SUBTYPE:
- if ((*copy_arg = va_arg(*args, void *)) == NULL)
+ if ((*copy_arg = va_arg(args, void *)) == NULL)
return &PL_sv_undef;
return purple_perl_sv_from_subtype(value, *copy_arg);
case PURPLE_TYPE_BOOLEAN:
- *copy_arg = GINT_TO_POINTER( va_arg(*args, gboolean) );
+ *copy_arg = GINT_TO_POINTER( va_arg(args, gboolean) );
return newSViv((gboolean)GPOINTER_TO_INT(*copy_arg));
case PURPLE_TYPE_INT:
- *copy_arg = GINT_TO_POINTER( va_arg(*args, int) );
+ *copy_arg = GINT_TO_POINTER( va_arg(args, int) );
return newSViv(GPOINTER_TO_INT(*copy_arg));
case PURPLE_TYPE_UINT:
- *copy_arg = GUINT_TO_POINTER(va_arg(*args, unsigned int));
+ *copy_arg = GUINT_TO_POINTER(va_arg(args, unsigned int));
return newSVuv(GPOINTER_TO_UINT(*copy_arg));
case PURPLE_TYPE_LONG:
- *copy_arg = (void *)va_arg(*args, long);
+ *copy_arg = (void *)va_arg(args, long);
return newSViv((long)*copy_arg);
case PURPLE_TYPE_ULONG:
- *copy_arg = (void *)va_arg(*args, unsigned long);
+ *copy_arg = (void *)va_arg(args, unsigned long);
return newSVuv((unsigned long)*copy_arg);
case PURPLE_TYPE_INT64:
#if 0
/* XXX This yells and complains. */
- *copy_arg = va_arg(*args, gint64);
+ *copy_arg = va_arg(args, gint64);
return newSViv(*copy_arg);
#endif
@@ -595,27 +595,27 @@ purple_perl_sv_from_vargs(const PurpleVa
case PURPLE_TYPE_UINT64:
/* XXX This also yells and complains. */
#if 0
- *copy_arg = (void *)va_arg(*args, guint64);
+ *copy_arg = (void *)va_arg(args, guint64);
return newSVuv(*copy_arg);
#endif
break;
case PURPLE_TYPE_STRING:
- if ((*copy_arg = (void *)va_arg(*args, char *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, char *)) == NULL)
return &PL_sv_undef;
return newSVGChar((char *)*copy_arg);
case PURPLE_TYPE_POINTER:
- if ((*copy_arg = (void *)va_arg(*args, void *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, void *)) == NULL)
return &PL_sv_undef;
return newSViv((IV)*copy_arg);
case PURPLE_TYPE_BOXED:
/* Uh.. I dunno. Try this? */
- if ((*copy_arg = (void *)va_arg(*args, void *)) == NULL)
+ if ((*copy_arg = (void *)va_arg(args, void *)) == NULL)
return &PL_sv_undef;
return sv_2mortal(purple_perl_bless_object(*copy_arg,
============================================================
--- libpurple/plugins/perl/perl-common.h a5e8672966d05aa79c881518e512bb430615ff5d
+++ libpurple/plugins/perl/perl-common.h 6de36df97116bb0740453ebc5619490ec0e675a3
@@ -65,7 +65,7 @@ void *purple_perl_data_from_sv(PurpleVal
#endif
void *purple_perl_data_from_sv(PurpleValue *value, SV *sv);
-SV *purple_perl_sv_from_vargs(const PurpleValue *value, va_list *args,
+SV *purple_perl_sv_from_vargs(const PurpleValue *value, va_list args,
void ***copy_arg);
SV *purple_perl_sv_from_fun(PurplePlugin *plugin, SV *callback);
#endif /* _PURPLE_PERL_COMMON_H_ */
============================================================
--- libpurple/plugins/perl/perl-handlers.c 2011d190d936b5e90a132e189b1b80db06cc2c37
+++ libpurple/plugins/perl/perl-handlers.c 6d5db4a77254f849dba439c24d20c6a1dc203268
@@ -298,11 +298,7 @@ perl_signal_cb(va_list args, void *data)
for (i = 0; i < value_count; i++) {
sv_args[i] = purple_perl_sv_from_vargs(values[i],
-#ifdef VA_COPY_AS_ARRAY
args,
-#else
- (va_list*)&args,
-#endif
©_args[i]);
XPUSHs(sv_args[i]);
More information about the Commits
mailing list