X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=blobdiff_plain;f=perl-module%2FPSPP.xs;h=8179d29a3721aa27b0b0e7417085a515eb65c591;hp=13386588b62c9738a6346a758717da61937cdb82;hb=6b562f8a8263930b8d1ed1862efec76f2511ed08;hpb=e588208caf725f595d63a07ddd2116331173e81d diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index 13386588..8179d29a 100644 --- a/perl-module/PSPP.xs +++ b/perl-module/PSPP.xs @@ -404,26 +404,27 @@ INIT: sv_setpv (errstr, ""); CODE: union value the_value; + int width = var_get_width (var); + int ok; + value_init (&the_value, width); if ( var_is_numeric (var)) { if ( ! looks_like_number (key)) { sv_setpv (errstr, "Cannot add label with string key to a numeric variable"); + value_destroy (&the_value, width); XSRETURN_IV (0); } the_value.f = SvNV (key); } else { - if ( var_is_long_string (var) ) - { - sv_setpv (errstr, "Cannot add label to a long string variable"); - XSRETURN_IV (0); - } - strncpy (the_value.short_string, SvPV_nolen(key), MAX_SHORT_STRING); + value_copy_str_rpad (&the_value, width, SvPV_nolen(key), ' '); } - if (! var_add_value_label (var, &the_value, label) ) + ok = var_add_value_label (var, &the_value, label); + value_destroy (&the_value, width); + if (!ok) { sv_setpv (errstr, "Something went wrong"); XSRETURN_IV (0);