当前位置: 首页>>代码示例>>C++>>正文


C++ ztrdup函数代码示例

本文整理汇总了C++中ztrdup函数的典型用法代码示例。如果您正苦于以下问题:C++ ztrdup函数的具体用法?C++ ztrdup怎么用?C++ ztrdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ztrdup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createaliastable

void
createaliastable(void)
{
    aliastab = newhashtable(23);

    aliastab->hash        = hasher;
    aliastab->emptytable  = NULL;
    aliastab->filltable   = NULL;
    aliastab->addnode     = addhashnode;
    aliastab->getnode     = gethashnode;
    aliastab->getnode2    = gethashnode2;
    aliastab->removenode  = removehashnode;
    aliastab->disablenode = disablehashnode;
    aliastab->enablenode  = enablehashnode;
    aliastab->freenode    = freealiasnode;
    aliastab->printnode   = printaliasnode;
#ifdef ZSH_HASH_DEBUG
    aliastab->printinfo   = printhashtabinfo;
    aliastab->tablename   = ztrdup("aliastab");
#endif

    /* add the default aliases */
    aliastab->addnode(aliastab, ztrdup("run-help"), createaliasnode(ztrdup("man"), 0));
    aliastab->addnode(aliastab, ztrdup("which-command"), createaliasnode(ztrdup("whence"), 0));
}
开发者ID:prabirshrestha,项目名称:winzsh,代码行数:25,代码来源:hashtable.c

示例2: hashdir

void
hashdir(char **dirp)
{
    Cmdnam cn;
    DIR *dir;
    char *fn;

    if (isrelative(*dirp) || !(dir = opendir(unmeta(*dirp))))
	return;

    while ((fn = zreaddir(dir))) {
	/* Ignore `.' and `..'. */
	if (fn[0] == '.' &&
	    (fn[1] == '\0' ||
	     (fn[1] == '.' && fn[2] == '\0')))
	    continue;
#ifndef WINNT
	if (!cmdnamtab->getnode(cmdnamtab, fn)) {
	    cn = (Cmdnam) zcalloc(sizeof *cn);
	    cn->flags = 0;
	    cn->u.name = dirp;
	    cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn);
	}
#else
	if (!cmdnamtab->getnode(cmdnamtab, fn)) {
	    char *fext;
	    fext = fn;
	    while(*fext++)
		;

	    while((fext >fn )&& (*fext != '.'))
		fext--;

	    if ( (fext == fn) /*no extension */
		    || is_pathext(fext+1) ) {
		cn = (Cmdnam) zcalloc(sizeof *cn);
		cn->flags = 0;
		cn->u.name = dirp;
		cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn);

		/*if (fext != fn && !strnicmp(fext+1,"exe",3)) */

		*fext = 0;
		cn = (Cmdnam) zcalloc(sizeof *cn);
		cn->flags = 0;
		cn->u.name = dirp;

		cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn);
	    }
#ifdef ZSH_HASH_DEBUG
	    printhashtabinfo(cmdnamtab);
#endif /* ZSH_HASH_DEBUG */
	}
#endif /* WINNT */
    }
    closedir(dir);
}
开发者ID:prabirshrestha,项目名称:winzsh,代码行数:57,代码来源:hashtable.c

示例3: zlegetline

mod_export char *
zlegetline(int *ll, int *cs)
{
    if (zlemetaline != NULL) {
	*ll = zlemetall;
	*cs = zlemetacs;
	return ztrdup(zlemetaline);
    }
    if (zleline)
	return zlelineasstring(zleline, zlell, zlecs, ll, cs, 0);
    *ll = *cs = 0;
    return ztrdup("");
}
开发者ID:Lujaw,项目名称:zsh,代码行数:13,代码来源:zle_utils.c

示例4: setline

void
setline(char *s, int flags)
{
    char *scp;

    UNMETACHECK();
    if (flags & ZSL_COPY)
	scp = ztrdup(s);
    else
	scp = s;
    /*
     * TBD: we could make this more efficient by passing the existing
     * allocated line to stringaszleline.
     */
    free(zleline);

    zleline = stringaszleline(scp, 0, &zlell, &linesz, NULL);

    if ((flags & ZSL_TOEND) && (zlecs = zlell) && invicmdmode())
	DECCS();
    else if (zlecs > zlell)
	zlecs = zlell;
    CCRIGHT();
    if (flags & ZSL_COPY)
	free(scp);
}
开发者ID:Lujaw,项目名称:zsh,代码行数:26,代码来源:zle_utils.c

示例5: setpmmapfiles

static void
setpmmapfiles(Param pm, HashTable ht)
{
    int i;
    HashNode hn;

    /* just to see if I've understood what's happening */
    DPUTS(pm != mapfile_pm, "BUG: setpmmapfiles called for wrong param");

    if (!ht)
	return;

    if (!(pm->flags & PM_READONLY))
	for (i = 0; i < ht->hsize; i++)
	    for (hn = ht->nodes[i]; hn; hn = hn->next) {
		struct value v;

		v.isarr = v.inv = v.start = 0;
		v.end = -1;
		v.arr = NULL;
		v.pm = (Param) hn;

		setpmmapfile(v.pm, ztrdup(getstrvalue(&v)));
	    }
    deleteparamtable(ht);
}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:26,代码来源:mapfile.c

示例6: set_compstate

static void
set_compstate(UNUSED(Param pm), HashTable ht)
{
    struct compparam *cp;
    Param *pp;
    HashNode hn;
    int i;
    struct value v;
    char *str;

    if (!ht)
        return;

    for (i = 0; i < ht->hsize; i++)
	for (hn = ht->nodes[i]; hn; hn = hn->next)
	    for (cp = compkparams,
		 pp = compkpms; cp->name; cp++, pp++)
		if (!strcmp(hn->nam, cp->name)) {
		    v.isarr = v.flags = v.start = 0;
		    v.end = -1;
		    v.arr = NULL;
		    v.pm = (Param) hn;
		    if (cp->type == PM_INTEGER)
			*((zlong *) cp->var) = getintvalue(&v);
		    else if ((str = getstrvalue(&v))) {
			zsfree(*((char **) cp->var));
			*((char **) cp->var) = ztrdup(str);
		    }
		    (*pp)->node.flags &= ~PM_UNSET;

		    break;
		}
    deleteparamtable(ht);
}
开发者ID:Jaharmi,项目名称:zsh,代码行数:34,代码来源:complete.c

示例7: cp_cpattern_element

mod_export Cpattern
cp_cpattern_element(Cpattern o)
{
    Cpattern n = zalloc(sizeof(struct cpattern));

    n->next = NULL;

    n->tp = o->tp;
    switch (o->tp)
    {
    case CPAT_CCLASS:
    case CPAT_NCLASS:
    case CPAT_EQUIV:
	n->u.str = ztrdup(o->u.str);
	break;

    case CPAT_CHAR:
	n->u.chr = o->u.chr;
	break;

    default:
	/* just to keep compiler quiet */
	break;
    }

    return n;
}
开发者ID:Jaharmi,项目名称:zsh,代码行数:27,代码来源:complete.c

示例8: createreswdtable

void
createreswdtable(void)
{
    Reswd rw;

    reswdtab = newhashtable(23);

    reswdtab->hash        = hasher;
    reswdtab->emptytable  = NULL;
    reswdtab->filltable   = NULL;
    reswdtab->addnode     = addhashnode;
    reswdtab->getnode     = gethashnode;
    reswdtab->getnode2    = gethashnode2;
    reswdtab->removenode  = NULL;
    reswdtab->disablenode = disablehashnode;
    reswdtab->enablenode  = enablehashnode;
    reswdtab->freenode    = NULL;
    reswdtab->printnode   = printreswdnode;
#ifdef ZSH_HASH_DEBUG
    reswdtab->printinfo   = printhashtabinfo;
    reswdtab->tablename   = ztrdup("reswdtab");
#endif

    for (rw = reswds; rw->nam; rw++)
	reswdtab->addnode(reswdtab, rw->nam, rw);
}
开发者ID:prabirshrestha,项目名称:winzsh,代码行数:26,代码来源:hashtable.c

示例9: createbuiltintable

void
createbuiltintable(void)
{
    Builtin bn;

    builtintab = newhashtable(85);

    builtintab->hash        = hasher;
    builtintab->emptytable  = NULL;
    builtintab->filltable   = NULL;
    builtintab->addnode     = addhashnode;
    builtintab->getnode     = gethashnode;
    builtintab->getnode2    = gethashnode2;
    builtintab->removenode  = NULL;
    builtintab->disablenode = disablehashnode;
    builtintab->enablenode  = enablehashnode;
    builtintab->freenode    = NULL;
    builtintab->printnode   = printbuiltinnode;
#ifdef ZSH_HASH_DEBUG
    builtintab->printinfo   = printhashtabinfo;
    builtintab->tablename   = ztrdup("builtintab");
#endif

    for (bn = builtins; bn->nam; bn++)
	builtintab->addnode(builtintab, bn->nam, bn);
}
开发者ID:prabirshrestha,项目名称:winzsh,代码行数:26,代码来源:hashtable.c

示例10: domove

static int
domove(char *nam, MoveFunc movefn, char *p, char *q, int flags)
{
    struct stat st;
    char *pbuf, *qbuf;

    pbuf = ztrdup(unmeta(p));
    qbuf = unmeta(q);
    if(flags & MV_NODIRS) {
	errno = EISDIR;
	if(lstat(pbuf, &st) || S_ISDIR(st.st_mode)) {
	    zwarnnam(nam, "%s: %e", p, errno);
	    zsfree(pbuf);
	    return 1;
	}
    }
    if(!lstat(qbuf, &st)) {
	int doit = flags & MV_FORCE;
	if(S_ISDIR(st.st_mode)) {
	    zwarnnam(nam, "%s: cannot overwrite directory", q);
	    zsfree(pbuf);
	    return 1;
	} else if(flags & MV_INTERACTIVE) {
	    nicezputs(nam, stderr);
	    fputs(": replace `", stderr);
	    nicezputs(q, stderr);
	    fputs("'? ", stderr);
	    fflush(stderr);
	    if(!ask()) {
		zsfree(pbuf);
		return 0;
	    }
	    doit = 1;
	} else if((flags & MV_ASKNW) &&
		!S_ISLNK(st.st_mode) &&
		access(qbuf, W_OK)) {
	    nicezputs(nam, stderr);
	    fputs(": replace `", stderr);
	    nicezputs(q, stderr);
	    fprintf(stderr, "', overriding mode %04o? ",
		mode_to_octal(st.st_mode));
	    fflush(stderr);
	    if(!ask()) {
		zsfree(pbuf);
		return 0;
	    }
	    doit = 1;
	}
	if(doit && !(flags & MV_ATOMIC))
	    unlink(qbuf);
    }
    if(movefn(pbuf, qbuf)) {
	zwarnnam(nam, "%s: %e", p, errno);
	zsfree(pbuf);
	return 1;
    }
    zsfree(pbuf);
    return 0;
}
开发者ID:AMDmi3,项目名称:zsh,代码行数:59,代码来源:files.c

示例11: rift_prompt

/**
 * This function will be called whenever the prompt is drawn by the zle.
 * Sets the zsh global variable 'prompt' which is equivalent to the env
 * PROMPT / PS1.
 */
static void rift_prompt(void)
{
  const char* rw_prompt = rwcli_get_prompt();
  if (rw_prompt) {
    zfree(prompt, 0);
    prompt = ztrdup(rw_prompt);
  }
}
开发者ID:RIFTIO,项目名称:RIFT.ware,代码行数:13,代码来源:rift.c

示例12: makesuffixstr

mod_export void
makesuffixstr(char *f, char *s, int n)
{
    if (f) {
	zsfree(suffixfunc);
	suffixfunc = ztrdup(f);
	suffixfunclen = n;
    } else if (s) {
	int inv, i, z = 0;
	ZLE_STRING_T ws, lasts, wptr;

	if (*s == '^' || *s == '!') {
	    inv = 1;
	    s++;
	} else
	    inv = 0;
	s = getkeystring(s, &i, GETKEYS_SUFFIX, &z);
	s = metafy(s, i, META_USEHEAP);
	ws = stringaszleline(s, 0, &i, NULL, NULL);

	if (z)
	    suffixnoinslen = inv ? 0 : n;
	else if (inv) {
	    /*
	     * negative match, \- wasn't present, so it *should*
	     * have this suffix length
	     */
	    suffixnoinslen = n;
	}

	lasts = wptr = ws;
	while (i) {
	    if (i >= 3 && wptr[1] == ZWC('-')) {
		ZLE_CHAR_T str[2];

		if (wptr > lasts)
		    addsuffix(inv ? SUFTYP_NEGSTR : SUFTYP_POSSTR, 0,
			      lasts, wptr - lasts, n);
		str[0] = *wptr;
		str[1] = wptr[2];
		addsuffix(inv ? SUFTYP_NEGRNG : SUFTYP_POSRNG, 0,
			  str, 2, n);

		wptr += 3;
		i -= 3;
		lasts = wptr;
	    } else {
		wptr++;
		i--;
	    }
	}
	if (wptr > lasts)
	    addsuffix(inv ? SUFTYP_NEGSTR : SUFTYP_POSSTR, 0,
		      lasts, wptr - lasts, n);
	free(ws);
    } else
	makesuffix(n);
}
开发者ID:Jaharmi,项目名称:zsh,代码行数:58,代码来源:zle_misc.c

示例13: rthingy

Thingy
rthingy(char *nam)
{
    Thingy t = (Thingy) thingytab->getnode2(thingytab, nam);

    if(!t)
	thingytab->addnode(thingytab, ztrdup(nam), t = makethingynode());
    return refthingy(t);
}
开发者ID:AMDmi3,项目名称:zsh,代码行数:9,代码来源:zle_thingy.c

示例14: insertlastword

void
insertlastword(void)
{
    int n;
    char *s, *t;
    int len;
    Histent he;

/* multiple calls will now search back through the history, pem */
    static char *lastinsert;
    static int lasthist, lastpos;
    int evhist = curhist - 1, save;

    if (lastinsert) {
	int lastlen = ztrlen(lastinsert);
	int pos = cs;

	if (lastpos <= pos &&
	    lastlen == pos - lastpos &&
	    memcmp(lastinsert, (char *)&line[lastpos], lastlen) == 0) {
	    evhist = --lasthist;
	    cs = lastpos;
	    foredel(pos - cs);
	}
	zsfree(lastinsert);
	lastinsert = NULL;
    }
    if (!(he = quietgethist(evhist)) || !he->nwords) {
	feep();
	return;
    }
    if (zmult > 0) {
	n = he->nwords - (zmult - 1);
    } else {
	n = 1 - zmult;
    }
    if (n < 1 || n > he->nwords) {
	feep();
	return;
    }
    s = he->text + he->words[2*n-2];
    t = he->text + he->words[2*n-1];
    save = *t;
    *t = '\0';			/* ignore trailing whitespace */

    lasthist = evhist;
    lastpos = cs;
    lastinsert = ztrdup(s);
    spaceinline(len = ztrlen(s));
    while (len--) {
	line[cs++] = *s == Meta ? *++s ^ 32 : *s;
	s++;
    }

    *t = save;
}
开发者ID:prabirshrestha,项目名称:winzsh,代码行数:56,代码来源:zle_hist.c

示例15: createaliastables

void
createaliastables(void)
{
    /* Table for regular and global aliases */

    aliastab = newhashtable(23, "aliastab", NULL);

    createaliastable(aliastab);

    /* add the default aliases */
    aliastab->addnode(aliastab, ztrdup("run-help"), createaliasnode(ztrdup("man"), 0));
    aliastab->addnode(aliastab, ztrdup("which-command"), createaliasnode(ztrdup("whence"), 0));


    /* Table for suffix aliases --- make this smaller */

    sufaliastab = newhashtable(11, "sufaliastab", NULL);

    createaliastable(sufaliastab);
}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:20,代码来源:hashtable.c


注:本文中的ztrdup函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。