FS#13497: '0' is sometimes a valid track number

Most notably for CD rips that use a track number of 0 for
the leadin.

Therefore change our "invalid track number" canary to -1 instead
of 0.  Additionally don't try to parse an empty string.

In the process, get rid of redudant 'discnum = 0' as well.

NOTE: While not strictly necessary, we recommend rebuilding the
      database to ensure files without track numbers are
      updated with the new canary.

Change-Id: I543f98ca49cec7b5eeffa7c14c1eca57171f345a
This commit is contained in:
Solomon Peachy 2025-11-19 21:03:34 -05:00
parent 481cc70fe0
commit e94a96cdcf
15 changed files with 104 additions and 89 deletions

View file

@ -263,7 +263,7 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
case SKIN_TOKEN_METADATA_TRACK_NUMBER:
if (id3->track_string)
return id3->track_string;
if (id3->tracknum) {
if (id3->tracknum >= 0) {
itoa_buf(buf, buf_size, id3->tracknum);
return buf;
}

View file

@ -173,7 +173,7 @@ void finalize_id3(struct mp3entry *id3)
id3->codectype = mul_id3.codectype;
id3->vbr = mul_id3.vbr;
id3->discnum = 0;
id3->tracknum = 0;
id3->tracknum = -1;
id3->track_level = 0;
id3->album_level = 0;
}

View file

@ -571,7 +571,7 @@ static const char * id3_get_or_speak_info(int selected_item, void* data,
if(say_it)
say_number_and_spell(val, true);
}
else if (id3->tracknum)
else if (id3->tracknum >= 0)
{
itoa_buf(buffer, buffer_len, id3->tracknum);
val = buffer;

View file

@ -2322,7 +2322,7 @@ static void NO_INLINE add_tagcache(char *path, unsigned long mtime)
logf("-> %s", path);
if (id3.tracknum <= 0) /* Track number missing? */
if (id3.tracknum < 0) /* Track number missing? */
{
id3.tracknum = -1;
}