summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5ff10dd)
raw | patch | inline | side by side (parent: 5ff10dd)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 26 Jun 2008 22:35:21 +0000 (15:35 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 27 Jun 2008 01:13:50 +0000 (18:13 -0700) |
The function name was too bland and not explicit enough as to what it is
checking. Split it into two, and call the one that checks if there is a
whitespace breakage "ws_check()", and call the other one that checks and
emits the line after color coding "ws_check_emit()".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
checking. Split it into two, and call the one that checks if there is a
whitespace breakage "ws_check()", and call the other one that checks and
emits the line after color coding "ws_check_emit()".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-apply.c | patch | blob | history | |
cache.h | patch | blob | history | |
diff.c | patch | blob | history | |
ws.c | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index c4978893122bbcfd80201fe937eb8433b29e1aa0..92f00471bbdeefaf987f77c407eea7cefa52280a 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -979,8 +979,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
static void check_whitespace(const char *line, int len, unsigned ws_rule)
{
char *err;
- unsigned result = check_and_emit_line(line + 1, len - 1, ws_rule,
- NULL, NULL, NULL, NULL);
+ unsigned result = ws_check(line + 1, len - 1, ws_rule);
if (!result)
return;
else {
err = whitespace_error_string(result);
fprintf(stderr, "%s:%d: %s.\n%.*s\n",
- patch_input_file, linenr, err, len - 2, line + 1);
+ patch_input_file, linenr, err, len - 2, line + 1);
free(err);
}
}
index 64ef86e129337fde851d701a30e70cb84b54ecb3..3dfa53c5668fda37bfce453d381445e5269fb979 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -819,9 +819,8 @@ void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, i
extern unsigned whitespace_rule_cfg;
extern unsigned whitespace_rule(const char *);
extern unsigned parse_whitespace_rule(const char *);
-extern unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
- FILE *stream, const char *set,
- const char *reset, const char *ws);
+extern unsigned ws_check(const char *line, int len, unsigned ws_rule);
+extern void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
extern char *whitespace_error_string(unsigned ws);
extern int ws_fix_copy(char *, const char *, int, unsigned, int *);
index c00d633c12cb82619159eb964ef2aa1ee43387cc..52a34eec913432a8928823e195c10875afd86d21 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -535,9 +535,9 @@ static void emit_add_line(const char *reset, struct emit_callback *ecbdata, cons
else {
/* Emit just the prefix, then the rest. */
emit_line(ecbdata->file, set, reset, line, ecbdata->nparents);
- (void)check_and_emit_line(line + ecbdata->nparents,
- len - ecbdata->nparents, ecbdata->ws_rule,
- ecbdata->file, set, reset, ws);
+ ws_check_emit(line + ecbdata->nparents,
+ len - ecbdata->nparents, ecbdata->ws_rule,
+ ecbdata->file, set, reset, ws);
}
}
if (line[0] == '+') {
unsigned bad;
data->lineno++;
- bad = check_and_emit_line(line + 1, len - 1,
- data->ws_rule, NULL, NULL, NULL, NULL);
+ bad = ws_check(line + 1, len - 1, data->ws_rule);
if (!bad)
return;
data->status |= bad;
fprintf(data->file, "%s:%d: %s.\n", data->filename, data->lineno, err);
free(err);
emit_line(data->file, set, reset, line, 1);
- (void)check_and_emit_line(line + 1, len - 1, data->ws_rule,
- data->file, set, reset, ws);
+ ws_check_emit(line + 1, len - 1, data->ws_rule,
+ data->file, set, reset, ws);
} else if (line[0] == ' ')
data->lineno++;
else if (line[0] == '@') {
index ba7e834ca819b1d2ccce6cf125aa9f34efea8d5c..24d3e3de078c699ca6bb0dfd524c097bf220b4b2 100644 (file)
--- a/ws.c
+++ b/ws.c
}
/* If stream is non-NULL, emits the line after checking. */
-unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
- FILE *stream, const char *set,
- const char *reset, const char *ws)
+static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule,
+ FILE *stream, const char *set,
+ const char *reset, const char *ws)
{
unsigned result = 0;
int written = 0;
return result;
}
+void ws_check_emit(const char *line, int len, unsigned ws_rule,
+ FILE *stream, const char *set,
+ const char *reset, const char *ws)
+{
+ (void)ws_check_emit_1(line, len, ws_rule, stream, set, reset, ws);
+}
+
+unsigned ws_check(const char *line, int len, unsigned ws_rule)
+{
+ return ws_check_emit_1(line, len, ws_rule, NULL, NULL, NULL, NULL);
+}
+
/* Copy the line to the buffer while fixing whitespaces */
int ws_fix_copy(char *dst, const char *src, int len, unsigned ws_rule, int *error_count)
{