85 lines
2.2 KiB
Diff
85 lines
2.2 KiB
Diff
FIXME: free()
|
|
|
|
---
|
|
pch.c | 32 +++++++++++++++++++++++++++++++-
|
|
pch.h | 1 +
|
|
2 files changed, 32 insertions(+), 1 deletion(-)
|
|
|
|
Index: b/pch.c
|
|
===================================================================
|
|
--- a/pch.c
|
|
+++ b/pch.c
|
|
@@ -68,6 +68,7 @@ static LINENUM p_sline; /* and the lin
|
|
static LINENUM p_hunk_beg; /* line number of current hunk */
|
|
static LINENUM p_efake = -1; /* end of faked up lines--don't free */
|
|
static LINENUM p_bfake = -1; /* beg of faked up lines */
|
|
+static char *p_c_function; /* the C function a hunk is in */
|
|
|
|
enum nametype { OLD, NEW, INDEX, NONE };
|
|
|
|
@@ -888,6 +889,19 @@ another_hunk (enum diff difftype, bool r
|
|
next_intuit_at(line_beginning,p_input_line);
|
|
return chars_read == (size_t) -1 ? -1 : 0;
|
|
}
|
|
+ s = buf;
|
|
+ while (*s == '*')
|
|
+ s++;
|
|
+ if (*s == ' ')
|
|
+ {
|
|
+ p_c_function = s;
|
|
+ while (*s != '\n')
|
|
+ s++;
|
|
+ *s = '\0';
|
|
+ p_c_function = savestr (p_c_function);
|
|
+ }
|
|
+ else
|
|
+ p_c_function = NULL;
|
|
p_hunk_beg = p_input_line + 1;
|
|
while (p_end < p_max) {
|
|
chars_read = get_line ();
|
|
@@ -1277,8 +1291,18 @@ another_hunk (enum diff difftype, bool r
|
|
else
|
|
p_repl_lines = 1;
|
|
if (*s == ' ') s++;
|
|
- if (*s != '@')
|
|
+ if (*s++ != '@')
|
|
malformed ();
|
|
+ if (*s++ == '@' && *s == ' ' && *s != '\0')
|
|
+ {
|
|
+ p_c_function = s;
|
|
+ while (*s != '\n')
|
|
+ s++;
|
|
+ *s = '\0';
|
|
+ p_c_function = savestr (p_c_function);
|
|
+ }
|
|
+ else
|
|
+ p_c_function = NULL;
|
|
if (!p_ptrn_lines)
|
|
p_first++; /* do append rather than insert */
|
|
if (!p_repl_lines)
|
|
@@ -1884,6 +1908,12 @@ pch_hunk_beg (void)
|
|
return p_hunk_beg;
|
|
}
|
|
|
|
+char const *
|
|
+pch_c_function (void)
|
|
+{
|
|
+ return p_c_function;
|
|
+}
|
|
+
|
|
/* Is the newline-terminated line a valid `ed' command for patch
|
|
input? If so, return the command character; if not, return 0.
|
|
This accepts accepts just a subset of the valid commands, but it's
|
|
Index: b/pch.h
|
|
===================================================================
|
|
--- a/pch.h
|
|
+++ b/pch.h
|
|
@@ -25,6 +25,7 @@
|
|
LINENUM pch_end (void);
|
|
LINENUM pch_first (void);
|
|
LINENUM pch_hunk_beg (void);
|
|
+char const *pch_c_function (void);
|
|
LINENUM pch_newfirst (void);
|
|
LINENUM pch_prefix_context (void);
|
|
LINENUM pch_ptrn_lines (void);
|