mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rb_enc_symname_type: refactor reduce goto
A bit readable to me.
This commit is contained in:
parent
0ead818d81
commit
0a43f0de27
1 changed files with 4 additions and 5 deletions
9
symbol.c
9
symbol.c
|
@ -372,9 +372,8 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
|
||||||
|
|
||||||
switch (f.kind) {
|
switch (f.kind) {
|
||||||
case invalid: return -1;
|
case invalid: return -1;
|
||||||
case stophere: goto stophere;
|
case stophere: break;
|
||||||
case needmore: break;
|
case needmore:
|
||||||
}
|
|
||||||
|
|
||||||
if (m >= e || (*m != '_' && !ISALPHA(*m) && ISASCII(*m))) {
|
if (m >= e || (*m != '_' && !ISALPHA(*m) && ISASCII(*m))) {
|
||||||
if (len > 1 && *(e-1) == '=') {
|
if (len > 1 && *(e-1) == '=') {
|
||||||
|
@ -384,7 +383,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
|
while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
|
||||||
if (m >= e) goto stophere;
|
if (m >= e) break;
|
||||||
switch (*m) {
|
switch (*m) {
|
||||||
case '!': case '?':
|
case '!': case '?':
|
||||||
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
|
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
|
||||||
|
@ -398,8 +397,8 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
|
||||||
++m;
|
++m;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stophere:
|
|
||||||
return m == e ? type : -1;
|
return m == e ? type : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue