changeset 608:f92f1b3d7fd4

Merge.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 16 Jan 2020 01:09:25 +0200
parents 566e6ef41f9d (current diff) 081426ee3d93 (diff)
children 69f1cb7f9b38
files
diffstat 4 files changed, 112 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.inc	Thu Jan 16 01:09:00 2020 +0200
+++ b/Makefile.inc	Thu Jan 16 01:09:25 2020 +0200
@@ -68,7 +68,8 @@
 all: $(NOBUILD_TARGETS) $(NOINST_TARGETS) $(TARGETS)
 
 
-$(THLIBS)th_string.c: $(addprefix $(THLIBS), th_printf.c th_printf1.c th_strmatch.c th_string.h)
+$(THLIBS)th_string.c: $(addprefix $(THLIBS), \
+	th_printf.c th_printf1.c th_strglob.c th_string.h)
 	@touch $@
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/th_strglob.c	Thu Jan 16 01:09:25 2020 +0200
@@ -0,0 +1,108 @@
+/*
+ * String glob match implementation
+ * Programmed and designed by Matti 'ccr' Hamalainen
+ * (C) Copyright 2002-2020 Tecnic Software productions (TNSP)
+ *
+ * Please read file 'COPYING' for information on license and distribution.
+ */
+
+BOOL TH_STRGLOB_FUNC (const char *haystack, const char *pattern)
+{
+    BOOL matched = TRUE, any = FALSE, end = FALSE;
+    const char *tmp = NULL;
+
+    // Check given pattern and string
+    if (haystack == NULL || pattern == NULL)
+        return FALSE;
+
+    // Start comparision
+    while (matched && !end)
+    switch (*pattern)
+    {
+    case '?':
+        // Any single character matches
+        if (*haystack)
+        {
+            pattern++;
+            haystack++;
+        }
+        else
+            matched = FALSE;
+        break;
+
+    case '*':
+        pattern++;
+        if (!*pattern || *pattern == '?')
+            end = TRUE;
+        any = TRUE;
+        tmp = pattern;
+        break;
+
+    case 0:
+        if (any)
+        {
+            if (*haystack)
+                haystack++;
+            else
+                end = TRUE;
+        }
+        else
+        if (*haystack)
+        {
+            if (tmp)
+            {
+                any = TRUE;
+                pattern = tmp;
+            }
+            else
+                matched = FALSE;
+        }
+        else
+            end = TRUE;
+        break;
+
+    default:
+        if (any)
+        {
+            if (TH_STRGLOB_COLLATE(*pattern) == TH_STRGLOB_COLLATE(*haystack))
+            {
+                any = FALSE;
+            }
+            else
+            if (*haystack)
+                haystack++;
+            else
+                matched = FALSE;
+        }
+        else
+        {
+            if (TH_STRGLOB_COLLATE(*pattern) == TH_STRGLOB_COLLATE(*haystack))
+            {
+                if (*pattern)
+                    pattern++;
+                if (*haystack)
+                    haystack++;
+            }
+            else
+            if (tmp)
+            {
+                any = TRUE;
+                pattern = tmp;
+            }
+            else
+                matched = FALSE;
+        }
+
+        if (!*haystack && !*pattern)
+            end = TRUE;
+
+        break;
+    }
+
+    return matched;
+}
+
+
+#undef TH_STRGLOB_FUNC
+#undef TH_STRGLOB_COLLATE
+
--- a/th_string.c	Thu Jan 16 01:09:00 2020 +0200
+++ b/th_string.c	Thu Jan 16 01:09:25 2020 +0200
@@ -543,14 +543,14 @@
  */
 #define TH_STRGLOB_FUNC th_strmatch
 #define TH_STRGLOB_COLLATE(px) (px)
-#include "th_strmatch.c"
+#include "th_strglob.c"
 
 
 /* Compare a string to a pattern. Case-INSENSITIVE version.
  */
 #define TH_STRGLOB_FUNC th_strcasematch
 #define TH_STRGLOB_COLLATE(px) th_tolower(px)
-#include "th_strmatch.c"
+#include "th_strglob.c"
 
 
 BOOL th_get_hex_triplet(const char *str, unsigned int *value)
--- a/th_strmatch.c	Thu Jan 16 01:09:00 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * String glob match implementation
- * Programmed and designed by Matti 'ccr' Hamalainen
- * (C) Copyright 2002-2020 Tecnic Software productions (TNSP)
- *
- * Please read file 'COPYING' for information on license and distribution.
- */
-
-BOOL TH_STRGLOB_FUNC (const char *haystack, const char *pattern)
-{
-    BOOL matched = TRUE, any = FALSE, end = FALSE;
-    const char *tmp = NULL;
-
-    // Check given pattern and string
-    if (haystack == NULL || pattern == NULL)
-        return FALSE;
-
-    // Start comparision
-    while (matched && !end)
-    switch (*pattern)
-    {
-    case '?':
-        // Any single character matches
-        if (*haystack)
-        {
-            pattern++;
-            haystack++;
-        }
-        else
-            matched = FALSE;
-        break;
-
-    case '*':
-        pattern++;
-        if (!*pattern || *pattern == '?')
-            end = TRUE;
-        any = TRUE;
-        tmp = pattern;
-        break;
-
-    case 0:
-        if (any)
-        {
-            if (*haystack)
-                haystack++;
-            else
-                end = TRUE;
-        }
-        else
-        if (*haystack)
-        {
-            if (tmp)
-            {
-                any = TRUE;
-                pattern = tmp;
-            }
-            else
-                matched = FALSE;
-        }
-        else
-            end = TRUE;
-        break;
-
-    default:
-        if (any)
-        {
-            if (TH_STRGLOB_COLLATE(*pattern) == TH_STRGLOB_COLLATE(*haystack))
-            {
-                any = FALSE;
-            }
-            else
-            if (*haystack)
-                haystack++;
-            else
-                matched = FALSE;
-        }
-        else
-        {
-            if (TH_STRGLOB_COLLATE(*pattern) == TH_STRGLOB_COLLATE(*haystack))
-            {
-                if (*pattern)
-                    pattern++;
-                if (*haystack)
-                    haystack++;
-            }
-            else
-            if (tmp)
-            {
-                any = TRUE;
-                pattern = tmp;
-            }
-            else
-                matched = FALSE;
-        }
-
-        if (!*haystack && !*pattern)
-            end = TRUE;
-
-        break;
-    }
-
-    return matched;
-}
-
-
-#undef TH_STRGLOB_FUNC
-#undef TH_STRGLOB_COLLATE
-