Fix whitespace and other formatting issues

This commit:
-- replaces space-based indents with tabs per the coding standards
-- removes extraneous whitespace (e.g. extra spaces between function args)
-- adds missing braces for a one-line if statement

Signed-off-by: Jason St. John <jstjohn@purdue.edu>
This commit is contained in:
Jason St. John 2013-11-08 00:44:40 -05:00 committed by Allan McRae
parent b7b3f9c5e7
commit 230bd5c2fd
25 changed files with 116 additions and 115 deletions

View file

@ -298,8 +298,8 @@ pkgcount=${#candidates[*]}
# copy the list, merging in any found sigs # copy the list, merging in any found sigs
for cand in "${candidates[@]}"; do for cand in "${candidates[@]}"; do
candtemp+=("$cand") candtemp+=("$cand")
[[ -f $cand.sig ]] && candtemp+=("$cand.sig") [[ -f $cand.sig ]] && candtemp+=("$cand.sig")
done done
candidates=("${candtemp[@]}") candidates=("${candtemp[@]}")
unset candtemp unset candtemp

View file

@ -184,7 +184,7 @@ elif [[ $FILE ]]; then
fi fi
timesarray=() timesarray=()
for line in "${linearray[@]}"; do for line in "${linearray[@]}"; do
if [[ $line =~ ^[[:space:]]*# ]]; then if [[ $line =~ ^[[:space:]]*# ]]; then
[[ $TIMESONLY ]] || echo $line [[ $TIMESONLY ]] || echo $line
elif [[ $line =~ ^[[:space:]]*Server ]]; then elif [[ $line =~ ^[[:space:]]*Server ]]; then

View file

@ -671,7 +671,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
break; break;
} }
/* run the post-install script if it exists */ /* run the post-install script if it exists */
if(alpm_pkg_has_scriptlet(newpkg) if(alpm_pkg_has_scriptlet(newpkg)
&& !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) { && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
char *scriptlet = _alpm_local_db_pkgpath(db, newpkg, "install"); char *scriptlet = _alpm_local_db_pkgpath(db, newpkg, "install");

View file

@ -79,17 +79,17 @@ typedef enum _alpm_pkgvalidation_t {
/** Types of version constraints in dependency specs. */ /** Types of version constraints in dependency specs. */
typedef enum _alpm_depmod_t { typedef enum _alpm_depmod_t {
/** No version constraint */ /** No version constraint */
ALPM_DEP_MOD_ANY = 1, ALPM_DEP_MOD_ANY = 1,
/** Test version equality (package=x.y.z) */ /** Test version equality (package=x.y.z) */
ALPM_DEP_MOD_EQ, ALPM_DEP_MOD_EQ,
/** Test for at least a version (package>=x.y.z) */ /** Test for at least a version (package>=x.y.z) */
ALPM_DEP_MOD_GE, ALPM_DEP_MOD_GE,
/** Test for at most a version (package<=x.y.z) */ /** Test for at most a version (package<=x.y.z) */
ALPM_DEP_MOD_LE, ALPM_DEP_MOD_LE,
/** Test for greater than some version (package>x.y.z) */ /** Test for greater than some version (package>x.y.z) */
ALPM_DEP_MOD_GT, ALPM_DEP_MOD_GT,
/** Test for less than some version (package<x.y.z) */ /** Test for less than some version (package<x.y.z) */
ALPM_DEP_MOD_LT ALPM_DEP_MOD_LT
} alpm_depmod_t; } alpm_depmod_t;
@ -250,7 +250,7 @@ typedef struct _alpm_sigresult_t {
/** /**
* Signature list. Contains the number of signatures found and a pointer to an * Signature list. Contains the number of signatures found and a pointer to an
* array of results. The array is of size count. * array of results. The array is of size count.
*/ */
typedef struct _alpm_siglist_t { typedef struct _alpm_siglist_t {
size_t count; size_t count;

View file

@ -423,7 +423,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
} }
config = 1; config = 1;
continue; continue;
} else if(strcmp(entry_name, ".INSTALL") == 0) { } else if(strcmp(entry_name, ".INSTALL") == 0) {
newpkg->scriptlet = 1; newpkg->scriptlet = 1;
} else if(*entry_name == '.') { } else if(*entry_name == '.') {
/* for now, ignore all files starting with '.' that haven't /* for now, ignore all files starting with '.' that haven't

View file

@ -381,8 +381,8 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_handle_t *handle,
/* 1. check upgrade list for satisfiers */ /* 1. check upgrade list for satisfiers */
/* 2. check dblist for satisfiers */ /* 2. check dblist for satisfiers */
if(causingpkg && if(causingpkg &&
!find_dep_satisfier(upgrade, depend) && !find_dep_satisfier(upgrade, depend) &&
!find_dep_satisfier(dblist, depend)) { !find_dep_satisfier(dblist, depend)) {
alpm_depmissing_t *miss; alpm_depmissing_t *miss;
char *missdepstring = alpm_dep_compute_string(depend); char *missdepstring = alpm_dep_compute_string(depend);
_alpm_log(handle, ALPM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n", _alpm_log(handle, ALPM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n",

View file

@ -357,7 +357,7 @@ int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir,
size_t j; size_t j;
int error = 0; int error = 0;
/* resolve the cachedir path to ensure we check the right mountpoint. We /* resolve the cachedir path to ensure we check the right mountpoint. We
* handle failures silently, and continue to use the possibly unresolved * handle failures silently, and continue to use the possibly unresolved
* path. */ * path. */
if(realpath(cachedir, resolved_cachedir) != NULL) { if(realpath(cachedir, resolved_cachedir) != NULL) {

View file

@ -465,7 +465,7 @@ static int curl_download_internal(struct dload_payload *payload,
payload->curlerr); payload->curlerr);
/* disconnect relationships from the curl handle for things that might go out /* disconnect relationships from the curl handle for things that might go out
* of scope, but could still be touched on connection teardown. This really * of scope, but could still be touched on connection teardown. This really
* only applies to FTP transfers. */ * only applies to FTP transfers. */
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, (char *)NULL); curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, (char *)NULL);

View file

@ -97,7 +97,7 @@ alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
} else { } else {
/* TODO: this creates conflicts between a symlink to a directory in /* TODO: this creates conflicts between a symlink to a directory in
* one package and a real directory in the other. For example, * one package and a real directory in the other. For example,
* lib -> /usr/lib in pkg1 and /lib in pkg2. This would be allowed * lib -> /usr/lib in pkg1 and /lib in pkg2. This would be allowed
* when installing one package at a time _provided_ pkg1 is installed * when installing one package at a time _provided_ pkg1 is installed
* first. This will need adjusted if the order of package install can * first. This will need adjusted if the order of package install can
* be guaranteed to install the symlink first */ * be guaranteed to install the symlink first */

View file

@ -52,7 +52,7 @@ do { \
struct __alpm_handle_t { struct __alpm_handle_t {
/* internal usage */ /* internal usage */
alpm_db_t *db_local; /* local db pointer */ alpm_db_t *db_local; /* local db pointer */
alpm_list_t *dbs_sync; /* List of (alpm_db_t *) */ alpm_list_t *dbs_sync; /* List of (alpm_db_t *) */
FILE *logstream; /* log file stream pointer */ FILE *logstream; /* log file stream pointer */
int lockfd; /* lock file descriptor */ int lockfd; /* lock file descriptor */
@ -64,10 +64,10 @@ struct __alpm_handle_t {
#endif #endif
/* callback functions */ /* callback functions */
alpm_cb_log logcb; /* Log callback function */ alpm_cb_log logcb; /* Log callback function */
alpm_cb_download dlcb; /* Download callback function */ alpm_cb_download dlcb; /* Download callback function */
alpm_cb_totaldl totaldlcb; /* Total download callback function */ alpm_cb_totaldl totaldlcb; /* Total download callback function */
alpm_cb_fetch fetchcb; /* Download file callback function */ alpm_cb_fetch fetchcb; /* Download file callback function */
alpm_cb_event eventcb; alpm_cb_event eventcb;
alpm_cb_question questioncb; alpm_cb_question questioncb;
alpm_cb_progress progresscb; alpm_cb_progress progresscb;

View file

@ -672,7 +672,7 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, "removing package %s-%s\n", _alpm_log(handle, ALPM_LOG_DEBUG, "removing package %s-%s\n",
pkgname, pkgver); pkgname, pkgver);
/* run the pre-remove scriptlet if it exists */ /* run the pre-remove scriptlet if it exists */
if(alpm_pkg_has_scriptlet(oldpkg) && if(alpm_pkg_has_scriptlet(oldpkg) &&
!(handle->trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) { !(handle->trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
char *scriptlet = _alpm_local_db_pkgpath(handle->db_local, char *scriptlet = _alpm_local_db_pkgpath(handle->db_local,
@ -692,7 +692,7 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
oldpkg->name, oldpkg->version); oldpkg->name, oldpkg->version);
} }
/* run the post-remove script if it exists */ /* run the post-remove script if it exists */
if(!newpkg && alpm_pkg_has_scriptlet(oldpkg) && if(!newpkg && alpm_pkg_has_scriptlet(oldpkg) &&
!(handle->trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) { !(handle->trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
char *scriptlet = _alpm_local_db_pkgpath(handle->db_local, char *scriptlet = _alpm_local_db_pkgpath(handle->db_local,

View file

@ -85,27 +85,27 @@ static alpm_list_t *list_sigsum(gpgme_sigsum_t sigsum)
/* The docs say this can be a bitmask...not sure I believe it, but we'll code /* The docs say this can be a bitmask...not sure I believe it, but we'll code
* for it anyway and show all possible flags in the returned string. */ * for it anyway and show all possible flags in the returned string. */
/* The signature is fully valid. */ /* The signature is fully valid. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_VALID, "valid"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_VALID, "valid");
/* The signature is good. */ /* The signature is good. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_GREEN, "green"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_GREEN, "green");
/* The signature is bad. */ /* The signature is bad. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_RED, "red"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_RED, "red");
/* One key has been revoked. */ /* One key has been revoked. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_KEY_REVOKED, "key revoked"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_KEY_REVOKED, "key revoked");
/* One key has expired. */ /* One key has expired. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_KEY_EXPIRED, "key expired"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_KEY_EXPIRED, "key expired");
/* The signature has expired. */ /* The signature has expired. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_SIG_EXPIRED, "sig expired"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_SIG_EXPIRED, "sig expired");
/* Can't verify: key missing. */ /* Can't verify: key missing. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_KEY_MISSING, "key missing"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_KEY_MISSING, "key missing");
/* CRL not available. */ /* CRL not available. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_CRL_MISSING, "crl missing"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_CRL_MISSING, "crl missing");
/* Available CRL is too old. */ /* Available CRL is too old. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_CRL_TOO_OLD, "crl too old"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_CRL_TOO_OLD, "crl too old");
/* A policy was not met. */ /* A policy was not met. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_BAD_POLICY, "bad policy"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_BAD_POLICY, "bad policy");
/* A system error occurred. */ /* A system error occurred. */
sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_SYS_ERROR, "sys error"); sigsum_test_bit(sigsum, &summary, GPGME_SIGSUM_SYS_ERROR, "sys error");
/* Fallback case */ /* Fallback case */
if(!sigsum) { if(!sigsum) {
@ -679,7 +679,7 @@ error:
return ret; return ret;
} }
#else /* HAVE_LIBGPGME */ #else /* HAVE_LIBGPGME */
int _alpm_key_in_keychain(alpm_handle_t UNUSED *handle, const char UNUSED *fpr) int _alpm_key_in_keychain(alpm_handle_t UNUSED *handle, const char UNUSED *fpr)
{ {
return -1; return -1;

View file

@ -289,7 +289,7 @@ int _alpm_runscriptlet(alpm_handle_t *handle, const char *filepath,
if(!is_archive && !grep(filepath, script)) { if(!is_archive && !grep(filepath, script)) {
/* script not found in scriptlet file; we can only short-circuit this early /* script not found in scriptlet file; we can only short-circuit this early
* if it is an actual scriptlet file and not an archive. */ * if it is an actual scriptlet file and not an archive. */
return 0; return 0;
} }

View file

@ -142,7 +142,7 @@ done:
/** Copies a file. /** Copies a file.
* @param src file path to copy from * @param src file path to copy from
* @param dest file path to copy to * @param dest file path to copy to
* @return 0 on success, 1 on error * @return 0 on success, 1 on error
*/ */
int _alpm_copyfile(const char *src, const char *dest) int _alpm_copyfile(const char *src, const char *dest)
{ {
@ -920,7 +920,7 @@ char SYMEXPORT *alpm_compute_sha256sum(const char *filename)
return hex_representation(output, 32); return hex_representation(output, 32);
} }
/** Calculates a file's MD5 or SHA2 digest and compares it to an expected value. /** Calculates a file's MD5 or SHA-2 digest and compares it to an expected value.
* @param filepath path of the file to check * @param filepath path of the file to check
* @param expected hash value to compare against * @param expected hash value to compare against
* @param type digest type to use * @param type digest type to use
@ -958,7 +958,7 @@ int _alpm_test_checksum(const char *filepath, const char *expected,
* Does not handle sparse files on purpose for speed. * Does not handle sparse files on purpose for speed.
* @param a * @param a
* @param b * @param b
* @return * @return
*/ */
int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b) int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b)
{ {

View file

@ -1336,8 +1336,8 @@ extract_sources() {
for netfile in "${source[@]}"; do for netfile in "${source[@]}"; do
local file=$(get_filename "$netfile") local file=$(get_filename "$netfile")
if in_array "$file" "${noextract[@]}"; then if in_array "$file" "${noextract[@]}"; then
#skip source files in the noextract=() array # skip source files in the noextract=() array
# these are marked explicitly to NOT be extracted # these are marked explicitly to NOT be extracted
continue continue
fi fi
local proto=$(get_protocol "$netfile") local proto=$(get_protocol "$netfile")
@ -2488,7 +2488,7 @@ usage() {
printf -- "$(gettext "Options:")\n" printf -- "$(gettext "Options:")\n"
printf -- "$(gettext " -A, --ignorearch Ignore incomplete %s field in %s")\n" "arch" "$BUILDSCRIPT" printf -- "$(gettext " -A, --ignorearch Ignore incomplete %s field in %s")\n" "arch" "$BUILDSCRIPT"
printf -- "$(gettext " -c, --clean Clean up work files after build")\n" printf -- "$(gettext " -c, --clean Clean up work files after build")\n"
printf -- "$(gettext " -C, --cleanbuild Remove %s dir before building the package")\n" "\$srcdir/" printf -- "$(gettext " -C, --cleanbuild Remove %s dir before building the package")\n" "\$srcdir/"
printf -- "$(gettext " -d, --nodeps Skip all dependency checks")\n" printf -- "$(gettext " -d, --nodeps Skip all dependency checks")\n"
printf -- "$(gettext " -e, --noextract Do not extract source files (use existing %s dir)")\n" "\$srcdir/" printf -- "$(gettext " -e, --noextract Do not extract source files (use existing %s dir)")\n" "\$srcdir/"
printf -- "$(gettext " -f, --force Overwrite existing package")\n" printf -- "$(gettext " -f, --force Overwrite existing package")\n"

View file

@ -142,8 +142,8 @@ msg "$(gettext "Making and MD5sum'ing the new database...")"
mkdir "$localdb.new" mkdir "$localdb.new"
bsdtar -xpf "$workdir/pacman-db.tar.gz" -C "$localdb.new" bsdtar -xpf "$workdir/pacman-db.tar.gz" -C "$localdb.new"
if (( $? )); then if (( $? )); then
rm -rf "$workdir" rm -rf "$workdir"
die_r "$(gettext "Untar'ing %s failed.")" "$localdb" die_r "$(gettext "Untar'ing %s failed.")" "$localdb"
fi fi
# immediate sync following extraction should get it written continuously on HDD # immediate sync following extraction should get it written continuously on HDD
msg "$(gettext "Syncing database to disk...")" msg "$(gettext "Syncing database to disk...")"

View file

@ -82,9 +82,9 @@ char *mdirname(const char *path)
*/ */
static size_t strnlen(const char *s, size_t max) static size_t strnlen(const char *s, size_t max)
{ {
register const char *p; register const char *p;
for(p = s; *p && max--; ++p); for(p = s; *p && max--; ++p);
return (p - s); return (p - s);
} }
/** Copies a string. /** Copies a string.
@ -95,14 +95,15 @@ static size_t strnlen(const char *s, size_t max)
*/ */
char *strndup(const char *s, size_t n) char *strndup(const char *s, size_t n)
{ {
size_t len = strnlen(s, n); size_t len = strnlen(s, n);
char *new = (char *) malloc(len + 1); char *new = (char *) malloc(len + 1);
if(new == NULL) if(new == NULL) {
return NULL; return NULL;
}
new[len] = '\0'; new[len] = '\0';
return (char *)memcpy(new, s, len); return (char *)memcpy(new, s, len);
} }
#endif #endif

View file

@ -156,7 +156,7 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
} }
switch(event) { switch(event) {
case ALPM_EVENT_CHECKDEPS_START: case ALPM_EVENT_CHECKDEPS_START:
printf(_("checking dependencies...\n")); printf(_("checking dependencies...\n"));
break; break;
case ALPM_EVENT_FILECONFLICTS_START: case ALPM_EVENT_FILECONFLICTS_START:
if(config->noprogressbar) { if(config->noprogressbar) {
@ -294,7 +294,7 @@ void cb_question(alpm_question_t event, void *data1, void *data2,
case ALPM_QUESTION_INSTALL_IGNOREPKG: case ALPM_QUESTION_INSTALL_IGNOREPKG:
if(!config->op_s_downloadonly) { if(!config->op_s_downloadonly) {
*response = yesno(_("%s is in IgnorePkg/IgnoreGroup. Install anyway?"), *response = yesno(_("%s is in IgnorePkg/IgnoreGroup. Install anyway?"),
alpm_pkg_get_name(data1)); alpm_pkg_get_name(data1));
} else { } else {
*response = 1; *response = 1;
} }
@ -698,7 +698,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total)
fname[len] = '\0'; fname[len] = '\0';
/* 1 space + filenamelen + 1 space + 6 for size + 1 space + 3 for label + /* 1 space + filenamelen + 1 space + 6 for size + 1 space + 3 for label +
* + 2 spaces + 4 for rate + 1 for label + 2 for /s + 1 space + * + 2 spaces + 4 for rate + 1 for label + 2 for /s + 1 space +
* 8 for eta, gives us the magic 30 */ * 8 for eta, gives us the magic 30 */
filenamelen = infolen - 30; filenamelen = infolen - 30;
/* see printf() code, we omit 'HH:' in these conditions */ /* see printf() code, we omit 'HH:' in these conditions */

View file

@ -689,7 +689,7 @@ static int setup_libalpm(void)
return ret; return ret;
} }
/* Set GnuPG's home directory. This is not relative to rootdir, even if /* Set GnuPG's home directory. This is not relative to rootdir, even if
* rootdir is defined. Reasoning: gpgdir contains configuration data. */ * rootdir is defined. Reasoning: gpgdir contains configuration data. */
config->gpgdir = config->gpgdir ? config->gpgdir : strdup(GPGDIR); config->gpgdir = config->gpgdir ? config->gpgdir : strdup(GPGDIR);
ret = alpm_option_set_gpgdir(handle, config->gpgdir); ret = alpm_option_set_gpgdir(handle, config->gpgdir);

View file

@ -189,7 +189,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
} }
if(from == ALPM_PKG_FROM_FILE || from == ALPM_PKG_FROM_LOCALDB) { if(from == ALPM_PKG_FROM_FILE || from == ALPM_PKG_FROM_LOCALDB) {
string_display(_("Install Script :"), string_display(_("Install Script :"),
alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"), cols); alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"), cols);
} }
if(from == ALPM_PKG_FROM_SYNCDB && extra) { if(from == ALPM_PKG_FROM_SYNCDB && extra) {
@ -206,7 +206,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
} }
string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg), cols); string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg), cols);
string_display(_("SHA256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols);
list_display(_("Signatures :"), keys, cols); list_display(_("Signatures :"), keys, cols);
} else { } else {
list_display(_("Validated By :"), validation, cols); list_display(_("Validated By :"), validation, cols);

View file

@ -601,7 +601,7 @@ static void checkargs_query(void)
invalid_opt(config->op_q_deps && config->op_q_explicit, "--deps", "--explicit"); invalid_opt(config->op_q_deps && config->op_q_explicit, "--deps", "--explicit");
invalid_opt((config->op_q_locality & PKG_LOCALITY_NATIVE) && invalid_opt((config->op_q_locality & PKG_LOCALITY_NATIVE) &&
(config->op_q_locality & PKG_LOCALITY_FOREIGN), (config->op_q_locality & PKG_LOCALITY_FOREIGN),
"--native", "--foreign"); "--native", "--foreign");
} }

View file

@ -170,7 +170,7 @@ static int query_fileowner(alpm_list_t *targets)
} }
if(lstat(filename, &buf) == -1) { if(lstat(filename, &buf) == -1) {
/* if it is not a path but a program name, then check in PATH */ /* if it is not a path but a program name, then check in PATH */
if(strchr(filename, '/') == NULL) { if(strchr(filename, '/') == NULL) {
if(search_path(&filename, &buf) == -1) { if(search_path(&filename, &buf) == -1) {
pm_printf(ALPM_LOG_ERROR, _("failed to find '%s' in PATH: %s\n"), pm_printf(ALPM_LOG_ERROR, _("failed to find '%s' in PATH: %s\n"),

View file

@ -1569,7 +1569,7 @@ int pm_asprintf(char **string, const char *format, ...)
/* print the message using va_arg list */ /* print the message using va_arg list */
va_start(args, format); va_start(args, format);
if(vasprintf(string, format, args) == -1) { if(vasprintf(string, format, args) == -1) {
pm_printf(ALPM_LOG_ERROR, _("failed to allocate string\n")); pm_printf(ALPM_LOG_ERROR, _("failed to allocate string\n"));
ret = -1; ret = -1;
} }
va_end(args); va_end(args);

View file

@ -5,43 +5,43 @@ declare -i testcount=0 fail=0 pass=0 total=15
# source the library function # source the library function
lib=${1:-${PMTEST_SCRIPTLIB_DIR}human_to_size.sh} lib=${1:-${PMTEST_SCRIPTLIB_DIR}human_to_size.sh}
if [[ -z $lib || ! -f $lib ]]; then if [[ -z $lib || ! -f $lib ]]; then
echo "Bail out! human_to_size library ($lib) could not be located\n" echo "Bail out! human_to_size library ($lib) could not be located\n"
exit 1 exit 1
fi fi
. "$lib" . "$lib"
if ! type -t human_to_size &>/dev/null; then if ! type -t human_to_size &>/dev/null; then
printf 'Bail out! human_to_size function not found\n' printf "Bail out! human_to_size function not found\n"
exit 1 exit 1
fi fi
parse_hts() { parse_hts() {
local input=$1 expected=$2 result local input=$1 expected=$2 result
(( ++testcount )) (( ++testcount ))
result=$(human_to_size "$1") result=$(human_to_size "$1")
if [[ $result = "$expected" ]]; then if [[ $result = "$expected" ]]; then
(( ++pass )) (( ++pass ))
printf "ok %d - %s\n" "$testcount" "$input" printf "ok %d - %s\n" "$testcount" "$input"
else else
(( ++fail )) (( ++fail ))
printf "not ok %d - %s\n" "$testcount" "$input" printf "not ok %d - %s\n" "$testcount" "$input"
printf '# [TEST %3s]: FAIL\n' "$testcount" printf '# [TEST %3s]: FAIL\n' "$testcount"
printf '# input: %s\n' "$input" printf '# input: %s\n' "$input"
printf '# output: %s\n' "$result" printf '# output: %s\n' "$result"
printf '# expected: %s\n' "$expected" printf '# expected: %s\n' "$expected"
fi fi
} }
summarize() { summarize() {
if (( !fail )); then if (( !fail )); then
printf '# All %s tests successful\n\n' "$testcount" printf '# All %s tests successful\n\n' "$testcount"
exit 0 exit 0
else else
printf '# %s of %s tests failed\n\n' "$fail" "$testcount" printf '# %s of %s tests failed\n\n' "$fail" "$testcount"
exit 1 exit 1
fi fi
} }
trap 'summarize' EXIT trap 'summarize' EXIT

View file

@ -5,14 +5,14 @@ declare -i testcount=0 pass=0 fail=0 total=25
# source the library function # source the library function
lib=${1:-${PMTEST_SCRIPTLIB_DIR}parseopts.sh} lib=${1:-${PMTEST_SCRIPTLIB_DIR}parseopts.sh}
if [[ -z $lib || ! -f $lib ]]; then if [[ -z $lib || ! -f $lib ]]; then
printf "Bail out! parseopts library ($lib) could not be located\n" printf "Bail out! parseopts library ($lib) could not be located\n"
exit 1 exit 1
fi fi
. "$lib" . "$lib"
if ! type -t parseopts &>/dev/null; then if ! type -t parseopts &>/dev/null; then
printf 'Bail out! parseopts function not found\n' printf "Bail out! parseopts function not found\n"
exit 1 exit 1
fi fi
# borrow opts from makepkg # borrow opts from makepkg
@ -24,38 +24,38 @@ OPT_LONG=('allsource' 'asroot' 'ignorearch' 'check' 'clean:' 'cleanall' 'nodeps'
'noconfirm' 'noprogressbar') 'noconfirm' 'noprogressbar')
parse() { parse() {
local result=$1 tokencount=$2; shift 2 local result=$1 tokencount=$2; shift 2
(( ++testcount )) (( ++testcount ))
parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@" 2>/dev/null parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@" 2>/dev/null
test_result "$result" "$tokencount" "$*" "${OPTRET[@]}" test_result "$result" "$tokencount" "$*" "${OPTRET[@]}"
unset OPTRET unset OPTRET
} }
test_result() { test_result() {
local result=$1 tokencount=$2 input=$3; shift 3 local result=$1 tokencount=$2 input=$3; shift 3
if [[ $result = "$*" ]] && (( tokencount == $# )); then if [[ $result = "$*" ]] && (( tokencount == $# )); then
(( ++pass )) (( ++pass ))
printf 'ok %d - %s\n' "$testcount" "$input" printf 'ok %d - %s\n' "$testcount" "$input"
else else
printf 'not ok %d - %s\n' "$testcount" "$input" printf 'not ok %d - %s\n' "$testcount" "$input"
printf '# [TEST %3s]: FAIL\n' "$testcount" printf '# [TEST %3s]: FAIL\n' "$testcount"
printf '# input: %s\n' "$input" printf '# input: %s\n' "$input"
printf '# output: %s (%s tokens)\n' "$*" "$#" printf '# output: %s (%s tokens)\n' "$*" "$#"
printf '# expected: %s (%s tokens)\n' "$result" "$tokencount" printf '# expected: %s (%s tokens)\n' "$result" "$tokencount"
(( ++fail )) (( ++fail ))
fi fi
} }
summarize() { summarize() {
if (( !fail )); then if (( !fail )); then
printf '# All %s tests successful\n\n' "$testcount" printf '# All %s tests successful\n\n' "$testcount"
exit 0 exit 0
else else
printf '# %s of %s tests failed\n\n' "$fail" "$testcount" printf '# %s of %s tests failed\n\n' "$fail" "$testcount"
exit 1 exit 1
fi fi
} }
trap 'summarize' EXIT trap 'summarize' EXIT