diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-21 08:19:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-21 08:19:59 +0000 |
commit | 72c8eeb6ae01c91e258f291e53036f6d6e921629 (patch) | |
tree | 9cd1243f86c02e5492c5fdd97f9eaf5d9455dd1a | |
parent | 043ef6fab2d078f4fca093d5c8b2fa1da78a544e (diff) | |
download | ruby-72c8eeb6ae01c91e258f291e53036f6d6e921629.tar.gz |
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
-rw-r--r-- | string.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -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); + } } /* |