History

trim text tags and ignore empty values

Sigrid Solveig Haflínudóttir committed 5 years ago

Commit 173b32f1 parent 7996f8d3 files · +15 −5Browse files

Unified · Split

3 files
  1. tags.c +13 −2
  2. tagspriv.h +1 −1
  3. xm.c +1 −2
tags.c+13−2
@@ -36,13 +36,24 @@ static const Getter g[] = · 35 unmodified lines
3636 };
3737
3838 void
39−tagscallcb(Tagctx *ctx, int type, const char *k, const char *s, int offset, int size, Tagread f)
39+tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size, Tagread f)
4040 {
41+ char *e;
42+
43+ if(f == nil && size == 0){
44+ while(*s <= ' ' && *s)
45+ s++;
46+ e = s + strlen(s);
47+ while(e != s && e[-1] <= ' ')
48+ e--;
49+ *e = 0;
50+ }
4151 if(type != Tunknown){
4252 ctx->found |= 1<<type;
4353 ctx->num++;
4454 }
45− ctx->tag(ctx, type, k, s, offset, size, f);
55+ if(*s)
56+ ctx->tag(ctx, type, k, s, offset, size, f);
4657 }
4758
4859 int
tagspriv.h+1−1
@@ -52,6 +52,6 @@ int cp437toutf8(char *o, int osz, const char *s, int sz); · 51 unmodified lines
5252 */
5353 void cbvorbiscomment(Tagctx *ctx, char *k, char *v);
5454
55−void tagscallcb(Tagctx *ctx, int type, const char *k, const char *s, int offset, int size, Tagread f);
55+void tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size, Tagread f);
5656
5757 #define txtcb(ctx, type, k, s) tagscallcb(ctx, type, k, (const char*)s, 0, 0, nil)
xm.c+1−2
@@ -3,12 +3,11 @@ · 2 unmodified lines
33 int
44 tagxm(Tagctx *ctx)
55 {
6− char d[17+20+1], o[20*UTFmax+1], *s;
6+ char d[17+20+1], o[20*UTFmax+1];
77
88 if(ctx->read(ctx, d, 17+20) != 17+20 || memcmp(d, "Extended Module: ", 17) != 0)
99 return -1;
1010 d[17+20] = 0;
11− for(s = d+17; *s == ' '; s++);
1211 if(cp437toutf8(o, sizeof(o), d+17, 20) > 0)
1312 txtcb(ctx, Ttitle, "", o);
1413

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t