summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-02-25 20:05:43 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-02-25 20:05:43 +0000
commit1b639b22eb9e94892080e1846608337f34b27b7b (patch)
tree49ac7182355829b3919d45e3e0bca14d0a016998 /usr.bin
parent707f5df90e7f0560dbe1ac7b3de7e7d61cb0a113 (diff)
add rcsnum_parse() to simplify the most common case
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/rcs.h3
-rw-r--r--usr.bin/cvs/rcsnum.c26
2 files changed, 26 insertions, 3 deletions
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index 3a4f8064fd5..002892460bf 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.7 2005/01/13 20:50:57 jfb Exp $ */
+/* $OpenBSD: rcs.h,v 1.8 2005/02/25 20:05:41 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -158,6 +158,7 @@ BUF* rcs_patch (const char *, const char *);
size_t rcs_stresc (int, const char *, char *, size_t *);
RCSNUM* rcsnum_alloc (void);
+RCSNUM* rcsnum_parse (const char *);
void rcsnum_free (RCSNUM *);
int rcsnum_aton (const char *, char **, RCSNUM *);
char* rcsnum_tostr (const RCSNUM *, char *, size_t);
diff --git a/usr.bin/cvs/rcsnum.c b/usr.bin/cvs/rcsnum.c
index 693af871326..ac7462f2be2 100644
--- a/usr.bin/cvs/rcsnum.c
+++ b/usr.bin/cvs/rcsnum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsnum.c,v 1.6 2005/01/03 22:10:12 jfb Exp $ */
+/* $OpenBSD: rcsnum.c,v 1.7 2005/02/25 20:05:42 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -59,11 +59,33 @@ rcsnum_alloc(void)
/*
+ * rcsnum_parse()
+ *
+ * Parse a string specifying an RCS number and return the corresponding RCSNUM.
+ */
+RCSNUM*
+rcsnum_parse(const char *str)
+{
+ char *ep;
+ RCSNUM *num;
+
+ if ((num = rcsnum_alloc()) == NULL)
+ return (NULL);
+
+ if (rcsnum_aton(str, &ep, num) < 0) {
+ rcsnum_free(num);
+ return (NULL);
+ }
+
+ return (num);
+}
+
+
+/*
* rcsnum_free()
*
* Free an RCSNUM structure previously allocated with rcsnum_alloc().
*/
-
void
rcsnum_free(RCSNUM *rn)
{