sb: add ty_sb_spaces_ltrim()
This commit is contained in:
parent
4a12891493
commit
15ee3702db
18
src/bin/sb.c
18
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
|
||||
|
|
|
@ -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…
Reference in New Issue