Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
76d752c0
Unverified
Commit
76d752c0
authored
Apr 28, 2020
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `presym_find` for strings without `NUL` terminators.
parent
33647b90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
src/symbol.c
src/symbol.c
+9
-10
No files found.
src/symbol.c
View file @
76d752c0
...
...
@@ -24,21 +24,21 @@ static const char *presym_table[] = {
};
static
mrb_sym
presym_find
(
const
char
*
name
)
presym_find
(
const
char
*
name
,
size_t
len
)
{
int
start
=
0
;
int
end
=
MRB_PRESYM_MAX
-
1
;
while
(
start
<=
end
)
{
int
mid
=
(
start
+
end
)
/
2
;
int
cmp
=
str
cmp
(
name
,
presym_table
[
mid
]
);
int
cmp
=
str
ncmp
(
name
,
presym_table
[
mid
],
len
);
if
(
cmp
==
0
)
{
if
(
cmp
==
0
&&
presym_table
[
mid
][
len
]
==
'\0'
)
{
return
mid
+
1
;
}
else
if
(
cmp
<
0
)
{
end
=
mid
-
1
;
}
else
{
}
else
if
(
cmp
>
0
)
{
start
=
mid
+
1
;
}
else
{
end
=
mid
-
1
;
}
}
return
0
;
...
...
@@ -170,10 +170,9 @@ find_symbol(mrb_state *mrb, const char *name, size_t len, uint8_t *hashp)
uint8_t
hash
;
/* presym */
if
(
strlen
(
name
)
==
len
)
{
i
=
presym_find
(
name
);
if
(
i
>
0
)
return
i
<<
SYMBOL_NORMAL_SHIFT
;
}
i
=
presym_find
(
name
,
len
);
if
(
i
>
0
)
return
i
<<
SYMBOL_NORMAL_SHIFT
;
/* inline symbol */
i
=
sym_inline_pack
(
name
,
len
);
if
(
i
>
0
)
return
i
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment