本文整理汇总了C++中pfmt函数的典型用法代码示例。如果您正苦于以下问题:C++ pfmt函数的具体用法?C++ pfmt怎么用?C++ pfmt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pfmt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: require_token
void parser_t::dippins()
{
pstring_list_t pins;
pins.add(get_identifier());
require_token(m_tok_comma);
while (true)
{
pstring t1 = get_identifier();
pins.add(t1);
token_t n = get_token();
if (n.is(m_tok_param_right))
break;
if (!n.is(m_tok_comma))
error(pfmt("expected a comma, found <{1}>")(n.str()) );
}
if ((pins.size() % 2) == 1)
error("You must pass an equal number of pins to DIPPINS");
unsigned n = pins.size();
for (unsigned i = 0; i < n / 2; i++)
{
m_setup.register_alias(pfmt("{1}")(i+1), pins[i*2]);
m_setup.register_alias(pfmt("{1}")(n-i), pins[i*2 + 1]);
}
}
示例2: addenv
void
addenv(var *v)
{
char envname[Maxenvname];
word *w;
int f;
io *fd;
if(v->changed){
v->changed = 0;
snprint(envname, sizeof envname, "/env/%s", v->name);
if((f = Creat(envname))<0)
pfmt(err, "rc: can't open %s: %r\n", envname);
else{
for(w = v->val;w;w = w->next)
write(f, w->word, strlen(w->word)+1L);
close(f);
}
}
if(v->fnchanged){
v->fnchanged = 0;
snprint(envname, sizeof envname, "/env/fn#%s", v->name);
if((f = Creat(envname))<0)
pfmt(err, "rc: can't open %s: %r\n", envname);
else{
if(v->fn){
fd = openfd(f);
pfmt(fd, "fn %q %s\n", v->name, v->fn[v->pc-1].s);
closeio(fd);
}
close(f);
}
}
}
示例3: panic
void
panic(char *s, int n)
{
pfmt(err, "rc: ");
pfmt(err, s, n);
pchr(err, '\n');
flush(err);
Abort();
}
示例4: Xsimple
void
Xsimple(void)
{
word *a;
thread *p = runq;
var *v;
struct builtin *bp;
int pid;
globlist();
a = runq->argv->words;
if(a==0){
Xerror1("empty argument list");
return;
}
if(flag['x'])
pfmt(err, "%v\n", p->argv->words); /* wrong, should do redirs */
v = gvlook(a->word);
if(v->fn)
execfunc(v);
else{
if(strcmp(a->word, "builtin")==0){
if(count(a)==1){
pfmt(err, "builtin: empty argument list\n");
setstatus("empty arg list");
poplist();
return;
}
a = a->next;
popword();
}
for(bp = Builtin;bp->name;bp++)
if(strcmp(a->word, bp->name)==0){
(*bp->fnc)();
return;
}
if(exitnext()){
/* fork and wait is redundant */
pushword("exec");
execexec();
Xexit();
}
else{
flush(err);
Updenv(); /* necessary so changes don't go out again */
if((pid = execforkexec()) < 0){
Xerror("try again");
return;
}
/* interrupts don't get us out */
poplist();
while(Waitfor(pid, 1) < 0)
;
}
}
}
示例5: bcheck2
static void bcheck2(int n, int c1, int c2)
{
if (n == 1)
pfmt(stderr, MM_ERROR, ":21:Missing %c\n", c2);
else if (n > 1)
pfmt(stderr, MM_ERROR, ":22:%d missing %c's\n", n, c2);
else if (n == -1)
pfmt(stderr, MM_ERROR, ":23:Extra %c\n", c2);
else if (n < -1)
pfmt(stderr, MM_ERROR, ":24:%d extra %c's\n", -n, c2);
}
示例6: Xerror1
void
Xerror1(char *s)
{
if(strcmp(argv0, "rc")==0 || strcmp(argv0, "/bin/rc")==0)
pfmt(err, "rc: %s\n", s);
else
pfmt(err, "rc (%s): %s\n", argv0, s);
flush(err);
setstatus("error");
while(!runq->iflag) Xreturn();
}
示例7: get_token
double ptokenizer::get_number_double()
{
token_t tok = get_token();
if (!tok.is_type(NUMBER))
{
error(pfmt("Expected a number, got <{1}>")(tok.str()) );
}
bool err = false;
double ret = tok.str().as_double(&err);
if (err)
error(pfmt("Expected a number, got <{1}>")(tok.str()) );
return ret;
}
示例8: get_token
// FIXME: combine into template
double ptokenizer::get_number_double()
{
token_t tok = get_token();
if (!tok.is_type(NUMBER))
{
error(pfmt("Expected a number, got <{1}>")(tok.str()) );
}
bool err;
double ret = plib::pstonum_ne<double>(tok.str(), err);
if (err)
error(pfmt("Expected a number, got <{1}>")(tok.str()) );
return ret;
}
示例9: execnewpgrp
void
execnewpgrp(void)
{
int arg;
char *s;
switch(count(runq->argv->words)){
case 1:
arg = RFENVG|RFNAMEG|RFNOTEG;
break;
case 2:
arg = 0;
for(s = runq->argv->words->next->word;*s;s++) switch(*s){
default:
goto Usage;
case 'n':
arg|=RFNAMEG; break;
case 'N':
arg|=RFCNAMEG;
break;
case 'm':
arg|=RFNOMNT; break;
case 'e':
arg|=RFENVG; break;
case 'E':
arg|=RFCENVG; break;
case 's':
arg|=RFNOTEG; break;
case 'f':
arg|=RFFDG; break;
case 'F':
arg|=RFCFDG; break;
}
break;
default:
Usage:
pfmt(err, "Usage: %s [fnesFNEm]\n", runq->argv->words->word);
setstatus("rfork usage");
poplist();
return;
}
if(rfork(arg)==-1){
pfmt(err, "rc: %s failed\n", runq->argv->words->word);
setstatus("rfork failed");
}
else
setstatus("");
poplist();
}
示例10: Xwrite
void
Xwrite(void)
{
char *file;
int f;
switch(count(runq->argv->words)){
default:
Xerror1("> requires singleton\n");
return;
case 0:
Xerror1("> requires file\n");
return;
case 1:
break;
}
file = runq->argv->words->word;
if((f = Creat(file))<0){
pfmt(err, "%s: ", file);
Xerror("can't open");
return;
}
pushredir(ROPEN, f, runq->code[runq->pc].i);
runq->pc++;
poplist();
}
示例11: execshift
void
execshift(void)
{
int n;
word *a;
var *star;
switch(count(runq->argv->words)){
default:
pfmt(err, "Usage: shift [n]\n");
setstatus("shift usage");
poplist();
return;
case 2:
n = atoi(runq->argv->words->next->word);
break;
case 1:
n = 1;
break;
}
star = vlook("*");
for(;n && star->val;--n){
a = star->val->next;
efree(star->val->word);
efree((char *)star->val);
star->val = a;
star->changed = 1;
}
setstatus("");
poplist();
}
示例12: yyerror
void
yyerror(char *s)
{
extern unsigned char /**cmdname,*/ *curfname;
static int been_here = 0;
if (been_here++ > 2)
return;
pfmt(stderr, (MM_ERROR | MM_NOGET), "%s", s);
pfmt(stderr, MM_NOSTD, atline, lineno);
if (curfname != NULL)
pfmt(stderr, MM_NOSTD, infunc, curfname);
fprintf(stderr, "\n");
errorflag = 2;
eprint();
}
示例13: Abort
void
Abort(void)
{
pfmt(err, "aborting\n");
flush(err);
Exit("aborting");
}
示例14: efree
void
efree(void *p)
{
/* pfmt(err, "free %p\n", p); flush(err); /**/
if(p)
free(p);
else pfmt(err, "free 0\n");
}
示例15: execcd
void
execcd(void)
{
word *a = runq->argv->words;
word *cdpath;
char dir[512];
setstatus("can't cd");
cdpath = vlook("cdpath")->val;
switch(count(a)){
default:
pfmt(err, "Usage: cd [directory]\n");
break;
case 2:
if(a->next->word[0]=='/' || cdpath==0)
cdpath=&nullpath;
for(;cdpath;cdpath = cdpath->next){
strcpy(dir, cdpath->word);
if(dir[0])
strcat(dir, "/");
strcat(dir, a->next->word);
if(dochdir(dir)>=0){
if(strlen(cdpath->word)
&& strcmp(cdpath->word, ".")!=0)
pfmt(err, "%s\n", dir);
setstatus("");
break;
}
}
if(cdpath==0)
pfmt(err, "Can't cd %s: %r\n", a->next->word);
break;
case 1:
a = vlook("home")->val;
if(count(a)>=1){
if(dochdir(a->word)>=0)
setstatus("");
else
pfmt(err, "Can't cd %s: %r\n", a->word);
}
else
pfmt(err, "Can't cd -- $home empty\n");
break;
}
poplist();
}