本文整理汇总了C++中STPUTC函数的典型用法代码示例。如果您正苦于以下问题:C++ STPUTC函数的具体用法?C++ STPUTC怎么用?C++ STPUTC使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STPUTC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evalcmd
int
evalcmd(shinstance *psh, int argc, char **argv)
{
char *p;
char *concat;
char **ap;
if (argc > 1) {
p = argv[1];
if (argc > 2) {
STARTSTACKSTR(psh, concat);
ap = argv + 2;
for (;;) {
while (*p)
STPUTC(psh, *p++, concat);
if ((p = *ap++) == NULL)
break;
STPUTC(psh, ' ', concat);
}
STPUTC(psh, '\0', concat);
p = grabstackstr(psh, concat);
}
evalstring(psh, p, EV_TESTED);
}
return psh->exitstatus;
}
示例2: evalcmd
int
evalcmd(int argc, char **argv)
{
char *p;
char *concat;
char **ap;
if (argc > 1) {
p = argv[1];
if (argc > 2) {
STARTSTACKSTR(concat);
ap = argv + 2;
for (;;) {
STPUTS(p, concat);
if ((p = *ap++) == NULL)
break;
STPUTC(' ', concat);
}
STPUTC('\0', concat);
p = grabstackstr(concat);
}
evalstring(p, builtin_flags);
} else
exitstatus = 0;
return exitstatus;
}
示例3: evalcmd
int
evalcmd(int argc, char **argv)
{
char *p;
char *concat;
char **ap;
if (argc > 1) {
p = argv[1];
if (argc > 2) {
STARTSTACKSTR(concat);
ap = argv + 2;
for (;;) {
while (*p)
STPUTC(*p++, concat);
if ((p = *ap++) == NULL)
break;
STPUTC(' ', concat);
}
STPUTC('\0', concat);
p = grabstackstr(concat);
}
evalstring(p);
}
return exitstatus;
}
示例4: evalcmd
int
evalcmd(int argc, char **argv)
{
char *p;
char *concat;
char **ap;
if (argc > 1) {
p = argv[1];
if (argc > 2) {
STARTSTACKSTR(concat);
ap = argv + 2;
for (;;) {
concat = stputs(p, concat);
if ((p = *ap++) == NULL)
break;
STPUTC(' ', concat);
}
STPUTC('\0', concat);
p = grabstackstr(concat);
}
return evalstring(p, ~SKIPEVAL);
}
return 0;
}
示例5: letcmd
/*
* The exp(1) builtin.
*/
int
letcmd(int argc, char **argv)
{
const char *p;
char *concat;
char **ap;
arith_t i;
if (argc > 1) {
p = argv[1];
if (argc > 2) {
/*
* Concatenate arguments.
*/
STARTSTACKSTR(concat);
ap = argv + 2;
for (;;) {
while (*p)
STPUTC(*p++, concat);
if ((p = *ap++) == NULL)
break;
STPUTC(' ', concat);
}
STPUTC('\0', concat);
p = grabstackstr(concat);
}
} else
p = "";
i = arith(p);
out1fmt(ARITH_FORMAT_STR "\n", i);
return !i;
}
示例6: readcmd
int
readcmd(int argc, char **argv)
{
char **ap;
int backslash;
char c;
int rflag;
char *prompt;
char *p;
int status;
int i;
rflag = 0;
prompt = NULL;
while ((i = nextopt("p:r")) != '\0') {
if (i == 'p')
prompt = optionarg;
else
rflag = 1;
}
if (prompt && isatty(0)) {
out2str(prompt);
#ifdef FLUSHERR
flushall();
#endif
}
if (*(ap = argptr) == NULL)
sh_error("arg count");
status = 0;
backslash = 0;
STARTSTACKSTR(p);
for (;;) {
if (read(0, &c, 1) != 1) {
status = 1;
break;
}
if (c == '\0')
continue;
if (backslash) {
if (c == '\n')
goto resetbs;
STPUTC(CTLESC, p);
goto put;
}
if (!rflag && c == '\\') {
backslash++;
continue;
}
if (c == '\n')
break;
put:
STPUTC(c, p);
resetbs:
backslash = 0;
}
STACKSTRNUL(p);
readcmd_handle_line(stackblock(), ap, p + 1 - (char *)stackblock());
return status;
}
示例7: expari
/*
* Expand arithmetic expression.
*/
static char *
expari(char *p, int flag, struct worddest *dst)
{
char *q, *start;
arith_t result;
int begoff;
int quoted;
int adj;
quoted = *p++ == '"';
begoff = expdest - stackblock();
p = argstr(p, 0, NULL);
STPUTC('\0', expdest);
start = stackblock() + begoff;
q = grabstackstr(expdest);
result = arith(start);
ungrabstackstr(q, expdest);
start = stackblock() + begoff;
adj = start - expdest;
STADJUST(adj, expdest);
CHECKSTRSPACE((int)(DIGITS(result) + 1), expdest);
fmtstr(expdest, DIGITS(result), ARITH_FORMAT_STR, result);
adj = strlen(expdest);
STADJUST(adj, expdest);
if (!quoted)
reprocess(expdest - adj - stackblock(), flag, VSNORMAL, 0, dst);
return p;
}
示例8: expandarg
/*
* Perform expansions on an argument, placing the resulting list of arguments
* in arglist. Parameter expansion, command substitution and arithmetic
* expansion are always performed; additional expansions can be requested
* via flag (EXP_*).
* The result is left in the stack string.
* When arglist is NULL, perform here document expansion.
*
* When doing something that may cause this to be re-entered, make sure
* the stack string is empty via grabstackstr() and do not assume expdest
* remains valid.
*/
void
expandarg(union node *arg, struct arglist *arglist, int flag)
{
struct worddest exparg;
struct nodelist *argbackq;
if (fflag)
flag &= ~EXP_GLOB;
argbackq = arg->narg.backquote;
exparg.list = arglist;
exparg.state = WORD_IDLE;
STARTSTACKSTR(expdest);
argstr(arg->narg.text, &argbackq, flag, &exparg);
if (arglist == NULL) {
STACKSTRNUL(expdest);
return; /* here document expanded */
}
if ((flag & EXP_SPLIT) == 0 || expdest != stackblock() ||
exparg.state == WORD_QUOTEMARK) {
STPUTC('\0', expdest);
if (flag & EXP_SPLIT) {
if (flag & EXP_GLOB)
expandmeta(grabstackstr(expdest), exparg.list);
else
appendarglist(exparg.list, grabstackstr(expdest));
}
}
if ((flag & EXP_SPLIT) == 0)
appendarglist(arglist, grabstackstr(expdest));
}
示例9: expari
/*
* Expand arithmetic expression.
* Note that flag is not required as digits never require CTLESC characters.
*/
static char *
expari(char *p)
{
char *q, *start;
arith_t result;
int begoff;
int quoted;
int adj;
quoted = *p++ == '"';
begoff = expdest - stackblock();
p = argstr(p, 0);
removerecordregions(begoff);
STPUTC('\0', expdest);
start = stackblock() + begoff;
q = grabstackstr(expdest);
result = arith(start);
ungrabstackstr(q, expdest);
start = stackblock() + begoff;
adj = start - expdest;
STADJUST(adj, expdest);
CHECKSTRSPACE((int)(DIGITS(result) + 1), expdest);
fmtstr(expdest, DIGITS(result), ARITH_FORMAT_STR, result);
adj = strlen(expdest);
STADJUST(adj, expdest);
if (!quoted)
recordregion(begoff, expdest - stackblock(), 0);
return p;
}
示例10: exptilde
STATIC char *
exptilde(char *p, int flag)
{
char c, *startp = p;
struct passwd *pw;
const char *home;
int quotes = flag & (EXP_FULL | EXP_CASE);
while ((c = *p) != '\0') {
switch(c) {
case CTLESC:
return (startp);
case CTLQUOTEMARK:
return (startp);
case ':':
if (flag & EXP_VARTILDE)
goto done;
break;
case '/':
goto done;
}
p++;
}
done:
*p = '\0';
if (*(startp+1) == '\0') {
if ((home = lookupvar("HOME")) == NULL)
goto lose;
} else {
if ((pw = getpwnam(startp+1)) == NULL)
goto lose;
home = pw->pw_dir;
}
if (*home == '\0')
goto lose;
*p = c;
while ((c = *home++) != '\0') {
if (quotes && SQSYNTAX[(int)c] == CCTL)
STPUTC(CTLESC, expdest);
STPUTC(c, expdest);
}
return (p);
lose:
*p = c;
return (startp);
}
示例11: exptilde
STATIC char *
exptilde(shinstance *psh, char *p, int flag)
{
char c, *startp = p;
const char *home;
int quotes = flag & (EXP_FULL | EXP_CASE);
while ((c = *p) != '\0') {
switch(c) {
case CTLESC:
return (startp);
case CTLQUOTEMARK:
return (startp);
case ':':
if (flag & EXP_VARTILDE)
goto done;
break;
case '/':
goto done;
}
p++;
}
done:
*p = '\0';
if (*(startp+1) == '\0') {
if ((home = lookupvar(psh, "HOME")) == NULL)
goto lose;
} else {
if ((home = sh_gethomedir(psh, startp+1)) == NULL)
goto lose;
}
if (*home == '\0')
goto lose;
*p = c;
while ((c = *home++) != '\0') {
if (quotes && SQSYNTAX[(int)c] == CCTL)
STPUTC(psh, CTLESC, psh->expdest);
STPUTC(psh, c, psh->expdest);
}
return (p);
lose:
*p = c;
return (startp);
}
示例12: fc_replace
STATIC const char *
fc_replace(const char *s, char *p, char *r)
{
char *dest;
int plen = strlen(p);
STARTSTACKSTR(dest);
while (*s) {
if (*s == *p && strncmp(s, p, plen) == 0) {
while (*r)
STPUTC(*r++, dest);
s += plen;
*p = '\0'; /* so no more matches */
} else
STPUTC(*s++, dest);
}
STACKSTRNUL(dest);
dest = grabstackstr(dest);
return (dest);
}
示例13: expandarg
/*
* Perform expansions on an argument, placing the resulting list of arguments
* in arglist. Parameter expansion, command substitution and arithmetic
* expansion are always performed; additional expansions can be requested
* via flag (EXP_*).
* The result is left in the stack string.
* When arglist is NULL, perform here document expansion.
*
* Caution: this function uses global state and is not reentrant.
* However, a new invocation after an interrupted invocation is safe
* and will reset the global state for the new call.
*/
void
expandarg(union node* arg, struct arglist* arglist, int32_t flag)
{
struct strlist* sp;
cstring_t p;
argbackq = arg->narg.backquote;
STARTSTACKSTR(expdest);
ifsfirst.next = NULL;
ifslastp = NULL;
argstr(arg->narg.text, flag);
if (arglist == NULL)
{
STACKSTRNUL(expdest);
return; /* here document expanded */
}
STPUTC('\0', expdest);
p = grabstackstr(expdest);
exparg.lastp = &exparg.list;
/*
* TODO - EXP_REDIR
*/
if (flag & EXP_FULL)
{
ifsbreakup(p, &exparg);
*exparg.lastp = NULL;
exparg.lastp = &exparg.list;
expandmeta(exparg.list, flag);
}
else
{
if (flag & EXP_REDIR) /*XXX - for now, just remove escapes */
rmescapes(p);
sp = (struct strlist*)stalloc(sizeof(struct strlist));
sp->text = p;
*exparg.lastp = sp;
exparg.lastp = &sp->next;
}
while (ifsfirst.next != NULL)
{
pifsregion_t ifsp;
INTOFF;
ifsp = ifsfirst.next->next;
ckfree(ifsfirst.next);
ifsfirst.next = ifsp;
INTON;
}
*exparg.lastp = NULL;
if (exparg.list)
{
*arglist->lastp = exparg.list;
arglist->lastp = exparg.lastp;
}
}
示例14: expari
/*
* Expand arithmetic expression.
* Note that flag is not required as digits never require CTLESC characters.
*/
static char *
expari(char *p)
{
char *q, *start;
arith_t result;
int begoff;
int quoted;
int c;
int nesting;
int adj;
quoted = *p++ == '"';
begoff = expdest - stackblock();
argstr(p, 0);
removerecordregions(begoff);
STPUTC('\0', expdest);
start = stackblock() + begoff;
q = grabstackstr(expdest);
result = arith(start);
ungrabstackstr(q, expdest);
start = stackblock() + begoff;
adj = start - expdest;
STADJUST(adj, expdest);
CHECKSTRSPACE((int)(DIGITS(result) + 1), expdest);
fmtstr(expdest, DIGITS(result), ARITH_FORMAT_STR, result);
adj = strlen(expdest);
STADJUST(adj, expdest);
if (!quoted)
recordregion(begoff, expdest - stackblock(), 0);
nesting = 1;
while (nesting > 0) {
c = *p++;
if (c == CTLESC)
p++;
else if (c == CTLARI)
nesting++;
else if (c == CTLENDARI)
nesting--;
else if (c == CTLVAR)
p++; /* ignore variable substitution byte */
else if (c == '\0')
return p - 1;
}
return p;
}
示例15: casematch
int
casematch(union node *pattern, const char *val)
{
struct stackmark smark;
int result;
char *p;
setstackmark(&smark);
argbackq = pattern->narg.backquote;
STARTSTACKSTR(expdest);
argstr(pattern->narg.text, EXP_TILDE | EXP_CASE, NULL);
STPUTC('\0', expdest);
p = grabstackstr(expdest);
result = patmatch(p, val);
popstackmark(&smark);
return result;
}