summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/getlog.c10
-rw-r--r--usr.bin/cvs/rcs.h6
-rw-r--r--usr.bin/cvs/rcsparse.c28
-rw-r--r--usr.bin/rcs/rcs.h6
-rw-r--r--usr.bin/rcs/rcsparse.c28
-rw-r--r--usr.bin/rcs/rlog.c10
6 files changed, 74 insertions, 14 deletions
diff --git a/usr.bin/cvs/getlog.c b/usr.bin/cvs/getlog.c
index 0df3887e0b2..dd045919cb9 100644
--- a/usr.bin/cvs/getlog.c
+++ b/usr.bin/cvs/getlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getlog.c,v 1.95 2010/07/30 21:47:18 ray Exp $ */
+/* $OpenBSD: getlog.c,v 1.96 2013/06/03 17:04:35 jcs Exp $ */
/*
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
@@ -376,10 +376,14 @@ log_rev_print(struct rcs_delta *rdp)
int added, removed;
rcs_delta_stats(nrdp, &added, &removed);
if (RCSNUM_ISBRANCHREV(rdp->rd_num))
- cvs_printf(" lines: +%d -%d", added, removed);
+ cvs_printf(" lines: +%d -%d;", added, removed);
else
- cvs_printf(" lines: +%d -%d", removed, added);
+ cvs_printf(" lines: +%d -%d;", removed, added);
}
+
+ if (rdp->rd_commitid != NULL)
+ printf(" commitid: %s;", rdp->rd_commitid);
+
cvs_printf("\n");
if (!TAILQ_EMPTY(&(rdp->rd_branches))) {
diff --git a/usr.bin/cvs/rcs.h b/usr.bin/cvs/rcs.h
index 3bcba820483..5de9ec59a0f 100644
--- a/usr.bin/cvs/rcs.h
+++ b/usr.bin/cvs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.100 2012/07/02 21:56:25 tedu Exp $ */
+/* $OpenBSD: rcs.h,v 1.101 2013/06/03 17:04:35 jcs Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -126,6 +126,9 @@ struct rcs_kw {
#define RCS_RD_DEAD 0x01 /* dead */
#define RCS_RD_SELECT 0x02 /* select for operation */
+/* commitids in cvs/cvsnt can be up to 64 bytes */
+#define RCS_COMMITID_MAXLEN 64
+
typedef struct rcs_num {
u_int rn_len;
u_int16_t rn_id[RCSNUM_MAXLEN];
@@ -163,6 +166,7 @@ struct rcs_delta {
struct tm rd_date;
char *rd_author;
char *rd_state;
+ char *rd_commitid;
char *rd_log;
char *rd_locker;
u_char *rd_text;
diff --git a/usr.bin/cvs/rcsparse.c b/usr.bin/cvs/rcsparse.c
index 737d212e038..4c73f384386 100644
--- a/usr.bin/cvs/rcsparse.c
+++ b/usr.bin/cvs/rcsparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsparse.c,v 1.6 2012/02/04 21:22:32 tobias Exp $ */
+/* $OpenBSD: rcsparse.c,v 1.7 2013/06/03 17:04:35 jcs Exp $ */
/*
* Copyright (c) 2010 Tobias Stoeckmann <tobias@openbsd.org>
*
@@ -107,6 +107,7 @@ static const struct rcs_keyword keywords[] = {
{ "branch", RCS_TOK_BRANCH},
{ "branches", RCS_TOK_BRANCHES},
{ "comment", RCS_TOK_COMMENT},
+ { "commitid", RCS_TOK_COMMITID},
{ "date", RCS_TOK_DATE},
{ "desc", RCS_TOK_DESC},
{ "expand", RCS_TOK_EXPAND},
@@ -151,6 +152,7 @@ static int rcsparse_string(RCSFILE *, int);
static int rcsparse_token(RCSFILE *, int);
static void rcsparse_warnx(RCSFILE *, char *, ...);
static int valid_login(char *);
+static int valid_commitid(char *);
/*
* head [REVISION];
@@ -528,7 +530,7 @@ rcsparse_commitid(RCSFILE *rfp, struct rcs_pdata *pdp)
if (rcsparse_token(rfp, RCS_TYPE_COMMITID) != RCS_TYPE_COMMITID)
return (1);
- /* XXX - do something with commitid */
+ pdp->rp_delta->rd_commitid = pdp->rp_value.str;
return (rcsparse_token(rfp, RCS_TOK_SCOLON) != RCS_TOK_SCOLON);
}
@@ -989,7 +991,12 @@ rcsparse_token(RCSFILE *rfp, int allowed)
switch (allowed) {
case RCS_TYPE_COMMITID:
- /* XXX validate commitid */
+ if (!valid_commitid(pdp->rp_buf)) {
+ rcsparse_warnx(rfp, "invalid commitid \"%s\"",
+ pdp->rp_buf);
+ return (0);
+ }
+ pdp->rp_value.str = xstrdup(pdp->rp_buf);
break;
case RCS_TYPE_LOGIN:
if (!valid_login(pdp->rp_buf)) {
@@ -1227,6 +1234,21 @@ valid_login(char *login_name)
}
static int
+valid_commitid(char *commitid)
+{
+ unsigned char *cp;
+
+ /* A-Za-z0-9 */
+ for (cp = commitid; *cp ; cp++) {
+ if (!isalnum(*cp))
+ return 0;
+ }
+ if ((char *)cp - commitid > RCS_COMMITID_MAXLEN)
+ return 0;
+ return 1;
+}
+
+static int
kw_cmp(const void *k, const void *e)
{
return (strcmp(k, ((const struct rcs_keyword *)e)->k_name));
diff --git a/usr.bin/rcs/rcs.h b/usr.bin/rcs/rcs.h
index 143250a9e1c..c12a2e012a2 100644
--- a/usr.bin/rcs/rcs.h
+++ b/usr.bin/rcs/rcs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.h,v 1.15 2011/07/06 15:36:52 nicm Exp $ */
+/* $OpenBSD: rcs.h,v 1.16 2013/06/03 17:04:35 jcs Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -142,6 +142,9 @@ struct rcs_kw {
#define CHECKOUT_REV_REMOVED 3
#define CHECKOUT_REV_UPDATED 4
+/* commitids in cvs/cvsnt can be up to 64 bytes */
+#define RCS_COMMITID_MAXLEN 64
+
typedef struct rcs_num {
u_int rn_len;
u_int16_t *rn_id;
@@ -179,6 +182,7 @@ struct rcs_delta {
struct tm rd_date;
char *rd_author;
char *rd_state;
+ char *rd_commitid;
char *rd_log;
char *rd_locker;
u_char *rd_text;
diff --git a/usr.bin/rcs/rcsparse.c b/usr.bin/rcs/rcsparse.c
index b4b9ef7d05b..f5f107ce871 100644
--- a/usr.bin/rcs/rcsparse.c
+++ b/usr.bin/rcs/rcsparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsparse.c,v 1.8 2012/02/04 21:22:32 tobias Exp $ */
+/* $OpenBSD: rcsparse.c,v 1.9 2013/06/03 17:04:35 jcs Exp $ */
/*
* Copyright (c) 2010 Tobias Stoeckmann <tobias@openbsd.org>
*
@@ -106,6 +106,7 @@ static const struct rcs_keyword keywords[] = {
{ "branch", RCS_TOK_BRANCH},
{ "branches", RCS_TOK_BRANCHES},
{ "comment", RCS_TOK_COMMENT},
+ { "commitid", RCS_TOK_COMMITID},
{ "date", RCS_TOK_DATE},
{ "desc", RCS_TOK_DESC},
{ "expand", RCS_TOK_EXPAND},
@@ -150,6 +151,7 @@ static int rcsparse_string(RCSFILE *, int);
static int rcsparse_token(RCSFILE *, int);
static void rcsparse_warnx(RCSFILE *, char *, ...);
static int valid_login(char *);
+static int valid_commitid(char *);
/*
* head [REVISION];
@@ -527,7 +529,7 @@ rcsparse_commitid(RCSFILE *rfp, struct rcs_pdata *pdp)
if (rcsparse_token(rfp, RCS_TYPE_COMMITID) != RCS_TYPE_COMMITID)
return (1);
- /* XXX - do something with commitid */
+ pdp->rp_delta->rd_commitid = pdp->rp_value.str;
return (rcsparse_token(rfp, RCS_TOK_SCOLON) != RCS_TOK_SCOLON);
}
@@ -988,7 +990,12 @@ rcsparse_token(RCSFILE *rfp, int allowed)
switch (allowed) {
case RCS_TYPE_COMMITID:
- /* XXX validate commitid */
+ if (!valid_commitid(pdp->rp_buf)) {
+ rcsparse_warnx(rfp, "invalid commitid \"%s\"",
+ pdp->rp_buf);
+ return (0);
+ }
+ pdp->rp_value.str = xstrdup(pdp->rp_buf);
break;
case RCS_TYPE_LOGIN:
if (!valid_login(pdp->rp_buf)) {
@@ -1226,6 +1233,21 @@ valid_login(char *login_name)
}
static int
+valid_commitid(char *commitid)
+{
+ unsigned char *cp;
+
+ /* A-Za-z0-9 */
+ for (cp = commitid; *cp ; cp++) {
+ if (!isalnum(*cp))
+ return 0;
+ }
+ if ((char *)cp - commitid > RCS_COMMITID_MAXLEN)
+ return 0;
+ return 1;
+}
+
+static int
kw_cmp(const void *k, const void *e)
{
return (strcmp(k, ((const struct rcs_keyword *)e)->k_name));
diff --git a/usr.bin/rcs/rlog.c b/usr.bin/rcs/rlog.c
index 0b95059453d..0eec9389239 100644
--- a/usr.bin/rcs/rlog.c
+++ b/usr.bin/rcs/rlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlog.c,v 1.65 2011/07/14 16:38:39 sobrado Exp $ */
+/* $OpenBSD: rlog.c,v 1.66 2013/06/03 17:04:35 jcs Exp $ */
/*
* Copyright (c) 2005, 2009 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -541,10 +541,14 @@ rlog_rev_print(struct rcs_delta *rdp)
rcs_delta_stats(nrdp, &added, &removed);
if (RCSNUM_ISBRANCHREV(rdp->rd_num))
- printf(" lines: +%d -%d", added, removed);
+ printf(" lines: +%d -%d;", added, removed);
else
- printf(" lines: +%d -%d", removed, added);
+ printf(" lines: +%d -%d;", removed, added);
}
+
+ if (rdp->rd_commitid != NULL)
+ printf(" commitid: %s;", rdp->rd_commitid);
+
printf("\n");
if (!TAILQ_EMPTY(&(rdp->rd_branches))) {