sb: add ty_sb_spaces_ltrim()

devs/bu5hm4n/fix-for-billiob
Boris Faure 3 years ago
parent 4a12891493
commit 15ee3702db
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
  1. 18
      src/bin/sb.c
  2. 1
      src/bin/sb.h

@ -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

@ -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);

Loading…
Cancel
Save