]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Use Unix line endings for win32-glob
authorWolfgang Stöggl <c72578@yahoo.de>
Mon, 28 Jan 2019 20:00:08 +0000 (21:00 +0100)
committerTobias Oetiker <tobi@oetiker.ch>
Sat, 2 Feb 2019 21:27:50 +0000 (22:27 +0100)
- Restore original line endings for win32-glob.c and win32-glob.h
- Furthermore, RRDtool source files use Unix line endings in general

win32/win32-glob.c
win32/win32-glob.h

index 111565ada5a36c434c5abf6735354c8812459780..74f389d3980cf38ba237ec885a7596b0c0dbf663 100644 (file)
-/* libSoX minimal glob for MS-Windows: (c) 2009 SoX contributors\r
- *\r
- * This library is free software; you can redistribute it and/or modify it\r
- * under the terms of the GNU Lesser General Public License as published by\r
- * the Free Software Foundation; either version 2.1 of the License, or (at\r
- * your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful, but\r
- * WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser\r
- * General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public License\r
- * along with this library; if not, write to the Free Software Foundation,\r
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
- */\r
-\r
-#include "win32-glob.h"\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <errno.h>\r
-#define WIN32_LEAN_AND_MEAN 1\r
-#include <windows.h>\r
-\r
-typedef struct file_entry\r
-{\r
-    char name[MAX_PATH];\r
-    struct file_entry *next;\r
-} file_entry;\r
-\r
-static int\r
-insert(\r
-    const char* path,\r
-    const char* name,\r
-    file_entry** phead)\r
-{\r
-    int len;\r
-    file_entry* cur = malloc(sizeof(file_entry));\r
-    if (!cur)\r
-    {\r
-        return ENOMEM;\r
-    }\r
-\r
-    len = _snprintf(cur->name, MAX_PATH, "%s%s", path, name);\r
-    cur->name[MAX_PATH - 1] = 0;\r
-    cur->next = *phead;\r
-    *phead = cur;\r
-\r
-    return len < 0 || len >= MAX_PATH ? ENAMETOOLONG : 0;\r
-}\r
-\r
-static int\r
-entry_comparer(\r
-    const void* pv1,\r
-    const void* pv2)\r
-{\r
-       const file_entry* const * pe1 = pv1;\r
-       const file_entry* const * pe2 = pv2;\r
-    return _stricmp((*pe1)->name, (*pe2)->name);\r
-}\r
-\r
-int\r
-glob(\r
-    const char *pattern,\r
-    int flags,\r
-    void *unused,\r
-    glob_t *pglob)\r
-{\r
-    char path[MAX_PATH];\r
-    file_entry *head = NULL;\r
-    int err = 0;\r
-    size_t len;\r
-    unsigned entries = 0;\r
-    WIN32_FIND_DATAA finddata;\r
-    HANDLE hfindfile = FindFirstFileA(pattern, &finddata);\r
-\r
-    if (!pattern || flags != (flags & GLOB_FLAGS) || unused || !pglob)\r
-    {\r
-        errno = EINVAL;\r
-        return EINVAL;\r
-    }\r
-\r
-    path[MAX_PATH - 1] = 0;\r
-    strncpy(path, pattern, MAX_PATH);\r
-    if (path[MAX_PATH - 1] != 0)\r
-    {\r
-        errno = ENAMETOOLONG;\r
-        return ENAMETOOLONG;\r
-    }\r
-\r
-    len = strlen(path);\r
-    while (len > 0 && path[len - 1] != '/' && path[len - 1] != '\\')\r
-        len--;\r
-    path[len] = 0;\r
-\r
-    if (hfindfile == INVALID_HANDLE_VALUE)\r
-    {\r
-        if (flags & GLOB_NOCHECK)\r
-        {\r
-            err = insert("", pattern, &head);\r
-            entries++;\r
-        }\r
-    }\r
-    else\r
-    {\r
-        do\r
-        {\r
-            err = insert(path, finddata.cFileName, &head);\r
-            entries++;\r
-        } while (!err && FindNextFileA(hfindfile, &finddata));\r
-\r
-        FindClose(hfindfile);\r
-    }\r
-\r
-    if (err == 0)\r
-    {\r
-        pglob->gl_pathv = malloc((entries + 1) * sizeof(char*));\r
-        if (pglob->gl_pathv)\r
-        {\r
-            pglob->gl_pathc = entries;\r
-            pglob->gl_pathv[entries] = NULL;\r
-            for (; head; head = head->next, entries--)\r
-                pglob->gl_pathv[entries - 1] = (char*)head;\r
-            qsort(pglob->gl_pathv, pglob->gl_pathc, sizeof(char*), entry_comparer);\r
-        }\r
-        else\r
-        {\r
-            pglob->gl_pathc = 0;\r
-            err = ENOMEM;\r
-        }\r
-    }\r
-    else if (pglob)\r
-    {\r
-        pglob->gl_pathc = 0;\r
-        pglob->gl_pathv = NULL;\r
-    }\r
-\r
-    if (err)\r
-    {\r
-        file_entry *cur;\r
-        while (head)\r
-        {\r
-            cur = head;\r
-            head = head->next;\r
-            free(cur);\r
-        }\r
-\r
-        errno = err;\r
-    }\r
-\r
-    return err;\r
-}\r
-\r
-void\r
-globfree(\r
-    glob_t* pglob)\r
-{\r
-    if (pglob)\r
-    {\r
-        char** cur;\r
-        for (cur = pglob->gl_pathv; *cur; cur++)\r
-        {\r
-            free(*cur);\r
-        }\r
-\r
-        pglob->gl_pathc = 0;\r
-        pglob->gl_pathv = NULL;\r
-    }\r
-}\r
+/* libSoX minimal glob for MS-Windows: (c) 2009 SoX contributors
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "win32-glob.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+
+typedef struct file_entry
+{
+    char name[MAX_PATH];
+    struct file_entry *next;
+} file_entry;
+
+static int
+insert(
+    const char* path,
+    const char* name,
+    file_entry** phead)
+{
+    int len;
+    file_entry* cur = malloc(sizeof(file_entry));
+    if (!cur)
+    {
+        return ENOMEM;
+    }
+
+    len = _snprintf(cur->name, MAX_PATH, "%s%s", path, name);
+    cur->name[MAX_PATH - 1] = 0;
+    cur->next = *phead;
+    *phead = cur;
+
+    return len < 0 || len >= MAX_PATH ? ENAMETOOLONG : 0;
+}
+
+static int
+entry_comparer(
+    const void* pv1,
+    const void* pv2)
+{
+       const file_entry* const * pe1 = pv1;
+       const file_entry* const * pe2 = pv2;
+    return _stricmp((*pe1)->name, (*pe2)->name);
+}
+
+int
+glob(
+    const char *pattern,
+    int flags,
+    void *unused,
+    glob_t *pglob)
+{
+    char path[MAX_PATH];
+    file_entry *head = NULL;
+    int err = 0;
+    size_t len;
+    unsigned entries = 0;
+    WIN32_FIND_DATAA finddata;
+    HANDLE hfindfile = FindFirstFileA(pattern, &finddata);
+
+    if (!pattern || flags != (flags & GLOB_FLAGS) || unused || !pglob)
+    {
+        errno = EINVAL;
+        return EINVAL;
+    }
+
+    path[MAX_PATH - 1] = 0;
+    strncpy(path, pattern, MAX_PATH);
+    if (path[MAX_PATH - 1] != 0)
+    {
+        errno = ENAMETOOLONG;
+        return ENAMETOOLONG;
+    }
+
+    len = strlen(path);
+    while (len > 0 && path[len - 1] != '/' && path[len - 1] != '\\')
+        len--;
+    path[len] = 0;
+
+    if (hfindfile == INVALID_HANDLE_VALUE)
+    {
+        if (flags & GLOB_NOCHECK)
+        {
+            err = insert("", pattern, &head);
+            entries++;
+        }
+    }
+    else
+    {
+        do
+        {
+            err = insert(path, finddata.cFileName, &head);
+            entries++;
+        } while (!err && FindNextFileA(hfindfile, &finddata));
+
+        FindClose(hfindfile);
+    }
+
+    if (err == 0)
+    {
+        pglob->gl_pathv = malloc((entries + 1) * sizeof(char*));
+        if (pglob->gl_pathv)
+        {
+            pglob->gl_pathc = entries;
+            pglob->gl_pathv[entries] = NULL;
+            for (; head; head = head->next, entries--)
+                pglob->gl_pathv[entries - 1] = (char*)head;
+            qsort(pglob->gl_pathv, pglob->gl_pathc, sizeof(char*), entry_comparer);
+        }
+        else
+        {
+            pglob->gl_pathc = 0;
+            err = ENOMEM;
+        }
+    }
+    else if (pglob)
+    {
+        pglob->gl_pathc = 0;
+        pglob->gl_pathv = NULL;
+    }
+
+    if (err)
+    {
+        file_entry *cur;
+        while (head)
+        {
+            cur = head;
+            head = head->next;
+            free(cur);
+        }
+
+        errno = err;
+    }
+
+    return err;
+}
+
+void
+globfree(
+    glob_t* pglob)
+{
+    if (pglob)
+    {
+        char** cur;
+        for (cur = pglob->gl_pathv; *cur; cur++)
+        {
+            free(*cur);
+        }
+
+        pglob->gl_pathc = 0;
+        pglob->gl_pathv = NULL;
+    }
+}
index 3dca881bdc9b119b6aa372784316820cea89c907..30f417965602479c8625895d21f4a60610afab5d 100644 (file)
@@ -1,49 +1,49 @@
-/* libSoX minimal glob for MS-Windows: (c) 2009 SoX contributors\r
- *\r
- * This library is free software; you can redistribute it and/or modify it\r
- * under the terms of the GNU Lesser General Public License as published by\r
- * the Free Software Foundation; either version 2.1 of the License, or (at\r
- * your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful, but\r
- * WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser\r
- * General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public License\r
- * along with this library; if not, write to the Free Software Foundation,\r
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
- */\r
-\r
-#ifndef GLOB_H\r
-#define GLOB_H 1\r
-\r
-#define GLOB_NOCHECK (16)\r
-#define GLOB_FLAGS (GLOB_NOCHECK)\r
-\r
-typedef struct glob_t\r
-{\r
-    unsigned gl_pathc;\r
-    char **gl_pathv;\r
-} glob_t;\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-int\r
-glob(\r
-    const char *pattern,\r
-    int flags,\r
-    void *unused,\r
-    glob_t *pglob);\r
-\r
-void\r
-globfree(\r
-    glob_t* pglob);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif /* ifndef GLOB_H */\r
+/* libSoX minimal glob for MS-Windows: (c) 2009 SoX contributors
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef GLOB_H
+#define GLOB_H 1
+
+#define GLOB_NOCHECK (16)
+#define GLOB_FLAGS (GLOB_NOCHECK)
+
+typedef struct glob_t
+{
+    unsigned gl_pathc;
+    char **gl_pathv;
+} glob_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int
+glob(
+    const char *pattern,
+    int flags,
+    void *unused,
+    glob_t *pglob);
+
+void
+globfree(
+    glob_t* pglob);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ifndef GLOB_H */