-#ifdef NET2_REGEX
-/*
- * resub()
- * apply the replacement to the matched expression. expand out the old
- * style ed(1) subexpression expansion.
- * Return:
- * -1 if error, or the number of characters added to the destination.
- */
-
-#ifdef __STDC__
-static int
-resub(regexp *prog, char *src, char *dest, register char *destend)
-#else
-static int
-resub(prog, src, dest, destend)
- regexp *prog;
- char *src;
- char *dest;
- register char *destend;
-#endif
-{
- register char *spt;
- register char *dpt;
- register char c;
- register int no;
- register int len;
-
- spt = src;
- dpt = dest;
- while ((dpt < destend) && ((c = *spt++) != '\0')) {
- if (c == '&')
- no = 0;
- else if ((c == '\\') && (*spt >= '0') && (*spt <= '9'))
- no = *spt++ - '0';
- else {
- if ((c == '\\') && ((*spt == '\\') || (*spt == '&')))
- c = *spt++;
- *dpt++ = c;
- continue;
- }
- if ((prog->startp[no] == NULL) || (prog->endp[no] == NULL) ||
- ((len = prog->endp[no] - prog->startp[no]) <= 0))
- continue;
-
- /*
- * copy the subexpression to the destination.
- * fail if we run out of space or the match string is damaged
- */
- if (len > (destend - dpt))
- len = destend - dpt;
- if (l_strncpy(dpt, prog->startp[no], len) != len)
- return(-1);
- dpt += len;
- }
- return(dpt - dest);
-}
-
-#else
-