diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2007-03-27 07:21:22 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2007-03-27 07:21:22 +0000 |
commit | 20512c914b245c89f355b9ba0ad94ddb4fb1bf71 (patch) | |
tree | c64d20d9b93c1d46d60fbc7c001decbd83e5fe37 /usr.bin/rcs | |
parent | 1abe50d437d4807aa0ee60d579fb456fb450f569 (diff) |
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/rcs')
-rw-r--r-- | usr.bin/rcs/diff.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c index 09d341a47a9..dee9330a61d 100644 --- a/usr.bin/rcs/diff.c +++ b/usr.bin/rcs/diff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.12 2007/02/27 07:59:13 xsa Exp $ */ +/* $OpenBSD: diff.c,v 1.13 2007/03/27 07:21:21 xsa Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. * All rights reserved. @@ -229,7 +229,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; @@ -1175,6 +1175,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) { @@ -1182,6 +1184,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) { @@ -1196,11 +1199,23 @@ match_function(const long *f, int pos, FILE *fp) if (p != NULL) *p = '\0'; if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { - if (strlcpy(lastbuf, (const char *)buf, - sizeof(lastbuf)) >= sizeof(lastbuf)) - errx(1, "match_function: strlcpy"); - 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 { + if (strlcpy(lastbuf, (const char *)buf, + sizeof(lastbuf)) >= sizeof(lastbuf)) + errx(1, + "match_function: strlcpy"); + lastmatchline = pos; + return lastbuf; + } } } pos--; |