]> diplodocus.org Git - nmh/blobdiff - uip/mhstoresbr.c
Generalized condition for support of parameter value tests.
[nmh] / uip / mhstoresbr.c
index 210a91be5ab664df55db52112cec61c23658333e..515699d8bd8a3b7748e1bfd5997a954d62caab9c 100644 (file)
@@ -40,6 +40,8 @@ struct mhstoreinfo {
     enum clobber_policy_t clobber_policy;  /* -clobber selection */
 };
 
+static bool use_param_as_filename(const char *p);
+
 mhstoreinfo_t
 mhstoreinfo_create (CT *ct, char *pwd, const char *csw, int asw, int vsw) {
     mhstoreinfo_t info;
@@ -431,12 +433,7 @@ store_external (CT ct, mhstoreinfo_t info)
     if (info->autosw) {
        char *cp;
 
-       if ((cp = e->eb_name)
-           && *cp != '/'
-           && *cp != '.'
-           && *cp != '|'
-           && *cp != '!'
-           && !strchr (cp, '%')) {
+       if ((cp = e->eb_name) && use_param_as_filename(cp)) {
            if (!ct->c_storeproc)
                ct->c_storeproc = mh_xstrdup(cp);
            if (!p->c_storeproc)
@@ -1068,12 +1065,8 @@ get_storeproc (CT ct)
      * use that (RFC-2183).
      */
     if (ct->c_dispo) {
-       if ((cp = get_param(ct->c_dispo_first, "filename", '_', 0))
-               && *cp != '/'
-               && *cp != '.'
-               && *cp != '|'
-               && *cp != '!'
-               && !strchr (cp, '%')) {
+       if ((cp = get_param(ct->c_dispo_first, "filename", '_', 0)) &&
+            use_param_as_filename(cp)) {
                ct->c_storeproc = mh_xstrdup(cp);
                free(cp);
                return;
@@ -1087,12 +1080,8 @@ get_storeproc (CT ct)
      * the storeproc.
      */
     ci = &ct->c_ctinfo;
-    if ((cp = get_param(ci->ci_first_pm, "name", '_', 0))
-         && *cp != '/'
-         && *cp != '.'
-         && *cp != '|'
-         && *cp != '!'
-         && !strchr (cp, '%')) {
+    if ((cp = get_param(ci->ci_first_pm, "name", '_', 0)) &&
+        use_param_as_filename(cp)) {
            ct->c_storeproc = mh_xstrdup(cp);
 
     }
@@ -1349,5 +1338,12 @@ clobber_check (char *original_file, mhstoreinfo_t info) {
   return file;
 }
 
+static bool use_param_as_filename(const char *p)
+{
+    /* Preserve result of original test that considered an empty string
+     * OK. */
+    return !*p || (!strchr("/.|!", *p) && !strchr(p, '%'));
+}
+
 /* -clobber support */
 /******************************************************************************/