billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=15ee3702db8b8d592ca1acd8daa2dce12b5e0cd9

commit 15ee3702db8b8d592ca1acd8daa2dce12b5e0cd9
Author: Boris Faure <bill...@gmail.com>
Date:   Fri May 15 23:15:18 2020 +0200

    sb: add ty_sb_spaces_ltrim()
---
 src/bin/sb.c | 18 ++++++++++++++++++
 src/bin/sb.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/src/bin/sb.c b/src/bin/sb.c
index 7aa7922..c91bfd3 100644
--- a/src/bin/sb.c
+++ b/src/bin/sb.c
@@ -59,6 +59,24 @@ ty_sb_prepend(struct ty_sb *sb, const char *s, size_t  len)
    return 0;
 }
 
+/* unlike eina_strbuf_rtrim, only trims \t, \f, ' ' */
+void
+ty_sb_spaces_ltrim(struct ty_sb *sb)
+{
+   if (!sb->buf)
+     return;
+
+   while (sb->len > 0)
+     {
+        char c = sb->buf[0];
+        if ((c != ' ') && (c != '\t') && (c != '\f'))
+            break;
+        sb->len--;
+        sb->buf++;
+        sb->gap++;
+     }
+   sb->buf[sb->len] = '\0';
+}
 
 /* unlike eina_strbuf_rtrim, only trims \t, \f, ' ' */
 void
diff --git a/src/bin/sb.h b/src/bin/sb.h
index f52f775..3462def 100644
--- a/src/bin/sb.h
+++ b/src/bin/sb.h
@@ -12,6 +12,7 @@ struct ty_sb {
 
 int ty_sb_add(struct ty_sb *sb, const char *s, size_t len);
 void ty_sb_spaces_rtrim(struct ty_sb *sb);
+void ty_sb_spaces_ltrim(struct ty_sb *sb);
 int ty_sb_prepend(struct ty_sb *sb, const char *s, size_t  len);
 char *ty_sb_steal_buf(struct ty_sb *sb);
 void ty_sb_lskip(struct ty_sb *sb, int len);

-- 


Reply via email to