/*****************************************************************************/
/* */
-/* filetab.h */
+/* filetab.h */
/* */
-/* Input file table for ca65 */
+/* Input file table for ca65 */
/* */
/* */
/* */
static unsigned HT_GenHash (const void* Key);
/* Generate the hash over a key. */
-static const void* HT_GetKey (void* Entry);
+static const void* HT_GetKey (const void* Entry);
/* Given a pointer to the user entry data, return a pointer to the key. */
static int HT_Compare (const void* Key1, const void* Key2);
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
struct FileEntry {
HashNode Node;
unsigned Name; /* File name */
- unsigned Index; /* Index of entry */
+ unsigned Index; /* Index of entry */
FileType Type; /* Type of file */
- unsigned long Size; /* Size of file */
- unsigned long MTime; /* Time of last modification */
+ unsigned long Size; /* Size of file */
+ unsigned long MTime; /* Time of last modification */
};
/* Array of all entries, listed by index */
-static const void* HT_GetKey (void* Entry)
+static const void* HT_GetKey (const void* Entry)
/* Given a pointer to the user entry data, return a pointer to the index */
{
return &((FileEntry*) Entry)->Name;
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
/* Initialize the fields */
InitHashNode (&F->Node);
F->Name = Name;
- F->Index = CollCount (&FileTab) + 1; /* First file has index #1 */
+ F->Index = CollCount (&FileTab) + 1; /* First file has index #1 */
F->Type = Type;
- F->Size = Size;
- F->MTime = MTime;
+ F->Size = Size;
+ F->MTime = MTime;
/* Insert the file into the file table */
CollAppend (&FileTab, F);
/* Insert the entry into the hash table */
- HT_Insert (&HashTab, &F->Node);
+ HT_Insert (&HashTab, F);
/* Return the new entry */
return F;
const FileEntry* F;
if (Name == 0) {
- /* Name was defined outside any file scope, use the name of the first
- * file instead. Errors are then reported with a file position of
- * line zero in the first file.
- */
- if (CollCount (&FileTab) == 0) {
- /* No files defined until now */
+ /* Name was defined outside any file scope, use the name of the first
+ * file instead. Errors are then reported with a file position of
+ * line zero in the first file.
+ */
+ if (CollCount (&FileTab) == 0) {
+ /* No files defined until now */
return &ErrorMsg;
- } else {
+ } else {
F = CollConstAt (&FileTab, 0);
- }
+ }
} else {
F = CollConstAt (&FileTab, Name-1);
}
unsigned NameIdx = GetStrBufId (Name);
/* Search in the hash table for the name */
- FileEntry* F = HT_FindEntry (&HashTab, &NameIdx);
+ const FileEntry* F = HT_Find (&HashTab, &NameIdx);
/* If we don't have this index, print a diagnostic and use the main file */
if (F == 0) {
/* Write the file data */
for (I = 0; I < CollCount (&FileTab); ++I) {
- /* Get a pointer to the entry */
- const FileEntry* F = CollConstAt (&FileTab, I);
- /* Write the fields */
- ObjWriteVar (F->Name);
- ObjWrite32 (F->MTime);
- ObjWriteVar (F->Size);
+ /* Get a pointer to the entry */
+ const FileEntry* F = CollConstAt (&FileTab, I);
+ /* Write the fields */
+ ObjWriteVar (F->Name);
+ ObjWrite32 (F->MTime);
+ ObjWriteVar (F->Size);
}
/* Done writing files */
const StrBuf* Filename;
- /* Get the next input file */
- const FileEntry* E = (const FileEntry*) CollAt (&FileTab, I);
+ /* Get the next input file */
+ const FileEntry* E = (const FileEntry*) CollAt (&FileTab, I);
/* Ignore it if it is not of the correct type */
if ((E->Type & Types) == 0) {
continue;
}
- /* If this is not the first file, add a space */
- if (I > 0) {
+ /* If this is not the first file, add a space */
+ if (I > 0) {
fputc (' ', F);
}
- /* Print the dependency */
+ /* Print the dependency */
Filename = GetStrBuf (E->Name);
fprintf (F, "%*s", SB_GetLen (Filename), SB_GetConstBuf (Filename));
}
/* Open the file */
FILE* F = fopen (Name, "w");
if (F == 0) {
- Fatal ("Cannot open dependency file `%s': %s", Name, strerror (errno));
+ Fatal ("Cannot open dependency file `%s': %s", Name, strerror (errno));
}
/* Print the output file followed by a tab char */
/* Close the file, check for errors */
if (fclose (F) != 0) {
- remove (Name);
- Fatal ("Cannot write to dependeny file (disk full?)");
+ remove (Name);
+ Fatal ("Cannot write to dependeny file (disk full?)");
}
}
FT_MAIN | FT_INCLUDE | FT_BINARY | FT_DBGINFO);
}
}
-
-