From d1d157d755669490d9b5ff65f015dc2a4ae10db7 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 13 Jan 2013 11:57:50 +0100 Subject: [PATCH] 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 --- CONTRIBUTORS | 3 +++ HISTORY | 5 ++++- recording.c | 16 +++++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 1d027ea5..2ee44fdd 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1004,6 +1004,9 @@ Andreas Mair 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 ) for translating OSD texts to the French language diff --git a/HISTORY b/HISTORY index b1ca024a..536e4008 100644 --- a/HISTORY +++ b/HISTORY @@ -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). 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);