git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rewrite the device subsystem interfaces (#48)
[lunaix-os.git]
/
lunaix-os
/
libs
/
klibc
/
string
/
trim.c
diff --git
a/lunaix-os/libs/klibc/string/trim.c
b/lunaix-os/libs/klibc/string/trim.c
index 82f29bd717ead44bcaddd5dd4c9fc6927a211a4c..82fbacc8622b85b642fe414874af3738d82a3a29 100644
(file)
--- a/
lunaix-os/libs/klibc/string/trim.c
+++ b/
lunaix-os/libs/klibc/string/trim.c
@@
-1,13
+1,14
@@
#include <klibc/string.h>
#include <klibc/string.h>
+#include <lunaix/compiler.h>
#define WS_CHAR(c) \
(c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\v' || c == '\r')
#define WS_CHAR(c) \
(c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\v' || c == '\r')
-void
+void
_weak
strrtrim(char* str)
{
strrtrim(char* str)
{
-
size_t
l = strlen(str);
- while (l < (
size_t
)-1) {
+
unsigned long
l = strlen(str);
+ while (l < (
unsigned long
)-1) {
char c = str[l];
if (!c || WS_CHAR(c)) {
l--;
char c = str[l];
if (!c || WS_CHAR(c)) {
l--;
@@
-18,12
+19,16
@@
strrtrim(char* str)
str[l + 1] = '\0';
}
str[l + 1] = '\0';
}
-void*
+char* _weak
strltrim_safe(char* str)
{
strltrim_safe(char* str)
{
-
size_t
l = 0;
+
unsigned long
l = 0;
char c = 0;
char c = 0;
- while ((c = str[l++]) && WS_CHAR(c))
- ;
- return strcpy(str, str + l);
+ while ((c = str[l]) && WS_CHAR(c)) {
+ l++;
+ }
+
+ if (l)
+ strcpy(str, str + l);
+ return str;
}
\ No newline at end of file
}
\ No newline at end of file