]> diplodocus.org Git - nmh/commitdiff
Added -debug switch to pick(1) and deprecated $MHPDEBUG.
authorDavid Levine <levinedl@acm.org>
Sun, 3 Aug 2014 12:53:15 +0000 (07:53 -0500)
committerDavid Levine <levinedl@acm.org>
Sun, 3 Aug 2014 12:53:15 +0000 (07:53 -0500)
docs/pending-release-notes
h/picksbr.h
man/mh-profile.man
man/pick.man
test/pick/test-pick
uip/pick.c
uip/picksbr.c

index 7830242dced3074f124f64d2bf46d511eb92d9e5..81946359230b7bfeb1d376f8a4569434af301d91 100644 (file)
@@ -22,6 +22,10 @@ OBSOLETE FEATURES
 -------------------
 DEPRECATED FEATURES
 -------------------
+
+- Support for the MHPDEBUG environment variable is deprecated and will be
+  removed from a future nmh release.  Instead, use the -debug switch to pick.
+
 ---------
 BUG FIXES
 ---------
index 27c2e66c3ae267712b039e6fc32c4d39358b86a8..fc3bc2a7446cc43907895bc8d8e43b7ecc2bcd88 100644 (file)
@@ -7,4 +7,4 @@
  * prototypes
  */
 int pcompile (char **, char *);
-int pmatches (FILE *, int, long, long);
+int pmatches (FILE *, int, long, long, int);
index 3ebae8baec65d1775c4c6faaa3c645f3dbb323a6..1cdc7395e8b9bdfcc21a50295dcded2357ec1a1a 100644 (file)
@@ -878,6 +878,13 @@ will emit debugging information.
 If this variable is set to a non-null value,
 .B pick
 will emit a representation of the search pattern.
+.B $MHPDEBUG
+is deprecated, so support for this variable will
+be removed from a future nmh release.  Instead,
+.B pick
+now supports a
+.B \-debug
+switch.
 .RE
 .PP
 .B $MHWDEBUG
index 38166453d17c9a233717ecd21ea9c5ec6271aec2..e023db5c8d0bd14eeb2f126cb1e00e752fc7c1d8 100644 (file)
@@ -1,4 +1,4 @@
-.TH PICK %manext1% "March 1, 2014" "%nmhversion%"
+.TH PICK %manext1% "August 3, 2014" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
@@ -46,6 +46,7 @@ pick \- search for messages by content
 .RB [ \-public " | " \-nopublic ]
 .RB [ \-zero " | " \-nozero ]
 .RB [ \-list " | " \-nolist ] 
+.RB [ \-debug ]
 .RB [ \-version ]
 .RB [ \-help ]
 .PP
@@ -287,6 +288,11 @@ in the
 same way
 .B mark
 uses them.
+.PP
+The
+.B \-debug
+switch causes pick to output a representation of the search
+pattern.
 .SS "Output when no messages are matched"
 If
 .B pick
index 4eff47cbbf01fa3b32549fff417de1f0c58d70ad..858d8e75e2a422051b060741984e732724f58067 100755 (executable)
@@ -76,10 +76,9 @@ run_test 'pick -not -lbrace -subject NoMatch -and -subject message.3 -rbrace' \
 10
 11'
 
-# Test MHPDEBUG.
-# Don't use run_prog here because it loses the environment setting.
-MHPDEBUG=1 pick -not -lbrace -subject NoMatch -and -subject message.3 -rbrace \
- >/dev/null 2>"$actual"
+# Test -debug.
+run_prog pick -debug -not -lbrace -subject NoMatch -and -subject message.3 \
+  -rbrace >/dev/null 2>"$actual"
 cat >"$expected" <<EOF
 NOT
 | AND
index 740f6f0a4e9524069b831a1bf88746708aa8a1e7..d29799b7a157ebcca5c2a38c50930a7621857ff4 100644 (file)
@@ -36,6 +36,7 @@
     X("nozero", 0, NZEROSW) \
     X("list", 0, LISTSW) \
     X("nolist", 0, NLISTSW) \
+    X("debug", 0, DEBUGSW) \
     X("version", 0, VERSIONSW) \
     X("help", 0, HELPSW) \
 
@@ -65,11 +66,16 @@ main (int argc, char **argv)
     struct msgnum_array nums = { 0, 0, NULL };
     struct msgs *mp, *mp2;
     register FILE *fp;
+    int debug = 0;
 
     if (nmh_init(argv[0], 1)) { return 1; }
 
     done=putzero_done;
 
+    /* Deprecated.  Use -debug instead. */
+    if ((cp = getenv ("MHPDEBUG")) && *cp)
+       ++debug;
+
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
@@ -156,6 +162,10 @@ main (int argc, char **argv)
            case NLISTSW: 
                listsw = 0;
                continue;
+
+           case DEBUGSW:
+               ++debug;
+               continue;
            }
        }
        if (*cp == '+' || *cp == '@') {
@@ -225,7 +235,7 @@ main (int argc, char **argv)
        if (is_selected (mp, msgnum)) {
            if ((fp = fopen (cp = m_name (msgnum), "r")) == NULL)
                admonish (cp, "unable to read message");
-           if (fp && pmatches (fp, msgnum, 0L, 0L)) {
+           if (fp && pmatches (fp, msgnum, 0L, 0L, debug)) {
                if (listsw)
                    printf ("%s\n", m_name (msgnum));
            } else {
index 6035470341e86573124c5113c6bdef3a84a51f68..74834f4eaa8ae5700f34e093dc59f1fc1c431fe5 100644 (file)
@@ -157,7 +157,6 @@ struct nexus {
 #define        n_tws    un.st3.un_tws
 
 static int talked;
-static int pdebug = 0;
 
 static char *datesw;
 static char **argp;
@@ -195,11 +194,6 @@ static int TWSaction();
 int
 pcompile (char **vec, char *date)
 {
-    register char *cp;
-
-    if ((cp = getenv ("MHPDEBUG")) && *cp)
-       pdebug++;
-
     argp = vec;
     if ((datesw = date) == NULL)
        datesw = "date";
@@ -474,12 +468,12 @@ newnexus (int (*action)())
                    stop;
 
 int
-pmatches (FILE *fp, int msgnum, long start, long stop)
+pmatches (FILE *fp, int msgnum, long start, long stop, int debug)
 {
     if (!head)
        return 1;
 
-    if (!talked++ && pdebug)
+    if (!talked++ && debug)
        PRaction (head, 0);
 
     return (*head->n_action) (args (head));