keep track of missing resources as well.

This commit is contained in:
Kelvin Sherlock 2018-07-27 08:42:17 -04:00
parent d527ab6ada
commit aac93fc859
1 changed files with 30 additions and 13 deletions

43
rlint.c
View File

@ -21,6 +21,7 @@ unsigned flag_v = 0;
struct node { struct node {
struct node *next; struct node *next;
unsigned status;
ResType type; ResType type;
ResID id; ResID id;
}; };
@ -43,7 +44,7 @@ void free_processed_map(void) {
} }
} }
unsigned processed(ResType type, ResID id) { unsigned *processed(ResType type, ResID id) {
unsigned hash = 0xaaaa; unsigned hash = 0xaaaa;
struct node *e; struct node *e;
@ -56,16 +57,17 @@ unsigned processed(ResType type, ResID id) {
e = processed_map[hash]; e = processed_map[hash];
while(e) { while(e) {
if (e->type == type && e->id == id) return 1; if (e->type == type && e->id == id) return &e->status;
e = e->next; e = e->next;
} }
e = malloc(sizeof(struct node)); e = malloc(sizeof(struct node));
e->next = processed_map[hash]; e->next = processed_map[hash];
e->status = 0;
e->type = type; e->type = type;
e->id = id; e->id = id;
processed_map[hash] = e; processed_map[hash] = e;
return 0; return &e->status;
} }
char *ResName(ResType type) { char *ResName(ResType type) {
@ -168,12 +170,34 @@ void check(ResType type, ResID id) {
Handle h; Handle h;
void (*callback)(Handle); void (*callback)(Handle);
unsigned *status;
if (flag_v) { if (flag_v) {
fprintf(stdout," %s:%08lx\n", ResName(type), id); fprintf(stdout," %s:%08lx\n", ResName(type), id);
} }
if (processed(type, id)) return; history[level].type = type;
history[level].id = id;
++level;
if (id == 0) {
error("Invalid resource ID");
--level;
return;
}
status = processed(type, id);
if (*status == 2) {
/* missing */
error("Unable to load Resource");
--level;
return;
}
if (*status == 1) {
--level;
return;
}
switch(type) { switch(type) {
case rMenu: callback = check_rMenu; break; case rMenu: callback = check_rMenu; break;
@ -188,22 +212,15 @@ void check(ResType type, ResID id) {
default: callback = 0; default: callback = 0;
} }
history[level].type = type;
history[level].id = id;
++level;
if (id == 0) {
error("Invalid resource ID");
--level;
return;
}
h = LoadResource(type, id); h = LoadResource(type, id);
if (_toolErr) { if (_toolErr) {
*status = 2;
error("Unable to load Resource"); error("Unable to load Resource");
--level; --level;
return; return;
} }
*status = 1;
if (callback) { if (callback) {
HLock(h); HLock(h);