From: Eric Biggers Date: Thu, 3 Mar 2016 03:04:41 +0000 (-0600) Subject: Rename string_set to string_list X-Git-Tag: v1.9.1~10 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=5864d8266f61b38fc5836a3cc72dbc6ba0d285be Rename string_set to string_list --- diff --git a/include/wimlib/scan.h b/include/wimlib/scan.h index 903f3d7f..13cd26d5 100644 --- a/include/wimlib/scan.h +++ b/include/wimlib/scan.h @@ -16,10 +16,10 @@ struct wim_inode; struct capture_config { /* List of path patterns to exclude */ - struct string_set exclusion_pats; + struct string_list exclusion_pats; /* List of path patterns to include, overriding exclusion_pats */ - struct string_set exclusion_exception_pats; + struct string_list exclusion_exception_pats; void *buf; }; @@ -84,7 +84,7 @@ extern void destroy_capture_config(struct capture_config *config); extern bool -match_pattern_list(const tchar *path, const struct string_set *list); +match_pattern_list(const tchar *path, const struct string_list *list); extern int try_exclude(const tchar *full_path, const struct scan_params *params); diff --git a/include/wimlib/textfile.h b/include/wimlib/textfile.h index 608ad08d..5854abb5 100644 --- a/include/wimlib/textfile.h +++ b/include/wimlib/textfile.h @@ -3,24 +3,24 @@ #include "wimlib/types.h" -struct string_set { +struct string_list { tchar **strings; size_t num_strings; size_t num_alloc_strings; }; -#define STRING_SET_INITIALIZER \ +#define STRING_LIST_INITIALIZER \ { .strings = NULL, .num_strings = 0, .num_alloc_strings = 0, } -#define STRING_SET(_strings) \ - struct string_set _strings = STRING_SET_INITIALIZER +#define STRING_LIST(_strings) \ + struct string_list _strings = STRING_LIST_INITIALIZER typedef int (*line_mangle_t)(tchar *line, const tchar *filename, unsigned long line_no); struct text_file_section { const tchar *name; - struct string_set *strings; + struct string_list *strings; }; #define LOAD_TEXT_FILE_REMOVE_QUOTES 0x00000001 diff --git a/programs/imagex.c b/programs/imagex.c index 7a57a86f..8a0b48df 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -586,68 +586,68 @@ set_compact_mode(const tchar *arg, int *extract_flags) } -struct string_set { +struct string_list { tchar **strings; unsigned num_strings; unsigned num_alloc_strings; }; -#define STRING_SET_INITIALIZER \ +#define STRING_LIST_INITIALIZER \ { .strings = NULL, .num_strings = 0, .num_alloc_strings = 0, } -#define STRING_SET(_strings) \ - struct string_set _strings = STRING_SET_INITIALIZER +#define STRING_LIST(_strings) \ + struct string_list _strings = STRING_LIST_INITIALIZER static int -string_set_append(struct string_set *set, tchar *glob) +string_list_append(struct string_list *list, tchar *glob) { - unsigned num_alloc_strings = set->num_alloc_strings; + unsigned num_alloc_strings = list->num_alloc_strings; - if (set->num_strings == num_alloc_strings) { + if (list->num_strings == num_alloc_strings) { tchar **new_strings; num_alloc_strings += 4; - new_strings = realloc(set->strings, - sizeof(set->strings[0]) * num_alloc_strings); + new_strings = realloc(list->strings, + sizeof(list->strings[0]) * num_alloc_strings); if (!new_strings) { imagex_error(T("Out of memory!")); return -1; } - set->strings = new_strings; - set->num_alloc_strings = num_alloc_strings; + list->strings = new_strings; + list->num_alloc_strings = num_alloc_strings; } - set->strings[set->num_strings++] = glob; + list->strings[list->num_strings++] = glob; return 0; } static void -string_set_destroy(struct string_set *set) +string_list_destroy(struct string_list *list) { - free(set->strings); + free(list->strings); } static int -wim_reference_globs(WIMStruct *wim, struct string_set *set, int open_flags) +wim_reference_globs(WIMStruct *wim, struct string_list *list, int open_flags) { - return wimlib_reference_resource_files(wim, (const tchar **)set->strings, - set->num_strings, + return wimlib_reference_resource_files(wim, (const tchar **)list->strings, + list->num_strings, WIMLIB_REF_FLAG_GLOB_ENABLE, open_flags); } static int -append_image_property_argument(struct string_set *image_properties) +append_image_property_argument(struct string_list *image_properties) { if (!tstrchr(optarg, '=')) { imagex_error(T("'--image-property' argument " "must be in the form NAME=VALUE")); return -1; } - return string_set_append(image_properties, optarg); + return string_list_append(image_properties, optarg); } static int -apply_image_properties(struct string_set *image_properties, +apply_image_properties(struct string_list *image_properties, WIMStruct *wim, int image, bool *any_changes_ret) { bool any_changes = false; @@ -683,7 +683,7 @@ apply_image_properties(struct string_set *image_properties, static void do_resource_not_found_warning(const tchar *wimfile, const struct wimlib_wim_info *info, - const struct string_set *refglobs) + const struct string_list *refglobs) { if (info->total_parts > 1) { if (refglobs->num_strings == 0) { @@ -1654,7 +1654,7 @@ imagex_apply(int argc, tchar **argv, int cmd) const tchar *image_num_or_name = NULL; int extract_flags = 0; - STRING_SET(refglobs); + STRING_LIST(refglobs); for_opt(c, apply_options) { switch (c) { @@ -1665,7 +1665,7 @@ imagex_apply(int argc, tchar **argv, int cmd) /* No longer does anything. */ break; case IMAGEX_REF_OPTION: - ret = string_set_append(&refglobs, optarg); + ret = string_list_append(&refglobs, optarg); if (ret) goto out_free_refglobs; break; @@ -1812,7 +1812,7 @@ imagex_apply(int argc, tchar **argv, int cmd) out_wimlib_free: wimlib_free(wim); out_free_refglobs: - string_set_destroy(&refglobs); + string_list_destroy(&refglobs); return ret; out_usage: @@ -1842,10 +1842,10 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) const tchar *wimfile; int wim_fd; const tchar *name; - STRING_SET(image_properties); + STRING_LIST(image_properties); WIMStruct *wim; - STRING_SET(base_wimfiles); + STRING_LIST(base_wimfiles); WIMStruct **base_wims; WIMStruct *template_wim; @@ -1914,7 +1914,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) case IMAGEX_FLAGS_OPTION: { tchar *p = alloca((6 + tstrlen(optarg) + 1) * sizeof(tchar)); tsprintf(p, T("FLAGS=%"TS), optarg); - ret = string_set_append(&image_properties, p); + ret = string_list_append(&image_properties, p); if (ret) goto out; break; @@ -1987,7 +1987,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) "valid for capture!")); goto out_usage; } - ret = string_set_append(&base_wimfiles, optarg); + ret = string_list_append(&base_wimfiles, optarg); if (ret) goto out; write_flags |= WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS; @@ -2111,7 +2111,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) if (argc >= 4) { tchar *p = alloca((12 + tstrlen(argv[3]) + 1) * sizeof(tchar)); tsprintf(p, T("DESCRIPTION=%"TS), argv[3]); - ret = string_set_append(&image_properties, p); + ret = string_list_append(&image_properties, p); if (ret) goto out; } @@ -2379,8 +2379,8 @@ out_free_capture_sources: out_free_source_list_contents: free(source_list_contents); out: - string_set_destroy(&image_properties); - string_set_destroy(&base_wimfiles); + string_list_destroy(&image_properties); + string_list_destroy(&base_wimfiles); return ret; out_usage: @@ -2741,7 +2741,7 @@ imagex_dir(int argc, tchar **argv, int cmd) }; int iterate_flags = WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE; - STRING_SET(refglobs); + STRING_LIST(refglobs); for_opt(c, dir_options) { switch (c) { @@ -2755,7 +2755,7 @@ imagex_dir(int argc, tchar **argv, int cmd) iterate_flags &= ~WIMLIB_ITERATE_DIR_TREE_FLAG_RECURSIVE; break; case IMAGEX_REF_OPTION: - ret = string_set_append(&refglobs, optarg); + ret = string_list_append(&refglobs, optarg); if (ret) goto out_free_refglobs; break; @@ -2820,7 +2820,7 @@ imagex_dir(int argc, tchar **argv, int cmd) out_wimlib_free: wimlib_free(wim); out_free_refglobs: - string_set_destroy(&refglobs); + string_list_destroy(&refglobs); return ret; out_usage: @@ -2852,7 +2852,7 @@ imagex_export(int argc, tchar **argv, int cmd) int image; struct stat stbuf; bool wim_is_new; - STRING_SET(refglobs); + STRING_LIST(refglobs); unsigned num_threads = 0; uint32_t chunk_size = UINT32_MAX; uint32_t solid_chunk_size = UINT32_MAX; @@ -2900,7 +2900,7 @@ imagex_export(int argc, tchar **argv, int cmd) goto out_err; break; case IMAGEX_REF_OPTION: - ret = string_set_append(&refglobs, optarg); + ret = string_list_append(&refglobs, optarg); if (ret) goto out_free_refglobs; break; @@ -3117,7 +3117,7 @@ out_free_dest_wim: out_free_src_wim: wimlib_free(src_wim); out_free_refglobs: - string_set_destroy(&refglobs); + string_list_destroy(&refglobs); return ret; out_usage: @@ -3144,7 +3144,7 @@ imagex_extract(int argc, tchar **argv, int cmd) WIMLIB_EXTRACT_FLAG_STRICT_GLOB; int notlist_extract_flags = WIMLIB_EXTRACT_FLAG_NO_PRESERVE_DIR_STRUCTURE; - STRING_SET(refglobs); + STRING_LIST(refglobs); tchar *root_path = WIMLIB_WIM_ROOT_PATH; @@ -3157,7 +3157,7 @@ imagex_extract(int argc, tchar **argv, int cmd) /* No longer does anything. */ break; case IMAGEX_REF_OPTION: - ret = string_set_append(&refglobs, optarg); + ret = string_list_append(&refglobs, optarg); if (ret) goto out_free_refglobs; break; @@ -3305,7 +3305,7 @@ imagex_extract(int argc, tchar **argv, int cmd) out_wimlib_free: wimlib_free(wim); out_free_refglobs: - string_set_destroy(&refglobs); + string_list_destroy(&refglobs); return ret; out_usage: @@ -3331,7 +3331,7 @@ imagex_info(int argc, tchar **argv, int cmd) const tchar *xml_out_file = NULL; const tchar *wimfile; const tchar *image_num_or_name; - STRING_SET(image_properties); + STRING_LIST(image_properties); WIMStruct *wim; int image; int ret; @@ -3387,7 +3387,7 @@ imagex_info(int argc, tchar **argv, int cmd) /* NEW_NAME */ tchar *p = alloca((5 + tstrlen(argv[2]) + 1) * sizeof(tchar)); tsprintf(p, T("NAME=%"TS), argv[2]); - ret = string_set_append(&image_properties, p); + ret = string_list_append(&image_properties, p); if (ret) goto out; } @@ -3396,7 +3396,7 @@ imagex_info(int argc, tchar **argv, int cmd) /* NEW_DESC */ tchar *p = alloca((12 + tstrlen(argv[3]) + 1) * sizeof(tchar)); tsprintf(p, T("DESCRIPTION=%"TS), argv[3]); - ret = string_set_append(&image_properties, p); + ret = string_list_append(&image_properties, p); if (ret) goto out; } @@ -3566,7 +3566,7 @@ imagex_info(int argc, tchar **argv, int cmd) out_wimlib_free: wimlib_free(wim); out: - string_set_destroy(&image_properties); + string_list_destroy(&image_properties); return ret; out_usage: @@ -3638,7 +3638,7 @@ imagex_mount_rw_or_ro(int argc, tchar **argv, int cmd) int image; int ret; - STRING_SET(refglobs); + STRING_LIST(refglobs); if (cmd == CMD_MOUNTRW) { mount_flags |= WIMLIB_MOUNT_FLAG_READWRITE; @@ -3670,7 +3670,7 @@ imagex_mount_rw_or_ro(int argc, tchar **argv, int cmd) } break; case IMAGEX_REF_OPTION: - ret = string_set_append(&refglobs, optarg); + ret = string_list_append(&refglobs, optarg); if (ret) goto out_free_refglobs; break; @@ -3738,7 +3738,7 @@ imagex_mount_rw_or_ro(int argc, tchar **argv, int cmd) out_free_wim: wimlib_free(wim); out_free_refglobs: - string_set_destroy(&refglobs); + string_list_destroy(&refglobs); return ret; out_usage: @@ -4257,13 +4257,13 @@ imagex_verify(int argc, tchar **argv, int cmd) WIMStruct *wim; int open_flags = WIMLIB_OPEN_FLAG_CHECK_INTEGRITY; int verify_flags = 0; - STRING_SET(refglobs); + STRING_LIST(refglobs); int c; for_opt(c, verify_options) { switch (c) { case IMAGEX_REF_OPTION: - ret = string_set_append(&refglobs, optarg); + ret = string_list_append(&refglobs, optarg); if (ret) goto out_free_refglobs; break; @@ -4319,7 +4319,7 @@ imagex_verify(int argc, tchar **argv, int cmd) out_wimlib_free: wimlib_free(wim); out_free_refglobs: - string_set_destroy(&refglobs); + string_list_destroy(&refglobs); return ret; out_usage: diff --git a/src/pathlist.c b/src/pathlist.c index b0bd820b..9ce3929e 100644 --- a/src/pathlist.c +++ b/src/pathlist.c @@ -33,7 +33,7 @@ read_path_list_file(const tchar *listfile, tchar ***paths_ret, size_t *num_paths_ret, void **mem_ret) { - STRING_SET(paths); + STRING_LIST(paths); struct text_file_section tmp = { .name = T(""), .strings = &paths, diff --git a/src/scan.c b/src/scan.c index 96abe715..be651439 100644 --- a/src/scan.c +++ b/src/scan.c @@ -195,9 +195,9 @@ read_capture_config(const tchar *config_file, const void *buf, * [CompressionFolderList]. This is a known issue that doesn't seem to * have any real consequences, so don't issue warnings about not * recognizing those sections. */ - STRING_SET(prepopulate_pats); - STRING_SET(compression_exclusion_pats); - STRING_SET(compression_folder_pats); + STRING_LIST(prepopulate_pats); + STRING_LIST(compression_exclusion_pats); + STRING_LIST(compression_folder_pats); struct text_file_section sections[] = { {T("ExclusionList"), @@ -257,7 +257,7 @@ destroy_capture_config(struct capture_config *config) * the patterns in @list. Path separators in @path must be WIM_PATH_SEPARATOR. */ bool -match_pattern_list(const tchar *path, const struct string_set *list) +match_pattern_list(const tchar *path, const struct string_list *list) { for (size_t i = 0; i < list->num_strings; i++) if (match_path(path, list->strings[i], true)) diff --git a/src/textfile.c b/src/textfile.c index 9bd9b6a7..114772cf 100644 --- a/src/textfile.c +++ b/src/textfile.c @@ -141,23 +141,23 @@ translate_text_buffer(const u8 *buf_raw, size_t bufsize_raw, } static int -string_set_append(struct string_set *set, tchar *str) +string_list_append(struct string_list *list, tchar *str) { - size_t num_alloc_strings = set->num_alloc_strings; + size_t num_alloc_strings = list->num_alloc_strings; - if (set->num_strings == num_alloc_strings) { + if (list->num_strings == num_alloc_strings) { tchar **new_strings; num_alloc_strings = max(num_alloc_strings * 3 / 2, num_alloc_strings + 4); - new_strings = REALLOC(set->strings, - sizeof(set->strings[0]) * num_alloc_strings); + new_strings = REALLOC(list->strings, + sizeof(list->strings[0]) * num_alloc_strings); if (!new_strings) return WIMLIB_ERR_NOMEM; - set->strings = new_strings; - set->num_alloc_strings = num_alloc_strings; + list->strings = new_strings; + list->num_alloc_strings = num_alloc_strings; } - set->strings[set->num_strings++] = str; + list->strings[list->num_strings++] = str; return 0; } @@ -264,8 +264,8 @@ parse_text_file(const tchar *path, tchar *buf, size_t buflen, return ret; } - ret = string_set_append(pos_sections[current_section].strings, - line_begin); + ret = string_list_append(pos_sections[current_section].strings, + line_begin); if (ret) return ret; } @@ -293,8 +293,7 @@ parse_text_file(const tchar *path, tchar *buf, size_t buflen, * consists of the name of the section (e.g. [ExclusionList], like in the * INI file format), along with a pointer to the list of lines parsed for * that section. Use an empty name to indicate the destination of lines - * not in any section. Each list must be initialized to an empty string - * set. + * not in any section. Each list must be initialized to empty. * @num_pos_sections * Number of entries in the @pos_sections array. * @flags diff --git a/src/win32_apply.c b/src/win32_apply.c index b7d506b3..ef5b9014 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -69,7 +69,7 @@ struct win32_apply_ctx { } wimboot; /* External backing information */ - struct string_set *prepopulate_pats; + struct string_list *prepopulate_pats; void *mem_prepopulate_pats; bool tried_to_load_prepopulate_list; @@ -338,7 +338,7 @@ load_prepopulate_pats(struct win32_apply_ctx *ctx) const struct blob_descriptor *blob; int ret; void *buf; - struct string_set *s; + struct string_list *strings; void *mem; struct text_file_section sec; @@ -366,14 +366,14 @@ load_prepopulate_pats(struct win32_apply_ctx *ctx) if (ret) return ret; - s = CALLOC(1, sizeof(struct string_set)); - if (!s) { + strings = CALLOC(1, sizeof(struct string_list)); + if (!strings) { FREE(buf); return WIMLIB_ERR_NOMEM; } sec.name = T("PrepopulateList"); - sec.strings = s; + sec.strings = strings; ret = do_load_text_file(path, buf, blob->size, &mem, &sec, 1, LOAD_TEXT_FILE_REMOVE_QUOTES | @@ -382,10 +382,10 @@ load_prepopulate_pats(struct win32_apply_ctx *ctx) STATIC_ASSERT(OS_PREFERRED_PATH_SEPARATOR == WIM_PATH_SEPARATOR); FREE(buf); if (ret) { - FREE(s); + FREE(strings); return ret; } - ctx->prepopulate_pats = s; + ctx->prepopulate_pats = strings; ctx->mem_prepopulate_pats = mem; return 0; } @@ -2436,7 +2436,7 @@ static wchar_t *bootloader_pattern_strings[] = { L"\\Windows\\System32\\CodeIntegrity\\driver.stl", }; -static const struct string_set bootloader_patterns = { +static const struct string_list bootloader_patterns = { .strings = bootloader_pattern_strings, .num_strings = ARRAY_LEN(bootloader_pattern_strings), };