diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fs.c | 13 | ||||
-rw-r--r-- | src/mime.c | 4 | ||||
-rw-r--r-- | src/mirrors.c | 2 | ||||
-rw-r--r-- | src/relocation.c | 2 | ||||
-rw-r--r-- | src/shlib.c | 2 | ||||
-rw-r--r-- | src/spm.c | 4 |
6 files changed, 17 insertions, 10 deletions
@@ -56,10 +56,10 @@ FSTree *fstree(const char *_path, char **filter_by, unsigned int filter_mode) { if (filter_mode & SPM_FSTREE_FLT_CONTAINS && strstr(node->fts_path, filter_by[i]) == NULL) { continue; } - else if (filter_mode & SPM_FSTREE_FLT_ENDSWITH && endswith(node->fts_path, filter_by[i]) != 0) { + else if (filter_mode & SPM_FSTREE_FLT_ENDSWITH && !endswith(node->fts_path, filter_by[i])) { continue; } - else if (filter_mode & SPM_FSTREE_FLT_STARTSWITH && startswith(node->fts_path, filter_by[i]) != 0) { + else if (filter_mode & SPM_FSTREE_FLT_STARTSWITH && !startswith(node->fts_path, filter_by[i])) { continue; } switch (node->fts_info) { @@ -475,13 +475,20 @@ char *human_readable_size(uint64_t n) { * @param name * @return success=path, failure=NULL */ -char *spm_mkdtemp(const char *name) { +char *spm_mkdtemp(const char *name, const char *extended_path) { const char *template_unique = "XXXXXX"; char *tmpdir = NULL; char *template = calloc(PATH_MAX, sizeof(char)); sprintf(template, "%s%s%s_%s", TMP_DIR, DIRSEPS, name, template_unique); tmpdir = mkdtemp(template); + if (extended_path != NULL) { + char extended[PATH_MAX] = {0,}; + strncpy(extended, tmpdir, PATH_MAX - 1); + strcat(extended, DIRSEPS); + strcat(extended, extended_path); + mkdirs(extended, 0755); + } return tmpdir; } @@ -103,7 +103,7 @@ int file_is_text(const char *filename) { int result = 0; char *path = normpath(filename); Mime *type = file_mimetype(path); - if (startswith(type->type, "text/") == 0) { + if (startswith(type->type, "text/")) { result = 1; } free(path); @@ -120,7 +120,7 @@ int file_is_binary(const char *filename) { int result = 0; char *path = normpath(filename); Mime *type = file_mimetype(path); - if (startswith(type->type, "application/") == 0 && strcmp(type->charset, "binary") == 0) { + if (startswith(type->type, "application/") && strcmp(type->charset, "binary") == 0) { result = 1; } free(path); diff --git a/src/mirrors.c b/src/mirrors.c index 6a67623..a4a17c2 100644 --- a/src/mirrors.c +++ b/src/mirrors.c @@ -93,7 +93,7 @@ char **mirror_list(const char *filename) { result = calloc(count + 1, sizeof(char **)); for (size_t i = 0; mirrors[i] != NULL; i++) { - if (startswith(mirrors[i], "#") == 0 || isempty(mirrors[i])) { + if (startswith(mirrors[i], "#") || isempty(mirrors[i])) { continue; } result[i] = join((char *[]) {mirrors[i], SPM_GLOBAL.repo_target, NULL}, DIRSEPS); diff --git a/src/relocation.c b/src/relocation.c index 1c5b1cf..2ef72eb 100644 --- a/src/relocation.c +++ b/src/relocation.c @@ -184,7 +184,7 @@ RelocationEntry **prefixes_read(const char *filename) { if (isempty(lptr)) { continue; } - if (startswith(lptr, "#") == 0) { + if (startswith(lptr, "#")) { do_prefix = 1; } else { diff --git a/src/shlib.c b/src/shlib.c index 1a427f6..db79cc3 100644 --- a/src/shlib.c +++ b/src/shlib.c @@ -59,7 +59,7 @@ StrList *shlib_deps(const char *filename) { // AFAIK when "NEEDED" is present, a string containing the library name is guaranteed to be there for (size_t i = 0; data[i] != NULL; i++) { data[i] = normalize_space(data[i]); - if (startswith(data[i], "NEEDED") == 0) { + if (startswith(data[i], "NEEDED")) { char **field = split(data[i], " "); strlist_append(result, field[1]); split_free(field); @@ -137,7 +137,7 @@ int main(int argc, char *argv[], char *arge[]) { for (int p = 0; i < argc; p++) { i++; char *next = argv[i]; - if (next == NULL || (startswith(next, "-") == 0 || startswith(next, "--") == 0)) { + if (next == NULL || (startswith(next, "-") || startswith(next, "--"))) { i--; break; } @@ -154,7 +154,7 @@ int main(int argc, char *argv[], char *arge[]) { for (int p = 0; i < argc; p++) { i++; char *next = argv[i]; - if (next == NULL || (startswith(next, "-") == 0 || startswith(next, "--") == 0)) { + if (next == NULL || (startswith(next, "-") || startswith(next, "--"))) { i--; break; } |