aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-21 16:29:28 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-21 16:29:45 +0200
commita1246757bcaa058144b335ff64a6a250e63effbd (patch)
tree45c34bd604ddea00493567a8174ae2d41f794a8d /lib
parent12727806af641970a651b8f969cba33677ae7395 (diff)
Make trim() helpers from get_line available outside
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r--lib/util/src/get_line.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/util/src/get_line.c b/lib/util/src/get_line.c
index 5a17b62..4273471 100644
--- a/lib/util/src/get_line.c
+++ b/lib/util/src/get_line.c
@@ -13,7 +13,7 @@
#include <string.h>
#include <ctype.h>
-static void ltrim(char *buffer)
+void ltrim(char *buffer)
{
size_t i = 0;
@@ -24,7 +24,7 @@ static void ltrim(char *buffer)
memmove(buffer, buffer + i, strlen(buffer + i) + 1);
}
-static void rtrim(char *buffer)
+void rtrim(char *buffer)
{
size_t i = strlen(buffer);
@@ -34,7 +34,13 @@ static void rtrim(char *buffer)
buffer[i] = '\0';
}
-static size_t trim(char *buffer, int flags)
+void trim(char *buffer)
+{
+ ltrim(buffer);
+ rtrim(buffer);
+}
+
+static size_t trim_flags(char *buffer, int flags)
{
if (flags & ISTREAM_LINE_LTRIM)
ltrim(buffer);
@@ -64,7 +70,7 @@ int istream_get_line(sqfs_istream_t *strm, char **out,
if (line_len == 0)
goto out_eof;
- line_len = trim(line, flags);
+ line_len = trim_flags(line, flags);
if (line_len > 0 ||!(flags & ISTREAM_LINE_SKIP_EMPTY))
break;
@@ -100,7 +106,7 @@ int istream_get_line(sqfs_istream_t *strm, char **out,
if (line_len > 0 && line[line_len - 1] == '\r')
line[--line_len] = '\0';
- line_len = trim(line, flags);
+ line_len = trim_flags(line, flags);
if (line_len > 0 || !(flags & ISTREAM_LINE_SKIP_EMPTY))
break;