aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/diff/diffreg.c
diff options
context:
space:
mode:
authorPiotr Pawel Stefaniak <pstef@FreeBSD.org>2021-09-05 14:54:07 +0000
committerPiotr Pawel Stefaniak <pstef@FreeBSD.org>2021-09-15 23:46:44 +0000
commite51aabf8cbb9b412c725c4c9c727ca6faa0630c6 (patch)
tree63813b2dec97de72f65db709ea956bda2f800b72 /usr.bin/diff/diffreg.c
parentf38702e5a52e1350b9349bc297ccd0b50b1941c3 (diff)
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r--usr.bin/diff/diffreg.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 47c1934a6a65..fc3c3406a073 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1407,7 +1407,15 @@ match_function(const long *f, int pos, FILE *fp)
continue;
buf[nc] = '\0';
buf[strcspn(buf, "\n")] = '\0';
- if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
+ if (most_recent_pat != NULL) {
+ int ret = regexec(&most_recent_re, buf, 0, NULL, 0);
+
+ if (ret != 0)
+ continue;
+ strlcpy(lastbuf, buf, sizeof(lastbuf));
+ lastmatchline = pos;
+ return (lastbuf);
+ } else if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') {
if (begins_with(buf, "private:")) {
if (!state)
state = " (private)";
@@ -1448,7 +1456,7 @@ dump_context_vec(FILE *f1, FILE *f2, int flags)
upd = MIN(len[1], context_vec_ptr->d + diff_context);
printf("***************");
- if ((flags & D_PROTOTYPE)) {
+ if (flags & (D_PROTOTYPE | D_MATCHLAST)) {
f = match_function(ixold, lowa - 1, f1);
if (f != NULL)
printf(" %s", f);
@@ -1555,7 +1563,7 @@ dump_unified_vec(FILE *f1, FILE *f2, int flags)
printf(" +");
uni_range(lowc, upd);
printf(" @@");
- if ((flags & D_PROTOTYPE)) {
+ if (flags & (D_PROTOTYPE | D_MATCHLAST)) {
f = match_function(ixold, lowa - 1, f1);
if (f != NULL)
printf(" %s", f);