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
42e1f0cd
Commit
42e1f0cd
authored
Jun 26, 2012
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #325 from monaka/pr-refactor-hex_to_str
Refactor hex_to_str().
parents
8f5017e7
568af551
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
src/load.c
src/load.c
+13
-9
No files found.
src/load.c
View file @
42e1f0cd
...
@@ -608,13 +608,11 @@ static char*
...
@@ -608,13 +608,11 @@ static char*
hex_to_str
(
char
*
hex
,
char
*
str
,
uint16_t
*
str_len
)
hex_to_str
(
char
*
hex
,
char
*
str
,
uint16_t
*
str_len
)
{
{
char
*
src
,
*
dst
;
char
*
src
,
*
dst
;
uint16_t
hex_len
=
strlen
(
hex
)
;
int
escape
=
0
;
*
str_len
=
0
;
*
str_len
=
0
;
for
(
src
=
hex
,
dst
=
str
;
*
src
!=
'\0'
;
src
++
)
{
for
(
src
=
hex
,
dst
=
str
;
hex_len
>
0
;
(
*
str_len
)
++
,
hex_len
--
)
{
if
(
escape
)
{
if
(
*
src
==
'\\'
&&
hex_len
>
1
)
{
src
++
;
hex_len
--
;
switch
(
*
src
)
{
switch
(
*
src
)
{
case
'a'
:
*
dst
++
=
'\a'
/* BEL */
;
break
;
case
'a'
:
*
dst
++
=
'\a'
/* BEL */
;
break
;
case
'b'
:
*
dst
++
=
'\b'
/* BS */
;
break
;
case
'b'
:
*
dst
++
=
'\b'
/* BS */
;
break
;
...
@@ -629,12 +627,18 @@ hex_to_str(char *hex, char *str, uint16_t *str_len)
...
@@ -629,12 +627,18 @@ hex_to_str(char *hex, char *str, uint16_t *str_len)
case
'\\'
:
*
dst
++
=
*
src
;
break
;
case
'\\'
:
*
dst
++
=
*
src
;
break
;
default:
break
;
default:
break
;
}
}
src
++
;
escape
=
0
;
}
else
{
}
else
{
*
dst
++
=
*
src
++
;
if
(
*
src
==
'\\'
)
{
escape
=
1
;
}
else
{
escape
=
0
;
*
dst
++
=
*
src
;
}
}
if
(
!
escape
)
{
(
*
str_len
)
++
;
}
}
}
}
return
str
;
return
str
;
}
}
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