string trimming
This commit is contained in:
1 parent
9be3473864
commit
810eaeac25
2 files changed
+16
No files matched your search
@@ -1409,6 +1409,20 @@ void str_inverse_bin(char *buf, size_t len) {
|
||||
}
|
||||
}
|
||||
|
||||
void str_trim(char *s) {
|
||||
if (s == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// handle empty string
|
||||
if (!*s) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *ptr;
|
||||
for (ptr = s + strlen(s) - 1; (ptr >= s) && isspace(*ptr); --ptr);
|
||||
ptr[1] = '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a hex string to component "hi2", "hi" and "lo" 32-bit integers
|
||||
|
||||
Reference in new issue
Block a user