summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjfb <jfb@openbsd.org>2005-02-25 20:05:41 +0000
committerjfb <jfb@openbsd.org>2005-02-25 20:05:41 +0000
commit17d257bd0e4388afa6c68bf5a9cc342c8a86cbec (patch)
tree002bb8d83d8c086909f168a9a095862d269040b7
parentdocument `cvs diff' options; input/ok jmc; ok jfb Joris Vink; (diff)
downloadwireguard-openbsd-17d257bd0e4388afa6c68bf5a9cc342c8a86cbec.tar.xz
wireguard-openbsd-17d257bd0e4388afa6c68bf5a9cc342c8a86cbec.zip
add rcsnum_parse() to simplify the most common case
-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)
{