mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a6fac6a669
commit
df925d91e2
2 changed files with 19 additions and 15 deletions
|
@ -1,3 +1,7 @@
|
|||
Fri Jan 7 00:37:35 2011 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* string.c: parenthesize macro arguments.
|
||||
|
||||
Thu Jan 6 20:55:49 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* lib/mkmf.rb (create_makefile): ignore rest from first dot from
|
||||
|
|
30
string.c
30
string.c
|
@ -16,8 +16,8 @@
|
|||
#include "ruby/encoding.h"
|
||||
#include <assert.h>
|
||||
|
||||
#define BEG(no) regs->beg[no]
|
||||
#define END(no) regs->end[no]
|
||||
#define BEG(no) (regs->beg[(no)])
|
||||
#define END(no) (regs->end[(no)])
|
||||
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
|
@ -53,21 +53,21 @@ VALUE rb_cSymbol;
|
|||
#define STR_NOEMBED FL_USER1
|
||||
#define STR_SHARED FL_USER2 /* = ELTS_SHARED */
|
||||
#define STR_ASSOC FL_USER3
|
||||
#define STR_SHARED_P(s) FL_ALL(s, STR_NOEMBED|ELTS_SHARED)
|
||||
#define STR_ASSOC_P(s) FL_ALL(s, STR_NOEMBED|STR_ASSOC)
|
||||
#define STR_SHARED_P(s) FL_ALL((s), STR_NOEMBED|ELTS_SHARED)
|
||||
#define STR_ASSOC_P(s) FL_ALL((s), STR_NOEMBED|STR_ASSOC)
|
||||
#define STR_NOCAPA (STR_NOEMBED|ELTS_SHARED|STR_ASSOC)
|
||||
#define STR_NOCAPA_P(s) (FL_TEST(s,STR_NOEMBED) && FL_ANY(s,ELTS_SHARED|STR_ASSOC))
|
||||
#define STR_NOCAPA_P(s) (FL_TEST((s),STR_NOEMBED) && FL_ANY((s),ELTS_SHARED|STR_ASSOC))
|
||||
#define STR_UNSET_NOCAPA(s) do {\
|
||||
if (FL_TEST(s,STR_NOEMBED)) FL_UNSET(s,(ELTS_SHARED|STR_ASSOC));\
|
||||
if (FL_TEST((s),STR_NOEMBED)) FL_UNSET((s),(ELTS_SHARED|STR_ASSOC));\
|
||||
} while (0)
|
||||
|
||||
|
||||
#define STR_SET_NOEMBED(str) do {\
|
||||
FL_SET(str, STR_NOEMBED);\
|
||||
STR_SET_EMBED_LEN(str, 0);\
|
||||
FL_SET((str), STR_NOEMBED);\
|
||||
STR_SET_EMBED_LEN((str), 0);\
|
||||
} while (0)
|
||||
#define STR_SET_EMBED(str) FL_UNSET(str, STR_NOEMBED)
|
||||
#define STR_EMBED_P(str) (!FL_TEST(str, STR_NOEMBED))
|
||||
#define STR_SET_EMBED(str) FL_UNSET((str), STR_NOEMBED)
|
||||
#define STR_EMBED_P(str) (!FL_TEST((str), STR_NOEMBED))
|
||||
#define STR_SET_EMBED_LEN(str, n) do { \
|
||||
long tmp_n = (n);\
|
||||
RBASIC(str)->flags &= ~RSTRING_EMBED_LEN_MASK;\
|
||||
|
@ -76,7 +76,7 @@ VALUE rb_cSymbol;
|
|||
|
||||
#define STR_SET_LEN(str, n) do { \
|
||||
if (STR_EMBED_P(str)) {\
|
||||
STR_SET_EMBED_LEN(str, n);\
|
||||
STR_SET_EMBED_LEN((str), (n));\
|
||||
}\
|
||||
else {\
|
||||
RSTRING(str)->as.heap.len = (n);\
|
||||
|
@ -87,7 +87,7 @@ VALUE rb_cSymbol;
|
|||
if (STR_EMBED_P(str)) {\
|
||||
long n = RSTRING_LEN(str);\
|
||||
n--;\
|
||||
STR_SET_EMBED_LEN(str, n);\
|
||||
STR_SET_EMBED_LEN((str), n);\
|
||||
}\
|
||||
else {\
|
||||
RSTRING(str)->as.heap.len--;\
|
||||
|
@ -97,7 +97,7 @@ VALUE rb_cSymbol;
|
|||
#define RESIZE_CAPA(str,capacity) do {\
|
||||
if (STR_EMBED_P(str)) {\
|
||||
if ((capacity) > RSTRING_EMBED_LEN_MAX) {\
|
||||
char *tmp = ALLOC_N(char, capacity+1);\
|
||||
char *tmp = ALLOC_N(char, (capacity)+1);\
|
||||
memcpy(tmp, RSTRING_PTR(str), RSTRING_LEN(str));\
|
||||
RSTRING(str)->as.heap.ptr = tmp;\
|
||||
RSTRING(str)->as.heap.len = RSTRING_LEN(str);\
|
||||
|
@ -1276,7 +1276,7 @@ str_make_independent_expand(VALUE str, long expand)
|
|||
RSTRING(str)->as.heap.aux.capa = capa;
|
||||
}
|
||||
|
||||
#define str_make_independent(str) str_make_independent_expand(str, 0L)
|
||||
#define str_make_independent(str) str_make_independent_expand((str), 0L)
|
||||
|
||||
void
|
||||
rb_str_modify(VALUE str)
|
||||
|
@ -1791,7 +1791,7 @@ str_buf_cat(VALUE str, const char *ptr, long len)
|
|||
return str;
|
||||
}
|
||||
|
||||
#define str_buf_cat2(str, ptr) str_buf_cat(str, (ptr), strlen(ptr))
|
||||
#define str_buf_cat2(str, ptr) str_buf_cat((str), (ptr), strlen(ptr))
|
||||
|
||||
VALUE
|
||||
rb_str_buf_cat(VALUE str, const char *ptr, long len)
|
||||
|
|
Loading…
Add table
Reference in a new issue