~ubuntu-branches/ubuntu/utopic/9base/utopic

« back to all changes in this revision

Viewing changes to rc/subr.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-08-20 17:34:06 UTC
  • mfrom: (6.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090820173406-xpwqa9ruyevvc0ut
* Updating maintainer field.
* Updating vcs fields.
* Updating package to standards version 3.8.3.
* Updatin variables writing in rules to consistent style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#include "exec.h"
3
3
#include "io.h"
4
4
#include "fns.h"
5
 
char *emalloc(long n){
6
 
        char *p=(char *)Malloc(n);
7
 
        if(p==0) panic("Can't malloc %d bytes", n);
8
 
/*      if(err){ pfmt(err, "malloc %d->%p\n", n, p); flush(err); } *//**/
 
5
 
 
6
char*
 
7
emalloc(long n)
 
8
{
 
9
        char *p = (char *)Malloc(n);
 
10
        if(p==0)
 
11
                panic("Can't malloc %d bytes", n);
 
12
/*      if(err){ pfmt(err, "malloc %d->%p\n", n, p); flush(err); } /**/
 
13
        memset(p, 0, n);
9
14
        return p;
10
15
}
11
 
void efree(char *p)
 
16
 
 
17
void
 
18
efree(char *p)
12
19
{
13
 
/*      pfmt(err, "free %p\n", p); flush(err); *//**/
14
 
        if(p) free(p);
 
20
/*      pfmt(err, "free %p\n", p); flush(err); /**/
 
21
        if(p)
 
22
                free(p);
15
23
        else pfmt(err, "free 0\n");
16
24
}
17
25
extern int lastword, lastdol;
18
 
void yyerror(char *m)
 
26
 
 
27
void
 
28
yyerror(char *m)
19
29
{
20
30
        pfmt(err, "rc: ");
21
31
        if(runq->cmdfile && !runq->iflag)
24
34
                pfmt(err, "%s: ", runq->cmdfile);
25
35
        else if(!runq->iflag)
26
36
                pfmt(err, "line %d: ", runq->lineno);
27
 
        if(tok[0] && tok[0]!='\n') pfmt(err, "token %q: ", tok);
 
37
        if(tok[0] && tok[0]!='\n')
 
38
                pfmt(err, "token %q: ", tok);
28
39
        pfmt(err, "%s\n", m);
29
40
        flush(err);
30
 
        lastword=0;
31
 
        lastdol=0;
 
41
        lastword = 0;
 
42
        lastdol = 0;
32
43
        while(lastc!='\n' && lastc!=EOF) advance();
33
44
        nerror++;
34
45
        setvar("status", newword(m, (word *)0));
35
46
}
36
47
char *bp;
37
 
void iacvt(int n){
 
48
 
 
49
static void
 
50
iacvt(int n)
 
51
{
38
52
        if(n<0){
39
53
                *bp++='-';
40
54
                n=-n;   /* doesn't work for n==-inf */
43
57
                iacvt(n/10);
44
58
        *bp++=n%10+'0';
45
59
}
46
 
void itoa(char *s, long n)
 
60
 
 
61
void
 
62
inttoascii(char *s, long n)
47
63
{
48
 
        bp=s;
 
64
        bp = s;
49
65
        iacvt(n);
50
66
        *bp='\0';
51
67
}
52
 
void panic(char *s, int n)
 
68
 
 
69
void
 
70
panic(char *s, int n)
53
71
{
54
72
        pfmt(err, "rc: ");
55
73
        pfmt(err, s, n);