summaryrefslogtreecommitdiff
path: root/recording.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2013-01-13 11:57:50 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2013-01-13 11:57:50 +0100
commitd1d157d755669490d9b5ff65f015dc2a4ae10db7 (patch)
treed088e5ce1ee1ccc5f1a813f5f958f78ee61cfb06 /recording.c
parentfef409fe23c9fb6c8114255ad045336a2b97c287 (diff)
downloadvdr-d1d157d755669490d9b5ff65f015dc2a4ae10db7.tar.gz
vdr-d1d157d755669490d9b5ff65f015dc2a4ae10db7.tar.bz2
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
Diffstat (limited to 'recording.c')
-rw-r--r--recording.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/recording.c b/recording.c
index ca50f433..09c238df 100644
--- a/recording.c
+++ b/recording.c
@@ -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);