libtags: trim text tags and ignore empty values
This commit is contained in:
parent
e5535fad32
commit
dd86214d77
2 changed files with 14 additions and 3 deletions
|
@ -36,12 +36,23 @@ static const Getter g[] =
|
|||
};
|
||||
|
||||
void
|
||||
tagscallcb(Tagctx *ctx, int type, const char *k, const char *s, int offset, int size, Tagread f)
|
||||
tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size, Tagread f)
|
||||
{
|
||||
char *e;
|
||||
|
||||
if(f == nil && size == 0){
|
||||
while(*s <= ' ' && *s)
|
||||
s++;
|
||||
e = s + strlen(s);
|
||||
while(e != s && e[-1] <= ' ')
|
||||
e--;
|
||||
*e = 0;
|
||||
}
|
||||
if(type != Tunknown){
|
||||
ctx->found |= 1<<type;
|
||||
ctx->num++;
|
||||
}
|
||||
if(*s)
|
||||
ctx->tag(ctx, type, k, s, offset, size, f);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,6 @@ int cp437toutf8(char *o, int osz, const char *s, int sz);
|
|||
*/
|
||||
void cbvorbiscomment(Tagctx *ctx, char *k, char *v);
|
||||
|
||||
void tagscallcb(Tagctx *ctx, int type, const char *k, const char *s, int offset, int size, Tagread f);
|
||||
void tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size, Tagread f);
|
||||
|
||||
#define txtcb(ctx, type, k, s) tagscallcb(ctx, type, k, (const char*)s, 0, 0, nil)
|
||||
|
|
Loading…
Reference in a new issue