index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | src/pacman/callback.c | 15 | ||||
-rw-r--r-- | src/pacman/package.c | 2 | ||||
-rw-r--r-- | src/pacman/pacman.c | 17 | ||||
-rw-r--r-- | src/pacman/query.c | 6 | ||||
-rw-r--r-- | src/pacman/sync.c | 8 | ||||
-rw-r--r-- | src/pacman/upgrade.c | 2 | ||||
-rw-r--r-- | src/pacman/util.c | 11 | ||||
-rw-r--r-- | src/pacman/util.h | 2 | ||||
-rw-r--r-- | src/util/testdb.c | 2 |
diff --git a/src/pacman/callback.c b/src/pacman/callback.c index f5bf17d1..3696d3cd 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -262,7 +262,7 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2, case PM_TRANS_CONV_CONFLICT_PKG: /* data parameters: target package, local package, conflict (strings) */ /* print conflict only if it contains new information */ - if(!strcmp(data1, data3) || !strcmp(data2, data3)) { + if(strcmp(data1, data3) == 0 || strcmp(data2, data3) == 0) { *response = noyes(_(":: %s and %s are in conflict. Remove %s?"), (char *)data1, (char *)data2, @@ -283,11 +283,16 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2, namelist = alpm_list_add(namelist, (char *)alpm_pkg_get_name(i->data)); } - printf(_(":: the following package(s) cannot be upgraded due to " - "unresolvable dependencies:\n")); + printf(_n( + ":: The following package cannot be upgraded due to unresolvable dependencies:\n", + ":: The following packages cannot be upgraded due to unresolvable dependencies:\n", + alpm_list_count(namelist))); list_display(" ", namelist); - *response = noyes(_("\nDo you want to skip the above " - "package(s) for this upgrade?")); + printf("\n"); + *response = noyes(_n( + "Do you want to skip the above package for this upgrade?", + "Do you want to skip the above packages for this upgrade?", + alpm_list_count(namelist))); alpm_list_free(namelist); } break; diff --git a/src/pacman/package.c b/src/pacman/package.c index 413754c7..ac84a0c7 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -189,7 +189,7 @@ void dump_pkg_backups(pmpkg_t *pkg) } /* if checksums don't match, file has been modified */ - if (strcmp(md5sum, ptr)) { + if (strcmp(md5sum, ptr) != 0) { printf(_("MODIFIED\t%s\n"), path); } else { printf(_("Not Modified\t%s\n"), path); diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 78407d67..049bc40b 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -676,6 +676,7 @@ int download_with_xfercommand(const char *url, const char *localpath, struct stat st; char *parsedcmd,*tempcmd; char cwd[PATH_MAX]; + int restore_cwd = 0; char *destfile, *tempfile, *filename; if(!config->xfercommand) { @@ -708,8 +709,14 @@ int download_with_xfercommand(const char *url, const char *localpath, parsedcmd = strreplace(tempcmd, "%u", url); free(tempcmd); + /* save the cwd so we can restore it later */ + if(getcwd(cwd, PATH_MAX) == NULL) { + pm_printf(PM_LOG_ERROR, _("could not get current working directory\n")); + } else { + restore_cwd = 1; + } + /* cwd to the download directory */ - getcwd(cwd, PATH_MAX); if(chdir(localpath)) { pm_printf(PM_LOG_WARNING, _("could not chdir to download directory %s\n"), localpath); ret = -1; @@ -736,7 +743,11 @@ int download_with_xfercommand(const char *url, const char *localpath, } cleanup: - chdir(cwd); + /* restore the old cwd if we have it */ + if(restore_cwd && chdir(cwd) != 0) { + pm_printf(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno)); + } + if(ret == -1) { /* hack to let an user the time to cancel a download */ sleep(2); @@ -989,7 +1000,7 @@ static int _parseconfig(const char *file, const char *givensection, file, linenum, value); break; default: - for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) { + for(size_t gindex = 0; gindex < globbuf.gl_pathc; gindex++) { pm_printf(PM_LOG_DEBUG, "config file %s, line %d: including %s\n", file, linenum, globbuf.gl_pathv[gindex]); _parseconfig(globbuf.gl_pathv[gindex], section, db); diff --git a/src/pacman/query.c b/src/pacman/query.c index 7f064f23..5538e811 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -406,8 +406,10 @@ static int check(pmpkg_t *pkg) } if(!config->quiet) { - printf(_("%s: %d total files, %d missing file(s)\n"), - pkgname, allfiles, errors); + printf(_n("%s: %d total file, ", "%s: %d total files, ", allfiles), + pkgname, allfiles); + printf(_n("%d missing file\n", "%d missing files\n", errors), + errors); } return(errors != 0 ? 1 : 0); diff --git a/src/pacman/sync.c b/src/pacman/sync.c index b2994389..b9497d65 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -60,11 +60,11 @@ static int sync_cleandb(const char *dbpath, int keep_used) { int found = 0; const char *dname = ent->d_name; - if(!strcmp(dname, ".") || !strcmp(dname, "..")) { + if(strcmp(dname, ".") == 0 || strcmp(dname, "..") == 0) { continue; } /* skip the local and sync directories */ - if(!strcmp(dname, "sync") || !strcmp(dname, "local")) { + if(strcmp(dname, "sync") == 0 || strcmp(dname, "local") == 0) { continue; } @@ -178,7 +178,7 @@ static int sync_cleancache(int level) pmpkg_t *localpkg = NULL, *pkg = NULL; alpm_list_t *j; - if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) { + if(strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { continue; } /* build the full filepath */ @@ -666,7 +666,7 @@ static int sync_trans(alpm_list_t *targets) const char *package2 = alpm_conflict_get_package2(conflict); const char *reason = alpm_conflict_get_reason(conflict); /* only print reason if it contains new information */ - if(!strcmp(package1, reason) || !strcmp(package2, reason)) { + if(strcmp(package1, reason) == 0 || strcmp(package2, reason) == 0) { printf(_(":: %s and %s are in conflict\n"), package1, package2); } else { printf(_(":: %s and %s are in conflict (%s)\n"), package1, package2, reason); diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 1442eb56..c9c8301f 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -112,7 +112,7 @@ int pacman_upgrade(alpm_list_t *targets) const char *package2 = alpm_conflict_get_package2(conflict); const char *reason = alpm_conflict_get_reason(conflict); /* only print reason if it contains new information */ - if(!strcmp(package1, reason) || !strcmp(package2, reason)) { + if(strcmp(package1, reason) == 0 || strcmp(package2, reason) == 0) { printf(_(":: %s and %s are in conflict\n"), package1, package2); } else { printf(_(":: %s and %s are in conflict (%s)\n"), package1, package2, reason); diff --git a/src/pacman/util.c b/src/pacman/util.c index 557696b0..b0824cfb 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -143,7 +143,7 @@ int rmrf(const char *path) if(dp->d_ino) { char name[PATH_MAX]; sprintf(name, "%s/%s", path, dp->d_name); - if(strcmp(dp->d_name, "..") && strcmp(dp->d_name, ".")) { + if(strcmp(dp->d_name, "..") != 0 && strcmp(dp->d_name, ".") != 0) { errflag += rmrf(name); } } @@ -690,7 +690,6 @@ void display_optdepends(pmpkg_t *pkg) static int question(short preset, char *fmt, va_list args) { char response[32]; - int sresponse = sizeof(response)-1; FILE *stream; if(config->noconfirm) { @@ -713,15 +712,15 @@ static int question(short preset, char *fmt, va_list args) return(preset); } - if(fgets(response, sresponse, stdin)) { + if(fgets(response, sizeof(response), stdin)) { strtrim(response); if(strlen(response) == 0) { return(preset); } - if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES"))) { + if(strcasecmp(response, _("Y")) == 0 || strcasecmp(response, _("YES")) == 0) { return(1); - } else if (!strcasecmp(response, _("N")) || !strcasecmp(response, _("NO"))) { + } else if (strcasecmp(response, _("N")) == 0 || strcasecmp(response, _("NO")) == 0) { return(0); } } @@ -824,7 +823,7 @@ int pm_vfprintf(FILE *stream, pmloglevel_t level, const char *format, va_list ar #if defined(PACMAN_DEBUG) /* If debug is on, we'll timestamp the output */ - if(config->logmask & PM_LOG_DEBUG) { + if(config->logmask & PM_LOG_DEBUG) { time_t t; struct tm *tmp; char timestr[10] = {0}; diff --git a/src/pacman/util.h b/src/pacman/util.h index bbf43827..d85ba7b6 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -30,8 +30,10 @@ #include <libintl.h> /* here so it doesn't need to be included elsewhere */ /* define _() as shortcut for gettext() */ #define _(str) gettext(str) +#define _n(str1, str2, ct) ngettext(str1, str2, ct) #else #define _(str) str +#define _n(str1, str2, ct) (ct == 1 ? str1 : str2) #endif /* update speed for the fill_progress based functions */ diff --git a/src/util/testdb.c b/src/util/testdb.c index 6d351ebd..45a2626d 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -69,7 +69,7 @@ static int db_test(char *dbpath, int local) } while ((ent = readdir(dir)) != NULL) { - if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..") + if(strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0 || ent->d_name[0] == '.') { continue; } |