diff --git a/src/bin/sb.c b/src/bin/sb.c index 7aa79226..c91bfd3a 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 f52f775e..3462defd 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);