1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Using strgetlast() in more places

This commit is contained in:
Klaus Schmidinger 2021-01-01 15:26:27 +01:00
parent c46fd1ff5b
commit 40ca081ff4
4 changed files with 10 additions and 19 deletions

View File

@ -9569,8 +9569,9 @@ Video Disk Recorder Revision History
- Events in the past are no longer marked as having a timer in the Schedules - Events in the past are no longer marked as having a timer in the Schedules
menu. menu.
2020-12-31: 2021-01-01:
- Fixed strreplace() to handle NULL strings (reported by Jürgen Schneider). - Fixed strreplace() to handle NULL strings (reported by Jürgen Schneider).
- Somewhere down the road the 'x' bit of Doxyfile.filter got lost, so the - Somewhere down the road the 'x' bit of Doxyfile.filter got lost, so the
Makefile now makes sure it is set before calling doxygen. Makefile now makes sure it is set before calling doxygen.
- Using strgetlast() in more places.

14
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 5.1 2020/12/26 15:49:01 kls Exp $ * $Id: menu.c 5.2 2021/01/01 15:26:27 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -1094,11 +1094,7 @@ void cMenuEditTimer::SetPatternItem(bool Initial)
return; return;
} }
if (!*data.pattern) { if (!*data.pattern) {
char *p = strrchr(data.file, FOLDERDELIMCHAR); char *p = strgetlast(data.file, FOLDERDELIMCHAR);
if (p)
p++;
else
p = data.file;
strn0cpy(data.pattern, p, sizeof(data.pattern)); strn0cpy(data.pattern, p, sizeof(data.pattern));
} }
Ins(pattern = new cMenuEditStrItem( tr("Pattern"), data.pattern, sizeof(data.pattern)), true, file); Ins(pattern = new cMenuEditStrItem( tr("Pattern"), data.pattern, sizeof(data.pattern)), true, file);
@ -1120,11 +1116,7 @@ eOSState cMenuEditTimer::SetFolder(void)
{ {
if (cMenuFolder *mf = dynamic_cast<cMenuFolder *>(SubMenu())) { if (cMenuFolder *mf = dynamic_cast<cMenuFolder *>(SubMenu())) {
cString Folder = mf->GetFolder(); cString Folder = mf->GetFolder();
char *p = strrchr(data.file, FOLDERDELIMCHAR); char *p = strgetlast(data.file, FOLDERDELIMCHAR);
if (p)
p++;
else
p = data.file;
if (!isempty(*Folder)) if (!isempty(*Folder))
strn0cpy(data.file, cString::sprintf("%s%c%s", *Folder, FOLDERDELIMCHAR, p), sizeof(data.file)); strn0cpy(data.file, cString::sprintf("%s%c%s", *Folder, FOLDERDELIMCHAR, p), sizeof(data.file));
else if (p != data.file) else if (p != data.file)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: recording.c 5.1 2020/12/26 15:49:01 kls Exp $ * $Id: recording.c 5.2 2021/01/01 15:26:27 kls Exp $
*/ */
#include "recording.h" #include "recording.h"
@ -1050,9 +1050,7 @@ cString cRecording::Folder(void) const
cString cRecording::BaseName(void) const cString cRecording::BaseName(void) const
{ {
if (char *s = strrchr(name, FOLDERDELIMCHAR)) return strgetlast(name, FOLDERDELIMCHAR);
return cString(s + 1);
return name;
} }
const char *cRecording::FileName(void) const const char *cRecording::FileName(void) const
@ -1158,8 +1156,7 @@ int cRecording::HierarchyLevels(void) const
bool cRecording::IsEdited(void) const bool cRecording::IsEdited(void) const
{ {
const char *s = strrchr(name, FOLDERDELIMCHAR); const char *s = strgetlast(name, FOLDERDELIMCHAR);
s = !s ? name : s + 1;
return *s == '%'; return *s == '%';
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: tools.h 5.1 2020/12/26 15:49:01 kls Exp $ * $Id: tools.h 5.2 2021/01/01 15:26:27 kls Exp $
*/ */
#ifndef __TOOLS_H #ifndef __TOOLS_H
@ -234,6 +234,7 @@ char *strreplace(char *s, const char *s1, const char *s2); ///< re-allocates 's'
const char *strchrn(const char *s, char c, size_t n); ///< returns a pointer to the n'th occurrence (counting from 1) of c in s, or NULL if no such character was found. If n is 0, s is returned. const char *strchrn(const char *s, char c, size_t n); ///< returns a pointer to the n'th occurrence (counting from 1) of c in s, or NULL if no such character was found. If n is 0, s is returned.
int strcountchr(const char *s, char c); ///< returns the number of occurrences of 'c' in 's'. int strcountchr(const char *s, char c); ///< returns the number of occurrences of 'c' in 's'.
const char *strgetlast(const char *s, char c); // returns the part of 's' after the last occurrence of 'c', or 's' if there is no 'c'. const char *strgetlast(const char *s, char c); // returns the part of 's' after the last occurrence of 'c', or 's' if there is no 'c'.
inline char *strgetlast(char *s, char c) { return const_cast<char *>(strgetlast(static_cast<const char *>(s), c)); } // returns the part of 's' after the last occurrence of 'c', or 's' if there is no 'c'.
inline char *skipspace(const char *s) inline char *skipspace(const char *s)
{ {
if ((uchar)*s > ' ') // most strings don't have any leading space, so handle this case as fast as possible if ((uchar)*s > ' ') // most strings don't have any leading space, so handle this case as fast as possible