mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
Remove STRNCPY macro from libalpm
Replaced calls to the STRNCPY macro with the actual strncpy function, and pacman passes all pactests. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
ea327cab84
commit
a58e17a1d7
@ -141,7 +141,7 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, const char *target)
|
||||
if(stat(path, &sbuf) || !S_ISDIR(sbuf.st_mode)) {
|
||||
continue;
|
||||
}
|
||||
STRNCPY(name, ent->d_name, PKG_FULLNAME_LEN);
|
||||
strncpy(name, ent->d_name, PKG_FULLNAME_LEN);
|
||||
/* truncate the string at the second-to-last hyphen, */
|
||||
/* which will give us the package name */
|
||||
if((ptr = rindex(name, '-'))) {
|
||||
@ -733,7 +733,7 @@ int _alpm_db_getlastupdate(pmdb_t *db, char *ts)
|
||||
} else {
|
||||
char line[256];
|
||||
if(fgets(line, sizeof(line), fp)) {
|
||||
STRNCPY(ts, line, 15); /* YYYYMMDDHHMMSS */
|
||||
strncpy(ts, line, 14); /* YYYYMMDDHHMMSS */
|
||||
ts[14] = '\0';
|
||||
} else {
|
||||
fclose(fp);
|
||||
|
@ -350,10 +350,10 @@ static alpm_list_t *add_fileconflict(alpm_list_t *conflicts,
|
||||
return(conflicts);
|
||||
}
|
||||
conflict->type = type;
|
||||
STRNCPY(conflict->target, name1, PKG_NAME_LEN);
|
||||
STRNCPY(conflict->file, filestr, CONFLICT_FILE_LEN);
|
||||
strncpy(conflict->target, name1, PKG_NAME_LEN);
|
||||
strncpy(conflict->file, filestr, CONFLICT_FILE_LEN);
|
||||
if(name2) {
|
||||
STRNCPY(conflict->ctarget, name2, PKG_NAME_LEN);
|
||||
strncpy(conflict->ctarget, name2, PKG_NAME_LEN);
|
||||
} else {
|
||||
conflict->ctarget[0] = '\0';
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ pmdb_t *_alpm_db_new(const char *root, const char *dbpath, const char *treename)
|
||||
}
|
||||
sprintf(db->path, "%s%s%s/", root, dbpath, treename);
|
||||
|
||||
STRNCPY(db->treename, treename, PATH_MAX);
|
||||
strncpy(db->treename, treename, PATH_MAX);
|
||||
|
||||
return(db);
|
||||
}
|
||||
|
@ -60,12 +60,12 @@ pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
|
||||
RET_ERR(PM_ERR_MEMORY, NULL);
|
||||
}
|
||||
|
||||
STRNCPY(miss->target, target, PKG_NAME_LEN);
|
||||
strncpy(miss->target, target, PKG_NAME_LEN);
|
||||
miss->type = type;
|
||||
miss->depend.mod = depmod;
|
||||
STRNCPY(miss->depend.name, depname, PKG_NAME_LEN);
|
||||
strncpy(miss->depend.name, depname, PKG_NAME_LEN);
|
||||
if(depversion) {
|
||||
STRNCPY(miss->depend.version, depversion, PKG_VERSION_LEN);
|
||||
strncpy(miss->depend.version, depversion, PKG_VERSION_LEN);
|
||||
} else {
|
||||
miss->depend.version[0] = 0;
|
||||
}
|
||||
|
@ -58,12 +58,12 @@ pmpkg_t *_alpm_pkg_new(const char *name, const char *version)
|
||||
}
|
||||
|
||||
if(name && name[0] != 0) {
|
||||
STRNCPY(pkg->name, name, PKG_NAME_LEN);
|
||||
strncpy(pkg->name, name, PKG_NAME_LEN);
|
||||
} else {
|
||||
pkg->name[0] = '\0';
|
||||
}
|
||||
if(version && version[0] != 0) {
|
||||
STRNCPY(pkg->version, version, PKG_VERSION_LEN);
|
||||
strncpy(pkg->version, version, PKG_VERSION_LEN);
|
||||
} else {
|
||||
pkg->version[0] = '\0';
|
||||
}
|
||||
@ -219,9 +219,9 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
|
||||
key = _alpm_strtoupper(key);
|
||||
_alpm_strtrim(ptr);
|
||||
if(!strcmp(key, "PKGNAME")) {
|
||||
STRNCPY(info->name, ptr, sizeof(info->name));
|
||||
strncpy(info->name, ptr, sizeof(info->name));
|
||||
} else if(!strcmp(key, "PKGVER")) {
|
||||
STRNCPY(info->version, ptr, sizeof(info->version));
|
||||
strncpy(info->version, ptr, sizeof(info->version));
|
||||
} else if(!strcmp(key, "PKGDESC")) {
|
||||
/*
|
||||
char *lang_tmp;
|
||||
@ -229,32 +229,32 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
|
||||
if((lang_tmp = (char *)malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
|
||||
RET_ERR(PM_ERR_MEMORY, -1);
|
||||
}
|
||||
STRNCPY(lang_tmp, setlocale(LC_ALL, ""), strlen(setlocale(LC_ALL, "")));
|
||||
strncpy(lang_tmp, setlocale(LC_ALL, ""), strlen(setlocale(LC_ALL, "")));
|
||||
if(info->desc_localized && !info->desc_localized->next) {
|
||||
*/
|
||||
STRNCPY(info->desc, ptr, sizeof(info->desc));
|
||||
strncpy(info->desc, ptr, sizeof(info->desc));
|
||||
/*
|
||||
} else if (ptr && !strncmp(ptr, lang_tmp, strlen(lang_tmp))) {
|
||||
STRNCPY(info->desc, ptr+strlen(lang_tmp)+1, sizeof(info->desc));
|
||||
strncpy(info->desc, ptr+strlen(lang_tmp)+1, sizeof(info->desc));
|
||||
}
|
||||
FREE(lang_tmp);
|
||||
*/
|
||||
} else if(!strcmp(key, "GROUP")) {
|
||||
info->groups = alpm_list_add(info->groups, strdup(ptr));
|
||||
} else if(!strcmp(key, "URL")) {
|
||||
STRNCPY(info->url, ptr, sizeof(info->url));
|
||||
strncpy(info->url, ptr, sizeof(info->url));
|
||||
} else if(!strcmp(key, "LICENSE")) {
|
||||
info->licenses = alpm_list_add(info->licenses, strdup(ptr));
|
||||
} else if(!strcmp(key, "BUILDDATE")) {
|
||||
STRNCPY(info->builddate, ptr, sizeof(info->builddate));
|
||||
strncpy(info->builddate, ptr, sizeof(info->builddate));
|
||||
} else if(!strcmp(key, "BUILDTYPE")) {
|
||||
STRNCPY(info->buildtype, ptr, sizeof(info->buildtype));
|
||||
strncpy(info->buildtype, ptr, sizeof(info->buildtype));
|
||||
} else if(!strcmp(key, "INSTALLDATE")) {
|
||||
STRNCPY(info->installdate, ptr, sizeof(info->installdate));
|
||||
strncpy(info->installdate, ptr, sizeof(info->installdate));
|
||||
} else if(!strcmp(key, "PACKAGER")) {
|
||||
STRNCPY(info->packager, ptr, sizeof(info->packager));
|
||||
strncpy(info->packager, ptr, sizeof(info->packager));
|
||||
} else if(!strcmp(key, "ARCH")) {
|
||||
STRNCPY(info->arch, ptr, sizeof(info->arch));
|
||||
strncpy(info->arch, ptr, sizeof(info->arch));
|
||||
} else if(!strcmp(key, "SIZE")) {
|
||||
/* size in the raw package is uncompressed (installed) size */
|
||||
info->isize = atol(ptr);
|
||||
@ -494,7 +494,7 @@ int _alpm_pkg_splitname(const char *target, char *name, char *version, int witha
|
||||
} else {
|
||||
t++;
|
||||
}
|
||||
STRNCPY(tmp, t, PKG_FULLNAME_LEN+7);
|
||||
strncpy(tmp, t, PKG_FULLNAME_LEN+7);
|
||||
/* trim file extension (if any) */
|
||||
if((p = strstr(tmp, PM_EXT_PKG))) {
|
||||
*p = '\0';
|
||||
@ -518,12 +518,12 @@ int _alpm_pkg_splitname(const char *target, char *name, char *version, int witha
|
||||
return(-1);
|
||||
}
|
||||
if(version) {
|
||||
STRNCPY(version, p+1, PKG_VERSION_LEN);
|
||||
strncpy(version, p+1, PKG_VERSION_LEN);
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
if(name) {
|
||||
STRNCPY(name, tmp, PKG_NAME_LEN);
|
||||
strncpy(name, tmp, PKG_NAME_LEN);
|
||||
}
|
||||
|
||||
return(0);
|
||||
|
@ -197,7 +197,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
|
||||
}
|
||||
if(!strlen(pkgname)) {
|
||||
/* just use the raw filename if we can't find crap */
|
||||
STRNCPY(pkgname, fn, PKG_NAME_LEN+1);
|
||||
strncpy(pkgname, fn, PKG_NAME_LEN);
|
||||
}
|
||||
_alpm_log(PM_LOG_DEBUG, _("using '%s' for download progress"), pkgname);
|
||||
|
||||
|
@ -266,7 +266,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
|
||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||
ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
||||
|
||||
STRNCPY(targline, name, PKG_FULLNAME_LEN);
|
||||
strncpy(targline, name, PKG_FULLNAME_LEN);
|
||||
targ = strchr(targline, '/');
|
||||
if(targ) {
|
||||
*targ = '\0';
|
||||
|
@ -449,7 +449,7 @@ int _alpm_runscriptlet(const char *root, const char *installfn,
|
||||
/* chop off the root so we can find the tmpdir in the chroot */
|
||||
scriptpath = scriptfn + strlen(root) - 1;
|
||||
} else {
|
||||
STRNCPY(scriptfn, installfn, PATH_MAX);
|
||||
strncpy(scriptfn, installfn, PATH_MAX);
|
||||
/* chop off the root so we can find the tmpdir in the chroot */
|
||||
scriptpath = scriptfn + strlen(root) - 1;
|
||||
}
|
||||
|
@ -34,11 +34,6 @@
|
||||
|
||||
#define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0)
|
||||
|
||||
#define STRNCPY(s1, s2, len) do { \
|
||||
strncpy(s1, s2, (len)-1); \
|
||||
s1[(len)-1] = 0; \
|
||||
} while(0)
|
||||
|
||||
#define ARCHIVE_EXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME
|
||||
|
||||
/* define _() as shortcut for gettext() */
|
||||
@ -62,6 +57,7 @@ int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
|
||||
int _alpm_rmrf(const char *path);
|
||||
int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
|
||||
int _alpm_ldconfig(const char *root);
|
||||
/* TODO wtf? this can't be right */
|
||||
#ifdef _ALPM_TRANS_H
|
||||
int _alpm_runscriptlet(const char *root, const char *installfn,
|
||||
const char *script, const char *ver,
|
||||
|
Loading…
Reference in New Issue
Block a user