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
36};36};
37 37
38void38void
39tagscallcb(Tagctx *ctx, int type, const char *k, const char *s, int offset, int size, Tagread f)39tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size, Tagread f)
40{40{
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 }
41 if(type != Tunknown){51 if(type != Tunknown){
42 ctx->found |= 1<<type;52 ctx->found |= 1<<type;
43 ctx->num++;53 ctx->num++;
44 }54 }
45 ctx->tag(ctx, type, k, s, offset, size, f);55 if(*s)
56 ctx->tag(ctx, type, k, s, offset, size, f);
46}57}
47 58
48int59int
tagspriv.h+1−1
@@ -52,6 +52,6 @@ int cp437toutf8(char *o, int osz, const char *s, int sz); · 51 unmodified lines
52 */52 */
53void cbvorbiscomment(Tagctx *ctx, char *k, char *v);53void cbvorbiscomment(Tagctx *ctx, char *k, char *v);
54 54
55void tagscallcb(Tagctx *ctx, int type, const char *k, const char *s, int offset, int size, Tagread f);55void tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size, Tagread f);
56 56
57#define txtcb(ctx, type, k, s) tagscallcb(ctx, type, k, (const char*)s, 0, 0, nil)57#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
3int3int
4tagxm(Tagctx *ctx)4tagxm(Tagctx *ctx)
5{5{
6 char d[17+20+1], o[20*UTFmax+1], *s;6 char d[17+20+1], o[20*UTFmax+1];
7 7
8 if(ctx->read(ctx, d, 17+20) != 17+20 || memcmp(d, "Extended Module: ", 17) != 0)8 if(ctx->read(ctx, d, 17+20) != 17+20 || memcmp(d, "Extended Module: ", 17) != 0)
9 return -1;9 return -1;
10 d[17+20] = 0;10 d[17+20] = 0;
11 for(s = d+17; *s == ' '; s++);
12 if(cp437toutf8(o, sizeof(o), d+17, 20) > 0)11 if(cp437toutf8(o, sizeof(o), d+17, 20) > 0)
13 txtcb(ctx, Ttitle, "", o);12 txtcb(ctx, Ttitle, "", o);
14 13

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