Fixed sorting recordings in case the locale ignores non-alphanumeric characters, or if two folders have the same name, but one of them ends in an additional digit

This commit is contained in:
Klaus Schmidinger 2013-01-13 11:57:50 +01:00
parent fef409fe23
commit d1d157d755
3 changed files with 18 additions and 6 deletions

View File

@ -1004,6 +1004,9 @@ Andreas Mair <amair.sob@googlemail.com>
for fixing initializing the timer's flags in the cTimer copy constructor
for reporting a crash in case CutRecording() is called from a plugin
for fixing the type of MBperMinute in cVideoDiskUsage::HasChanged()
for reporting a bug in sorting recordings in case the locale ignores non-alphanumeric
characters, or if two folders have the same name, but one of them ends in an
additional digit, as in "abc" and "abc2"
Olivier Jacques <jacquesolivier@hotmail.com>)
for translating OSD texts to the French language

View File

@ -7494,7 +7494,7 @@ Video Disk Recorder Revision History
use it.
- Added maximum SNR value for PCTV Systems PCTV 73ESE (thanks to Cedric Dewijs).
2013-01-12: Version 1.7.36
2013-01-13: Version 1.7.36
- Added maximum SNR value for PCTV Systems nanoStick T2 290e (thanks to Antti
Hartikainen).
@ -7513,3 +7513,6 @@ Video Disk Recorder Revision History
parameter ONEDIR=1 (using Make.config) to have all files in one /video directory as
before.
- Fixed the example for cReceiver in PLUGINS.html.
- Fixed sorting recordings in case the locale ignores non-alphanumeric characters,
or if two folders have the same name, but one of them ends in an additional digit,
as in "abc" and "abc2" (reported by Andreas Mair).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: recording.c 2.81 2012/12/23 15:11:28 kls Exp $
* $Id: recording.c 2.82 2013/01/13 11:47:44 kls Exp $
*/
#include "recording.h"
@ -824,10 +824,10 @@ char *cRecording::StripEpisodeName(char *s)
}
if (s1 && s2) {
// To have folders sorted before plain recordings, the '/' s1 points to
// is replaced by the character 'b'. All other slashes will be replaced
// by 'a' in SortName() (see below), which will result in the desired
// is replaced by the character '1'. All other slashes will be replaced
// by '0' in SortName() (see below), which will result in the desired
// sequence:
*s1 = 'b';
*s1 = '1';
s1++;
memmove(s1, s2, t - s2 + 1);
}
@ -840,7 +840,13 @@ char *cRecording::SortName(void) const
if (!*sb) {
char *s = (RecordingsSortMode == rsmName) ? strdup(FileName() + strlen(VideoDirectory))
: StripEpisodeName(strdup(FileName() + strlen(VideoDirectory)));
strreplace(s, '/', 'a'); // some locales ignore '/' when sorting
strreplace(s, '/', '0'); // some locales ignore '/' when sorting
for (char *p = s; *p; p++) {
if (*p == '/')
*p = '0'; // some locales ignore '/' when sorting
else if (*p < '0')
*p = ' '; // avoids multiple occurences of the same folder in case the locale ignores non-alphanumeric characters when sorting
}
int l = strxfrm(NULL, s, 0) + 1;
*sb = MALLOC(char, l);
strxfrm(*sb, s, l);