summaryrefslogtreecommitdiffstats
path: root/usr.bin/cvs/diff_internals.c
diff options
context:
space:
mode:
authorxsa <xsa@openbsd.org>2007-03-27 07:21:21 +0000
committerxsa <xsa@openbsd.org>2007-03-27 07:21:21 +0000
commite22e6974f103fe1b2fe2c955596f8c1bc650d328 (patch)
treed71f953ac8b36ecc474ed908b68030a71e141fcd /usr.bin/cvs/diff_internals.c
parentdisable serverworks sata until it works (been busted for a year on the (diff)
downloadwireguard-openbsd-e22e6974f103fe1b2fe2c955596f8c1bc650d328.tar.xz
wireguard-openbsd-e22e6974f103fe1b2fe2c955596f8c1bc650d328.zip
sync with espie@'s latest change to diff(1).
from src/usr.bin/diff/diffreg.c rev 1.67: improve -p for C++ code: classes definition often have public:/protected:/private: at the start of line. This lets the -p scanner just take note of the section and keep looking for the actual class definition. Also increase function name bufsize so it shows most of these pesky C++ decls... OK niallo@ espie@.
Diffstat (limited to 'usr.bin/cvs/diff_internals.c')
-rw-r--r--usr.bin/cvs/diff_internals.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/usr.bin/cvs/diff_internals.c b/usr.bin/cvs/diff_internals.c
index 930e4fc0057..c5ee3302edd 100644
--- a/usr.bin/cvs/diff_internals.c
+++ b/usr.bin/cvs/diff_internals.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff_internals.c,v 1.4 2007/02/22 06:42:09 otto Exp $ */
+/* $OpenBSD: diff_internals.c,v 1.5 2007/03/27 07:21:21 xsa Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -226,7 +226,7 @@ static struct context_vec *context_vec_start;
static struct context_vec *context_vec_end;
static struct context_vec *context_vec_ptr;
-#define FUNCTION_CONTEXT_SIZE 41
+#define FUNCTION_CONTEXT_SIZE 55
static char lastbuf[FUNCTION_CONTEXT_SIZE];
static int lastline;
static int lastmatchline;
@@ -1164,6 +1164,8 @@ asciifile(FILE *f)
return (1);
}
+#define begins_with(s, pre) (strncmp(s, pre, sizeof(pre)-1) == 0)
+
static char*
match_function(const long *f, int pos, FILE *fp)
{
@@ -1171,6 +1173,7 @@ match_function(const long *f, int pos, FILE *fp)
size_t nc;
int last = lastline;
char *p;
+ char *state = NULL;
lastline = pos;
while (pos > last) {
@@ -1185,10 +1188,24 @@ match_function(const long *f, int pos, FILE *fp)
if (p != NULL)
*p = '\0';
if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
- strlcpy(lastbuf, (const char *)buf,
- sizeof lastbuf);
- lastmatchline = pos;
- return lastbuf;
+ if (begins_with(buf, "private:")) {
+ if (!state)
+ state = " (private)";
+ } else if (begins_with(buf, "protected:")) {
+ if (!state)
+ state = " (protected)";
+ } else if (begins_with(buf, "public:")) {
+ if (!state)
+ state = " (public)";
+ } else {
+ strlcpy(lastbuf, (const char *)buf,
+ sizeof lastbuf);
+ if (state)
+ strlcat(lastbuf, state,
+ sizeof lastbuf);
+ lastmatchline = pos;
+ return lastbuf;
+ }
}
}
pos--;