From 8849308cf9ad1e85ed1790aa832806ce7f74e565 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 22 Jul 2007 18:00:00 +0200 Subject: =?UTF-8?q?Version=201.5.6=20-=20Fixed=20a=20buffer=20overflow=20i?= =?UTF-8?q?n=20initializing=20the=20system=20character=20table=20(thanks?= =?UTF-8?q?=20=20=20to=20Marco=20Schl=C3=BC=C3=9Fler).=20-=20Updated=20the?= =?UTF-8?q?=20Russian=20OSD=20texts=20(thanks=20to=20Oleg=20Roitburd).=20-?= =?UTF-8?q?=20Fixed=20handling=20single=20byte=20characters=20>0x7F=20in?= =?UTF-8?q?=20Utf8ToArray()=20(thanks=20to=20Udo=20=20=20Richter).=20-=20I?= =?UTF-8?q?mproved=20numdigits(),=20isnumber()=20and=20strreplace()=20(tha?= =?UTF-8?q?nks=20to=20Tobias=20Bratfisch).=20-=20Fixed=20clearing=20color?= =?UTF-8?q?=20buttons=20in=20the=20'curses'=20skin=20(thanks=20to=20Udo=20?= =?UTF-8?q?Richter).=20-=20Fixed=20a=20typo=20in=20the=20function=20name?= =?UTF-8?q?=20of=20cOsd::SetOsdPosition()=20and=20added=20a=20range=20=20?= =?UTF-8?q?=20check=20to=20it=20(thanks=20to=20Christoph=20Haubrich).=20-?= =?UTF-8?q?=20Updated=20the=20Finnish=20OSD=20texts=20(thanks=20to=20Rolf?= =?UTF-8?q?=20Ahrenberg).=20-=20Improved=20cControl::Launch()=20to=20keep?= =?UTF-8?q?=20'control'=20from=20pointing=20to=20uninitialized=20=20=20mem?= =?UTF-8?q?ory=20(thanks=20to=20Rolf=20Ahrenberg).=20-=20Made=20skipspace(?= =?UTF-8?q?)=20an=20inline=20function=20(suggested=20by=20Tobias=20Bratfis?= =?UTF-8?q?ch)=20and=20changed=20=20=20it=20to=20handle=20the=20most=20com?= =?UTF-8?q?mon=20case=20of=20'no=20leading=20space'=20very=20fast,=20and?= =?UTF-8?q?=20avoid=20=20=20calling=20isspace(),=20which=20made=20the=20wh?= =?UTF-8?q?ole=20function=20a=20lot=20faster.=20-=20Fixed=20detection=20of?= =?UTF-8?q?=20Premiere=20NVOD=20channel=20links=20(thanks=20to=20Markus=20?= =?UTF-8?q?Hahn).=20-=20Added=20a=20table=20of=20the=20used=20trick=20spee?= =?UTF-8?q?d=20values=20to=20the=20description=20of=20=20=20cDevice::Trick?= =?UTF-8?q?Speed()=20(suggested=20by=20Martin=20Dauskardt).=20-=20Added=20?= =?UTF-8?q?a=20missing=20'P'=20to=20vdr.c's=20SHUTDOWNCANCELROMPT=20macro?= =?UTF-8?q?=20(reported=20by=20Marco=20=20=20Schl=C3=BC=C3=9Fler).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'tools.c') diff --git a/tools.c b/tools.c index edff762..0d471bb 100644 --- a/tools.c +++ b/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 1.130 2007/06/23 13:38:30 kls Exp $ + * $Id: tools.c 1.134 2007/07/21 13:02:45 kls Exp $ */ #include "tools.h" @@ -158,21 +158,15 @@ char *strreplace(char *s, const char *s1, const char *s2) int l1 = strlen(s1); int l2 = strlen(s2); if (l2 > l1) - s = (char *)realloc(s, strlen(s) + l2 - l1 + 1); + s = (char *)realloc(s, l + l2 - l1 + 1); + char *sof = s + of; if (l2 != l1) - memmove(s + of + l2, s + of + l1, l - of - l1 + 1); - strncpy(s + of, s2, l2); + memmove(sof + l2, sof + l1, l - of - l1 + 1); + strncpy(sof, s2, l2); } return s; } -char *skipspace(const char *s) -{ - while (*s && isspace(*s)) - s++; - return (char *)s; -} - char *stripspace(char *s) { if (s && *s) { @@ -252,20 +246,22 @@ bool isempty(const char *s) int numdigits(int n) { - char buf[16]; - snprintf(buf, sizeof(buf), "%d", n); - return strlen(buf); + int res = 1; + while (n >= 10) { + n /= 10; + res++; + } + return res; } bool isnumber(const char *s) { if (!*s) return false; - while (*s) { - if (!isdigit(*s)) - return false; - s++; - } + do { + if (!isdigit(*s)) + return false; + } while (*++s); return true; } @@ -685,7 +681,7 @@ int Utf8ToArray(const char *s, uint *a, int Size) int n = 0; while (*s && --Size > 0) { if (cCharSetConv::SystemCharacterTable()) - *a++ = *s++; + *a++ = (uchar)(*s++); else { int sl = Utf8CharLen(s); *a++ = Utf8CharGet(s, sl); @@ -756,7 +752,7 @@ void cCharSetConv::SetSystemCharacterTable(const char *CharacterTable) char buf[129]; for (int i = 0; i < 128; i++) buf[i] = i + 128; - buf[129] = 0; + buf[128] = 0; cCharSetConv csc(CharacterTable); const char *s = csc.Convert(buf); int i = 0; -- cgit v1.2.3