Sebastian Kuschel reports that pfd_closing can be called for a socket
[u/mdw/putty] / wildcard.c
index 999dfde..c1cb0b4 100644 (file)
@@ -10,6 +10,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "putty.h"
+
 /*
  * Definition of wildcard syntax:
  * 
  */
 
 /*
+ * Some notes on differences from POSIX globs (IEEE Std 1003.1, 2003 ed.):
+ *  - backslashes act as escapes even within [] bracket expressions
+ *  - does not support [!...] for non-matching list (POSIX are weird);
+ *    NB POSIX allows [^...] as well via "A bracket expression starting
+ *    with an unquoted circumflex character produces unspecified
+ *    results". If we wanted to allow [!...] we might want to define
+ *    [^!] as having its literal meaning (match '^' or '!').
+ *  - none of the scary [[:class:]] stuff, etc
+ */
+
+/*
  * The wildcard matching technique we use is very simple and
  * potentially O(N^2) in running time, but I don't anticipate it
  * being that bad in reality (particularly since N will be the size
@@ -54,7 +67,7 @@
 enum {
     WC_TRAILINGBACKSLASH = 1,
     WC_UNCLOSEDCLASS,
-    WC_INVALIDRANGE,
+    WC_INVALIDRANGE
 };
 
 /*
@@ -313,7 +326,8 @@ int wc_unescape(char *output, const char *wildcard)
            wildcard++;
        }
     }
-    *output = '\0';
+    if (output)
+        *output = '\0';
     return 1;                         /* it's clean */
 }