FS#12132 - tagnavi: Support "basename" in formats and conditions; replace <Untagged> in track views

Attached to Project: Rockbox
Opened by sideral (sideral) - Saturday, 28 May 2011, 22:20 GMT
Last edited by sideral (sideral) - Thursday, 04 August 2011, 12:38 GMT
Task Type Patches
Category Database
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


This patch set (in patch 0006) adds support to the tagnavi.config syntax for using a file's basename (path name without directories) in display formats and conditions.

Patch 0007 changes the database's default title format to display a file's basename rather than "<Untagged>" if no title tag is present in the file.

In passing, patch 0001 fixes two bugs introduced with r26192 ( FS#10976  - make the <Untagged> string translatable):

* The translation was done too early: before the tagnavi format clauses were checked. This prevented comparisons against "<Untagged>" when a non-English translation was active.
* The code overwrote the buffer containing the constant string "<Untagged>" with the translation. This is neither safe nor necessary: The result pointer simply can be swapped with a pointer to the translation.

Patches 0002–0005 contain various minor DB cleanups the other patches rely on. (I'll commit the fixes and cleanups separately from the basename feature after some testing.)

Patches relative to r29928.
This task depends upon

Closed by  sideral (sideral)
Thursday, 04 August 2011, 12:38 GMT
Reason for closing:  Accepted
Comment by Michael Sevakis (MikeS) - Wednesday, 01 June 2011, 02:00 GMT
All your basename are belong to us.

I appreciate you taking on the basname/untagged issue (well, one of my peeves as it were).
Comment by sideral (sideral) - Wednesday, 01 June 2011, 08:52 GMT
Committed the untagged-translation fix (patch 0001) as r29941.
Comment by sideral (sideral) - Monday, 06 June 2011, 16:24 GMT
Updated patch 0006: Added support for "%{width}.{truncation}s" in tagnavi %formats. String truncation is especially useful when using part of a string tag, filename, or basename for sorting and %strip'ing.

Also renovated the format_str() code a bit (improved structuring, removed code duplication) and increased the maximum length of a printf conversion specification to 20 characters.

Rebased patch to r29975 (required because of r29937 /  FS#12136 ).
Comment by sideral (sideral) - Monday, 06 June 2011, 23:04 GMT
Committed patches 0002–0005 as r29978–r29981.
Comment by sideral (sideral) - Tuesday, 07 June 2011, 13:33 GMT
Updated patch 0007 to also provides a sane default format for Database->Tracks.
Comment by sideral (sideral) - Monday, 01 August 2011, 12:22 GMT
Committed patches 6 and 7 as r30229–r30231.

The binsize increase struck me as a bit large, so I went and optimized it a bit – see attached patch. Also reduces stack usage quite a bit.
Comment by sideral (sideral) - Thursday, 04 August 2011, 12:37 GMT
Committed patch 8 as r30248. Sadly, it didn't yield the binsize decrease I'd envisioned across the board, but I think the stack-usage decrease was worth it, as was the buffer-bounds check fix.