📄 maker.c
字号:
DeallocateMemory(target);
DeallocateMemory(path);
}
DeallocateMemory(buf);
return (0);
}
//-------------------------------------------------------------------------
void ReleaseFile(FILEREC *file)
{
DeallocateMemory(file->depends);
DeallocateMemory(file->target);
DeallocateMemory(file->path);
DeallocateMemory(file);
}
//-------------------------------------------------------------------------
FILEREC *RecurseTarget(short *target)
{
FILEREC *q = FileData(target), *r, *rv = q, *foundimp = 0;
short *d, *de;
if (!q)
return (0);
if (q->targetable)
{
d = q->depends;
de = d + pstrlen(d);
while (de > d)
{
FILEREC *s;
*de = 0;
de--;
while (de > d && iswhitespacechar(*de))
de--;
if (de >= d)
{
*(de + 1) = 0;
do
{
de--;
}
while (de >= d && !iswhitespacechar(*de));
}
if (de >= d - 1)
{
r = RecurseTarget(de + 1);
if (r)
{
if (de == d - 1)
foundimp = r;
s = r;
while (s->link)
s = s->link;
s->parent = q;
s->link = rv;
rv = r;
}
else
if (!q->implicit)
nxtarget(de + 1);
}
}
if (q->implicit)
{
short *p = pstrchr(q->depends, ' ');
if (p)
*p = 0;
if (foundimp)
{
FILEREC *s;
if (foundimp && foundimp->depends)
{
short *p = pstrchr(foundimp->depends, ' ');
if (p)
*p = 0;
}
r = RecurseTarget(q->target);
if (r)
{
s = r;
while (s->link)
s = s->link;
s->parent = q;
s->link = rv;
rv = r;
}
}
else
{
if (q->exists)
q->targetable = FALSE;
else
{
ReleaseFile(q);
rv = 0;
}
}
}
}
return (rv);
}
//-------------------------------------------------------------------------
BOOL matches(short *string, short *wild)
{
int i;
while (*string)
{
switch (*wild)
{
case STAR:
{
int len = strlen(string) - strlen(++wild);
char buf[40];
for (i = 0; i < len; i++)
{
int j;
for (j = 0; j < i; j++)
buf[j] = '?';
strcat(&buf[j], wild);
if (matches(string, buf))
return (TRUE);
}
}
return (FALSE);
case QMARK:
string++;
wild++;
break;
default:
if (*string != *wild)
return (FALSE);
}
}
while (*wild++)
{
if (*wild != STAR && *wild != QMARK)
return (FALSE);
}
return (TRUE);
}
//-------------------------------------------------------------------------
void Stamp(FILEREC *rec, char *string)
{
if (prm_displaystamp)
{
char buf[200];
CompressFile(buf, rec->path);
printf("%-30s:%s ", buf, string);
if (rec->exists)
{
int month, day, year, hour, minute, second;
year = (rec->time >> 25) + 1980;
month = (rec->time >> 21) &0xf;
day = (rec->time >> 16) &0x1f;
hour = (rec->time >> 11) &0x1f;
minute = (rec->time >> 5) &0x3f;
second = (rec->time &0x1f) *2;
printf("%2d-%s-%4d %02d:%02d:%02d\n", day, months[month - 1], year,
hour, minute, second);
}
else
printf("No file\n");
}
}
//-------------------------------------------------------------------------
FILEREC *Weed(FILEREC *list)
{
FILEREC *p = list, **q, *r;
while (p)
{
if (!p->exists)
p->timedout = TRUE;
if (p->parent && (p->time > p->parent->time || p->timedout ||
prm_buildall))
p->parent->timedout = TRUE;
p = p->link;
}
p = list;
while (p)
{
q = &(p->link);
while (*q)
{
if (!pstrcmp((*q)->path, p->path))
{
r = (*q);
(*q) = r->link;
ReleaseFile(r);
}
q = *q;
}
p = p->link;
}
p = list;
while (p)
{
if (p->timedout)
Stamp(p, "*");
else
Stamp(p, " ");
p = p->link;
}
p = list;
q = &p;
while (*q)
{
while (*q && !(*q)->timedout)
{
r = *q;
*q = r->link;
ReleaseFile(r);
}
while (*q && (*q)->timedout)
q = *q;
}
return (p);
}
//-------------------------------------------------------------------------
FILEREC *RecurseAllTargets(void)
{
LIST *p = targetlist;
FILEREC *rv = 0;
targetlist = 0;
if (!p)
return (0);
while (p)
{
short *c = p->data;
FILEREC **s, *q;
if (!pstrchr(c, '*') && !pstrchr(c, '?'))
{
q = RecurseTarget(c);
if (!q)
nxtarget(c);
s = &rv;
while (*s)
s = *s;
*s = q;
}
else
{
int i;
REGISTRY *x;
for (i = 0; i < HASH_TABLE_SIZE; i++)
{
x = hashtable[i];
while (x && x->type == R_EXPLICIT)
{
if (matches(x->name, c))
{
q = RecurseTarget(c);
s = &rv;
while (*s)
s = *s;
*s = q;
}
x = x->link;
}
}
}
p = p->link;
}
return (Weed(rv));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -