summaryrefslogtreecommitdiffstats
path: root/loader/fnmatch-stub.c
diff options
context:
space:
mode:
authorjakub <jakub>2000-08-07 11:45:49 +0000
committerjakub <jakub>2000-08-07 11:45:49 +0000
commit440c7c040b3fb919efda03185097606d1ad080be (patch)
tree77f5eedbb0e11a295edb17de6e43d895ad07cc68 /loader/fnmatch-stub.c
parent2e8cc2f6429b22f3d6eb0beb871aa5aa29bf8900 (diff)
downloadanaconda-440c7c040b3fb919efda03185097606d1ad080be.tar.gz
anaconda-440c7c040b3fb919efda03185097606d1ad080be.tar.xz
anaconda-440c7c040b3fb919efda03185097606d1ad080be.zip
The IMHO safe part of the stripping down changes.
Saves more than 200KB of the /sbin/loader's unused crap.
Diffstat (limited to 'loader/fnmatch-stub.c')
-rw-r--r--loader/fnmatch-stub.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/loader/fnmatch-stub.c b/loader/fnmatch-stub.c
new file mode 100644
index 000000000..88de2221d
--- /dev/null
+++ b/loader/fnmatch-stub.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <string.h>
+#include <fnmatch.h>
+
+/* A very simplified fnmatch which just supports one
+ * in the string and no [, ? or { */
+int fnmatch(const char *pattern, const char *string, int flags)
+{
+ const char *p, *q, *r;
+
+ if (flags == (FNM_PATHNAME | FNM_PERIOD)
+ && strpbrk (pattern, "[?{") == NULL
+ && (p = strchr (pattern, '*')) != NULL
+ && strchr (p + 1, '*') == NULL)
+ {
+ if (strncmp (string, pattern, p - pattern))
+ return FNM_NOMATCH;
+ q = strstr (string + (p - pattern), p + 1);
+ r = strchr (string + (p - pattern), '/');
+ if (q == NULL || strlen (q) != strlen (p + 1)
+ || (r != NULL && r < q))
+ return FNM_NOMATCH;
+ return 0;
+ }
+ fprintf (stderr, "fnmatch stub does not support '%s' patterns\n", pattern);
+ exit (1);
+}