This commit is contained in:
Kelvin Sherlock 2018-07-19 21:35:32 -04:00
parent 06fa20d449
commit fc67e2e791
5 changed files with 119 additions and 109 deletions

View File

@ -1,18 +1,18 @@
OBJ = o/rlint.a o/menu.a o/control.a OBJ = o/rlint.a o/menu.a o/control.a
rlint : $(OBJ) rlint : $(OBJ)
$(RM) o/menu.root o/control.root $(RM) o/menu.root o/control.root
iix link o/rlint o/menu o/control keep=$@ iix link o/rlint o/menu o/control keep=$@
o/rlint.a : rlint.c rlint.h o/rlint.a : rlint.c rlint.h
o/menu.a : menu.c rlint.h o/menu.a : menu.c rlint.h
o/control.a : control.c rlint.h o/control.a : control.c rlint.h
o : o :
mkdir $@ mkdir $@
o/%.a : %.c | o o/%.a : %.c | o
iix compile $< keep=o/$* iix compile $< keep=o/$*

View File

@ -11,7 +11,7 @@ void check_rControlList(Handle h) {
for(i = 0; ; ++i) { for(i = 0; ; ++i) {
Ref ref = list[i]; Ref ref = list[i];
if (!ref) break; if (!ref) break;
check(rControl, ref, check_rControl); check(rControlTemplate, ref);
} }
} }
@ -22,48 +22,48 @@ void check_rControlTemplate(Handle h) {
unsigned moreFlags = ptr->moreFlags; unsigned moreFlags = ptr->moreFlags;
if (ptr->procRef == simpleButtonControl) { if (ptr->procRef == simpleButtonControl) {
ref = (SimpleButtonTemplate *)ptr->titleRef; ref = ((SimpleButtonTemplate *)ptr)->titleRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rPString, ref, check_rPString); check(rPString, ref);
ref = (SimpleButtonTemplate *)ptr->colorTableRef; ref = ((SimpleButtonTemplate *)ptr)->colorTableRef;
if ((moreFlags & 0x0c) == colorTableIsResource) if ((moreFlags & 0x0c) == colorTableIsResource)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
return; return;
} }
if (ptr->procRef == checkControl) { if (ptr->procRef == checkControl) {
ref = (CheckBoxTemplate *)ptr->titleRef; ref = ((CheckBoxTemplate *)ptr)->titleRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rPString, ref, check_rPString); check(rPString, ref);
ref = (CheckBoxTemplate *)ptr->colorTableRef; ref = ((CheckBoxTemplate *)ptr)->colorTableRef;
if ((moreFlags & 0x0c) == colorTableIsResource) if ((moreFlags & 0x0c) == colorTableIsResource)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
return; return;
} }
if (ptr->procRef == radioControl) { if (ptr->procRef == radioControl) {
ref = (RadioButtonTemplate *)ptr->titleRef; ref = ((RadioButtonTemplate *)ptr)->titleRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rPString, ref, check_rPString); check(rPString, ref);
ref = (RadioButtonTemplate *)ptr->colorTableRef; ref = ((RadioButtonTemplate *)ptr)->colorTableRef;
if ((moreFlags & 0x0c) == colorTableIsResource) if ((moreFlags & 0x0c) == colorTableIsResource)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
return; return;
} }
if (ptr->procRef == scrollBarControl) { if (ptr->procRef == scrollBarControl) {
ref = (ScrollBarTemplate *)ptr->colorTableRef; ref = ((ScrollBarTemplate *)ptr)->colorTableRef;
if ((moreFlags & 0x0c) == colorTableIsResource) if ((moreFlags & 0x0c) == colorTableIsResource)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
return; return;
} }
@ -71,61 +71,61 @@ void check_rControlTemplate(Handle h) {
if (ptr->procRef == iconButtonControl) { if (ptr->procRef == iconButtonControl) {
ref = (IconButtonTemplate *)ptr->titleRef; ref = ((IconButtonTemplate *)ptr)->titleRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rPString, ref, check_rPString); check(rPString, ref);
ref = (IconButtonTemplate *)ptr->colorTableRef; ref = ((IconButtonTemplate *)ptr)->colorTableRef;
if ((moreFlags & 0x0c) == colorTableIsResource) if ((moreFlags & 0x0c) == colorTableIsResource)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
ref = (IconButtonTemplate *)ptr->iconRef; ref = ((IconButtonTemplate *)ptr)->iconRef;
if ((moreFlags & 0x30) == 0x20) if ((moreFlags & 0x30) == 0x20)
check(rIcon, ref, check_rIcon); check(rIcon, ref);
return; return;
} }
if (ptr->procRef == scrollBarControl) { if (ptr->procRef == scrollBarControl) {
ref = (LineEditTemplate *)ptr->defaultRef; ref = ((LineEditTemplate *)ptr)->defaultRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rPString, ref, check_rPString); check(rPString, ref);
return; return;
} }
if (ptr->procRef == listControl) { if (ptr->procRef == listControl) {
ref = (ListTemplate *)ptr->listRef; ref = ((ListTemplate *)ptr)->listRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rListRef, ref, check_rListRef); check(rListRef, ref);
ref = (ListTemplate *)ptr->colorTableRef; ref = ((ListTemplate *)ptr)->colorTableRef;
if ((moreFlags & 0x0c) == colorTableIsResource) if ((moreFlags & 0x0c) == colorTableIsResource)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
return; return;
} }
if (ptr->procRef == pictureControl) { if (ptr->procRef == pictureControl) {
ref = (PictureTemplate *)ptr->pictureRef; ref = ((PictureTemplate *)ptr)->pictureRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rPicture, ref, check_rPicture); check(rPicture, ref);
return; return;
} }
if (ptr->procRef == popUpControl) { if (ptr->procRef == popUpControl) {
ref = (PopupTemplate *)ptr->menuRef; ref = ((PopupTemplate *)ptr)->menuRef;
if ((moreFlags & 0x07) == titleIsResource) if ((moreFlags & 0x07) == titleIsResource)
check(rMenu, ref, check_rMenu); check(rMenu, ref);
ref = (PopupTemplate *)ptr->colorTableRef; ref = ((PopupTemplate *)ptr)->colorTableRef;
if ((moreFlags & 0x18) == 0x10) if ((moreFlags & 0x18) == 0x10)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
return; return;
} }
@ -133,9 +133,9 @@ void check_rControlTemplate(Handle h) {
if (ptr->procRef == growControl) { if (ptr->procRef == growControl) {
ref = (SizeBoxTemplate *)ptr->colorTableRef; ref = ((SizeBoxTemplate *)ptr)->colorTableRef;
if ((moreFlags & 0x0c) == colorTableIsResource) if ((moreFlags & 0x0c) == colorTableIsResource)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
return; return;
} }
@ -143,9 +143,9 @@ void check_rControlTemplate(Handle h) {
if (ptr->procRef == statTextControl) { if (ptr->procRef == statTextControl) {
ref = (StaticTextTemplate *)ptr->textRef; ref = ((StaticTextTemplate *)ptr)->textRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rTextForLETextBox2, ref, check_rTextForLETextBox2); check(rTextForLETextBox2, ref);
return; return;
} }
@ -153,13 +153,13 @@ void check_rControlTemplate(Handle h) {
if (ptr->procRef == editTextControl) { if (ptr->procRef == editTextControl) {
ref = (TextEditTemplate *)ptr->styleRef; ref = ((TextEditTemplate *)ptr)->styleRef;
if ((moreFlags & 0x03) == titleIsResource) if ((moreFlags & 0x03) == titleIsResource)
check(rStyleBlock, ref, check_rStyleBlock); check(rStyleBlock, ref);
ref = (TextEditTemplate *)ptr->colorRef; ref = ((TextEditTemplate *)ptr)->colorRef;
if ((moreFlags & 0x0c) == colorTableIsResource) if ((moreFlags & 0x0c) == colorTableIsResource)
check(rCtlColorTbl, ref, check_rCtlColorTbl); check(rCtlColorTbl, ref);
return; return;
} }
@ -172,17 +172,17 @@ void check_rWindParam1(Handle h) {
Ref ref; Ref ref;
unsigned desc = ptr->p1InDesc; unsigned desc = ptr->p1InDesc;
ref = ptr->p1Title; ref = (Ref)ptr->p1Title;
if (desc & 0x0200) check(rPString, ref, check_rPString); if (desc & 0x0200) check(rPString, ref);
ref = ptr->p1ColorTable; ref = (Ref)ptr->p1ColorTable;
if (desc & 0x0800) check(rWindColor, ref, check_rWindColor); if (desc & 0x0800) check(rWindColor, ref);
ref = ptr->p1ControlList; ref = (Ref)ptr->p1ControlList;
switch(desc & 0xff) { switch(desc & 0xff) {
case singleResource: check(rControlTemplate, ref, check_rControlTemplate); break; case singleResource: check(rControlTemplate, ref); break;
case resourceToResource: check(rControlList, ref, check_rControlList); break; case resourceToResource: check(rControlList, ref); break;
default: /* warn about invalid value ? */ default: break; /* warn about invalid value ? */
} }
} }

16
menu.c
View File

@ -16,11 +16,11 @@ void check_rMenuItem(Handle h) {
if (mi->itemFlag & 0x0400) { if (mi->itemFlag & 0x0400) {
if (mi->itemFlag & 0x200) { if (mi->itemFlag & 0x200) {
if (ref) check(rItemStruct, ref, check_rItemStruct); if (ref) check(rItemStruct, ref);
} }
} }
else if (mi->itemFlag & mRefResource) { else if (mi->itemFlag & mRefResource) {
if (ref) check(rPString, ref, check_rPString); if (ref) check(rPString, ref);
} }
} }
@ -33,13 +33,13 @@ void check_rMenu(Handle h) {
m = *(MenuTemplate **)h; m = *(MenuTemplate **)h;
if (m->menuFlag & mRefResource) { if (m->menuFlag & mRefResource) {
ref = m->menuTitleRef; ref = m->menuTitleRef;
if (ref) check(rPString, ref, check_rPString); if (ref) check(rPString, ref);
} }
if (m->menuFlag & 0x2000) { if (m->menuFlag & 0x2000) {
for (i = 0; ; ++i) { for (i = 0; ; ++i) {
ref = m->itemRefArray[i]; ref = m->itemRefArray[i];
if (!ref) break; if (!ref) break;
check(rMenuItem, ref, check_rMenuItem); check(rMenuItem, ref);
} }
} }
} }
@ -55,7 +55,7 @@ void check_rMenuBar(Handle h) {
for (i = 0; ; ++i) { for (i = 0; ; ++i) {
Ref ref = mb->menuRefArray[i]; Ref ref = mb->menuRefArray[i];
if (!ref) break; if (!ref) break;
check(rMenu, ref, check_rMenu); check(rMenu, ref);
} }
} }
} }
@ -69,12 +69,10 @@ void check_rItemStruct(Handle h) {
ptr = *(itemStruct **)h; ptr = *(itemStruct **)h;
if (ptr->itemFlag2 & mRefResource) { if (ptr->itemFlag2 & mRefResource) {
ref = ptr->itemTitleRef; ref = ptr->itemTitleRef;
if (ref) check(rPString, ref, check_rPString); if (ref) check(rPString, ref);
ref = ptr->itemIconRef; ref = ptr->itemIconRef;
if (ref) check(rIcon, ref, check_rIcon); if (ref) check(rIcon, ref);
} }
} }

44
rlint.c
View File

@ -6,7 +6,7 @@
#include <gsos.h> #include <gsos.h>
#include <resources.h> #include <resources.h>
#include <memory.h>
#include "rlint.h" #include "rlint.h"
@ -108,17 +108,30 @@ void check_rStringList(Handle h){
unsigned i; unsigned i;
for (i = 0; i < ptr->count; ++i) { for (i = 0; i < ptr->count; ++i) {
Ref ref = ptr->strings[i]; Ref ref = ptr->strings[i];
if (ref) check(rPString, ref, check_rPString); if (ref) check(rPString, ref);
} }
} }
void check(ResType type, ResID id, void (*callback)(Handle)) { void check(ResType type, ResID id) {
Handle h; Handle h;
void (*callback)(Handle);
switch(type) {
case rMenu: callback = check_rMenu; break;
case rMenuItem: callback = check_rMenuItem; break;
case rMenuBar: callback = check_rMenuBar; break;
case rItemStruct: callback = check_rItemStruct; break;
case rControlList: callback = check_rControlList; break;
case rControlTemplate: callback = check_rControlTemplate; break;
case rWindParam1: callback = check_rWindParam1; break;
case rStringList: callback = check_rStringList; break;
default: callback = 0;
}
history[level].type = type; history[level].type = type;
history[level].id = id; history[level].id = id;
++level; ++level;
@ -177,7 +190,7 @@ void one_file(const char *name) {
rfd = OpenResourceFile(0x8000 | readEnable, NULL, (Pointer)gname); rfd = OpenResourceFile(0x8000 | readEnable, NULL, (Pointer)gname);
if (_toolErr) { if (_toolErr) {
++error_count; ++error_count;
fprintf(stderr, "%s: OpenResourceFile: $%04x\n", name); fprintf(stderr, "%s: OpenResourceFile: $%04x\n", name, _toolErr);
free(gname); free(gname);
return; return;
} }
@ -186,7 +199,6 @@ void one_file(const char *name) {
/* now iterate through all resource types... */ /* now iterate through all resource types... */
for (ti = 1; ; ++ti) { for (ti = 1; ; ++ti) {
void (*callback)(Handle) = 0;
ResType type = GetIndType(ti); ResType type = GetIndType(ti);
if (_toolErr == resIndexRange) break; if (_toolErr == resIndexRange) break;
if (_toolErr) { if (_toolErr) {
@ -195,15 +207,17 @@ void one_file(const char *name) {
} }
switch(type) { switch(type) {
case rMenu: callback = check_rMenu; break; case rMenu:
case rMenuItem: callback = check_rMenuItem; break; case rMenuItem:
case rMenuBar: callback = check_rMenuBar; break; case rMenuBar:
case rItemStruct: callback = check_rItemStruct; break; case rItemStruct:
case rControlList: callback = check_rControlList; break; case rControlList:
case rControlTemplate: callback = check_rControlTemplate; break; case rControlTemplate:
case rWindParam1: callback = check_rWindParam1; break; case rWindParam1:
case rStringList: callback = check_rStringList; break; case rStringList:
default: callback = 0; break;
default:
continue;
} }
for (ri = 1; ; ++ri) { for (ri = 1; ; ++ri) {
@ -213,7 +227,7 @@ void one_file(const char *name) {
fprintf(stderr, "%s: GetIndResource: $%04x\n", name, _toolErr); fprintf(stderr, "%s: GetIndResource: $%04x\n", name, _toolErr);
continue; continue;
} }
check(type, id, callback); check(type, id);
} }
} }

36
rlint.h
View File

@ -1,19 +1,17 @@
#include <types.h> #include <types.h>
#include <resources.h> #include <resources.h>
void check_rMenu(Handle h); void check_rMenu(Handle h);
void check_rMenuItem(Handle h); void check_rMenuItem(Handle h);
void check_rMenuBar(Handle h); void check_rMenuBar(Handle h);
void check_rItemStruct(Handle h); void check_rItemStruct(Handle h);
void check_rControlList(Handle h); void check_rControlList(Handle h);
void check_rControlTemplate(Handle h); void check_rControlTemplate(Handle h);
void check_rWindParam1(Handle h); void check_rWindParam1(Handle h);
void check_rStringList(Handle h); void check_rStringList(Handle h);
#define check_rPString 0 void error(const char *msg);
#define check_rIcon 0 void check(ResType type, ResID id);
#define check_rWindColor 0
#define check_rCtlColorTbl 0 #pragma lint -1
#pragma optimize -1
void error(const char *msg);
void check(ResType type, ResID id, void (*callback)(Handle));