]> wimlib.net Git - wimlib/blobdiff - src/wildcard.c
A few cleanups and fixes from recent changes
[wimlib] / src / wildcard.c
index 2619f47b59fe445f84d2e31012d2e6f90828464e..febe8ee039def9e92f435664756ff53ce2801837 100644 (file)
@@ -7,20 +7,18 @@
 /*
  * Copyright (C) 2013 Eric Biggers
  *
- * This file is part of wimlib, a library for working with WIM files.
+ * This file 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 3 of the License, or (at your option) any
+ * later version.
  *
- * wimlib is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * wimlib 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 General Public License for more
+ * This file 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 General Public License
- * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this file; if not, see http://www.gnu.org/licenses/.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -28,6 +26,7 @@
 #endif
 
 #include <ctype.h>
+
 #include "wimlib/dentry.h"
 #include "wimlib/encoding.h"
 #include "wimlib/error.h"
@@ -188,29 +187,25 @@ wildcard_status(const tchar *wildcard)
 static int
 match_dentry(struct wim_dentry *cur_dentry, struct match_dentry_ctx *ctx)
 {
-       tchar *name;
-       size_t name_len;
+       const tchar *name;
+       size_t name_nchars;
        int ret;
 
        if (cur_dentry->file_name_nbytes == 0)
                return 0;
 
-#if TCHAR_IS_UTF16LE
-       name = cur_dentry->file_name;
-       name_len = cur_dentry->file_name_nbytes;
-#else
-       ret = utf16le_to_tstr(cur_dentry->file_name,
-                             cur_dentry->file_name_nbytes,
-                             &name, &name_len);
+       ret = utf16le_get_tstr(cur_dentry->file_name,
+                              cur_dentry->file_name_nbytes,
+                              &name, &name_nchars);
        if (ret)
                return ret;
-#endif
-       name_len /= sizeof(tchar);
+       name_nchars /= sizeof(tchar);
 
-       if (match_wildcard(name,
-                          &ctx->wildcard_path[ctx->cur_component_offset],
-                          ctx->cur_component_len,
-                          ctx->case_insensitive))
+       if (do_match_wildcard(name,
+                             name_nchars,
+                             &ctx->wildcard_path[ctx->cur_component_offset],
+                             ctx->cur_component_len,
+                             ctx->case_insensitive))
        {
                switch (wildcard_status(&ctx->wildcard_path[
                                ctx->cur_component_offset +
@@ -235,9 +230,8 @@ match_dentry(struct wim_dentry *cur_dentry, struct match_dentry_ctx *ctx)
                ret = 0;
        }
 
-#if !TCHAR_IS_UTF16LE
-       FREE(name);
-#endif
+       utf16le_put_tstr(name);
+
        return ret;
 }
 
@@ -332,7 +326,7 @@ expand_wildcard(WIMStruct *wim,
        struct wim_dentry *root;
        int ret;
 
-       root = wim_root_dentry(wim);
+       root = wim_get_current_root_dentry(wim);
        if (root == NULL)
                goto no_match;