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
Hide whitespace changes
Inline
Side-by-side
fex2bin.c
View file @
995eadb4
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
*/
*/
#include "fex2bin.h"
#include "fex2bin.h"
#include <ctype.h>
#include <errno.h>
#include <errno.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
...
@@ -27,28 +28,22 @@
...
@@ -27,28 +28,22 @@
static
inline
char
*
alltrim
(
char
*
s
,
size_t
*
l
)
static
inline
char
*
alltrim
(
char
*
s
,
size_t
*
l
)
{
{
char
*
p
;
char
*
p
;
while
(
*
s
==
' '
||
*
s
==
'\t'
)
while
(
isblank
(
*
s
)
)
s
++
;
s
++
;
p
=
s
;
p
=
s
;
while
(
*++
p
)
while
(
*++
p
)
;
/* seek \0 */
;
/* seek \0 */
if
(
p
>
s
&&
p
[
-
1
]
==
'\n'
)
{
if
(
p
>
s
+
1
&&
p
[
-
2
]
==
'\r'
&&
p
[
-
1
]
==
'\n'
)
if
(
p
>
s
+
1
&&
p
[
-
2
]
==
'\r'
)
p
-=
2
;
p
-=
2
;
else
if
(
p
>
s
&&
p
[
-
1
]
==
'\n'
)
else
p
-=
1
;
p
-=
1
;
*
p
--
=
'\0'
;
}
while
(
p
>
s
)
{
while
(
p
>
s
&&
isblank
(
*
p
))
if
(
*
p
==
' '
||
*
p
==
'\t'
)
*
p
--
=
'\0'
;
p
--
;
else
break
;
}
*
p
=
'\0'
;
*
l
=
p
-
s
+
1
;
*
l
=
p
-
s
;
return
s
;
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