From d0179ea21969cdc9c8d98154b84fd0106be83078 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 16 Jul 2000 15:02:33 +0200 Subject: Improved handling of blanks in channel and timer names --- HISTORY | 4 +++- MANUAL | 6 +++++- config.c | 4 ++-- menu.c | 12 ++++++------ recording.c | 5 ++++- tools.c | 14 +++++++++++++- tools.h | 3 ++- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/HISTORY b/HISTORY index b6340a02..35d36e5a 100644 --- a/HISTORY +++ b/HISTORY @@ -77,4 +77,6 @@ Video Disk Recorder Revision History replay has been reduced to 2 digits to allow more space for the recording's title. In the internal file structure the year is still stored with 4 digits, so there will be no problem at the next turn of the century ;-) - +- Channel names and timer filenames can now contain blanks. To avoid problems + with file names that contain blanks, all blanks in recording file names are + converted to underscores. diff --git a/MANUAL b/MANUAL index d5d13a3f..c9b71a37 100644 --- a/MANUAL +++ b/MANUAL @@ -41,7 +41,11 @@ Video Disk Recorder User's Manual by pressing the "Right" button (which puts brackets around the current character as in "[R]TL"), selecting the desired character position with "Left" and "Right", and changing the character with the "Up" and "Down" - keys. "Ok" then confirms the changes. + keys. "Ok" then confirms the changes. The special character '^' can be used + to "cut off" a string at this position. When this character is visible in the + brackets (as in abc[^]), the next press to the "Left" or "Ok" button will + actually cut off the string. Using "Up" and/or "Down" brings back the + original rest of the string (unless you have pressed "Left" or "Ok"). The "Red", "Green", "Yellow" and "Blue" buttons have special meanings in various menus and are listed at the bottom of the on-screen-display. diff --git a/config.c b/config.c index 30bb74b6..6df847c0 100644 --- a/config.c +++ b/config.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 1.10 2000/07/16 11:47:30 kls Exp $ + * $Id: config.c 1.11 2000/07/16 14:28:20 kls Exp $ */ #include "config.h" @@ -318,7 +318,7 @@ bool cTimer::Parse(char *s) { char *buffer1 = NULL; char *buffer2 = NULL; - if (8 == sscanf(s, "%d:%d:%a[^:]:%d:%d:%d:%d:%as", &active, &channel, &buffer1, &start, &stop, &priority, &lifetime, &buffer2)) { + if (8 == sscanf(s, "%d:%d:%a[^:]:%d:%d:%d:%d:%a[^:\n]", &active, &channel, &buffer1, &start, &stop, &priority, &lifetime, &buffer2)) { day = ParseDay(buffer1); strncpy(file, buffer2, MaxFileName - 1); file[strlen(buffer2)] = 0; diff --git a/menu.c b/menu.c index db3730fe..1a8103ce 100644 --- a/menu.c +++ b/menu.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menu.c 1.18 2000/07/16 13:42:29 kls Exp $ + * $Id: menu.c 1.19 2000/07/16 14:52:48 kls Exp $ */ #include "menu.h" @@ -16,7 +16,7 @@ #define MENUTIMEOUT 120 // seconds -const char *FileNameChars = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789-.# "; +const char *FileNameChars = " aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789-.#^"; // --- cMenuEditItem --------------------------------------------------------- @@ -429,7 +429,7 @@ void cMenuEditStrItem::Set(void) char buf[1000]; if (pos >= 0) { strncpy(buf, value, pos); - const char *s = value[pos] != ' ' ? value + pos + 1 : ""; + const char *s = value[pos] != '^' ? value + pos + 1 : ""; snprintf(buf + pos, sizeof(buf) - pos - 2, "[%c]%s", *(value + pos), s); SetValue(buf); } @@ -455,12 +455,12 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key) { switch (Key) { case kLeft: if (pos > 0) { - if (value[pos] == ' ') + if (value[pos] == '^') value[pos] = 0; pos--; } break; - case kRight: if (pos < length && value[pos] != ' ') { + case kRight: if (pos < length && value[pos] != '^' && (pos < int(strlen(value) - 1) || value[pos] != ' ')) { if (++pos >= int(strlen(value))) { value[pos] = ' '; value[pos + 1] = 0; @@ -474,7 +474,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key) return cMenuEditItem::ProcessKey(Key); break; case kOk: if (pos >= 0) { - if (value[pos] == ' ') + if (value[pos] == '^') value[pos] = 0; pos = -1; break; diff --git a/recording.c b/recording.c index 714c7f13..3e9df374 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 1.10 2000/07/16 13:41:45 kls Exp $ + * $Id: recording.c 1.11 2000/07/16 14:21:37 kls Exp $ */ #define _GNU_SOURCE @@ -141,6 +141,7 @@ cRecording::cRecording(const char *FileName) name = new char[p - FileName + 1]; strncpy(name, FileName, p - FileName); name[p - FileName] = 0; + strreplace(name, '_', ' '); } } } @@ -157,6 +158,8 @@ const char *cRecording::FileName(void) if (!fileName) { struct tm *t = localtime(&start); asprintf(&fileName, NAMEFORMAT, BaseDir, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime); + if (fileName) + strreplace(fileName, ' ', '_'); } return fileName; } diff --git a/tools.c b/tools.c index c0eb2ec5..b2c95f37 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.8 2000/06/24 15:26:15 kls Exp $ + * $Id: tools.c 1.9 2000/07/16 14:14:44 kls Exp $ */ #define _GNU_SOURCE @@ -76,6 +76,18 @@ char *readline(FILE *f) return NULL; } +char *strreplace(char *s, char c1, char c2) +{ + char *p = s; + + while (*p) { + if (*p == c1) + *p = c2; + p++; + } + return s; +} + int time_ms(void) { static time_t t0 = 0; diff --git a/tools.h b/tools.h index db55983f..0e26ec21 100644 --- a/tools.h +++ b/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 1.8 2000/06/24 15:25:00 kls Exp $ + * $Id: tools.h 1.9 2000/07/16 14:11:34 kls Exp $ */ #ifndef __TOOLS_H @@ -37,6 +37,7 @@ char readchar(int filedes); bool readint(int filedes, int &n); void purge(int filedes); char *readline(FILE *f); +char *strreplace(char *s, char c1, char c2); int time_ms(void); void delay_ms(int ms); bool MakeDirs(const char *FileName, bool IsDirectory = false); -- cgit v1.2.3