mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
CASEMAP_DEBUG [ci skip]
* string.c (rb_str_casemap, rb_str_ascii_casemap): move debug/tuning messages under a preprocessor condition, CASEMAP_DEBUG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0f8a24a706
commit
bcf0a198f1
1 changed files with 15 additions and 6 deletions
21
string.c
21
string.c
|
@ -5755,6 +5755,9 @@ check_case_options(int argc, VALUE *argv, OnigCaseFoldType flags)
|
|||
|
||||
/* 16 should be long enough to absorb any kind of single character length increase */
|
||||
#define CASE_MAPPING_ADDITIONAL_LENGTH 20
|
||||
#ifndef CASEMAP_DEBUG
|
||||
# define CASEMAP_DEBUG 0
|
||||
#endif
|
||||
|
||||
struct mapping_buffer;
|
||||
typedef struct mapping_buffer {
|
||||
|
@ -5784,7 +5787,9 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
|
|||
while (source_current < source_end) {
|
||||
/* increase multiplier using buffer count to converge quickly */
|
||||
size_t capa = (size_t)(source_end-source_current)*++buffer_count + CASE_MAPPING_ADDITIONAL_LENGTH;
|
||||
/* fprintf(stderr, "Buffer allocation, capa is %d\n", capa); *//* for tuning */
|
||||
if (CASEMAP_DEBUG) {
|
||||
fprintf(stderr, "Buffer allocation, capa is %"PRIuSIZE"\n", capa); /* for tuning */
|
||||
}
|
||||
current_buffer->next = (mapping_buffer*)ALLOC_N(char, sizeof(mapping_buffer)+capa);
|
||||
current_buffer = current_buffer->next;
|
||||
current_buffer->next = NULL;
|
||||
|
@ -5807,7 +5812,9 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
|
|||
}
|
||||
target_length += current_buffer->used = buffer_length_or_invalid;
|
||||
}
|
||||
/* fprintf(stderr, "Buffer count is %d\n", buffer_count); *//* for tuning */
|
||||
if (CASEMAP_DEBUG) {
|
||||
fprintf(stderr, "Buffer count is %"PRIuSIZE"\n", buffer_count); /* for tuning */
|
||||
}
|
||||
|
||||
if (buffer_count==1) {
|
||||
target = rb_str_new_with_class(source, (const char*)current_buffer->space, target_length);
|
||||
|
@ -5854,10 +5861,12 @@ rb_str_ascii_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
|
|||
source_current, source_end, enc);
|
||||
if (length_or_invalid < 0)
|
||||
rb_raise(rb_eArgError, "input string invalid");
|
||||
/* if (length_or_invalid != old_length)
|
||||
printf("problem with rb_str_ascii_casemap; old_length=%d, new_length=%d\n", old_length, length_or_invalid),
|
||||
rb_raise(rb_eArgError, "internal problem with rb_str_ascii_casemap");
|
||||
*/
|
||||
if (CASEMAP_DEBUG && length_or_invalid != old_length) {
|
||||
fprintf(stderr, "problem with rb_str_ascii_casemap"
|
||||
"; old_length=%ld, new_length=%d\n", old_length, length_or_invalid);
|
||||
rb_raise(rb_eArgError, "internal problem with rb_str_ascii_casemap"
|
||||
"; old_length=%ld, new_length=%d\n", old_length, length_or_invalid);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue