]> diplodocus.org Git - nmh/commitdiff
Renamed getmymbox mh-format escape function to getmyaddr, and
authorDavid Levine <levinedl@acm.org>
Tue, 28 Oct 2014 02:20:07 +0000 (21:20 -0500)
committerDavid Levine <levinedl@acm.org>
Tue, 28 Oct 2014 02:20:07 +0000 (21:20 -0500)
added new getmymbox that returns the user's address with any
personal name.

docs/pending-release-notes
h/fmt_compile.h
man/mh-format.man
sbr/fmt_compile.c
sbr/fmt_scan.c
test/format/test-mymbox
uip/fmtdump.c
uip/fmttest.c

index 1f46d79..5889557 100644 (file)
@@ -24,7 +24,7 @@ NEW FEATURES
   obsolete support programs that should be removed.
 - When building from source, configure will derive ${prefix} from an existing
   nmh installation if it finds one in your $PATH.
   obsolete support programs that should be removed.
 - When building from source, configure will derive ${prefix} from an existing
   nmh installation if it finds one in your $PATH.
-- Added getmymbox function escape.
+- Added getmymbox and getmyaddr mh-format(5) function escapes.
 
 -----------------
 OBSOLETE FEATURES
 
 -----------------
 OBSOLETE FEATURES
index bda2e61..9e94b3c 100644 (file)
 #define FT_FORMATADDR   71      /* let external routine format addr    */
 #define FT_CONCATADDR   72      /* formataddr w/out duplicate removal  */
 #define FT_MYMBOX       73      /* do "mymbox" test on comp            */
 #define FT_FORMATADDR   71      /* let external routine format addr    */
 #define FT_CONCATADDR   72      /* formataddr w/out duplicate removal  */
 #define FT_MYMBOX       73      /* do "mymbox" test on comp            */
-#define FT_GETMYMBOX    74      /* do "mymbox" test on comp, ret str   */
+#define FT_GETMYMBOX    74      /* return "mymbox" mailbox string      */
+#define FT_GETMYADDR    75      /* return "mymbox" addr string         */
 
 /* conditionals & control flow (must be last) */
 
 /* conditionals & control flow (must be last) */
-#define FT_SAVESTR      75      /* save current str reg               */
-#define FT_DONE         76      /* stop formatting                    */
-#define FT_PAUSE        77      /* pause                              */
-#define FT_NOP          78      /* nop                                */
-#define FT_GOTO         79      /* (relative) goto                    */
-#define FT_IF_S_NULL    80      /* test if "str" null                 */
-#define FT_IF_S         81      /* test if "str" non-null             */
-#define FT_IF_V_EQ      82      /* test if "value" = literal          */
-#define FT_IF_V_NE      83      /* test if "value" != literal         */
-#define FT_IF_V_GT      84      /* test if "value" > literal          */
-#define FT_IF_MATCH     85      /* test if "str" contains literal     */
-#define FT_IF_AMATCH    86      /* test if "str" starts with literal  */
-#define FT_S_NULL       87      /* V = 1 if "str" null                */
-#define FT_S_NONNULL    88      /* V = 1 if "str" non-null            */
-#define FT_V_EQ         89      /* V = 1 if "value" = literal         */
-#define FT_V_NE         90      /* V = 1 if "value" != literal        */
-#define FT_V_GT         91      /* V = 1 if "value" > literal         */
-#define FT_V_MATCH      92      /* V = 1 if "str" contains literal    */
-#define FT_V_AMATCH     93      /* V = 1 if "str" starts with literal */
+#define FT_SAVESTR      76      /* save current str reg               */
+#define FT_DONE         77      /* stop formatting                    */
+#define FT_PAUSE        78      /* pause                              */
+#define FT_NOP          79      /* nop                                */
+#define FT_GOTO         80      /* (relative) goto                    */
+#define FT_IF_S_NULL    81      /* test if "str" null                 */
+#define FT_IF_S         82      /* test if "str" non-null             */
+#define FT_IF_V_EQ      83      /* test if "value" = literal          */
+#define FT_IF_V_NE      84      /* test if "value" != literal         */
+#define FT_IF_V_GT      85      /* test if "value" > literal          */
+#define FT_IF_MATCH     86      /* test if "str" contains literal     */
+#define FT_IF_AMATCH    87      /* test if "str" starts with literal  */
+#define FT_S_NULL       88      /* V = 1 if "str" null                */
+#define FT_S_NONNULL    89      /* V = 1 if "str" non-null            */
+#define FT_V_EQ         90      /* V = 1 if "value" = literal         */
+#define FT_V_NE         91      /* V = 1 if "value" != literal        */
+#define FT_V_GT         92      /* V = 1 if "value" > literal         */
+#define FT_V_MATCH      93      /* V = 1 if "str" contains literal    */
+#define FT_V_AMATCH     94      /* V = 1 if "str" starts with literal */
 
 #define IF_FUNCS FT_S_NULL      /* start of "if" functions */
 
 #define IF_FUNCS FT_S_NULL      /* start of "if" functions */
index 87dee2f..1e2f41a 100644 (file)
@@ -1,4 +1,4 @@
-.TH MH-FORMAT %manext5% "November 4, 2012" "%nmhversion%"
+.TH MH-FORMAT %manext5% "October 27, 2014" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
 .\"
 .\" %nmhwarning%
 .\"
@@ -397,6 +397,8 @@ note        addr    string  commentary text*
 mbox   addr    string  the local mailbox*
 mymbox addr    integer list has the user's address? (0 or 1)
 getmymbox      addr    string  the user's (first) address,
 mbox   addr    string  the local mailbox*
 mymbox addr    integer list has the user's address? (0 or 1)
 getmymbox      addr    string  the user's (first) address,
+                       with personal name
+getmyaddr      addr    string  the user's (first) address,
                        without personal name
 host   addr    string  the host domain*
 nohost addr    integer no host was present (0 or 1)*
                        without personal name
 host   addr    string  the host domain*
 nohost addr    integer no host was present (0 or 1)*
index 3f3db64..dd43dc8 100644 (file)
@@ -223,7 +223,8 @@ static struct ftable functable[] = {
      { "friendly",   TF_COMP,  FT_LS_FRIENDLY, FT_PARSEADDR,   TFL_PUTS },
 
      { "mymbox",     TF_COMP,  FT_LV_COMPFLAG, FT_MYMBOX,      TFL_PUTN },
      { "friendly",   TF_COMP,  FT_LS_FRIENDLY, FT_PARSEADDR,   TFL_PUTS },
 
      { "mymbox",     TF_COMP,  FT_LV_COMPFLAG, FT_MYMBOX,      TFL_PUTN },
-     { "getmymbox",  TF_COMP,  FT_LS_ADDR,     FT_GETMYMBOX,   TFL_PUTS },
+     { "getmymbox",  TF_COMP,  FT_STR,         FT_GETMYMBOX,   0 },
+     { "getmyaddr",  TF_COMP,  FT_LS_ADDR,     FT_GETMYADDR,   TFL_PUTS },
 
      { "unquote",    TF_EXPR,  FT_LS_UNQUOTE,  0,              TFL_PUTS },
 
 
      { "unquote",    TF_EXPR,  FT_LS_UNQUOTE,  0,              TFL_PUTS },
 
@@ -575,6 +576,7 @@ do_name(char *sp, int preprocess)
 
     case FT_MYMBOX:
     case FT_GETMYMBOX:
 
     case FT_MYMBOX:
     case FT_GETMYMBOX:
+    case FT_GETMYADDR:
        if (!primed) {
            ismymbox ((struct mailname *) 0);
            primed++;
        if (!primed) {
            ismymbox ((struct mailname *) 0);
            primed++;
index 759a81f..692d564 100644 (file)
@@ -1063,6 +1063,7 @@ fmt_scan (struct format *format, charstring_t scanlp, int width, int *dat,
 
        case FT_MYMBOX:
        case FT_GETMYMBOX:
 
        case FT_MYMBOX:
        case FT_GETMYMBOX:
+       case FT_GETMYADDR:
            /*
             * if there's no component, we say true.  Otherwise we
             * say "true" only if we can parse the address and it
            /*
             * if there's no component, we say true.  Otherwise we
             * say "true" only if we can parse the address and it
@@ -1076,13 +1077,14 @@ fmt_scan (struct format *format, charstring_t scanlp, int width, int *dat,
                comp->c_mn = mn;
                if (ismymbox(mn)) {
                    comp->c_flags |= CF_TRUE;
                comp->c_mn = mn;
                if (ismymbox(mn)) {
                    comp->c_flags |= CF_TRUE;
-                   /* Set str for use with FT_GETMYMBOX.  It will be
+                   /* Set str for use with FT_GETMYMBOX and
+                      FT_GETMYADDR.  With FT_GETMYADDR, it will be
                       run through FT_LS_ADDR, which will strip off
                       any pers name. */
                       run through FT_LS_ADDR, which will strip off
                       any pers name. */
-                    str = mn->m_text;
+                   str = mn->m_text;
                } else {
                    comp->c_flags &= ~CF_TRUE;
                } else {
                    comp->c_flags &= ~CF_TRUE;
-                }
+               }
                while ((sp = getname(sp)))
                    if ((comp->c_flags & CF_TRUE) == 0 &&
                        (mn = getm (sp, NULL, 0, NULL, 0)))
                while ((sp = getname(sp)))
                    if ((comp->c_flags & CF_TRUE) == 0 &&
                        (mn = getm (sp, NULL, 0, NULL, 0)))
@@ -1096,11 +1098,11 @@ fmt_scan (struct format *format, charstring_t scanlp, int width, int *dat,
                    comp->c_flags |= CF_TRUE;
                else {
                    comp->c_flags &= ~CF_TRUE;
                    comp->c_flags |= CF_TRUE;
                else {
                    comp->c_flags &= ~CF_TRUE;
-                }
+               }
                comp->c_mn = &fmt_mnull;
            }
            if ((comp->c_flags & CF_TRUE) == 0  &&
                comp->c_mn = &fmt_mnull;
            }
            if ((comp->c_flags & CF_TRUE) == 0  &&
-               fmt->f_type == FT_GETMYMBOX) {
+               (fmt->f_type == FT_GETMYMBOX || fmt->f_type == FT_GETMYADDR)) {
                /* Fool FT_LS_ADDR into not producing an address. */
                comp->c_mn = &fmt_mnull; comp->c_text = NULL;
            }
                /* Fool FT_LS_ADDR into not producing an address. */
                comp->c_mn = &fmt_mnull; comp->c_text = NULL;
            }
index 8816cb6..8efee5b 100755 (executable)
@@ -53,6 +53,9 @@ run_test "echo \
 # check getmymbox, without match
 run_test 'fmttest -message -format %(getmymbox{from}) first' ''
 
 # check getmymbox, without match
 run_test 'fmttest -message -format %(getmymbox{from}) first' ''
 
+# check getmyaddr, without match
+run_test 'fmttest -message -format %(getmyaddr{from}) first' ''
+
 grep -v 'Alternate-Mailboxes: ' "$MH" > "$MH".new
 mv -f "$MH".new "$MH"
 cat >>"$MH" <<EOF
 grep -v 'Alternate-Mailboxes: ' "$MH" > "$MH".new
 mv -f "$MH".new "$MH"
 cat >>"$MH" <<EOF
@@ -61,6 +64,10 @@ EOF
 
 # check getmymbox, with match
 run_test 'fmttest -message -format %(getmymbox{from}) first' \
 
 # check getmymbox, with match
 run_test 'fmttest -message -format %(getmymbox{from}) first' \
+         'Test1 <test1@example.com>'
+
+# check getmyaddr, with match
+run_test 'fmttest -message -format %(getmyaddr{from}) first' \
          'test1@example.com'
 
 exit $failed
          'test1@example.com'
 
 exit $failed
index 7879431..463c7ed 100644 (file)
@@ -211,6 +211,7 @@ dumpone(struct format *fmt)
        case FT_PARSEADDR:
        case FT_MYMBOX:
        case FT_GETMYMBOX:
        case FT_PARSEADDR:
        case FT_MYMBOX:
        case FT_GETMYMBOX:
+       case FT_GETMYADDR:
                printf(", c_name ");
                litputs(fmt->f_comp->c_name);
                if (fmt->f_comp->c_type)
                printf(", c_name ");
                litputs(fmt->f_comp->c_name);
                if (fmt->f_comp->c_type)
@@ -415,6 +416,7 @@ f_typestr(int t)
        case FT_CONCATADDR: return("CONCATADDR");
        case FT_MYMBOX: return("MYMBOX");
        case FT_GETMYMBOX: return("GETMYMBOX");
        case FT_CONCATADDR: return("CONCATADDR");
        case FT_MYMBOX: return("MYMBOX");
        case FT_GETMYMBOX: return("GETMYMBOX");
+       case FT_GETMYADDR: return("GETMYADDR");
        case FT_SAVESTR: return("SAVESTR");
 #ifdef FT_PAUSE
        case FT_PAUSE: return ("PAUSE");
        case FT_SAVESTR: return("SAVESTR");
 #ifdef FT_PAUSE
        case FT_PAUSE: return ("PAUSE");
index f5fe246..4206088 100644 (file)
@@ -847,6 +847,7 @@ dumpone(struct format *fmt)
        case FT_PARSEADDR:
        case FT_MYMBOX:
        case FT_GETMYMBOX:
        case FT_PARSEADDR:
        case FT_MYMBOX:
        case FT_GETMYMBOX:
+       case FT_GETMYADDR:
                printf(", c_name ");
                litputs(fmt->f_comp->c_name);
                if (fmt->f_comp->c_type)
                printf(", c_name ");
                litputs(fmt->f_comp->c_name);
                if (fmt->f_comp->c_type)
@@ -1088,6 +1089,7 @@ f_typestr(int t)
        case FT_CONCATADDR: return("CONCATADDR");
        case FT_MYMBOX: return("MYMBOX");
        case FT_GETMYMBOX: return("GETMYMBOX");
        case FT_CONCATADDR: return("CONCATADDR");
        case FT_MYMBOX: return("MYMBOX");
        case FT_GETMYMBOX: return("GETMYMBOX");
+       case FT_GETMYADDR: return("GETMYADDR");
 #ifdef FT_ADDTOSEQ
        case FT_ADDTOSEQ: return("ADDTOSEQ");
 #endif
 #ifdef FT_ADDTOSEQ
        case FT_ADDTOSEQ: return("ADDTOSEQ");
 #endif