sync with plan 9

This commit is contained in:
rsc 2007-03-26 12:02:41 +00:00
parent 79049567a0
commit c8f538425f
23 changed files with 1962 additions and 1227 deletions

View file

@ -2,20 +2,29 @@
#include "exec.h"
#include "io.h"
#include "fns.h"
char *emalloc(long n){
char *p=(char *)Malloc(n);
if(p==0) panic("Can't malloc %d bytes", n);
/* if(err){ pfmt(err, "malloc %d->%p\n", n, p); flush(err); } */
char*
emalloc(long n)
{
char *p = (char *)Malloc(n);
if(p==0)
panic("Can't malloc %d bytes", n);
/* if(err){ pfmt(err, "malloc %d->%p\n", n, p); flush(err); } /**/
return p;
}
void efree(char *p)
void
efree(char *p)
{
/* pfmt(err, "free %p\n", p); flush(err); */
if(p) free(p);
/* pfmt(err, "free %p\n", p); flush(err); /**/
if(p)
free(p);
else pfmt(err, "free 0\n");
}
extern int lastword, lastdol;
void yyerror(char *m)
void
yyerror(char *m)
{
pfmt(err, "rc: ");
if(runq->cmdfile && !runq->iflag)
@ -24,17 +33,21 @@ void yyerror(char *m)
pfmt(err, "%s: ", runq->cmdfile);
else if(!runq->iflag)
pfmt(err, "line %d: ", runq->lineno);
if(tok[0] && tok[0]!='\n') pfmt(err, "token %q: ", tok);
if(tok[0] && tok[0]!='\n')
pfmt(err, "token %q: ", tok);
pfmt(err, "%s\n", m);
flush(err);
lastword=0;
lastdol=0;
lastword = 0;
lastdol = 0;
while(lastc!='\n' && lastc!=EOF) advance();
nerror++;
setvar("status", newword(m, (word *)0));
}
char *bp;
void iacvt(int n){
static void
iacvt(int n)
{
if(n<0){
*bp++='-';
n=-n; /* doesn't work for n==-inf */
@ -43,13 +56,17 @@ void iacvt(int n){
iacvt(n/10);
*bp++=n%10+'0';
}
void itoa(char *s, long n)
void
inttoascii(char *s, long n)
{
bp=s;
bp = s;
iacvt(n);
*bp='\0';
}
void panic(char *s, int n)
void
panic(char *s, int n)
{
pfmt(err, "rc: ");
pfmt(err, s, n);