diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2005-02-25 20:05:43 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2005-02-25 20:05:43 +0000 |
commit | 1b639b22eb9e94892080e1846608337f34b27b7b (patch) | |
tree | 49ac7182355829b3919d45e3e0bca14d0a016998 /usr.bin/cvs/rcsnum.c | |
parent | 707f5df90e7f0560dbe1ac7b3de7e7d61cb0a113 (diff) |
add rcsnum_parse() to simplify the most common case
Diffstat (limited to 'usr.bin/cvs/rcsnum.c')
-rw-r--r-- | usr.bin/cvs/rcsnum.c | 26 |
1 files changed, 24 insertions, 2 deletions
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) { |