From: Rémi Bernon rbernon@codeweavers.com
Instead of costly wcschr. --- dlls/ntdll/unix/file.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index b1b09e80e5a..d3c7e7d6751 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -169,7 +169,6 @@ typedef struct #define IS_SEPARATOR(ch) ((ch) == '\' || (ch) == '/')
#define INVALID_NT_CHARS '*','?','<','>','|','"' -#define INVALID_DOS_CHARS INVALID_NT_CHARS,'+','=',',',';','[',']',' ','\345'
#define MAX_DIR_ENTRY_LEN 255 /* max length of a directory entry in chars */
@@ -258,6 +257,16 @@ static inline BOOL is_invalid_dos_char( WCHAR ch ) return ch <= 0x7f ? is_invalid[ch] : TRUE; }
+static inline BOOL is_invalid_8dot3_char( WCHAR ch ) +{ + static const char is_invalid[0x7f] = + { + ['*'] = 1, ['?'] = 1, ['<'] = 1, ['>'] = 1, ['|'] = 1, ['"'] = 1, ['+'] = 1, ['='] = 1, + [','] = 1, [';'] = 1, ['['] = 1, [']'] = 1, [' '] = 1, [':'] = 1, ['/'] = 1, ['\'] = 1, + }; + return ch <= 0x7f ? is_invalid[ch] : TRUE; +} + /* check if the device can be a mounted volume */ static inline BOOL is_valid_mounted_device( const struct stat *st ) { @@ -1461,7 +1470,6 @@ static BOOLEAN match_filename( const WCHAR *name, int length, const UNICODE_STRI */ static BOOLEAN is_legal_8dot3_name( const WCHAR *name, int len ) { - static const WCHAR invalid_chars[] = { INVALID_DOS_CHARS,':','/','\',0 }; int i, dot = -1;
if (len > 12) return FALSE; @@ -1471,8 +1479,7 @@ static BOOLEAN is_legal_8dot3_name( const WCHAR *name, int len )
for (i = 0; i < len; i++) { - if (name[i] > 0x7f) return FALSE; - if (wcschr( invalid_chars, name[i] )) return FALSE; + if (is_invalid_8dot3_char( name[i] )) return FALSE; if (name[i] == '.') { if (dot != -1) return FALSE;