mirror of
https://github.com/ascii-boxes/boxes.git
synced 2024-12-14 02:40:38 +01:00
Bugfix: REPLACE "^" with "a" caused a hangup. Now automatically declaring
matches which have a length of zero to be of scope "once".
This commit is contained in:
parent
3a6fef29c6
commit
f0c4f546d6
@ -3,7 +3,7 @@
|
|||||||
* Date created: Copyright (c) 1986 by University of Toronto.
|
* Date created: Copyright (c) 1986 by University of Toronto.
|
||||||
* Author: Henry Spencer.
|
* Author: Henry Spencer.
|
||||||
* Extensions and modifications by Thomas Jensen
|
* Extensions and modifications by Thomas Jensen
|
||||||
* Version: $Id: regsub.c,v 1.2 1999/04/05 19:39:27 tsjensen Exp tsjensen $
|
* Version: $Id: regsub.c,v 1.3 1999/04/12 18:13:57 tsjensen Exp tsjensen $
|
||||||
* Language: K&R C (traditional)
|
* Language: K&R C (traditional)
|
||||||
* World Wide Web: http://home.pages.de/~jensen/boxes/
|
* World Wide Web: http://home.pages.de/~jensen/boxes/
|
||||||
* Purpose: Perform substitutions after a regexp match
|
* Purpose: Perform substitutions after a regexp match
|
||||||
@ -24,6 +24,9 @@
|
|||||||
* Revision History:
|
* Revision History:
|
||||||
*
|
*
|
||||||
* $Log: regsub.c,v $
|
* $Log: regsub.c,v $
|
||||||
|
* Revision 1.3 1999/04/12 18:13:57 tsjensen
|
||||||
|
* Added missing '$' to rcs id string, changed from #ident to char
|
||||||
|
*
|
||||||
* Revision 1.2 1999/04/05 19:39:27 tsjensen
|
* Revision 1.2 1999/04/05 19:39:27 tsjensen
|
||||||
* Hopefully fixed a potential buffer overrun problem in regsub()
|
* Hopefully fixed a potential buffer overrun problem in regsub()
|
||||||
*
|
*
|
||||||
@ -39,7 +42,7 @@
|
|||||||
#include "regmagic.h"
|
#include "regmagic.h"
|
||||||
|
|
||||||
char rcsid_regsub_c[] =
|
char rcsid_regsub_c[] =
|
||||||
"$Id$";
|
"$Id: regsub.c,v 1.3 1999/04/12 18:13:57 tsjensen Exp tsjensen $";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -147,7 +150,6 @@ myregsub (prog, orig, orig_len, repstr, dest, dest_size, mode)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
rc = regexec (prog, sp);
|
rc = regexec (prog, sp);
|
||||||
|
|
||||||
if (!rc) break;
|
if (!rc) break;
|
||||||
|
|
||||||
partlen = prog->startp[0] - sp;
|
partlen = prog->startp[0] - sp;
|
||||||
@ -164,6 +166,8 @@ myregsub (prog, orig, orig_len, repstr, dest, dest_size, mode)
|
|||||||
return dest_size - 1;
|
return dest_size - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* fprintf (stderr, "regsub (%p, \"%s\", \"%s\", %d);\n", */
|
||||||
|
/* prog, repstr, dp, rest_size); */
|
||||||
fill += regsub (prog, repstr, dp, rest_size);
|
fill += regsub (prog, repstr, dp, rest_size);
|
||||||
dp = dest + fill;
|
dp = dest + fill;
|
||||||
sp = prog->endp[0];
|
sp = prog->endp[0];
|
||||||
@ -174,6 +178,10 @@ myregsub (prog, orig, orig_len, repstr, dest, dest_size, mode)
|
|||||||
return dest_size - 1;
|
return dest_size - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* fprintf (stderr, "dest = \"%s\";\n", dest); */
|
||||||
|
if (prog->startp[0] == prog->endp[0])
|
||||||
|
break; /* match "^" or "$" only once */
|
||||||
|
|
||||||
} while (mode == 'g');
|
} while (mode == 'g');
|
||||||
|
|
||||||
partlen = orig + orig_len - sp;
|
partlen = orig + orig_len - sp;
|
||||||
|
Loading…
Reference in New Issue
Block a user