Compare commits

...

3 Commits

Author SHA1 Message Date
Dianne Skoll
a19b009f7c Fix man page typo and cppcheck warnings.
All checks were successful
Remind unit tests / tests (push) Successful in 32s
2024-12-13 15:22:46 -05:00
Dianne Skoll
6373ae8ca5 Update release notes. 2024-12-13 15:08:54 -05:00
Dianne Skoll
b8c4786b33 Allow INCLUDE/DO/SYSINCLUDE to take a QuotedString argument. This allows for filenames with spaces in them. 2024-12-13 10:38:34 -05:00
10 changed files with 57 additions and 25 deletions

View File

@@ -4,7 +4,12 @@ CHANGES TO REMIND
- MAJOR NEW FEATURE: remind: Add the TRANSLATE command, the _() - MAJOR NEW FEATURE: remind: Add the TRANSLATE command, the _()
built-in function and the %(...) substitution sequence. These allow built-in function and the %(...) substitution sequence. These allow
you to localize your reminder files more easily. you to localize your reminder files more easily. The translation table
is also made available to back-ends like rem2pdf and tkremind,
which they can use as they see fit.
- MINOR FEATURE: tkremind, rem2html: Localize the names of the moon
phases.
- MAJOR CHANGE: remind: Remind used to support compile-time localization - MAJOR CHANGE: remind: Remind used to support compile-time localization
into different languages (French, English, etc.) That compile-time into different languages (French, English, etc.) That compile-time
@@ -27,6 +32,10 @@ CHANGES TO REMIND
INCLUDE [$SysInclude]/foo/bar.rem INCLUDE [$SysInclude]/foo/bar.rem
- MINOR IMPROVEMENT: Allow INCLUDE, DO and SYSINCLUDE to include files with
spaces in their names; in this case, you have to put the filename inside
double-quotes.
- IMPROVEMENT: remind: Refuse to open subdirectories named "*.rem" - IMPROVEMENT: remind: Refuse to open subdirectories named "*.rem"
under a top-level directory rather than trying and failing with a under a top-level directory rather than trying and failing with a
confusing error. confusing error.
@@ -43,8 +52,12 @@ CHANGES TO REMIND
- MINOR FIXES: remind: Fix typos in comments; use memcpy to copy OMIT - MINOR FIXES: remind: Fix typos in comments; use memcpy to copy OMIT
contexts internally. contexts internally.
- BUG FIX: Actually allow the documented 9 levels of INCLUDE rather than - BUG FIX: remind: Actually allow the documented 9 levels of INCLUDE
8. rather than 8.
- BUG FIX: remind: If an INCLUDE statement failed inside an IF statement,
Remind would print spurious errors about unmatched IF/ENDIF. This has
been fixed.
* VERSION 5.1 Patch 1 - 2024-11-18 * VERSION 5.1 Patch 1 - 2024-11-18

View File

@@ -1927,19 +1927,18 @@ commands.
.SH THE DO, INCLUDE AND SYSINCLUDE COMMANDS .SH THE DO, INCLUDE AND SYSINCLUDE COMMANDS
.PP .PP
\fBRemind\fR allows you to include other files in your reminder script, \fBRemind\fR allows you to include other files in your reminder script,
similar to the C preprocessor #include directive. For example, your similar to the C preprocessor #include directive. For example, you
system administrator may maintain a file of holidays or system-wide might organize different reminders into different files like this:
reminders. You can include these in your reminder script as follows:
.PP .PP
.nf .nf
INCLUDE /usr/share/remind/holidays INCLUDE holidays.rem
INCLUDE /usr/share/remind/reminders INCLUDE birthdays.rem
INCLUDE "quote files with spaces.rem"
.fi .fi
.PP .PP
(The actual pathnames vary from system to system - ask your system \fBINCLUDE\fR files can be nested up to a depth of 8. As shown above, if a
administrator.) filename has spaces in it (not recommended!) you can use double-quotes
.PP around the filename.
\fBINCLUDE\fR files can be nested up to a depth of 8.
.PP .PP
If you specify a filename of "-" in the \fBINCLUDE\fR command, \fBRemind\fR If you specify a filename of "-" in the \fBINCLUDE\fR command, \fBRemind\fR
will begin reading from standard input. will begin reading from standard input.
@@ -1983,7 +1982,7 @@ symbolic links to files.
.PP .PP
The \fBSYSINCLUDE\fR command is similar to \fBDO\fR, but it looks for The \fBSYSINCLUDE\fR command is similar to \fBDO\fR, but it looks for
relative pathnames under the system directory containing standard reminder relative pathnames under the system directory containing standard reminder
scripts. For thie version of \fBRemind\fR, the system directory is scripts. For this version of \fBRemind\fR, the system directory is
"@prefix@/share/remind". "@prefix@/share/remind".
.PP .PP
.SH THE RUN COMMAND .SH THE RUN COMMAND

View File

@@ -608,7 +608,7 @@ int DoInclude(ParsePtr p, enum TokTypes tok)
DBufInit(&buf); DBufInit(&buf);
DBufInit(&fullname); DBufInit(&fullname);
DBufInit(&path); DBufInit(&path);
if ( (r=ParseToken(p, &buf)) ) return r; if ( (r=ParseTokenOrQuotedString(p, &buf)) ) return r;
e = VerifyEoln(p); e = VerifyEoln(p);
if (e) Eprint("%s", GetErr(e)); if (e) Eprint("%s", GetErr(e));

View File

@@ -600,6 +600,24 @@ int ParseNonSpaceChar(ParsePtr p, int *err, int peek)
return ch; return ch;
} }
/***************************************************************/
/* */
/* ParseTokenOrQuotedString */
/* */
/* Parse either a token or a double-quote-delimited string. */
/* */
/***************************************************************/
int ParseTokenOrQuotedString(ParsePtr p, DynamicBuffer *dbuf)
{
int c, err;
c = ParseNonSpaceChar(p, &err, 1);
if (err) return err;
if (c != '"') {
return ParseToken(p, dbuf);
}
return ParseQuotedString(p, dbuf);
}
/***************************************************************/ /***************************************************************/
/* */ /* */
/* ParseQuotedString */ /* ParseQuotedString */
@@ -1980,7 +1998,7 @@ get_day_name(int wkday)
if (wkday < 0 || wkday > 6) { if (wkday < 0 || wkday > 6) {
return "INVALID_WKDAY"; return "INVALID_WKDAY";
} }
return t(DayName[wkday]); return tr(DayName[wkday]);
} }
char const * char const *
@@ -1989,7 +2007,7 @@ get_month_name(int mon)
if (mon < 0 || mon > 11) { if (mon < 0 || mon > 11) {
return "INVALID_MON"; return "INVALID_MON";
} }
return t(MonthName[mon]); return tr(MonthName[mon]);
} }
static int GetOnceDateFromFile(void) static int GetOnceDateFromFile(void)

View File

@@ -88,6 +88,7 @@ int JulianToGregorianOffset(int y, int m);
int ParseChar (ParsePtr p, int *err, int peek); int ParseChar (ParsePtr p, int *err, int peek);
int ParseToken (ParsePtr p, DynamicBuffer *dbuf); int ParseToken (ParsePtr p, DynamicBuffer *dbuf);
int ParseQuotedString (ParsePtr p, DynamicBuffer *dbuf); int ParseQuotedString (ParsePtr p, DynamicBuffer *dbuf);
int ParseTokenOrQuotedString (ParsePtr p, DynamicBuffer *dbuf);
int ParseIdentifier (ParsePtr p, DynamicBuffer *dbuf); int ParseIdentifier (ParsePtr p, DynamicBuffer *dbuf);
expr_node * ParseExpr(ParsePtr p, int *r); expr_node * ParseExpr(ParsePtr p, int *r);
void print_expr_nodes_stats(void); void print_expr_nodes_stats(void);
@@ -271,6 +272,5 @@ void InitTranslationTable(void);
char const *GetTranslatedString(char const *orig); char const *GetTranslatedString(char const *orig);
int GetTranslatedStringTryingVariants(char const *orig, DynamicBuffer *out); int GetTranslatedStringTryingVariants(char const *orig, DynamicBuffer *out);
char const *GetErr(int r); char const *GetErr(int r);
char const *t(char const *s);
char const *tr(char const *s); char const *tr(char const *s);
void print_escaped_string(FILE *fp, char const *s); void print_escaped_string(FILE *fp, char const *s);

View File

@@ -313,7 +313,7 @@ GetTranslatedStringTryingVariants(char const *orig, DynamicBuffer *out)
return 0; return 0;
} }
char const *t(char const *orig) char const *tr(char const *orig)
{ {
char const *n = GetTranslatedString(orig); char const *n = GetTranslatedString(orig);
if (n) { if (n) {
@@ -322,12 +322,6 @@ char const *t(char const *orig)
return orig; return orig;
} }
/* If another "t" is in scope... */
char const *tr(char const *orig)
{
return t(orig);
}
int int
DoTranslate(ParsePtr p) DoTranslate(ParsePtr p)
{ {

View File

@@ -968,7 +968,7 @@ static int SetTranslatableVariable(SysVar *v, Value *value)
static int GetTranslatableVariable(SysVar *v, Value *value) static int GetTranslatableVariable(SysVar *v, Value *value)
{ {
char const *translated = t((char const *) v->value); char const *translated = tr((char const *) v->value);
if (translated) { if (translated) {
value->v.str = StrDup(translated); value->v.str = StrDup(translated);
} else { } else {

View File

@@ -16232,6 +16232,11 @@ IF 1
../tests/test.rem(1435): Can't open file: /non/existent/file/should/not/work/wookie ../tests/test.rem(1435): Can't open file: /non/existent/file/should/not/work/wookie
ENDIF ENDIF
do "with space.rem"
REM MSG D'oh, a file whose name has spaces! [filename()]
D'oh, a file whose name has spaces! ../tests/with space.rem
DEBUG -e DEBUG -e
Var hash: total = 100141; maxlen = 5; avglen = 1.142 Var hash: total = 100141; maxlen = 5; avglen = 1.142
Func hash: total = 100016; maxlen = 5; avglen = 1.140 Func hash: total = 100016; maxlen = 5; avglen = 1.140

View File

@@ -1435,6 +1435,8 @@ IF 1
INCLUDE /non/existent/file/should/not/work/wookie INCLUDE /non/existent/file/should/not/work/wookie
ENDIF ENDIF
do "with space.rem"
DEBUG -e DEBUG -e
# Output expression-node stats # Output expression-node stats

1
tests/with space.rem Normal file
View File

@@ -0,0 +1 @@
REM MSG D'oh, a file whose name has spaces! [filename()]