Skip to content

Commit bf64cf4

Browse files
committed
fix an off-by-one in AT_LAST(), needed for "make check"
1 parent 13227ca commit bf64cf4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

regexp_system.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $MawkId: regexp_system.c,v 1.23 2010/06/25 00:52:32 tom Exp $
2+
* $MawkId: regexp_system.c,v 1.24 2010/06/25 08:30:10 tom Exp $
33
*/
44
#include <sys/types.h>
55
#include <stdio.h>
@@ -26,7 +26,7 @@ static int err_code = 0;
2626
#define TRACE(params) /*nothing */
2727
#endif
2828

29-
#define AT_LAST() ((size_t) (source + 1 - base) >= limit)
29+
#define AT_LAST() ((size_t) (source - base) >= limit)
3030
#define MORE_CH() ((size_t) (source - base) < limit)
3131
#define NEXT_CH() (char) (MORE_CH() ? *source : 0)
3232
#define LIMITED() (char) (MORE_CH() ? *source++ : 0)
@@ -214,6 +214,7 @@ prepare_regexp(char *regexp, const char *source, size_t limit)
214214
switch (ch) {
215215
case '\\':
216216
if (AT_LAST()) {
217+
errmsg(-1, "dangling backslash");
217218
*tail++ = '\\';
218219
*tail++ = '\\';
219220
} else {

0 commit comments

Comments
 (0)