Ticket #976: remove-struct-poking.patch
File remove-struct-poking.patch, 4.9 KB (added by darbelo, 12 years ago) |
---|
-
src/interp/inter_cb.c
299 299 PMC *sub; 300 300 STRING *sig_str; 301 301 char *p; 302 char ch; 303 char *sig_cstr; 302 304 char pasm_sig[4]; 303 305 INTVAL i_param; 304 306 PMC *p_param; … … 311 313 signature = VTABLE_getprop(interp, user_data, sc); 312 314 313 315 sig_str = VTABLE_get_string(interp, signature); 314 p = sig_str->strstart; 316 sig_cstr = Parrot_str_to_cstring(interp, sig_str); 317 p = sig_cstr; 315 318 ++p; /* Skip return type */ 316 319 317 320 pasm_sig[0] = 'v'; /* no return value supported yet */ … … 367 370 param = Parrot_str_new(interp, external_data, 0); 368 371 break; 369 372 default: 373 ch = *p; 374 Parrot_str_free_cstring(sig_cstr); 370 375 Parrot_ex_throw_from_c_args(interp, NULL, 1, 371 "unhandled signature char '%c' in run_cb", *p);376 "unhandled signature char '%c' in run_cb", ch); 372 377 } 378 Parrot_str_free_cstring(sig_cstr); 373 379 pasm_sig[3] = '\0'; 374 380 Parrot_runops_fromc_args_event(interp, sub, pasm_sig, 375 381 user_data, param); -
src/pmc/string.pmc
734 734 enum_class_Integer)); 735 735 736 736 /* TODO verify encoding */ 737 const STRING *me = VTABLE_get_string(INTERP, SELF); 738 const char *start = me->strstart; 739 const char * const end = start + me->bufused; 740 UINTVAL i = 0; 737 const STRING *me = VTABLE_get_string(INTERP, SELF); 738 char *str = Parrot_str_to_cstring(INTERP, me); 739 UINTVAL i = 0; 740 size_t j = 0; 741 size_t len = strlen(str); 741 742 742 743 if (base < 2 || base > 36) 743 744 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION, 744 745 "invalid conversion to int - bad base %d", base); 745 746 746 while ( start < end) {747 const unsigned char c = *start;747 while ( j < len) { 748 const unsigned char c = str[j]; 748 749 int dig; 749 750 750 751 if (isdigit((unsigned char)c)) … … 760 761 break; 761 762 762 763 i = i * base + dig; 763 ++start;764 j++; 764 765 } 765 766 766 if (start < end) 767 if (j < len) { 768 char ch = str[j]; 769 Parrot_str_free_cstring(str); 767 770 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION, 768 "invalid conversion to int - bad char %c", *start); 771 "invalid conversion to int - bad char %c", ch); 772 } 769 773 774 Parrot_str_free_cstring(str); 770 775 /* TODO: autopromote to BigInt instead of casting away the high bit */ 771 776 VTABLE_set_integer_native(INTERP, result, (INTVAL)i); 772 777 RETURN(PMC *result); -
src/pmc/hash.pmc
620 620 621 621 for (j = 0; j < n; ++j) { 622 622 STRING * const key = VTABLE_shift_string(INTERP, iter); 623 char * key_str; 624 size_t i, str_len; 623 625 int all_digit = 1; 624 int i;625 626 PMC *val; 626 627 627 for (i = 0; i < (int)key->strlen; ++i) { 628 if (!isdigit((unsigned char)((const char *)key->strstart)[i])) { 628 key_str = Parrot_str_to_cstring(INTERP, key); 629 str_len = strlen(key_str); 630 for (i = 0; i < str_len; ++i) { 631 if (!isdigit(key_str[i])) { 629 632 all_digit = 0; 630 633 break; 631 634 } 632 635 } 636 Parrot_str_free_cstring(key_str); 633 637 634 638 if (all_digit) { 635 639 res = Parrot_str_append(INTERP, res, key); -
src/packdump.c
224 224 ct_index = PackFile_find_in_const(interp, ct, key, PFC_STRING); 225 225 Parrot_io_printf(interp, " PFC_OFFSET => %ld\n", ct_index); 226 226 detail = ct->constants[ct_index]; 227 Parrot_io_printf(interp, " DATA => '%.*s'\n", 228 (int)detail->u.string->bufused, 229 (char *)detail->u.string->strstart); 227 Parrot_io_printf(interp, " DATA => '%Ss'\n", 228 detail->u.string); 230 229 Parrot_io_printf(interp, " },\n"); 231 230 } 232 231 break;