~ubuntu-branches/ubuntu/natty/9base/natty

« back to all changes in this revision

Viewing changes to mk/file.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
Tags: 1:3-3
* 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:
1
 
#include        "mk.h"
2
 
 
3
 
/* table-driven version in bootes dump of 12/31/96 */
4
 
 
5
 
long
6
 
mtime(char *name)
7
 
{
8
 
        return mkmtime(name);
9
 
}
10
 
 
11
 
long
12
 
timeof(char *name, int force)
13
 
{
14
 
        Symtab *sym;
15
 
        long t;
16
 
 
17
 
        if(utfrune(name, '('))
18
 
                return atimeof(force, name);    /* archive */
19
 
 
20
 
        if(force)
21
 
                return mtime(name);
22
 
 
23
 
 
24
 
        sym = symlook(name, S_TIME, 0);
25
 
        if (sym)
26
 
                return (long) sym->value;               /* uggh */
27
 
 
28
 
        t = mtime(name);
29
 
        if(t == 0)
30
 
                return 0;
31
 
 
32
 
        symlook(name, S_TIME, (void*)t);                /* install time in cache */
33
 
        return t;
34
 
}
35
 
 
36
 
void
37
 
touch(char *name)
38
 
{
39
 
        Bprint(&bout, "touch(%s)\n", name);
40
 
        if(nflag)
41
 
                return;
42
 
 
43
 
        if(utfrune(name, '('))
44
 
                atouch(name);           /* archive */
45
 
        else if(chgtime(name) < 0) {
46
 
                fprint(2, "%s: %r\n", name);
47
 
                Exit();
48
 
        }
49
 
}
50
 
 
51
 
void
52
 
delete(char *name)
53
 
{
54
 
        if(utfrune(name, '(') == 0) {           /* file */
55
 
                if(remove(name) < 0)
56
 
                        fprint(2, "remove %s: %r\n", name);
57
 
        } else
58
 
                fprint(2, "hoon off; mk can'tdelete archive members\n");
59
 
}
60
 
 
61
 
void
62
 
timeinit(char *s)
63
 
{
64
 
        long t;
65
 
        char *cp;
66
 
        Rune r;
67
 
        int c, n;
68
 
 
69
 
        t = time(0);
70
 
        while (*s) {
71
 
                cp = s;
72
 
                do{
73
 
                        n = chartorune(&r, s);
74
 
                        if (r == ' ' || r == ',' || r == '\n')
75
 
                                break;
76
 
                        s += n;
77
 
                } while(*s);
78
 
                c = *s;
79
 
                *s = 0;
80
 
                symlook(strdup(cp), S_TIME, (void *)t)->value = (void *)t;
81
 
                if (c)
82
 
                        *s++ = c;
83
 
                while(*s){
84
 
                        n = chartorune(&r, s);
85
 
                        if(r != ' ' && r != ',' && r != '\n')
86
 
                                break;
87
 
                        s += n;
88
 
                }
89
 
        }
90
 
}