867
free_pattern_expr(opt->pattern_expression);
868
}
869
870
-static char *end_of_line(char *cp, unsigned long *left)
870
+static const char *end_of_line(const char *cp, unsigned long *left)
871
{
872
unsigned long l = *left;
873
while (l && *cp != '\n') {
908
opt->output(opt, opt->null_following_name ? "\0" : "\n", 1);
909
}
910
911
-static int patmatch(struct grep_pat *p, char *line, char *eol,
911
+static int patmatch(struct grep_pat *p,
912
+ const char *line, const char *eol,
913
regmatch_t *match, int eflags)
914
{
915
int hit;
923
return hit;
924
}
925
925
-static void strip_timestamp(char *bol, char **eol_p)
926
+static void strip_timestamp(const char *bol, const char **eol_p)
927
{
927
- char *eol = *eol_p;
928
+ const char *eol = *eol_p;
929
930
while (bol < --eol) {
931
if (*eol != '>')
944
{ "reflog ", 7 },
945
};
946
946
-static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
947
+static int match_one_pattern(struct grep_pat *p,
948
+ const char *bol, const char *eol,
949
enum grep_context ctx,
950
regmatch_t *pmatch, int eflags)
951
{
1025
return hit;
1026
}
1027
1026
-static int match_expr_eval(struct grep_opt *opt, struct grep_expr *x, char *bol,
1027
- char *eol, enum grep_context ctx, ssize_t *col,
1028
+static int match_expr_eval(struct grep_opt *opt, struct grep_expr *x,
1029
+ const char *bol, const char *eol,
1030
+ enum grep_context ctx, ssize_t *col,
1031
ssize_t *icol, int collect_hits)
1032
{
1033
int h = 0;
1094
return h;
1095
}
1096
1094
-static int match_expr(struct grep_opt *opt, char *bol, char *eol,
1097
+static int match_expr(struct grep_opt *opt,
1098
+ const char *bol, const char *eol,
1099
enum grep_context ctx, ssize_t *col,
1100
ssize_t *icol, int collect_hits)
1101
{
1103
return match_expr_eval(opt, x, bol, eol, ctx, col, icol, collect_hits);
1104
}
1105
1102
-static int match_line(struct grep_opt *opt, char *bol, char *eol,
1106
+static int match_line(struct grep_opt *opt,
1107
+ const char *bol, const char *eol,
1108
ssize_t *col, ssize_t *icol,
1109
enum grep_context ctx, int collect_hits)
1110
{
1136
return hit;
1137
}
1138
1134
-static int match_next_pattern(struct grep_pat *p, char *bol, char *eol,
1139
+static int match_next_pattern(struct grep_pat *p,
1140
+ const char *bol, const char *eol,
1141
enum grep_context ctx,
1142
regmatch_t *pmatch, int eflags)
1143
{
1158
return 1;
1159
}
1160
1155
-static int next_match(struct grep_opt *opt, char *bol, char *eol,
1161
+static int next_match(struct grep_opt *opt,
1162
+ const char *bol, const char *eol,
1163
enum grep_context ctx, regmatch_t *pmatch, int eflags)
1164
{
1165
struct grep_pat *p;
1215
}
1216
}
1217
1211
-static void show_line(struct grep_opt *opt, char *bol, char *eol,
1218
+static void show_line(struct grep_opt *opt,
1219
+ const char *bol, const char *eol,
1220
const char *name, unsigned lno, ssize_t cno, char sign)
1221
{
1222
int rest = eol - bol;
1305
pthread_mutex_unlock(&grep_attr_mutex);
1306
}
1307
1300
-static int match_funcname(struct grep_opt *opt, struct grep_source *gs, char *bol, char *eol)
1308
+static int match_funcname(struct grep_opt *opt, struct grep_source *gs,
1309
+ const char *bol, const char *eol)
1310
{
1311
xdemitconf_t *xecfg = opt->priv;
1312
if (xecfg && !xecfg->find_func) {
1333
}
1334
1335
static void show_funcname_line(struct grep_opt *opt, struct grep_source *gs,
1327
- char *bol, unsigned lno)
1336
+ const char *bol, unsigned lno)
1337
{
1338
while (bol > gs->buf) {
1330
- char *eol = --bol;
1339
+ const char *eol = --bol;
1340
1341
while (bol > gs->buf && bol[-1] != '\n')
1342
bol--;
1355
static int is_empty_line(const char *bol, const char *eol);
1356
1357
static void show_pre_context(struct grep_opt *opt, struct grep_source *gs,
1349
- char *bol, char *end, unsigned lno)
1358
+ const char *bol, const char *end, unsigned lno)
1359
{
1360
unsigned cur = lno, from = 1, funcname_lno = 0, orig_from;
1361
int funcname_needed = !!opt->funcname, comment_needed = 0;
1375
1376
/* Rewind. */
1377
while (bol > gs->buf && cur > from) {
1369
- char *next_bol = bol;
1370
- char *eol = --bol;
1378
+ const char *next_bol = bol;
1379
+ const char *eol = --bol;
1380
1381
while (bol > gs->buf && bol[-1] != '\n')
1382
bol--;
1407
1408
/* Back forward. */
1409
while (cur < lno) {
1401
- char *eol = bol, sign = (cur == funcname_lno) ? '=' : '-';
1410
+ const char *eol = bol, sign = (cur == funcname_lno) ? '=' : '-';
1411
1412
while (*eol != '\n')
1413
eol++;
1435
static int look_ahead(struct grep_opt *opt,
1436
unsigned long *left_p,
1437
unsigned *lno_p,
1429
- char **bol_p)
1438
+ const char **bol_p)
1439
{
1440
unsigned lno = *lno_p;
1432
- char *bol = *bol_p;
1441
+ const char *bol = *bol_p;
1442
struct grep_pat *p;
1434
- char *sp, *last_bol;
1443
+ const char *sp, *last_bol;
1444
regoff_t earliest = -1;
1445
1446
for (p = opt->pattern_list; p; p = p->next) {
1542
1543
static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int collect_hits)
1544
{
1536
- char *bol;
1537
- char *peek_bol = NULL;
1545
+ const char *bol;
1546
+ const char *peek_bol = NULL;
1547
unsigned long left;
1548
unsigned lno = 1;
1549
unsigned last_hit = 0;
1625
bol = gs->buf;
1626
left = gs->size;
1627
while (left) {
1619
- char *eol;
1628
+ const char *eol;
1629
int hit;
1630
ssize_t cno;
1631
ssize_t col = -1, icol = -1;
1709
}
1710
if (show_function && (!peek_bol || peek_bol < bol)) {
1711
unsigned long peek_left = left;
1703
- char *peek_eol = eol;
1712
+ const char *peek_eol = eol;
1713
1714
/*
1715
* Trailing empty lines are not interesting.