diff --git a/compat/fnmatch_rarch.c b/compat/fnmatch_rarch.c index c03865c5a3..6fc9558196 100644 --- a/compat/fnmatch_rarch.c +++ b/compat/fnmatch_rarch.c @@ -98,8 +98,11 @@ int rl_fnmatch(const char *pattern, const char *string, int flags) /* Match following character verbatim */ case '\\': c++; - /* Dangling escape at end of pattern */ - if (*c == '\0') /* FIXME: Was c == '\0' (makes no sense). Not sure if c == NULL or *c == '\0' is intended. Assuming *c due to c++ right before. */ + /* Dangling escape at end of pattern. + * FIXME: Was c == '\0' (makes no sense). + * Not sure if c == NULL or *c == '\0' + * is intended. Assuming *c due to c++ right before. */ + if (*c == '\0') return FNM_NOMATCH; default: if (*c != *string) diff --git a/compat/rxml/rxml.c b/compat/rxml/rxml.c index 33fef0bdc2..75d560284c 100644 --- a/compat/rxml/rxml.c +++ b/compat/rxml/rxml.c @@ -274,7 +274,8 @@ static struct rxml_node *rxml_parse_node(const char **ptr_) goto error; } - node->data = strdup_range(cdata_start + strlen("data = strdup_range(cdata_start + + strlen("data = strdup_range(closing + 1, closing_start); @@ -288,7 +289,8 @@ static struct rxml_node *rxml_parse_node(const char **ptr_) const char *first_start = strchr(ptr, '<'); const char *first_closing = strstr(ptr, "data, size, &defaultChar, &defUsed); + 0, (LPCWSTR)s, len, (char *)buf->data, + size, &defaultChar, &defUsed); if (numChars == 0 || numChars >= size) return SZ_ERROR_FAIL; buf->data[numChars] = 0; @@ -277,7 +278,7 @@ int read_7zip_file(const char * archive_path, if (res == SZ_OK && file_found == true) return outsize; - //Error handling: + /* Error handling */ if (!file_found) RARCH_ERR("File %s not found in %s\n",relative_path,archive_path); else if (res == SZ_ERROR_UNSUPPORTED) @@ -412,27 +413,16 @@ struct string_list *compressed_7zip_file_list_new(const char *path, { /* Error handling */ if (res == SZ_ERROR_UNSUPPORTED) - { RARCH_ERR("7Zip decoder doesn't support this archive\n"); - goto error; - } else if (res == SZ_ERROR_MEM) - { RARCH_ERR("7Zip decoder could not allocate memory\n"); - goto error; - } else if (res == SZ_ERROR_CRC) - { RARCH_ERR("7Zip decoder encountered a CRC error in the archive\n"); - goto error; - } else - { RARCH_ERR( "\nUnspecified error in 7-ZIP archive, error number was: #%d\n", res); - goto error; - } + goto error; } string_list_free(ext_list); @@ -446,5 +436,4 @@ error: string_list_free(list); string_list_free(ext_list); return NULL; - } diff --git a/decompress/zip_support.c b/decompress/zip_support.c index 5730dc7693..ec5b28f2de 100644 --- a/decompress/zip_support.c +++ b/decompress/zip_support.c @@ -27,11 +27,14 @@ #include "../deps/rzlib/unzip.h" -/* Extract the relative path relative_path from a zip archive archive_path and allocate a buf for it to write it in. */ +/* Extract the relative path relative_path from a + * zip archive archive_path and allocate a buf for it to write it in. */ /* This code is inspired by: - * http://stackoverflow.com/questions/10440113/simple-way-to-unzip-a-zip-file-using-zlib + * stackoverflow.com/questions/10440113/simple-way-to-unzip-a-zip-file-using-zlib */ -int read_zip_file(const char * archive_path, const char *relative_path, void **buf) + +int read_zip_file(const char * archive_path, + const char *relative_path, void **buf) { ssize_t bytes_read = -1; bool finished_reading = false; @@ -47,7 +50,8 @@ int read_zip_file(const char * archive_path, const char *relative_path, void **b if ( unzGetGlobalInfo( zipfile, &global_info ) != UNZ_OK ) { RARCH_ERR("Could not get global zipfile info of %s." - "Could be only a gzip file without the zip part.\n",archive_path); + "Could be only a gzip file without the zip part.\n", + archive_path); unzClose( zipfile ); return -1; } @@ -66,7 +70,8 @@ int read_zip_file(const char * archive_path, const char *relative_path, void **b PATH_MAX, NULL, 0, NULL, 0 ) != UNZ_OK ) { - RARCH_ERR("Could not read file info in zip %s.\n",archive_path); + RARCH_ERR("Could not read file info in zip %s.\n", + archive_path); unzClose( zipfile ); return -1; } @@ -83,7 +88,8 @@ int read_zip_file(const char * archive_path, const char *relative_path, void **b /* We found the correct file in the zip, now extract it to *buf */ if ( unzOpenCurrentFile( zipfile ) != UNZ_OK ) { - RARCH_ERR("The file %s in %s could not be read.\n",relative_path,archive_path); + RARCH_ERR("The file %s in %s could not be read.\n", + relative_path, archive_path); unzClose( zipfile ); return -1; } @@ -94,8 +100,10 @@ int read_zip_file(const char * archive_path, const char *relative_path, void **b bytes_read = unzReadCurrentFile( zipfile, *buf, file_info.uncompressed_size ); if (bytes_read != file_info.uncompressed_size) { - RARCH_ERR("We tried to read %d bytes, but only got %d of file %s in zip %s.\n", - (unsigned int) file_info.uncompressed_size,(int)bytes_read,relative_path,archive_path); + RARCH_ERR( + "We tried to read %d bytes, but only got %d of file %s in zip %s.\n", + (unsigned int) file_info.uncompressed_size, (int)bytes_read, + relative_path, archive_path); free(*buf); unzCloseCurrentFile( zipfile ); unzClose( zipfile ); @@ -112,7 +120,9 @@ int read_zip_file(const char * archive_path, const char *relative_path, void **b { if ( unzGoToNextFile( zipfile ) != UNZ_OK ) { - RARCH_ERR( "Could not iterate to next file in %s. Zipfile might be corrupt.\n",archive_path ); + RARCH_ERR( + "Could not iterate to next file in %s. Zipfile might be corrupt.\n", + archive_path ); unzClose( zipfile ); return -1; } @@ -162,7 +172,8 @@ struct string_list *compressed_zip_file_list_new(const char *path, if ( unzGetGlobalInfo( zipfile, &global_info ) != UNZ_OK ) { RARCH_ERR("Could not get global zipfile info of %s." - "Could be only a gzip file without the zip part.\n",path); + "Could be only a gzip file without the zip part.\n", + path); unzClose( zipfile ); return NULL; } diff --git a/file_path.c b/file_path.c index 13abed9e45..2c2f61a11e 100644 --- a/file_path.c +++ b/file_path.c @@ -179,9 +179,7 @@ long read_file(const char *path, void **buf) * */ #ifdef HAVE_COMPRESSION if (path_contains_compressed_file(path)) - { return read_compressed_file(path,buf); - } #endif return read_generic_file(path,buf); } @@ -442,15 +440,11 @@ struct string_list *compressed_file_list_new(const char *path, const char* file_ext = path_get_extension(path); #ifdef HAVE_7ZIP if (strcasecmp(file_ext,"7z") == 0) - { return compressed_7zip_file_list_new(path,ext); - } #endif #ifdef HAVE_ZLIB if (strcasecmp(file_ext,"zip") == 0) - { return compressed_zip_file_list_new(path,ext); - } #endif #endif @@ -683,15 +677,11 @@ bool path_is_compressed_file(const char* path) const char* file_ext = path_get_extension(path); #ifdef HAVE_7ZIP if (strcmp(file_ext,"7z") == 0) - { return true; - } #endif #ifdef HAVE_ZLIB if (strcmp(file_ext,"zip") == 0) - { return true; - } #endif #endif @@ -856,7 +846,7 @@ const char *path_basename(const char *path) bool path_is_absolute(const char *path) { #ifdef _WIN32 - // Many roads lead to Rome ... + /* Many roads lead to Rome ... */ return path[0] == '/' || (strstr(path, "\\\\") == path) || strstr(path, ":/") || strstr(path, ":\\") || strstr(path, ":\\\\"); #else @@ -1003,10 +993,11 @@ void fill_pathname_expand_special(char *out_path, } else if ((in_path[0] == ':') && #ifdef _WIN32 - ((in_path[1] == '/') || (in_path[1] == '\\'))) + ((in_path[1] == '/') || (in_path[1] == '\\')) #else - (in_path[1] == '/')) + (in_path[1] == '/') #endif + ) { char application_dir[PATH_MAX]; fill_pathname_application_path(application_dir, sizeof(application_dir)); @@ -1040,8 +1031,8 @@ void fill_short_pathname_representation(char* out_rep, */ if(last_hash != NULL) { - /* We check whether something is actually after the hash to avoid - * going over the buffer. + /* We check whether something is actually + * after the hash to avoid going over the buffer. */ rarch_assert(strlen(last_hash) > 1); strlcpy(out_rep,last_hash + 1, size);