static void resizehashtable(HashTable ht, int newsize) { struct hashnode **ha, *hn, *hp; int i; /* free all the hash nodes */ ha = ht->nodes; for (i = 0; i < ht->hsize; i++, ha++) { for (hn = *ha; hn;) { hp = hn->next; ht->freenode(hn); hn = hp; } } /* If new size desired is different from current size, * * we free it and allocate a new nodes array. */ if (ht->hsize != newsize) { zfree(ht->nodes, ht->hsize * sizeof(HashNode)); ht->nodes = (HashNode *) zshcalloc(newsize * sizeof(HashNode)); ht->hsize = newsize; } else { /* else we just re-zero the current nodes array */ memset(ht->nodes, 0, newsize * sizeof(HashNode)); } ht->ct = 0; }
int setup_(UNUSED(Module m)) { /* Set up editor entry points */ zle_entry_ptr = zle_main_entry; zle_load_state = 1; /* initialise the thingies */ init_thingies(); lbindk = NULL; /* miscellaneous initialisations */ stackhist = stackcs = -1; kungetbuf = (char *) zalloc(kungetsz = 32); comprecursive = 0; rdstrs = NULL; /* initialise the keymap system */ init_keymaps(); varedarg = NULL; incompfunc = incompctlfunc = hascompmod = 0; hascompwidgets = 0; clwords = (char **) zshcalloc((clwsize = 16) * sizeof(char *)); return 0; }
static Thingy makethingynode(void) { Thingy t = (Thingy) zshcalloc(sizeof(*t)); t->flags = DISABLED; return t; }
void inungetc(int c) { if (!lexstop) { if (inbufptr != inbuf) { #ifdef DEBUG /* Just for debugging: enable only if foul play suspected. */ if (inbufptr[-1] != (char) c) fprintf(stderr, "Warning: backing up wrong character.\n"); #endif /* Just decrement the pointer: if it's not the same * character being pushed back, we're in trouble anyway. */ inbufptr--; inbufct++; inbufleft++; if (((inbufflags & INP_LINENO) || !strin) && c == '\n') lineno--; } #ifdef DEBUG else if (!(inbufflags & INP_CONT)) { /* Just for debugging */ fprintf(stderr, "Attempt to inungetc() at start of input.\n"); } #endif else { /* * The character is being backed up from a previous input stack * layer. However, there was an expansion in the middle, so we * can't back up where we want to. Instead, we just push it * onto the input stack as an extra character. */ char *cback = (char *)zshcalloc(2); cback[0] = (char) c; inpush(cback, INP_FREE|INP_CONT, NULL); } /* If we are back at the start of a segment, * we may need to restore an alias popped from the stack. * Note this may be a dummy (history expansion) entry. */ if (inbufptr == inbufpush && inbufflags & INP_ALCONT) { /* * Go back up the stack over all entries which were alias * expansions and were pushed with nothing remaining to read. */ do { if (instacktop->alias) instacktop->alias->inuse = 1; instacktop++; } while ((instacktop->flags & INP_ALCONT) && !instacktop->bufleft); inbufflags = INP_CONT|INP_ALIAS; inbufleft = 0; inbuf = inbufptr = ""; } } }
mod_export Alias createaliasnode(char *txt, int flags) { Alias al; al = (Alias) zshcalloc(sizeof *al); al->flags = flags; al->text = txt; al->inuse = 0; return al; }
void hashdir(char **dirp) { Cmdnam cn; DIR *dir; char *fn; #if defined(_WIN32) || defined(__CYGWIN__) char *exe; #endif /* _WIN32 || _CYGWIN__ */ if (isrelative(*dirp) || !(dir = opendir(unmeta(*dirp)))) return; while ((fn = zreaddir(dir, 1))) { if (!cmdnamtab->getnode(cmdnamtab, fn)) { cn = (Cmdnam) zshcalloc(sizeof *cn); cn->flags = 0; cn->u.name = dirp; cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn); } #if defined(_WIN32) || defined(__CYGWIN__) /* Hash foo.exe as foo, since when no real foo exists, foo.exe will get executed by DOS automatically. This quiets spurious corrections when CORRECT or CORRECT_ALL is set. */ if ((exe = strrchr(fn, '.')) && (exe[1] == 'E' || exe[1] == 'e') && (exe[2] == 'X' || exe[2] == 'x') && (exe[3] == 'E' || exe[3] == 'e') && exe[4] == 0) { *exe = 0; if (!cmdnamtab->getnode(cmdnamtab, fn)) { cn = (Cmdnam) zshcalloc(sizeof *cn); cn->flags = 0; cn->u.name = dirp; cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn); } } #endif /* _WIN32 || __CYGWIN__ */ } closedir(dir); }
static int bin_listattr(char *nam, char **argv, Options ops, UNUSED(int func)) { int ret = 0; int val_len, list_len = 0, slen; char *value, *file = argv[0], *param = argv[1]; int symlink = OPT_ISSET(ops, 'h'); unmetafy(file, &slen); val_len = xlistxattr(file, NULL, 0, symlink); if (val_len == 0) { if (param) unsetparam(param); return 0; } if (val_len > 0) { value = (char *)zalloc(val_len+1); list_len = xlistxattr(file, value, val_len, symlink); if (list_len > 0 && list_len <= val_len) { char *p = value; if (param) { if (strlen(value) + 1 == list_len) setsparam(param, metafy(value, list_len-1, META_DUP)); else { int arrlen = 0; char **array = NULL, **arrptr = NULL; while (p < &value[list_len]) { arrlen++; p += strlen(p) + 1; } arrptr = array = (char **)zshcalloc((arrlen+1) * sizeof(char *)); p = value; while (p < &value[list_len]) { *arrptr++ = metafy(p, -1, META_DUP); p += strlen(p) + 1; } setaparam(param, array); } } else while (p < &value[list_len]) { printf("%s\n", p); p += strlen(p) + 1; } } zfree(value, val_len+1); } if (val_len < 0 || list_len < 0 || list_len > val_len) { zwarnnam(nam, "%s: %e", metafy(file, slen, META_NOALLOC), errno); ret = 1 + (list_len > val_len || list_len < 0); } return ret; }
/* "allocate" a tcp_session */ static Tcp_session zts_alloc(int ztflags) { Tcp_session sess; sess = (Tcp_session)zshcalloc(sizeof(struct tcp_session)); if (!sess) return NULL; sess->fd=-1; sess->flags=ztflags; zinsertlinknode(ztcp_sessions, lastnode(ztcp_sessions), (void *)sess); return sess; }
int setup_(UNUSED(Module m)) { char **bpaste; /* Set up editor entry points */ zle_entry_ptr = zle_main_entry; zle_load_state = 1; /* initialise the thingies */ init_thingies(); lbindk = NULL; /* miscellaneous initialisations */ stackhist = stackcs = -1; kungetbuf = (char *) zalloc(kungetsz = 32); comprecursive = 0; rdstrs = NULL; /* initialise the keymap system */ init_keymaps(); varedarg = NULL; incompfunc = incompctlfunc = hascompmod = 0; hascompwidgets = 0; clwords = (char **) zshcalloc((clwsize = 16) * sizeof(char *)); bpaste = zshcalloc(3*sizeof(char *)); bpaste[0] = ztrdup("\033[?2004h"); bpaste[1] = ztrdup("\033[?2004l"); /* Intended to be global, no WARNCREATEGLOBAL check. */ assignaparam("zle_bracketed_paste", bpaste, 0); return 0; }
mod_export HashTable newhashtable(int size, UNUSED(char const *name), UNUSED(PrintTableStats printinfo)) { HashTable ht; ht = (HashTable) zshcalloc(sizeof *ht); #ifdef ZSH_HASH_DEBUG ht->next = NULL; if(!firstht) firstht = ht; ht->last = lastht; if(lastht) lastht->next = ht; lastht = ht; ht->printinfo = printinfo ? printinfo : printhashtabinfo; ht->tablename = ztrdup(name); #endif /* ZSH_HASH_DEBUG */ ht->nodes = (HashNode *) zshcalloc(size * sizeof(HashNode)); ht->hsize = size; ht->ct = 0; ht->scan = NULL; ht->scantab = NULL; return ht; }
static void set_killring(UNUSED(Param pm), char **x) { int kcnt; Cutbuffer kptr; char **p; if (kring) { for (kptr = kring, kcnt = 0; kcnt < kringsize; kcnt++, kptr++) if (kptr->buf) free(kptr->buf); zfree(kring, kringsize * sizeof(struct cutbuffer)); kring = NULL; kringsize = kringnum = 0; } if (x) { /* * Insert the elements into the kill ring. * Regardless of the old order, we number it with the current * entry first. * * Be careful to add elements by looping backwards; this * fits in with how we cycle the ring. */ int kpos = 0; kringsize = arrlen(x); if (kringsize != 0) { kring = (Cutbuffer)zshcalloc(kringsize * sizeof(struct cutbuffer)); for (p = x; *p; p++) { int n, len = strlen(*p); kptr = kring + kpos; kptr->buf = stringaszleline(*p, 0, &n, NULL, NULL); kptr->len = n; zfree(*p, len+1); kpos = (kpos + kringsize -1 ) % kringsize; } } free(x); } }
mod_export void restrict_range(int b, int e) { int wl = arrlen(compwords) - 1; if (wl && b >= 0 && e >= 0 && (b > 0 || e < wl)) { int i; char **p, **q, **pp; if (e > wl) e = wl; i = e - b + 1; p = (char **) zshcalloc((i + 1) * sizeof(char *)); for (q = p, pp = compwords + b; i; i--, q++, pp++) *q = ztrdup(*pp); freearray(compwords); compwords = p; compcurrent -= b; } }
static void compunsetfn(Param pm, int exp) { if (exp) { if (pm->u.data) { if (PM_TYPE(pm->node.flags) == PM_SCALAR) { zsfree(*((char **) pm->u.data)); *((char **) pm->u.data) = ztrdup(""); } else if (PM_TYPE(pm->node.flags) == PM_ARRAY) { freearray(*((char ***) pm->u.data)); *((char ***) pm->u.data) = zshcalloc(sizeof(char *)); } else if (PM_TYPE(pm->node.flags) == PM_HASHED) { deleteparamtable(pm->u.hash); pm->u.hash = NULL; } } } else if (PM_TYPE(pm->node.flags) == PM_HASHED) { Param *p; int i; deletehashtable(pm->u.hash); pm->u.hash = NULL; for (p = compkpms, i = CP_KEYPARAMS; i--; p++) *p = NULL; } if (!exp) { Param *p; int i; for (p = comprpms, i = CP_REALPARAMS; i; p++, i--) if (*p == pm) { *p = NULL; break; } } }
static void expandhashtable(HashTable ht) { struct hashnode **onodes, **ha, *hn, *hp; int i, osize; osize = ht->hsize; onodes = ht->nodes; ht->hsize = osize * 4; ht->nodes = (HashNode *) zshcalloc(ht->hsize * sizeof(HashNode)); ht->ct = 0; /* scan through the old list of nodes, and * * rehash them into the new list of nodes */ for (i = 0, ha = onodes; i < osize; i++, ha++) { for (hn = *ha; hn;) { hp = hn->next; ht->addnode(ht, hn->nam, hn); hn = hp; } } zfree(onodes, osize * sizeof(HashNode)); }
static int bin_stat(char *name, char **args, Options ops, UNUSED(int func)) { char **aptr, *arrnam = NULL, **array = NULL, **arrptr = NULL; char *hashnam = NULL, **hash = NULL, **hashptr = NULL; int len, iwhich = -1, ret = 0, flags = 0, arrsize = 0, fd = 0; struct stat statbuf; int found = 0, nargs; timefmt = "%a %b %e %k:%M:%S %Z %Y"; for (; *args && (**args == '+' || **args == '-'); args++) { char *arg = *args+1; if (!*arg || *arg == '-' || *arg == '+') { args++; break; } if (**args == '+') { if (found) break; len = strlen(arg); for (aptr = statelts; *aptr; aptr++) if (!strncmp(*aptr, arg, len)) { found++; iwhich = aptr - statelts; } if (found > 1) { zwarnnam(name, "%s: ambiguous stat element", arg); return 1; } else if (found == 0) { zwarnnam(name, "%s: no such stat element", arg); return 1; } /* if name of link requested, turn on lstat */ if (iwhich == ST_READLINK) ops->ind['L'] = 1; flags |= STF_PICK; } else { for (; *arg; arg++) { if (strchr("glLnNorstT", *arg)) ops->ind[STOUC(*arg)] = 1; else if (*arg == 'A') { if (arg[1]) { arrnam = arg+1; } else if (!(arrnam = *++args)) { zwarnnam(name, "missing parameter name"); return 1; } flags |= STF_ARRAY; break; } else if (*arg == 'H') { if (arg[1]) { hashnam = arg+1; } else if (!(hashnam = *++args)) { zwarnnam(name, "missing parameter name"); return 1; } flags |= STF_HASH; break; } else if (*arg == 'f') { char *sfd; ops->ind['f'] = 1; if (arg[1]) { sfd = arg+1; } else if (!(sfd = *++args)) { zwarnnam(name, "missing file descriptor"); return 1; } fd = zstrtol(sfd, &sfd, 10); if (*sfd) { zwarnnam(name, "bad file descriptor"); return 1; } break; } else if (*arg == 'F') { if (arg[1]) { timefmt = arg+1; } else if (!(timefmt = *++args)) { zwarnnam(name, "missing time format"); return 1; } /* force string format in order to use time format */ ops->ind['s'] = 1; break; } else { zwarnnam(name, "bad option: -%c", *arg); return 1; } } } } if ((flags & STF_ARRAY) && (flags & STF_HASH)) { /* We don't implement setting multiple variables at once */ zwarnnam(name, "both array and hash requested"); return 1; /* Alternate method would be to make -H blank arrnam etc etc * * and so get 'silent loss' of earlier choice, which would * * be similar to stat -A foo -A bar filename */ } if (OPT_ISSET(ops,'l')) { /* list types and return: can also list to array */ if (arrnam) { arrptr = array = (char **)zalloc((ST_COUNT+1)*sizeof(char *)); array[ST_COUNT] = NULL; } for (aptr = statelts; *aptr; aptr++) { if (arrnam) { *arrptr++ = ztrdup(*aptr); } else { printf("%s", *aptr); if (aptr[1]) putchar(' '); } } if (arrnam) { setaparam(arrnam, array); if (errflag) return 1; } else putchar('\n'); return 0; } if (!*args && !OPT_ISSET(ops,'f')) { zwarnnam(name, "no files given"); return 1; } else if (*args && OPT_ISSET(ops,'f')) { zwarnnam(name, "no files allowed with -f"); return 1; } nargs = 0; if (OPT_ISSET(ops,'f')) nargs = 1; else for (aptr = args; *aptr; aptr++) nargs++; if (OPT_ISSET(ops,'g')) { flags |= STF_GMT; ops->ind['s'] = 1; } if (OPT_ISSET(ops,'s') || OPT_ISSET(ops,'r')) flags |= STF_STRING; if (OPT_ISSET(ops,'r') || !OPT_ISSET(ops,'s')) flags |= STF_RAW; if (OPT_ISSET(ops,'n')) flags |= STF_FILE; if (OPT_ISSET(ops,'o')) flags |= STF_OCTAL; if (OPT_ISSET(ops,'t')) flags |= STF_NAME; if (!(arrnam || hashnam)) { if (nargs > 1) flags |= STF_FILE; if (!(flags & STF_PICK)) flags |= STF_NAME; } if (OPT_ISSET(ops,'N') || OPT_ISSET(ops,'f')) flags &= ~STF_FILE; if (OPT_ISSET(ops,'T') || OPT_ISSET(ops,'H')) flags &= ~STF_NAME; if (hashnam) { if (nargs > 1) { zwarnnam(name, "only one file allowed with -H"); return 1; } arrsize = (flags & STF_PICK) ? 1 : ST_COUNT; if (flags & STF_FILE) arrsize++; hashptr = hash = (char **)zshcalloc((arrsize+1)*2*sizeof(char *)); } if (arrnam) { arrsize = (flags & STF_PICK) ? 1 : ST_COUNT; if (flags & STF_FILE) arrsize++; arrsize *= nargs; arrptr = array = (char **)zshcalloc((arrsize+1)*sizeof(char *)); } for (; OPT_ISSET(ops,'f') || *args; args++) { char outbuf[PATH_MAX + 9]; /* "link " + link name + NULL */ int rval = OPT_ISSET(ops,'f') ? fstat(fd, &statbuf) : OPT_ISSET(ops,'L') ? lstat(unmeta(*args), &statbuf) : stat(unmeta(*args), &statbuf); if (rval) { if (OPT_ISSET(ops,'f')) sprintf(outbuf, "%d", fd); zwarnnam(name, "%s: %e", OPT_ISSET(ops,'f') ? outbuf : *args, errno); ret = 1; if (OPT_ISSET(ops,'f') || arrnam) break; else continue; } if (flags & STF_FILE) { if (arrnam) *arrptr++ = ztrdup(*args); else if (hashnam) { *hashptr++ = ztrdup(HNAMEKEY); *hashptr++ = ztrdup(*args); } else printf("%s%s", *args, (flags & STF_PICK) ? " " : ":\n"); } if (iwhich > -1) { statprint(&statbuf, outbuf, *args, iwhich, flags); if (arrnam) *arrptr++ = metafy(outbuf, -1, META_DUP); else if (hashnam) { /* STF_NAME explicitly turned off for ops.ind['H'] above */ *hashptr++ = ztrdup(statelts[iwhich]); *hashptr++ = metafy(outbuf, -1, META_DUP); } else printf("%s\n", outbuf); } else { int i; for (i = 0; i < ST_COUNT; i++) { statprint(&statbuf, outbuf, *args, i, flags); if (arrnam) *arrptr++= metafy(outbuf, -1, META_DUP); else if (hashnam) { /* STF_NAME explicitly turned off for ops.ind['H'] above */ *hashptr++ = ztrdup(statelts[i]); *hashptr++ = metafy(outbuf, -1, META_DUP); } else printf("%s\n", outbuf); } } if (OPT_ISSET(ops,'f')) break; if (!arrnam && !hashnam && args[1] && !(flags & STF_PICK)) putchar('\n'); } if (arrnam) { if (ret) freearray(array); else { setaparam(arrnam, array); if (errflag) return 1; } } if (hashnam) { if (ret) freearray(hash); else { sethparam(hashnam, hash); if (errflag) return 1; } } return ret; }
mod_export char * promptexpand(char *s, int ns, char *rs, char *Rs, unsigned int *txtchangep) { struct buf_vars new_vars; if(!s) return ztrdup(""); if ((termflags & TERM_UNKNOWN) && (unset(INTERACTIVE))) init_term(); if (isset(PROMPTSUBST)) { int olderr = errflag; int oldval = lastval; s = dupstring(s); if (!parsestr(s)) singsub(&s); /* * We don't need the special Nularg hack here and we're * going to be using Nularg for other things. */ if (*s == Nularg && s[1] == '\0') *s = '\0'; /* Ignore errors and status change in prompt substitution */ errflag = olderr; lastval = oldval; } memset(&new_vars, 0, sizeof(new_vars)); new_vars.last = bv; bv = &new_vars; new_vars.rstring = rs; new_vars.Rstring = Rs; new_vars.fm = s; new_vars.bufspc = 256; new_vars.bp = new_vars.bufline = new_vars.buf = zshcalloc(new_vars.bufspc); new_vars.bp1 = NULL; new_vars.truncwidth = 0; putpromptchar(1, '\0', txtchangep); addbufspc(2); if (new_vars.dontcount) *new_vars.bp++ = Outpar; *new_vars.bp = '\0'; if (!ns) { /* If zero, Inpar, Outpar and Nularg should be removed. */ for (new_vars.bp = new_vars.buf; *new_vars.bp; ) { if (*new_vars.bp == Meta) new_vars.bp += 2; else if (*new_vars.bp == Inpar || *new_vars.bp == Outpar || *new_vars.bp == Nularg) chuck(new_vars.bp); else new_vars.bp++; } } bv = new_vars.last; return new_vars.buf; }
void hashdir(char **dirp) { Cmdnam cn; DIR *dir; char *fn, *unmetadir, *pathbuf, *pathptr; int dirlen; #if defined(_WIN32) || defined(__CYGWIN__) char *exe; #endif /* _WIN32 || _CYGWIN__ */ if (isrelative(*dirp)) return; unmetadir = unmeta(*dirp); if (!(dir = opendir(unmetadir))) return; dirlen = strlen(unmetadir); pathbuf = (char *)zalloc(dirlen + PATH_MAX + 2); sprintf(pathbuf, "%s/", unmetadir); pathptr = pathbuf + dirlen + 1; while ((fn = zreaddir(dir, 1))) { if (!cmdnamtab->getnode(cmdnamtab, fn)) { char *fname = ztrdup(fn); struct stat statbuf; int add = 0, dummylen; unmetafy(fn, &dummylen); if (strlen(fn) > PATH_MAX) { /* Too heavy to do all the allocation */ add = 1; } else { strcpy(pathptr, fn); /* * This is the same test as for the glob qualifier for * executable plain files. */ if (unset(HASHEXECUTABLESONLY) || (access(pathbuf, X_OK) == 0 && stat(pathbuf, &statbuf) == 0 && S_ISREG(statbuf.st_mode) && (statbuf.st_mode & S_IXUGO))) add = 1; } if (add) { cn = (Cmdnam) zshcalloc(sizeof *cn); cn->node.flags = 0; cn->u.name = dirp; cmdnamtab->addnode(cmdnamtab, fname, cn); } else zsfree(fname); } #if defined(_WIN32) || defined(__CYGWIN__) /* Hash foo.exe as foo, since when no real foo exists, foo.exe will get executed by DOS automatically. This quiets spurious corrections when CORRECT or CORRECT_ALL is set. */ if ((exe = strrchr(fn, '.')) && (exe[1] == 'E' || exe[1] == 'e') && (exe[2] == 'X' || exe[2] == 'x') && (exe[3] == 'E' || exe[3] == 'e') && exe[4] == 0) { *exe = 0; if (!cmdnamtab->getnode(cmdnamtab, fn)) { cn = (Cmdnam) zshcalloc(sizeof *cn); cn->node.flags = 0; cn->u.name = dirp; cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn); } } #endif /* _WIN32 || __CYGWIN__ */ } closedir(dir); zfree(pathbuf, dirlen + PATH_MAX + 2); }
void cuttext(ZLE_STRING_T line, int ct, int flags) { if (!ct) return; UNMETACHECK(); if (zmod.flags & MOD_VIBUF) { struct cutbuffer *b = &vibuf[zmod.vibuf]; if (!(zmod.flags & MOD_VIAPP) || !b->buf) { free(b->buf); b->buf = (ZLE_STRING_T)zalloc(ct * ZLE_CHAR_SIZE); ZS_memcpy(b->buf, line, ct); b->len = ct; b->flags = vilinerange ? CUTBUFFER_LINE : 0; } else { int len = b->len; if(vilinerange) b->flags |= CUTBUFFER_LINE; b->buf = (ZLE_STRING_T) realloc((char *)b->buf, (ct + len + !!(b->flags & CUTBUFFER_LINE)) * ZLE_CHAR_SIZE); if (b->flags & CUTBUFFER_LINE) b->buf[len++] = ZWC('\n'); ZS_memcpy(b->buf + len, line, ct); b->len = len + ct; } return; } else { /* Save in "1, shifting "1-"8 along to "2-"9 */ int n; free(vibuf[34].buf); for(n=34; n>26; n--) vibuf[n] = vibuf[n-1]; vibuf[26].buf = (ZLE_STRING_T)zalloc(ct * ZLE_CHAR_SIZE); ZS_memcpy(vibuf[26].buf, line, ct); vibuf[26].len = ct; vibuf[26].flags = vilinerange ? CUTBUFFER_LINE : 0; } if (!cutbuf.buf) { cutbuf.buf = (ZLE_STRING_T)zalloc(ZLE_CHAR_SIZE); cutbuf.buf[0] = ZWC('\0'); cutbuf.len = cutbuf.flags = 0; } else if (!(lastcmd & ZLE_KILL) || (flags & CUT_REPLACE)) { Cutbuffer kptr; if (!kring) { kringsize = KRINGCTDEF; kring = (Cutbuffer)zshcalloc(kringsize * sizeof(struct cutbuffer)); } else kringnum = (kringnum + 1) % kringsize; kptr = kring + kringnum; if (kptr->buf) free(kptr->buf); *kptr = cutbuf; cutbuf.buf = (ZLE_STRING_T)zalloc(ZLE_CHAR_SIZE); cutbuf.buf[0] = ZWC('\0'); cutbuf.len = cutbuf.flags = 0; } if (flags & (CUT_FRONT|CUT_REPLACE)) { ZLE_STRING_T s = (ZLE_STRING_T)zalloc((cutbuf.len + ct)*ZLE_CHAR_SIZE); ZS_memcpy(s, line, ct); ZS_memcpy(s + ct, cutbuf.buf, cutbuf.len); free(cutbuf.buf); cutbuf.buf = s; cutbuf.len += ct; } else { cutbuf.buf = realloc((char *)cutbuf.buf, (cutbuf.len + ct) * ZLE_CHAR_SIZE); ZS_memcpy(cutbuf.buf + cutbuf.len, line, ct); cutbuf.len += ct; } if(vilinerange) cutbuf.flags |= CUTBUFFER_LINE; else cutbuf.flags &= ~CUTBUFFER_LINE; }