Commit Diff


commit - 2fa08c64136f5b53fb382e8369815ef94ba74ce0
commit + b756ffd26fea20daeeb98e205cc5655350cad80f
blob - 56fa5047632143a80c4e6c2514162e5a9dc18f88
blob + c3b32d7b258109c65dd18dbed7f2502d2481fc14
--- lib/diff_output.c
+++ lib/diff_output.c
@@ -242,6 +242,7 @@ is_function_prototype(const char *buf)
 }
 
 #define FUNCTION_CONTEXT_SIZE	55
+#define begins_with(s, pre) (strncmp(s, pre, sizeof(pre)-1) == 0)
 
 int
 diff_output_match_function_prototype(char **prototype,
@@ -251,6 +252,7 @@ diff_output_match_function_prototype(char **prototype,
 	struct diff_atom *start_atom, *atom;
 	const struct diff_data *data;
 	unsigned char buf[FUNCTION_CONTEXT_SIZE];
+	char *state = NULL;
 	int rc, i;
 
 	*prototype = NULL;
@@ -276,10 +278,23 @@ diff_output_match_function_prototype(char **prototype,
 		}
 		buf[i] = '\0';
 		if (is_function_prototype(buf)) {
-			*prototype = strdup(buf);
-			if (*prototype == NULL)
-				return ENOMEM;
-			return DIFF_RC_OK;
+			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 (state)  /* don't care about truncation */
+					strlcat(buf, state, sizeof(buf));
+				*prototype = strdup(buf);
+				if (*prototype == NULL)
+					return ENOMEM;
+				return DIFF_RC_OK;
+			}
 		}
 	}