summaryrefslogtreecommitdiff
path: root/src/util/vercmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/vercmp.c')
-rw-r--r--src/util/vercmp.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/util/vercmp.c b/src/util/vercmp.c
index 959dc137..adb5a42a 100644
--- a/src/util/vercmp.c
+++ b/src/util/vercmp.c
@@ -1,7 +1,7 @@
/*
* vercmp.c
*
- * Copyright (c) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2005 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -18,23 +18,20 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
+#include <stdlib.h>
#include <stdio.h> /* printf */
#include <string.h> /* strncpy */
#define BASENAME "vercmp"
-#define MAX_LEN 255
-
-/* forward declaration, comes from vercmp.o in libalpm source that is linked in
- * directly so we don't have any library deps */
+/* forward declaration, comes from version.o in libalpm source that is linked
+ * in directly so we don't have any library deps */
int alpm_pkg_vercmp(const char *a, const char *b);
-static void usage()
+static void usage(void)
{
fprintf(stderr, "usage: %s <ver1> <ver2>\n\n", BASENAME);
- fprintf(stderr, "return values:\n");
+ fprintf(stderr, "output values:\n");
fprintf(stderr, " < 0 : if ver1 < ver2\n");
fprintf(stderr, " 0 : if ver1 == ver2\n");
fprintf(stderr, " > 0 : if ver1 > ver2\n");
@@ -42,8 +39,8 @@ static void usage()
int main(int argc, char *argv[])
{
- char s1[MAX_LEN] = "";
- char s2[MAX_LEN] = "";
+ const char *s1 = "";
+ const char *s2 = "";
int ret;
if(argc == 1) {
@@ -56,19 +53,14 @@ int main(int argc, char *argv[])
usage();
return(0);
}
- if(argc > 1) {
- strncpy(s1, argv[1], MAX_LEN);
- s1[MAX_LEN -1] = '\0';
- }
if(argc > 2) {
- strncpy(s2, argv[2], MAX_LEN);
- s2[MAX_LEN -1] = '\0';
- } else {
- printf("0\n");
- return(0);
+ s2 = argv[2];
+ }
+ if(argc > 1) {
+ s1 = argv[1];
}
ret = alpm_pkg_vercmp(s1, s2);
printf("%d\n", ret);
- return(ret);
+ return(EXIT_SUCCESS);
}