@@ -867,7 +867,7 @@ void free_grep_patterns(struct grep_opt *opt)
867
867
free_pattern_expr (opt -> pattern_expression );
868
868
}
869
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
871
{
872
872
unsigned long l = * left ;
873
873
while (l && * cp != '\n' ) {
@@ -908,7 +908,8 @@ static void show_name(struct grep_opt *opt, const char *name)
908
908
opt -> output (opt , opt -> null_following_name ? "\0" : "\n" , 1 );
909
909
}
910
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 ,
912
913
regmatch_t * match , int eflags )
913
914
{
914
915
int hit ;
@@ -922,9 +923,9 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,
922
923
return hit ;
923
924
}
924
925
925
- static void strip_timestamp (char * bol , char * * eol_p )
926
+ static void strip_timestamp (const char * bol , const char * * eol_p )
926
927
{
927
- char * eol = * eol_p ;
928
+ const char * eol = * eol_p ;
928
929
929
930
while (bol < -- eol ) {
930
931
if (* eol != '>' )
@@ -943,7 +944,8 @@ static struct {
943
944
{ "reflog " , 7 },
944
945
};
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 ,
947
949
enum grep_context ctx ,
948
950
regmatch_t * pmatch , int eflags )
949
951
{
@@ -1023,8 +1025,9 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
1023
1025
return hit ;
1024
1026
}
1025
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 ,
1028
1031
ssize_t * icol , int collect_hits )
1029
1032
{
1030
1033
int h = 0 ;
@@ -1091,15 +1094,17 @@ static int match_expr_eval(struct grep_opt *opt, struct grep_expr *x, char *bol,
1091
1094
return h ;
1092
1095
}
1093
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 ,
1095
1099
enum grep_context ctx , ssize_t * col ,
1096
1100
ssize_t * icol , int collect_hits )
1097
1101
{
1098
1102
struct grep_expr * x = opt -> pattern_expression ;
1099
1103
return match_expr_eval (opt , x , bol , eol , ctx , col , icol , collect_hits );
1100
1104
}
1101
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 ,
1103
1108
ssize_t * col , ssize_t * icol ,
1104
1109
enum grep_context ctx , int collect_hits )
1105
1110
{
@@ -1131,7 +1136,8 @@ static int match_line(struct grep_opt *opt, char *bol, char *eol,
1131
1136
return hit ;
1132
1137
}
1133
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 ,
1135
1141
enum grep_context ctx ,
1136
1142
regmatch_t * pmatch , int eflags )
1137
1143
{
@@ -1152,7 +1158,8 @@ static int match_next_pattern(struct grep_pat *p, char *bol, char *eol,
1152
1158
return 1 ;
1153
1159
}
1154
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 ,
1156
1163
enum grep_context ctx , regmatch_t * pmatch , int eflags )
1157
1164
{
1158
1165
struct grep_pat * p ;
@@ -1208,7 +1215,8 @@ static void show_line_header(struct grep_opt *opt, const char *name,
1208
1215
}
1209
1216
}
1210
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 ,
1212
1220
const char * name , unsigned lno , ssize_t cno , char sign )
1213
1221
{
1214
1222
int rest = eol - bol ;
@@ -1297,7 +1305,8 @@ static inline void grep_attr_unlock(void)
1297
1305
pthread_mutex_unlock (& grep_attr_mutex );
1298
1306
}
1299
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 )
1301
1310
{
1302
1311
xdemitconf_t * xecfg = opt -> priv ;
1303
1312
if (xecfg && !xecfg -> find_func ) {
@@ -1324,10 +1333,10 @@ static int match_funcname(struct grep_opt *opt, struct grep_source *gs, char *bo
1324
1333
}
1325
1334
1326
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 )
1328
1337
{
1329
1338
while (bol > gs -> buf ) {
1330
- char * eol = -- bol ;
1339
+ const char * eol = -- bol ;
1331
1340
1332
1341
while (bol > gs -> buf && bol [-1 ] != '\n' )
1333
1342
bol -- ;
@@ -1346,7 +1355,7 @@ static void show_funcname_line(struct grep_opt *opt, struct grep_source *gs,
1346
1355
static int is_empty_line (const char * bol , const char * eol );
1347
1356
1348
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 )
1350
1359
{
1351
1360
unsigned cur = lno , from = 1 , funcname_lno = 0 , orig_from ;
1352
1361
int funcname_needed = !!opt -> funcname , comment_needed = 0 ;
@@ -1366,8 +1375,8 @@ static void show_pre_context(struct grep_opt *opt, struct grep_source *gs,
1366
1375
1367
1376
/* Rewind. */
1368
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 ;
1371
1380
1372
1381
while (bol > gs -> buf && bol [-1 ] != '\n' )
1373
1382
bol -- ;
@@ -1398,7 +1407,7 @@ static void show_pre_context(struct grep_opt *opt, struct grep_source *gs,
1398
1407
1399
1408
/* Back forward. */
1400
1409
while (cur < lno ) {
1401
- char * eol = bol , sign = (cur == funcname_lno ) ? '=' : '-' ;
1410
+ const char * eol = bol , sign = (cur == funcname_lno ) ? '=' : '-' ;
1402
1411
1403
1412
while (* eol != '\n' )
1404
1413
eol ++ ;
@@ -1426,12 +1435,12 @@ static int should_lookahead(struct grep_opt *opt)
1426
1435
static int look_ahead (struct grep_opt * opt ,
1427
1436
unsigned long * left_p ,
1428
1437
unsigned * lno_p ,
1429
- char * * bol_p )
1438
+ const char * * bol_p )
1430
1439
{
1431
1440
unsigned lno = * lno_p ;
1432
- char * bol = * bol_p ;
1441
+ const char * bol = * bol_p ;
1433
1442
struct grep_pat * p ;
1434
- char * sp , * last_bol ;
1443
+ const char * sp , * last_bol ;
1435
1444
regoff_t earliest = -1 ;
1436
1445
1437
1446
for (p = opt -> pattern_list ; p ; p = p -> next ) {
@@ -1533,8 +1542,8 @@ static int is_empty_line(const char *bol, const char *eol)
1533
1542
1534
1543
static int grep_source_1 (struct grep_opt * opt , struct grep_source * gs , int collect_hits )
1535
1544
{
1536
- char * bol ;
1537
- char * peek_bol = NULL ;
1545
+ const char * bol ;
1546
+ const char * peek_bol = NULL ;
1538
1547
unsigned long left ;
1539
1548
unsigned lno = 1 ;
1540
1549
unsigned last_hit = 0 ;
@@ -1616,7 +1625,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
1616
1625
bol = gs -> buf ;
1617
1626
left = gs -> size ;
1618
1627
while (left ) {
1619
- char * eol ;
1628
+ const char * eol ;
1620
1629
int hit ;
1621
1630
ssize_t cno ;
1622
1631
ssize_t col = -1 , icol = -1 ;
@@ -1700,7 +1709,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
1700
1709
}
1701
1710
if (show_function && (!peek_bol || peek_bol < bol )) {
1702
1711
unsigned long peek_left = left ;
1703
- char * peek_eol = eol ;
1712
+ const char * peek_eol = eol ;
1704
1713
1705
1714
/*
1706
1715
* Trailing empty lines are not interesting.
0 commit comments