Updated Make rules so default is bp
This commit is contained in:
parent
eb0f18dc79
commit
af668004e8
8
Makefile
8
Makefile
@ -25,14 +25,14 @@ ALL_FLAGS=$(CFLAGS) $(OSFLAGS) -DBP_NAME="\"$(NAME)\"" $(EXTRA) $(CWARN) $(G) $(
|
||||
CFILES=pattern.c utils.c match.c files.c printmatch.c json.c utf8.c
|
||||
OBJFILES=$(CFILES:.c=.o)
|
||||
|
||||
$(NAME): $(OBJFILES) bp.c
|
||||
$(CC) $(ALL_FLAGS) -o $@ $(OBJFILES) bp.c
|
||||
|
||||
all: $(NAME) bp.1 lua
|
||||
|
||||
%.o: %.c %.h utf8.h
|
||||
$(CC) -c $(ALL_FLAGS) -o $@ $<
|
||||
|
||||
$(NAME): $(OBJFILES) bp.c
|
||||
$(CC) $(ALL_FLAGS) -o $@ $(OBJFILES) bp.c
|
||||
|
||||
bp.1: bp.1.md
|
||||
pandoc --lua-filter=.pandoc/bold-code.lua -s $< -t man -o $@
|
||||
|
||||
@ -43,7 +43,7 @@ clean:
|
||||
rm -f $(NAME) $(OBJFILES)
|
||||
|
||||
lua:
|
||||
cd Lua && make
|
||||
@cd Lua && make
|
||||
|
||||
test: $(NAME)
|
||||
./$(NAME) Comment -r '[@0]' >/dev/null
|
||||
|
20
match.c
20
match.c
@ -565,7 +565,22 @@ static match_t *match(match_ctx_t *ctx, const char *str, pat_t *pat)
|
||||
if (m1->pat->type == BP_CAPTURE && m1->pat->args.capture.name) {
|
||||
// Temporarily add a rule that the backref name matches the
|
||||
// exact string of the original match (no replacements)
|
||||
pat_t *backref = bp_raw_literal(m1->start, (size_t)(m1->end - m1->start));
|
||||
pat_t *backref;
|
||||
if (m1->children && m1->children[0]->pat->type == BP_CURDENT) {
|
||||
const char *linestart = m1->start;
|
||||
while (linestart > ctx->start && linestart[-1] != '\n') --linestart;
|
||||
|
||||
// Current indentation:
|
||||
char denter = *linestart;
|
||||
size_t dents = 0;
|
||||
if (denter == ' ' || denter == '\t') {
|
||||
while (linestart[dents] == denter && &linestart[dents] < ctx->end)
|
||||
++dents;
|
||||
}
|
||||
backref = bp_raw_literal(linestart, dents);
|
||||
} else {
|
||||
backref = bp_raw_literal(m1->start, (size_t)(m1->end - m1->start));
|
||||
}
|
||||
match_ctx_t ctx2 = *ctx;
|
||||
ctx2.cache = &(cache_t){0};
|
||||
ctx2.parent_ctx = ctx;
|
||||
@ -711,6 +726,9 @@ static match_t *match(match_ctx_t *ctx, const char *str, pat_t *pat)
|
||||
|
||||
return new_match(pat, start, &str[dents], NULL);
|
||||
}
|
||||
case BP_CURDENT: {
|
||||
return new_match(pat, str, str, NULL);
|
||||
}
|
||||
default: {
|
||||
errx(EXIT_FAILURE, "Unknown pattern type: %u", pat->type);
|
||||
return NULL;
|
||||
|
@ -320,6 +320,9 @@ static pat_t *_bp_simplepattern(const char *str, const char *end, bool inside_st
|
||||
if (*str == 'N') { // \N (nodent)
|
||||
all = either_pat(all, new_pat(BP_NODENT, itemstart, ++str, 1, -1));
|
||||
continue;
|
||||
} else if (*str == 'C') { // \C (current indent)
|
||||
all = either_pat(all, new_pat(BP_CURDENT, itemstart, ++str, 1, -1));
|
||||
continue;
|
||||
} else if (*str == 'i') { // \i (identifier char)
|
||||
all = either_pat(all, new_pat(BP_ID_CONTINUE, itemstart, ++str, 1, -1));
|
||||
continue;
|
||||
|
17
pattern.h
17
pattern.h
@ -29,14 +29,15 @@ enum pattype_e {
|
||||
BP_REPLACE = 17,
|
||||
BP_REF = 18,
|
||||
BP_NODENT = 19,
|
||||
BP_START_OF_FILE = 20,
|
||||
BP_START_OF_LINE = 21,
|
||||
BP_END_OF_FILE = 22,
|
||||
BP_END_OF_LINE = 23,
|
||||
BP_WORD_BOUNDARY = 24,
|
||||
BP_DEFINITIONS = 25,
|
||||
BP_TAGGED = 26,
|
||||
BP_LEFTRECURSION = 27,
|
||||
BP_CURDENT = 20,
|
||||
BP_START_OF_FILE = 21,
|
||||
BP_START_OF_LINE = 22,
|
||||
BP_END_OF_FILE = 23,
|
||||
BP_END_OF_LINE = 24,
|
||||
BP_WORD_BOUNDARY = 25,
|
||||
BP_DEFINITIONS = 26,
|
||||
BP_TAGGED = 27,
|
||||
BP_LEFTRECURSION = 28,
|
||||
};
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user