mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
Added cString::Append(char)
This commit is contained in:
parent
6458f8b581
commit
f0bbf64da0
18
tools.c
18
tools.c
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: tools.c 5.7 2022/11/22 14:33:48 kls Exp $
|
||||
* $Id: tools.c 5.8 2023/12/29 10:24:29 kls Exp $
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
@ -1130,6 +1130,22 @@ cString &cString::Append(const char *String)
|
||||
return *this;
|
||||
}
|
||||
|
||||
cString &cString::Append(char c)
|
||||
{
|
||||
if (c) {
|
||||
int l1 = s ? strlen(s) : 0;
|
||||
int l2 = 1;
|
||||
if (char *p = (char *)realloc(s, l1 + l2 + 1)) {
|
||||
s = p;
|
||||
*(s + l1) = c;
|
||||
*(s + l1 + 1) = 0;
|
||||
}
|
||||
else
|
||||
esyslog("ERROR: out of memory");
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
cString &cString::Truncate(int Index)
|
||||
{
|
||||
int l = strlen(s);
|
||||
|
3
tools.h
3
tools.h
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: tools.h 5.6 2021/05/26 13:37:53 kls Exp $
|
||||
* $Id: tools.h 5.7 2023/12/29 10:21:59 kls Exp $
|
||||
*/
|
||||
|
||||
#ifndef __TOOLS_H
|
||||
@ -189,6 +189,7 @@ public:
|
||||
cString &operator=(const cString &String);
|
||||
cString &operator=(const char *String);
|
||||
cString &Append(const char *String);
|
||||
cString &Append(char c);
|
||||
cString &Truncate(int Index); ///< Truncate the string at the given Index (if Index is < 0 it is counted from the end of the string).
|
||||
cString &CompactChars(char c); ///< Compact any sequence of characters 'c' to a single character, and strip all of them from the beginning and end of this string.
|
||||
static cString sprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user