Rename fnmatchemu to just emu, because I'm sure we'll want to put more stuff

there.
This commit is contained in:
David Given
2019-07-08 23:21:49 +02:00
parent b0e905fdd0
commit 3b6ea24df5
6 changed files with 30 additions and 27 deletions

View File

@@ -90,11 +90,11 @@
* path delimiter must be aware that 0x5C is NOT unique within SHIFT-JIS.
*/
#include "fnmatch.h"
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include "fnmatchemu.h"
#include "charclass.h"
#define RANGE_MATCH 1
@@ -275,12 +275,11 @@ fnmatch_ch_success:
}
int fnmatchemu(const char *pattern, const char *string, int flags)
int fnmatch(const char *pattern, const char *string, int flags)
{
static const char dummystring[2] = {' ', 0};
const int escape = !(flags & FNM_NOESCAPE);
const int slash = !!(flags & FNM_PATHNAME);
const int leading_dir = !!(flags & FNM_LEADING_DIR);
const char *strendseg;
const char *dummyptr;
const char *matchptr;
@@ -463,16 +462,13 @@ firstsegment:
}
}
if (*string && !((slash || leading_dir) && (*string == '/')))
if (*string && !(slash && (*string == '/')))
return FNM_NOMATCH;
if (*pattern && !(slash && ((*pattern == '/')
|| (escape && (*pattern == '\\')
&& (pattern[1] == '/')))))
return FNM_NOMATCH;
if (leading_dir && !*pattern && *string == '/')
return 0;
}
/* Where both pattern and string are at EOS, declare success

21
dep/emu/fnmatch.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef FNMATCH_H
#define FNMATCH_H
#ifdef __cplusplus
extern "C" {
#endif
#define FNM_NOMATCH 1 /* Match failed. */
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
#define FNM_PERIOD 0x04 /* Period must be matched by period. */
#define FNM_CASEFOLD 0x08 /* Fold cases */
extern int fnmatch(const char *pattern, const char *string, int flags);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,14 +0,0 @@
#ifndef FNMATCHEMU_H
#define FNMATCHEMU_H
#ifdef __cplusplus
extern "C" {
#endif
extern int fnmatchemu(const char *pattern, const char *string, int flags);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -184,15 +184,15 @@ buildprogram fluxengine \
libfmt.a \
buildlibrary libbrother120tool.a \
-Idep/fnmatchemu \
-Idep/emu \
tools/brother120tool.cc \
buildlibrary libfnmatchemu.a \
dep/fnmatchemu/fnmatchemu.c
buildlibrary libemu.a \
dep/emu/fnmatch.c
buildprogram brother120tool \
libbrother120tool.a \
libfnmatchemu.a \
libemu.a \
libfmt.a \
buildlibrary libcwftoflux.a \

View File

@@ -1,7 +1,7 @@
#include "globals.h"
#include "fmt/format.h"
#include <fstream>
#include "fnmatchemu.h"
#include "fnmatch.h"
/* Theoretical maximum number of sectors. */
static const int SECTOR_COUNT = 640;
@@ -129,7 +129,7 @@ void extractFile(const std::string& pattern)
if (dirent.type != 0)
continue;
if (fnmatchemu(pattern.c_str(), dirent.filename.c_str(), 0))
if (fnmatch(pattern.c_str(), dirent.filename.c_str(), 0))
continue;
std::cout << fmt::format("Extracting '{}'\n", dirent.filename);