mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Add optional add_quote argument to escape()
This commit is contained in:
@@ -3426,7 +3426,7 @@ Note that \fBeasterdate\fR computes the Western Easter. For the Orthodox
|
||||
Easter date, see \fBorthodoxeaster\fR.
|
||||
.RE
|
||||
.TP
|
||||
.B escape(s_string)
|
||||
.B escape(s_string [,i_add_quotes])
|
||||
Returns a \fBSTRING\fR that is the same as the input string, but with
|
||||
all special characters backslashed-escaped. For example, the following
|
||||
command:
|
||||
@@ -3440,6 +3440,9 @@ will set a to "foo\\nbar" where "\\n" is the literal sequence "\\" followed
|
||||
by "n". This is useful if you want to compute a string in a pasted-in
|
||||
expression that \fBRemind\fR will then parse as a quoted string again,
|
||||
such as in a TRANSLATE command or an INFO clause.
|
||||
.PP
|
||||
If the optional \fIadd_quotes\fR argument is supplied and is non-zero, then
|
||||
the return value from \fBescape\fR will include surrounding double-quotes.
|
||||
.RE
|
||||
.TP
|
||||
.B evaltrig(s_trigger [,dq_start])
|
||||
|
||||
23
src/funcs.c
23
src/funcs.c
@@ -253,7 +253,7 @@ BuiltinFunc Func[] = {
|
||||
{ "dosubst", 1, 3, 0, FDosubst, NULL },
|
||||
{ "dusk", 0, 1, 0, FDusk, NULL },
|
||||
{ "easterdate", 0, 1, 0, FEasterdate, NULL },
|
||||
{ "escape", 1, 1, 1, FEscape, NULL },
|
||||
{ "escape", 1, 2, 1, FEscape, NULL },
|
||||
{ "evaltrig", 1, 2, 0, FEvalTrig, NULL },
|
||||
{ "filedate", 1, 1, 0, FFiledate, NULL },
|
||||
{ "filedatetime", 1, 1, 0, FFiledatetime, NULL },
|
||||
@@ -2376,9 +2376,21 @@ static int FEscape(func_info *info)
|
||||
char const *s;
|
||||
char hexbuf[16];
|
||||
int r;
|
||||
|
||||
int include_quotes = 0;
|
||||
ASSERT_TYPE(0, STR_TYPE);
|
||||
if (Nargs >= 2) {
|
||||
ASSERT_TYPE(1, INT_TYPE);
|
||||
include_quotes = ARGV(1);
|
||||
}
|
||||
|
||||
DBufInit(&dbuf);
|
||||
if (include_quotes) {
|
||||
r = DBufPutc(&dbuf, '"');
|
||||
if (r != OK) {
|
||||
DBufFree(&dbuf);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
s = ARGSTR(0);
|
||||
while(*s) {
|
||||
switch(*s) {
|
||||
@@ -2424,6 +2436,13 @@ static int FEscape(func_info *info)
|
||||
}
|
||||
s++;
|
||||
}
|
||||
if (include_quotes) {
|
||||
r = DBufPutc(&dbuf, '"');
|
||||
if (r != OK) {
|
||||
DBufFree(&dbuf);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
r = RetStrVal(DBufValue(&dbuf), info);
|
||||
DBufFree(&dbuf);
|
||||
return r;
|
||||
|
||||
@@ -673,6 +673,8 @@ FLUSH
|
||||
dump a
|
||||
set b escape(a)
|
||||
REM msg b = [b]
|
||||
set b escape(a,1)
|
||||
REM msg b = [b]
|
||||
FLUSH
|
||||
dump b
|
||||
FLUSH
|
||||
|
||||
@@ -1047,7 +1047,7 @@ set a057 value("a05"+"6")
|
||||
"a05" + "6" => "a056"
|
||||
value("a056") => "SDFJHSDF KSJDFH KJSDFH KSJDFH"
|
||||
set a058 version()
|
||||
version() => "05.02.03"
|
||||
version() => "05.03.00"
|
||||
set a059 wkday(today())
|
||||
today() => 1991-02-16
|
||||
wkday(1991-02-16) => "Saturday"
|
||||
@@ -2611,7 +2611,7 @@ a056 "SDFJHSDF KSJDFH KJSDFH KSJDFH"
|
||||
a007 "1991-02-16"
|
||||
a057 "SDFJHSDF KSJDFH KJSDFH KSJDFH"
|
||||
a008 "11:44"
|
||||
a058 "05.02.03"
|
||||
a058 "05.03.00"
|
||||
a059 "Saturday"
|
||||
a010 12
|
||||
a060 6
|
||||
@@ -5632,8 +5632,8 @@ REM SATISFY ""
|
||||
REM SATISFY [version() > "01.00.00"]
|
||||
../tests/test.rem(1050): SATISFY: expression has no reference to trigdate() or $T...
|
||||
../tests/test.rem(1050): Trig = Saturday, 16 February, 1991
|
||||
version() => "05.02.03"
|
||||
"05.02.03" > "01.00.00" => 1
|
||||
version() => "05.03.00"
|
||||
"05.03.00" > "01.00.00" => 1
|
||||
../tests/test.rem(1050): Trig(satisfied) = Saturday, 16 February, 1991
|
||||
REM SATISFY [max(x, max(x, 1, 2, 3), 4, 5, 6) * 5]
|
||||
../tests/test.rem(1051): SATISFY: expression has no reference to trigdate() or $T...
|
||||
@@ -23200,7 +23200,7 @@ SECURITY: Won't read world-writable file or directory!
|
||||
Error reading include_dir/ww: Can't open file
|
||||
SECURITY: Won't read world-writable file or directory!
|
||||
Error reading include_dir/ww: No files matching *.rem
|
||||
05.02.03
|
||||
05.03.00
|
||||
Enabling test mode: This is meant for the acceptance test.
|
||||
Do not use --test in production.
|
||||
In test mode, the system time is fixed at 2025-01-06@19:00
|
||||
@@ -24675,19 +24675,20 @@ Variable Value
|
||||
|
||||
a "vartest: \\\" \a\b\f\\n\r\t\v\x03\x1b haha"
|
||||
b = vartest: \\\" \a\b\f\\n\r\t\v\x03\x1b haha
|
||||
b = "vartest: \\\" \a\b\f\\n\r\t\v\x03\x1b haha"
|
||||
Variable Value
|
||||
|
||||
b "vartest: \\\\\\\" \\a\\b\\f\\\\n\\r\\t\\v\\x03\\x1b ha"...
|
||||
b "\"vartest: \\\\\\\" \\a\\b\\f\\\\n\\r\\t\\v\\x03\\x1b h"...
|
||||
Variable Value
|
||||
|
||||
a "x"
|
||||
Variable Value
|
||||
|
||||
a "xPOO"
|
||||
-stdin-(21): \x00 is not a valid escape sequence
|
||||
-stdin-(22): \x00 is not a valid escape sequence
|
||||
-stdin-(23): \x00 is not a valid escape sequence
|
||||
-stdin-(24): \x00 is not a valid escape sequence
|
||||
-stdin-(25): \x00 is not a valid escape sequence
|
||||
-stdin-(26): \x00 is not a valid escape sequence
|
||||
Agenda pel dijous, 1 de febrer de 2024:
|
||||
|
||||
Language: ca
|
||||
|
||||
Reference in New Issue
Block a user