summaryrefslogtreecommitdiffhomepage
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-24 19:18:18 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-24 19:18:18 +0000
commitb78d1c045facbebd21ea94072b6905e40e0147cf (patch)
tree953d97430baefc87afd9bceb825bd5d8784e7aaa /miscutils
parent4f82bdb050024b3475f5371a0612b1fb0fc4c09f (diff)
less: shrink
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/less.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 7351a634d..da595f428 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -1175,41 +1175,40 @@ static void goto_mark(void)
static char opp_bracket(char bracket)
{
switch (bracket) {
- case '{': case '[':
- return bracket + 2;
- case '(':
- return ')';
- case '}': case ']':
- return bracket - 2;
- case ')':
- return '(';
- }
- return 0;
+ case '{': case '[': /* '}' == '{' + 2. Same for '[' */
+ bracket++;
+ case '(': /* ')' == '(' + 1 */
+ bracket++;
+ break;
+ case '}': case ']':
+ bracket--;
+ case ')':
+ bracket--;
+ break;
+ };
+ return bracket;
}
static void match_right_bracket(char bracket)
{
- int bracket_line = -1;
int i;
if (strchr(flines[cur_fline], bracket) == NULL) {
print_statusline("No bracket in top line");
return;
}
+ bracket = opp_bracket(bracket);
for (i = cur_fline + 1; i < max_fline; i++) {
- if (strchr(flines[i], opp_bracket(bracket)) != NULL) {
- bracket_line = i;
- break;
+ if (strchr(flines[i], bracket) != NULL) {
+ buffer_line(i);
+ return;
}
}
- if (bracket_line == -1)
- print_statusline("No matching bracket found");
- buffer_line(bracket_line - max_displayed_line);
+ print_statusline("No matching bracket found");
}
static void match_left_bracket(char bracket)
{
- int bracket_line = -1;
int i;
if (strchr(flines[cur_fline + max_displayed_line], bracket) == NULL) {
@@ -1217,15 +1216,14 @@ static void match_left_bracket(char bracket)
return;
}
+ bracket = opp_bracket(bracket);
for (i = cur_fline + max_displayed_line; i >= 0; i--) {
- if (strchr(flines[i], opp_bracket(bracket)) != NULL) {
- bracket_line = i;
- break;
+ if (strchr(flines[i], bracket) != NULL) {
+ buffer_line(i);
+ return;
}
}
- if (bracket_line == -1)
- print_statusline("No matching bracket found");
- buffer_line(bracket_line);
+ print_statusline("No matching bracket found");
}
#endif /* FEATURE_LESS_BRACKETS */