1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-11-27 15:01:00 +01:00

zsh-workers/8319

This commit is contained in:
Tanaka Akira 1999-10-18 09:57:00 +00:00
parent 2246999a84
commit 910dc80a58
6 changed files with 155 additions and 39 deletions

View file

@ -427,8 +427,13 @@ patcompile(char *exp, int inflags, char **endexp)
* The pattern was compiled in a fixed buffer: unless told otherwise,
* we stick the compiled pattern on the heap. This is necessary
* for files where we will often be compiling multiple segments at once.
* But if we get the ZDUP flag w always put it in zalloc()ed memory.
*/
if (!(patflags & PAT_STATIC)) {
if (patflags & PAT_ZDUP) {
Patprog newp = (Patprog)zalloc(patsize);
memcpy((char *)newp, (char *)p, patsize);
p = newp;
} else if (!(patflags & PAT_STATIC)) {
Patprog newp = (Patprog)zhalloc(patsize);
memcpy((char *)newp, (char *)p, patsize);
p = newp;
@ -2188,6 +2193,32 @@ static int patrepeat(Upat p)
return count;
}
/* Duplicate a patprog. */
/**/
Patprog
duppatprog(Patprog prog)
{
if (prog && prog != dummy_patprog1 && prog != dummy_patprog2) {
Patprog ret = (Patprog) alloc(prog->size);
memcpy(ret, prog, prog->size);
return ret;
}
return prog;
}
/* Free a patprog. */
/**/
void
freepatprog(Patprog prog)
{
if (prog && prog != dummy_patprog1 && prog != dummy_patprog2)
zfree(prog, prog->size);
}
/**/
#ifdef ZSH_PAT_DEBUG