summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2017-07-01 20:57:18 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2017-07-01 20:57:18 (GMT)
commit45533be53dacd60ee8fa0c648e60dcc76bc83e1f (patch) (side-by-side diff)
tree9a000fbdbcd718fb3a42d362507e8dd397dcd3ec
parent9671c7d62638d1ab02261717863a7e9864b67cbd (diff)
downloadmailutils-45533be53dacd60ee8fa0c648e60dcc76bc83e1f.tar.gz
mailutils-45533be53dacd60ee8fa0c648e60dcc76bc83e1f.tar.bz2
Minor fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mh/mh_fmtgram.y8
-rw-r--r--mh/mh_format.c53
-rw-r--r--mh/tests/fmtfunc.at12
3 files changed, 23 insertions, 50 deletions
diff --git a/mh/mh_fmtgram.y b/mh/mh_fmtgram.y
index 67560d3..328a7a6 100644
--- a/mh/mh_fmtgram.y
+++ b/mh/mh_fmtgram.y
@@ -676,6 +676,14 @@ token_function (void)
{
return bogus ("unknown function");
}
+ if (!yylval.builtin->fun
+ && !(yylval.builtin->flags & (MHA_SPECIAL|MHA_VOID)))
+ {
+ mu_error ("INTERNAL ERROR at %s:%d: \"%s\" has no associated function"
+ " and is not marked as MHA_SPECIAL",
+ __FILE__, __LINE__, yylval.builtin->name);
+ abort ();
+ }
return FUNCTION;
}
diff --git a/mh/mh_format.c b/mh/mh_format.c
index 1690630..48ac3a3 100644
--- a/mh/mh_format.c
+++ b/mh/mh_format.c
@@ -848,18 +848,6 @@ builtin_modulo (struct mh_fvm *mach)
}
static void
-builtin_num (struct mh_fvm *mach)
-{
- mach->num[R_REG] = mach->num[R_ARG];
-}
-
-static void
-builtin_lit (struct mh_fvm *mach)
-{
- mh_string_copy (mach, R_REG, R_ARG);
-}
-
-static void
builtin_getenv (struct mh_fvm *mach)
{
char const *val = getenv (mh_string_value (&mach->str[R_ARG]));
@@ -922,37 +910,6 @@ builtin_trim (struct mh_fvm *mach)
mu_rtrim_class (mach->str[R_REG].ptr, MU_CTYPE_SPACE);
}
-/* putstr expr print str*/
-static void
-builtin_putstr (struct mh_fvm *mach)
-{
- print_string (mach, 0, mh_string_value (&mach->str[R_ARG]));
-}
-
-/* putstrf expr print str in a fixed width*/
-static void
-builtin_putstrf (struct mh_fvm *mach)
-{
- mh_string_copy (mach, R_REG, R_ARG);
-}
-
-/* putnum expr print num*/
-static void
-builtin_putnum (struct mh_fvm *mach)
-{
- char *p;
- mu_asprintf (&p, "%ld", mach->num[R_ARG]);
- print_string (mach, 0, p);
- free (p);
-}
-
-/* putnumf expr print num in a fixed width*/
-static void
-builtin_putnumf (struct mh_fvm *mach)
-{
- format_num (mach, mach->num[R_ARG]);
-}
-
static int
_parse_date (struct mh_fvm *mach, struct tm *tm, struct mu_timezone *tz)
{
@@ -1852,11 +1809,11 @@ mh_builtin_t builtin_tab[] = {
{ "nonnull", builtin_nonnull, mhtype_num, mhtype_str, MHA_OPTARG },
{ "comp", builtin_comp, mhtype_str, mhtype_str },
{ "compval", builtin_compval, mhtype_num, mhtype_str },
- { "trim", builtin_trim, mhtype_none, mhtype_str, MHA_OPTARG },
- { "putstr", builtin_putstr, mhtype_none, mhtype_str, MHA_OPTARG },
- { "putstrf", NULL, mhtype_str, mhtype_str, MHA_SPECIAL|MHA_OPTARG },
- { "putnum", builtin_putnum, mhtype_none, mhtype_num, MHA_OPTARG },
- { "putnumf", NULL, mhtype_num, mhtype_num, MHA_SPECIAL|MHA_OPTARG },
+ { "trim", builtin_trim, mhtype_none, mhtype_str, MHA_OPTARG },
+ { "putstr", NULL, mhtype_str, mhtype_str, MHA_SPECIAL|MHA_OPTARG|MHA_OPTARG|MHA_IGNOREFMT },
+ { "putstrf", NULL, mhtype_str, mhtype_str, MHA_SPECIAL|MHA_OPTARG },
+ { "putnum", NULL, mhtype_num, mhtype_num, MHA_SPECIAL|MHA_OPTARG|MHA_IGNOREFMT },
+ { "putnumf", NULL, mhtype_num, mhtype_num, MHA_SPECIAL|MHA_OPTARG },
{ "sec", builtin_sec, mhtype_num, mhtype_str },
{ "min", builtin_min, mhtype_num, mhtype_str },
{ "hour", builtin_hour, mhtype_num, mhtype_str },
diff --git a/mh/tests/fmtfunc.at b/mh/tests/fmtfunc.at
index 5191e9e..113b588 100644
--- a/mh/tests/fmtfunc.at
+++ b/mh/tests/fmtfunc.at
@@ -360,7 +360,7 @@ FMTFUNC([putnum],
[%(void(num 10))%(putnum)
%(putnum 15)
%(putnum{X-Number})
-%(putstr(msg))
+%(putnum(msg))
],
[From: foo@example.org
X-Number: 8
@@ -373,8 +373,16 @@ body
1
])
-# FIXME: putnumf
+FMTFUNC([putnumf],
+[%(void(num 10))%03(putnumf)
+%(void(num 65535))%03(putnumf)
+],
+[
+],
+[010
+?35
+])
# FIXME: putlit

Return to:

Send suggestions and report system problems to the System administrator.