From c6a302283cee53d113d88db89c0a242576dbc8c4 Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期六, 13 六月 2020 10:15:50 +0800 Subject: [PATCH] 修改包路径 --- common/usg_common.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/common/usg_common.c b/common/usg_common.c index 4b0f76e..6ba65ae 100644 --- a/common/usg_common.c +++ b/common/usg_common.c @@ -76,3 +76,41 @@ fputs(buf, stderr); fflush(NULL); /* flushes all stdio output streams */ } + +char *ltrim(char *str, const char *seps) +{ + size_t totrim; + if (seps == NULL) { + seps = "\t\n\v\f\r "; + } + totrim = strspn(str, seps); + if (totrim > 0) { + size_t len = strlen(str); + if (totrim == len) { + str[0] = '\0'; + } + else { + memmove(str, str + totrim, len + 1 - totrim); + } + } + return str; +} + +char *rtrim(char *str, const char *seps) +{ + int i; + if (seps == NULL) { + seps = "\t\n\v\f\r "; + } + i = strlen(str) - 1; + while (i >= 0 && strchr(seps, str[i]) != NULL) { + str[i] = '\0'; + i--; + } + return str; +} + +char *trim(char *str, const char *seps) +{ + return ltrim(rtrim(str, seps), seps); +} \ No newline at end of file -- Gitblit v1.8.0