From a074ddb85b4d1f9b90842e5a4f15e2416e3147fe Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Tue, 20 Dec 2005 23:59:56 +0000 Subject: [PATCH] VMiklos: add STRNCPY macro from alpm to pacman --- src/pacman/download.c | 2 +- src/pacman/util.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pacman/download.c b/src/pacman/download.c index 4cd1596a..b7799f43 100644 --- a/src/pacman/download.c +++ b/src/pacman/download.c @@ -451,7 +451,7 @@ int downloadfiles_forreal(list_t *servers, const char *localpath, if(!strcmp(server->protocol, "file")) { char out[56]; printf(" %s [", sync_fnm); - strncpy(out, server->path, 33); + STRNCPY(out, server->path, 33); printf("%s", out); for(j = strlen(out); j < maxcols-64; j++) { printf(" "); diff --git a/src/pacman/util.h b/src/pacman/util.h index 755f0b96..d48303c0 100644 --- a/src/pacman/util.h +++ b/src/pacman/util.h @@ -28,6 +28,11 @@ #define FREE(p) do { if (p) { free(p); (p) = NULL; }} while(0) +#define STRNCPY(s1, s2, len) do { \ + strncpy(s1, s2, (len)-1); \ + s1[(len)-1] = 0; \ +} while(0) + int makepath(char *path); int rmrf(char *path); void indentprint(char *str, int indent);