ruby-changes:60195
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Wed, 26 Feb 2020 16:00:30 +0900 (JST)
Subject: [ruby-changes:60195] e7bcb416af (master): avoid #if inside of rb_str_new_cstr
https://git.ruby-lang.org/ruby.git/commit/?id=e7bcb416af From e7bcb416af64b6a935ff4ff18476aea606d12ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Tue, 25 Feb 2020 11:29:55 +0900 Subject: avoid #if inside of rb_str_new_cstr ISO/IEC 9899:1999 section 6.10.3 paragraph 11 explicitly states that "If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined." rb_str_new_cstr is in fact a macro. We cannot do this. diff --git a/gc.c b/gc.c index 21c93b1..7d24235 100644 --- a/gc.c +++ b/gc.c @@ -11331,7 +11331,7 @@ gc_profile_dump_on(VALUE out, VALUE (*append)(VALUE, VALUE)) https://github.com/ruby/ruby/blob/trunk/gc.c#L11331 } #if GC_PROFILE_MORE_DETAIL - append(out, rb_str_new_cstr("\n\n" \ + const char *str = "\n\n" \ "More detail.\n" \ "Prepare Time = Previously GC's rest sweep time\n" "Index Flags Allocate Inc. Allocate Limit" @@ -11345,7 +11345,8 @@ gc_profile_dump_on(VALUE out, VALUE (*append)(VALUE, VALUE)) https://github.com/ruby/ruby/blob/trunk/gc.c#L11345 #if GC_PROFILE_DETAIL_MEMORY " MaxRSS(KB) MinorFLT MajorFLT" #endif - "\n")); + "\n"; + append(out, rb_str_new_cstr(str)); for (i = 0; i < count; i++) { record = &objspace->profile.records[i]; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/