• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dupstring函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getlanginfo

static HashNode
getlanginfo(UNUSED(HashTable ht), const char *name)
{
    int len, *elem;
    char *listr, *nameu;
    Param pm = NULL;

    nameu = dupstring(name);
    unmetafy(nameu, &len);

    pm = (Param) hcalloc(sizeof(struct param));
    pm->node.nam = nameu;
    pm->node.flags = PM_READONLY | PM_SCALAR;
    pm->gsu.s = &nullsetscalar_gsu;

    if(name)
	elem = liitem(name);
    else
	elem = NULL;

    if (elem && (listr = nl_langinfo(*elem))) {
	pm->u.str = dupstring(listr);
    }
    else
    {
	/* zwarn("no such lang info: %s", name); */
	pm->u.str = dupstring("");
	pm->node.flags |= PM_UNSET;
    }
    return &pm->node;
}
开发者ID:Jaharmi,项目名称:zsh,代码行数:31,代码来源:langinfo.c


示例2: init_gconf

static void
init_gconf (void)
{
#if defined (HAVE_GCONF)
  char *s;

#if ! GLIB_CHECK_VERSION (2, 36, 0)
  g_type_init ();
#endif

  gconf_client = gconf_client_get_default ();
  gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE);
  gconf_client_add_dir (gconf_client,
                        GCONF_TOOL_BAR_STYLE,
                        GCONF_CLIENT_PRELOAD_ONELEVEL,
                        NULL);
  gconf_client_notify_add (gconf_client,
                           GCONF_TOOL_BAR_STYLE,
                           something_changed_gconfCB,
                           NULL, NULL, NULL);

  s = gconf_client_get_string (gconf_client, GCONF_TOOL_BAR_STYLE, NULL);
  if (s)
    {
      current_tool_bar_style = map_tool_bar_style (s);
      g_free (s);
    }

#ifdef HAVE_XFT
  s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
  if (s)
    {
      dupstring (&current_mono_font, s);
      g_free (s);
    }
  s = gconf_client_get_string (gconf_client, GCONF_FONT_NAME, NULL);
  if (s)
    {
      dupstring (&current_font, s);
      g_free (s);
    }
  gconf_client_add_dir (gconf_client,
                        GCONF_MONO_FONT,
                        GCONF_CLIENT_PRELOAD_ONELEVEL,
                        NULL);
  gconf_client_notify_add (gconf_client,
                           GCONF_MONO_FONT,
                           something_changed_gconfCB,
                           NULL, NULL, NULL);
  gconf_client_add_dir (gconf_client,
                        GCONF_FONT_NAME,
                        GCONF_CLIENT_PRELOAD_ONELEVEL,
                        NULL);
  gconf_client_notify_add (gconf_client,
                           GCONF_FONT_NAME,
                           something_changed_gconfCB,
                           NULL, NULL, NULL);
#endif /* HAVE_XFT */
#endif /* HAVE_GCONF */
}
开发者ID:Ferryworld,项目名称:emacs,代码行数:60,代码来源:xsettings.c


示例3: zgetcwd

char *
zgetcwd(void)
{
    char *ret = zgetdir(NULL);
#ifdef HAVE_GETCWD
    if (!ret) {
#ifdef GETCWD_CALLS_MALLOC
	char *cwd = getcwd(NULL, 0);
	if (cwd) {
	    ret = dupstring(cwd);
	    free(cwd);
	}
#else
	char *cwdbuf = zalloc(PATH_MAX);
	ret = getcwd(cwdbuf, PATH_MAX);
	if (ret)
	    ret = dupstring(ret);
	free(cwdbuf);
#endif /* GETCWD_CALLS_MALLOC */
    }
#endif /* HAVE_GETCWD */
    if (!ret)
	ret = pwd;
    if (!ret)
	ret = dupstring(".");
    return ret;
}
开发者ID:Web5design,项目名称:zsh,代码行数:27,代码来源:compat.c


示例4: gettermcap

static HashNode
gettermcap(UNUSED(HashTable ht), char *name)
{
    int len, num;
    char *tcstr, buf[2048], *u;
    Param pm = NULL;

    /* This depends on the termcap stuff in init.c */
    if (termflags & TERM_BAD)
	return NULL;
    if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
	return NULL;

    unmetafy(name, &len);

    pm = (Param) hcalloc(sizeof(struct param));
    pm->nam = dupstring(name);
    pm->flags = PM_READONLY;
    u = buf;

    /* logic in the following cascade copied from echotc, above */

    if ((num = tgetnum(name)) != -1) {
	pm->gsu.i = &nullsetinteger_gsu;
	pm->u.val = num;
	pm->flags |= PM_INTEGER;
	return (HashNode) pm;
    }

    pm->gsu.s = &nullsetscalar_gsu;
    switch (ztgetflag(name)) {
    case -1:
	break;
    case 0:
	pm->u.str = dupstring("no");
	pm->flags |= PM_SCALAR;
	return (HashNode) pm;
    default:
	pm->u.str = dupstring("yes");
	pm->flags |= PM_SCALAR;
	return (HashNode) pm;
    }
    if ((tcstr = (char*)tgetstr(name, &u)) != NULL && tcstr != (char *)-1)
    {
	pm->u.str = dupstring(tcstr);
	pm->flags |= PM_SCALAR;
    }
    else
    {
	/* zwarn("no such capability: %s", name, 0); */
	pm->u.str = dupstring("");
	pm->flags |= PM_UNSET;
    }
    return (HashNode) pm;
}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:55,代码来源:termcap.c


示例5: read_and_apply_settings

static void
read_and_apply_settings (struct x_display_info *dpyinfo, bool send_event_p)
{
  struct xsettings settings;

  if (!read_settings (dpyinfo, &settings))
    return;

  apply_xft_settings (dpyinfo, &settings);
  if (settings.seen & SEEN_TB_STYLE)
    {
      if (send_event_p)
        store_tool_bar_style_changed (settings.tb_style, dpyinfo);
      else
        current_tool_bar_style = map_tool_bar_style (settings.tb_style);
      xfree (settings.tb_style);
    }
#ifdef HAVE_XFT
  if (settings.seen & SEEN_FONT)
    {
      if (send_event_p)
        store_font_name_changed (settings.font);
      else
	dupstring (&current_font, settings.font);
      xfree (settings.font);
    }
#endif
}
开发者ID:Ferryworld,项目名称:emacs,代码行数:28,代码来源:xsettings.c


示例6: ptywrite

static int
ptywrite(Ptycmd cmd, char **args, int nonl)
{
    if (*args) {
	char sp = ' ', *tmp;
	int len;

	while (*args) {
	    unmetafy((tmp = dupstring(*args)), &len);
	    if (ptywritestr(cmd, tmp, len) ||
		(*++args && ptywritestr(cmd, &sp, 1)))
		return 1;
	}
	if (!nonl) {
	    sp = '\n';
	    if (ptywritestr(cmd, &sp, 1))
		return 1;
	}
    } else {
	int n;
	char buf[BUFSIZ];

	while ((n = read(0, buf, BUFSIZ)) > 0)
	    if (ptywritestr(cmd, buf, n))
		return 1;
    }
    return 0;
}
开发者ID:zsh-users,项目名称:zsh,代码行数:28,代码来源:zpty.c


示例7: optlookup

mod_export int
optlookup(char const *name)
{
    char *s, *t;
    Optname n;

    s = t = dupstring(name);

    /* exorcise underscores, and change to lowercase */
    while (*t)
	if (*t == '_')
	    chuck(t);
	else {
	    /*
	     * Some locales (in particular tr_TR.UTF-8) may
	     * have non-standard mappings of ASCII characters,
	     * so be careful.  Option names must be ASCII so
	     * we don't need to be too clever.
	     */
	    if (*t >= 'A' && *t <= 'Z')
		*t = (*t - 'A') + 'a';
	    t++;
	}

    /* look up name in the table */
    if (s[0] == 'n' && s[1] == 'o' &&
	(n = (Optname) optiontab->getnode(optiontab, s + 2))) {
	return -n->optno;
    } else if ((n = (Optname) optiontab->getnode(optiontab, s)))
	return n->optno;
    else
	return OPT_INVALID;
}
开发者ID:koreden,项目名称:oh-my-zsh,代码行数:33,代码来源:options.c


示例8: parse_subscript

mod_export char *
parse_subscript(char *s, int sub, int endchar)
{
    int l = strlen(s), err;
    char *t;

    if (!*s || *s == endchar)
	return 0;
    zcontext_save();
    untokenize(t = dupstring(s));
    inpush(t, 0, NULL);
    strinbeg(0);
    lexbuf.len = 0;
    lexbuf.ptr = tokstr = s;
    lexbuf.siz = l + 1;
    err = dquote_parse(endchar, sub);
    if (err) {
	err = *lexbuf.ptr;
	*lexbuf.ptr = '\0';
	untokenize(s);
	*lexbuf.ptr = err;
	s = NULL;
    } else {
	s = lexbuf.ptr;
    }
    strinend();
    inpop();
    DPUTS(cmdsp, "BUG: parse_subscript: cmdstack not empty.");
    zcontext_restore();
    return s;
}
开发者ID:netroby,项目名称:zsh,代码行数:31,代码来源:lex.c


示例9: optlookup

mod_export int
optlookup(char const *name)
{
    char *s, *t;
    Optname n;

    s = t = dupstring(name);

    /* exorcise underscores, and change to lowercase */
    while (*t)
	if (*t == '_')
	    chuck(t);
	else {
	    *t = tulower(*t);
	    t++;
	}

    /* look up name in the table */
    if (s[0] == 'n' && s[1] == 'o' &&
	(n = (Optname) optiontab->getnode(optiontab, s + 2))) {
	return -n->optno;
    } else if ((n = (Optname) optiontab->getnode(optiontab, s)))
	return n->optno;
    else
	return OPT_INVALID;
}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:26,代码来源:options.c


示例10: scanpmmapfile

static void
scanpmmapfile(UNUSED(HashTable ht), ScanFunc func, int flags)
{
    struct param pm;
    DIR *dir;

    if (!(dir = opendir(".")))
	return;

    memset((void *)&pm, 0, sizeof(struct param));
    pm.flags = PM_SCALAR;
    pm.gsu.s = &mapfile_gsu;
    pm.flags |= (mapfile_pm->flags & PM_READONLY);

    /* Here we scan the current directory, calling func() for each file */
    while ((pm.nam = zreaddir(dir, 1))) {
	/*
	 * Hmmm, it's rather wasteful always to read the contents.
	 * In fact, it's grotesequely wasteful, since that would mean
	 * we always read the entire contents of every single file
	 * in the directory into memory.  Hence just leave it empty.
	 */
	pm.nam = dupstring(pm.nam);
	pm.u.str = "";
	func((HashNode) &pm, flags);
    }
    closedir(dir);
}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:28,代码来源:mapfile.c


示例11: get_buffer

static char *
get_buffer(UNUSED(Param pm))
{
    if (zlemetaline != 0)
	return dupstring(zlemetaline);
    return zlelineasstring(zleline, zlell, 0, NULL, NULL, 1);
}
开发者ID:psych0tik,项目名称:zsh,代码行数:7,代码来源:zle_params.c


示例12: stdCmdName

void MConsole::AddCommand(SMJS_Plugin *pl, const char *cmdName, v8::Handle<v8::Function> func, bool serverOnly){
	std::string stdCmdName(cmdName);
	std::transform(stdCmdName.begin(), stdCmdName.end(), stdCmdName.begin(), ::tolower);


	CommandHook *wrapper = new CommandHook;
	wrapper->pl = pl;
	wrapper->func = v8::Persistent<v8::Function>::New(func);
	wrapper->serverOnly = serverOnly;

	auto infoIt = g_MConsole->pluginCmds2.find(stdCmdName);
	
	if(infoIt == g_MConsole->pluginCmds2.end()){
		CommandHookInfo *info = new CommandHookInfo();

		g_MConsole->pluginCmds2.insert(std::make_pair(stdCmdName, info));
		infoIt = g_MConsole->pluginCmds2.find(stdCmdName);

		ConCommand *conCmd = icvar->FindCommand(cmdName);
		if(!conCmd){
			conCmd = new ConCommand(dupstring(cmdName), MConsole::CommandCallback2);
			icvar->RegisterConCommand(conCmd);
			info->isSMJS = true;
		}else{
			SH_ADD_HOOK(ConCommand, Dispatch, conCmd, SH_STATIC(MConsole::CommandCallback), false);
			info->isSMJS = false;
		}
	}

	infoIt->second->hooks.push_back(wrapper);
}
开发者ID:zures,项目名称:SourceMod.js,代码行数:31,代码来源:MConsole.cpp


示例13: parse_subscript

mod_export char *
parse_subscript(char *s, int sub)
{
    int l = strlen(s), err;
    char *t;

    if (!*s || *s == ']')
	return 0;
    lexsave();
    untokenize(t = dupstring(s));
    inpush(t, 0, NULL);
    strinbeg(0);
    len = 0;
    bptr = tokstr = s;
    bsiz = l + 1;
    err = dquote_parse(']', sub);
    if (err) {
	err = *bptr;
	*bptr = 0;
	untokenize(s);
	*bptr = err;
	s = 0;
    } else
	s = bptr;
    strinend();
    inpop();
    DPUTS(cmdsp, "BUG: parse_subscript: cmdstack not empty.");
    lexrestore();
    return s;
}
开发者ID:cdaffara,项目名称:symbiandump-mw1,代码行数:30,代码来源:lex.c


示例14: get_intarg

int
get_intarg(char **s)
{
    char *t = get_strarg(*s + 1);
    char *p, sav;
    long ret;

    if (!*t)
	return -1;
    sav = *t;
    *t = '\0';
    p = dupstring(*s + 2);
    *s = t;
    *t = sav;
    if (parsestr(p))
	return -1;
    singsub(&p);
    if (errflag)
	return -1;
    ret = matheval(p);
    if (errflag)
	return -1;
    if (ret < 0)
	ret = -ret;
    return ret < 0 ? -ret : ret;
}
开发者ID:redwinner,项目名称:unxutils,代码行数:26,代码来源:subst.c


示例15: parse_subscript

mod_export char *
parse_subscript(char *s, int sub, int endchar)
{
    int l = strlen(s), err, toklen;
    char *t;

    if (!*s || *s == endchar)
	return 0;
    zcontext_save();
    untokenize(t = dupstring(s));
    inpush(t, 0, NULL);
    strinbeg(0);
    /*
     * Warning to Future Generations:
     *
     * This way of passing the subscript through the lexer is brittle.
     * Code above this for several layers assumes that when we tokenise
     * the input it goes into the same place as the original string.
     * However, the lexer may overwrite later bits of the string or
     * reallocate it, in particular when expanding aliaes.  To get
     * around this, we copy the string and then copy it back.  This is a
     * bit more robust but still relies on the underlying assumption of
     * length preservation.
     */
    lexbuf.len = 0;
    lexbuf.ptr = tokstr = dupstring(s);
    lexbuf.siz = l + 1;
    err = dquote_parse(endchar, sub);
    toklen = (int)(lexbuf.ptr - tokstr);
    DPUTS(toklen > l, "Bad length for parsed subscript");
    memcpy(s, tokstr, toklen);
    if (err) {
	char *strend = s + toklen;
	err = *strend;
	*strend = '\0';
	untokenize(s);
	*strend = err;
	s = NULL;
    } else {
	s += toklen;
    }
    strinend();
    inpop();
    DPUTS(cmdsp, "BUG: parse_subscript: cmdstack not empty.");
    zcontext_restore();
    return s;
}
开发者ID:AMDmi3,项目名称:zsh,代码行数:47,代码来源:lex.c


示例16: dupstring

void CString::Tokenize(char ***tokens, int *iNumTokens, char *szDelimiters) {
	char *szBuf = dupstring(m_szString);
	char *p;
	int NumTokens = 0;

	for (p = strtok(szBuf, szDelimiters); p; p = strtok(NULL, szDelimiters), NumTokens++);

	char **tokenArray = NumTokens ? new char *[NumTokens] : NULL;
	strcpy(szBuf, m_szString);
	for (p = strtok(szBuf, szDelimiters), NumTokens = 0; p; p = strtok(NULL, szDelimiters)) 
		tokenArray[NumTokens++] = dupstring(p);

	*tokens = tokenArray;
	*iNumTokens = NumTokens;

	delete szBuf;
}
开发者ID:goldenpython,项目名称:ObjLoader,代码行数:17,代码来源:String.cpp


示例17: get_prebuffer

static char *
get_prebuffer(UNUSED(Param pm))
{
    /*
     * Use the editing current history line, not necessarily the
     * history line that's currently in the history mechanism
     * since our line may have been stacked.
     */
    if (zle_chline) {
	/* zle_chline was NULL terminated when pushed onto the stack */
	return dupstring(zle_chline);
    }
    if (chline) {
	/* hptr is valid */
	return dupstrpfx(chline, hptr - chline);
    }
    return dupstring("");
}
开发者ID:psych0tik,项目名称:zsh,代码行数:18,代码来源:zle_params.c


示例18: scanlanginfo

static void
scanlanginfo(UNUSED(HashTable ht), ScanFunc func, int flags)
{
    Param pm = NULL;
    char **element, *langstr;
    nl_item *nlcode;

    pm = (Param) hcalloc(sizeof(struct param));
    pm->gsu.s = &nullsetscalar_gsu;
    pm->node.flags = PM_READONLY | PM_SCALAR;

    nlcode = &nl_vals[0];
    for (element = (char **)nl_names; *element; element++, nlcode++) {
	if ((langstr = nl_langinfo(*nlcode)) != NULL) {
	    pm->u.str = dupstring(langstr);
	    pm->node.nam = dupstring(*element);
	    func(&pm->node, flags);
	}
    }
    
}
开发者ID:Jaharmi,项目名称:zsh,代码行数:21,代码来源:langinfo.c


示例19: getterminfo

static HashNode
getterminfo(UNUSED(HashTable ht), const char *name)
{
    int len, num;
    char *tistr, *nameu;
    Param pm = NULL;

    /* This depends on the termcap stuff in init.c */
    if (termflags & TERM_BAD)
	return NULL;
    if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
	return NULL;

    nameu = dupstring(name);
    unmetafy(nameu, &len);

    pm = (Param) hcalloc(sizeof(struct param));
    pm->node.nam = nameu;
    pm->node.flags = PM_READONLY;

    if (((num = tigetnum(nameu)) != -1) && (num != -2)) {
	pm->u.val = num;
	pm->node.flags |= PM_INTEGER;
	pm->gsu.i = &nullsetinteger_gsu;
    } else if ((num = tigetflag(nameu)) != -1) {
	pm->u.str = num ? dupstring("yes") : dupstring("no");
	pm->node.flags |= PM_SCALAR;
	pm->gsu.s = &nullsetscalar_gsu;
    } else if ((tistr = (char *)tigetstr(nameu)) != NULL && tistr != (char *)-1) {
	pm->u.str = dupstring(tistr);
	pm->node.flags |= PM_SCALAR;
	pm->gsu.s = &nullsetscalar_gsu;
    } else {
	/* zwarn("no such capability: %s", name); */
	pm->u.str = dupstring("");
	pm->node.flags |= PM_UNSET;
	pm->gsu.s = &nullsetscalar_gsu;
    }
    return &pm->node;
}
开发者ID:zsh-users,项目名称:zsh,代码行数:40,代码来源:terminfo.c


示例20: fillpmsysparams

static void
fillpmsysparams(Param pm, const char *name)
{
    char buf[DIGBUFSIZE];
    int num;

    pm->node.nam = dupstring(name);
    pm->node.flags = PM_SCALAR | PM_READONLY;
    pm->gsu.s = &nullsetscalar_gsu;
    if (!strcmp(name, "pid")) {
	num = (int)getpid();
    } else if (!strcmp(name, "ppid")) {
	num = (int)getppid();
    } else {
	pm->u.str = dupstring("");
	pm->node.flags |= PM_UNSET;
	return;
    }

    sprintf(buf, "%d", num);
    pm->u.str = dupstring(buf);
}
开发者ID:Jaharmi,项目名称:zsh,代码行数:22,代码来源:system.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ duration函数代码示例发布时间:2022-05-30
下一篇:
C++ dupprintf函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap