summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-21 08:19:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-21 08:19:59 +0000
commitbcf0a198f1d593b9711117a347544d8101e7288b (patch)
tree9cd1243f86c02e5492c5fdd97f9eaf5d9455dd1a /string.c
parent0f8a24a706e1e598a0e4bfaff3df0e0f8fc88d8c (diff)
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
Diffstat (limited to 'string.c')
-rw-r--r--string.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/string.c b/string.c
index e4f0293bb8..9a23ef554a 100644
--- a/string.c
+++ b/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);
+ }
}
/*