diff options
| author | Jakub Zelenka <bukka@php.net> | 2016-02-29 19:31:20 +0000 |
|---|---|---|
| committer | Jakub Zelenka <bukka@php.net> | 2016-02-29 19:31:20 +0000 |
| commit | 70141093a731049ee9220e9e965f61ded56ed4d5 (patch) | |
| tree | 6e67b382253a186889bfdc37c31062d6fb9880d9 /ext/zip/lib/zip_name_locate.c | |
| parent | e453af3851daf08f5af9b45fc7819c3a9c336f1e (diff) | |
| parent | 97294aca7e066443291cc2d77f8674ac23eabb32 (diff) | |
| download | php-git-70141093a731049ee9220e9e965f61ded56ed4d5.tar.gz | |
Merge branch 'master' into openssl_aead
Diffstat (limited to 'ext/zip/lib/zip_name_locate.c')
| -rw-r--r-- | ext/zip/lib/zip_name_locate.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/ext/zip/lib/zip_name_locate.c b/ext/zip/lib/zip_name_locate.c index 820ea0ca7f..50ca40b1a9 100644 --- a/ext/zip/lib/zip_name_locate.c +++ b/ext/zip/lib/zip_name_locate.c @@ -1,6 +1,6 @@ /* zip_name_locate.c -- get index by name - Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner + Copyright (C) 1999-2015 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <libzip@nih.at> @@ -62,27 +62,33 @@ _zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags, zip_error_t *e return -1; } - cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp; - - for (i=0; i<za->nentry; i++) { - fn = _zip_get_name(za, i, flags, error); - - /* newly added (partially filled) entry or error */ - if (fn == NULL) - continue; - - if (flags & ZIP_FL_NODIR) { - p = strrchr(fn, '/'); - if (p) - fn = p+1; + if (flags & (ZIP_FL_NOCASE|ZIP_FL_NODIR|ZIP_FL_ENC_CP437)) { + /* can't use hash table */ + cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp; + + for (i=0; i<za->nentry; i++) { + fn = _zip_get_name(za, i, flags, error); + + /* newly added (partially filled) entry or error */ + if (fn == NULL) + continue; + + if (flags & ZIP_FL_NODIR) { + p = strrchr(fn, '/'); + if (p) + fn = p+1; + } + + if (cmp(fname, fn) == 0) { + _zip_error_clear(error); + return (zip_int64_t)i; + } } - if (cmp(fname, fn) == 0) { - _zip_error_clear(error); - return (zip_int64_t)i; - } + zip_error_set(error, ZIP_ER_NOENT, 0); + return -1; + } + else { + return _zip_hash_lookup(za->names, (const zip_uint8_t *)fname, flags, error); } - - zip_error_set(error, ZIP_ER_NOENT, 0); - return -1; } |
