=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/diff/diffreg.c,v retrieving revision 1.66 retrieving revision 1.67 diff -c -r1.66 -r1.67 *** src/usr.bin/diff/diffreg.c 2007/02/23 08:03:19 1.66 --- src/usr.bin/diff/diffreg.c 2007/03/18 21:12:27 1.67 *************** *** 1,4 **** ! /* $OpenBSD: diffreg.c,v 1.66 2007/02/23 08:03:19 espie Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. --- 1,4 ---- ! /* $OpenBSD: diffreg.c,v 1.67 2007/03/18 21:12:27 espie Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. *************** *** 65,71 **** */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.66 2007/02/23 08:03:19 espie Exp $"; #endif /* not lint */ #include --- 65,71 ---- */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.67 2007/03/18 21:12:27 espie Exp $"; #endif /* not lint */ #include *************** *** 195,201 **** static struct context_vec *context_vec_end; static struct context_vec *context_vec_ptr; ! #define FUNCTION_CONTEXT_SIZE 41 static char lastbuf[FUNCTION_CONTEXT_SIZE]; static int lastline; static int lastmatchline; --- 195,201 ---- static struct context_vec *context_vec_end; static struct context_vec *context_vec_ptr; ! #define FUNCTION_CONTEXT_SIZE 55 static char lastbuf[FUNCTION_CONTEXT_SIZE]; static int lastline; static int lastmatchline; *************** *** 1303,1308 **** --- 1303,1310 ---- return (a > b ? a : b); } + #define begins_with(s, pre) (strncmp(s, pre, sizeof(pre)-1) == 0) + static char * match_function(const long *f, int pos, FILE *file) { *************** *** 1310,1315 **** --- 1312,1318 ---- size_t nc; int last = lastline; char *p; + char *state = NULL; lastline = pos; while (pos > last) { *************** *** 1324,1332 **** if (p != NULL) *p = '\0'; if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { ! strlcpy(lastbuf, buf, sizeof lastbuf); ! lastmatchline = pos; ! return lastbuf; } } pos--; --- 1327,1349 ---- if (p != NULL) *p = '\0'; if (isalpha(buf[0]) || buf[0] == '_' || buf[0] == '$') { ! 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, buf, sizeof lastbuf); ! if (state) ! strlcat(lastbuf, state, ! sizeof lastbuf); ! lastmatchline = pos; ! return lastbuf; ! } } } pos--;