Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
995eadb4
Commit
995eadb4
authored
May 05, 2012
by
Alejandro Mery
Browse files
fex2bin: use ctype to make alltrim() easier to digest
parent
6f4f4f86
Changes
1
Show whitespace changes
Inline
Side-by-side
fex2bin.c
View file @
995eadb4
...
...
@@ -16,6 +16,7 @@
*/
#include "fex2bin.h"
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
...
...
@@ -27,28 +28,22 @@
static
inline
char
*
alltrim
(
char
*
s
,
size_t
*
l
)
{
char
*
p
;
while
(
*
s
==
' '
||
*
s
==
'\t'
)
while
(
isblank
(
*
s
)
)
s
++
;
p
=
s
;
while
(
*++
p
)
;
/* seek \0 */
if
(
p
>
s
&&
p
[
-
1
]
==
'\n'
)
{
if
(
p
>
s
+
1
&&
p
[
-
2
]
==
'\r'
)
p
-=
2
;
else
p
-=
1
;
}
if
(
p
>
s
+
1
&&
p
[
-
2
]
==
'\r'
&&
p
[
-
1
]
==
'\n'
)
p
-=
2
;
else
if
(
p
>
s
&&
p
[
-
1
]
==
'\n'
)
p
-=
1
;
*
p
--
=
'\0'
;
while
(
p
>
s
)
{
if
(
*
p
==
' '
||
*
p
==
'\t'
)
p
--
;
else
break
;
}
while
(
p
>
s
&&
isblank
(
*
p
))
*
p
--
=
'\0'
;
*
p
=
'\0'
;
*
l
=
p
-
s
;
*
l
=
p
-
s
+
1
;
return
s
;
}
...
...
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