Removed (pretty inconsistently used) tab chars from source code base.

This commit is contained in:
Oliver Schmidt
2013-05-09 13:56:54 +02:00
parent 44fd1082ae
commit 85885001b1
1773 changed files with 62864 additions and 62868 deletions

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* add.c */
/* add.c */
/* */
/* Object file adding for the ar65 archiver */
/* Object file adding for the ar65 archiver */
/* */
/* */
/* */
@@ -43,7 +43,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -55,10 +55,10 @@ void AddObjFiles (int argc, char* argv [])
/* Check the argument count */
if (argc <= 0) {
Error ("No library name given");
Error ("No library name given");
}
if (argc <= 1) {
Error ("No object files to add");
Error ("No object files to add");
}
/* Open the library, read the index */
@@ -67,8 +67,8 @@ void AddObjFiles (int argc, char* argv [])
/* Add the object files */
I = 1;
while (I < argc) {
ObjAdd (argv [I]);
++I;
ObjAdd (argv [I]);
++I;
}
/* Create a new library file and close the old one */

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* add.h */
/* add.h */
/* */
/* Object file adding for the ar65 archiver */
/* Object file adding for the ar65 archiver */
/* */
/* */
/* */
@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* del.h */
/* del.h */
/* */
/* Object file deleting for the ar65 archiver */
/* Object file deleting for the ar65 archiver */
/* */
/* */
/* */
@@ -43,7 +43,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -55,10 +55,10 @@ void DelObjFiles (int argc, char* argv [])
/* Check the argument count */
if (argc <= 0) {
Error ("No library name given");
Error ("No library name given");
}
if (argc <= 1) {
Error ("No modules to delete");
Error ("No modules to delete");
}
/* Open the library, read the index */
@@ -67,9 +67,9 @@ void DelObjFiles (int argc, char* argv [])
/* Delete the modules */
I = 1;
while (I < argc) {
/* Delete the module from the list */
DelObjData (argv [I]);
++I;
/* Delete the module from the list */
DelObjData (argv [I]);
++I;
}
/* Create a new library file and close the old one */

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* del.h */
/* del.h */
/* */
/* Object file deleting for the ar65 archiver */
/* Object file deleting for the ar65 archiver */
/* */
/* */
/* */
@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -49,7 +49,7 @@ void DelObjFiles (int argc, char* argv []);
/* End of del.h */
/* End of del.h */
#endif

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* global.c */
/* global.c */
/* */
/* Error handling for the ar65 archiver */
/* Error handling for the ar65 archiver */
/* */
/* */
/* */
@@ -46,7 +46,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* global.h */
/* global.h */
/* */
/* Error handling for the ar65 archiver */
/* Error handling for the ar65 archiver */
/* */
/* */
/* */
@@ -44,7 +44,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* exports.c */
/* exports.c */
/* */
/* Duplicate export checking for the ar65 archiver */
/* Duplicate export checking for the ar65 archiver */
/* */
/* */
/* */
@@ -48,7 +48,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -56,19 +56,19 @@
/* A hash table entry */
typedef struct HashEntry HashEntry;
struct HashEntry {
HashEntry* Next; /* Next in list */
const ObjData* Module; /* Pointer to object module */
char Name [1]; /* Name of identifier */
HashEntry* Next; /* Next in list */
const ObjData* Module; /* Pointer to object module */
char Name [1]; /* Name of identifier */
};
/* Hash table */
#define HASHTAB_SIZE 4783
static HashEntry* HashTab [HASHTAB_SIZE];
#define HASHTAB_SIZE 4783
static HashEntry* HashTab [HASHTAB_SIZE];
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -83,8 +83,8 @@ static HashEntry* NewHashEntry (const char* Name, const ObjData* Module)
HashEntry* H = xmalloc (sizeof (HashEntry) + Len);
/* Initialize the fields and return it */
H->Next = 0;
H->Module = Module;
H->Next = 0;
H->Module = Module;
memcpy (H->Name, Name, Len);
H->Name [Len] = '\0';
return H;
@@ -105,23 +105,23 @@ void ExpInsert (const char* Name, const ObjData* Module)
/* Search through the list in that slot and print matching duplicates */
if (HashTab [HashVal] == 0) {
/* The slot is empty */
HashTab [HashVal] = H;
return;
/* The slot is empty */
HashTab [HashVal] = H;
return;
}
L = HashTab [HashVal];
while (1) {
if (strcmp (L->Name, Name) == 0) {
/* Duplicate entry */
Warning ("External symbol `%s' in module `%s', library `%s' "
if (strcmp (L->Name, Name) == 0) {
/* Duplicate entry */
Warning ("External symbol `%s' in module `%s', library `%s' "
"is duplicated in module `%s'",
Name, L->Name, LibName, Module->Name);
}
if (L->Next == 0) {
break;
} else {
L = L->Next;
}
Name, L->Name, LibName, Module->Name);
}
if (L->Next == 0) {
break;
} else {
L = L->Next;
}
}
L->Next = H;
}
@@ -137,11 +137,11 @@ const ObjData* ExpFind (const char* Name)
HashEntry* L = HashTab [HashStr (Name) % HASHTAB_SIZE];
while (L) {
/* Search through the list in that slot */
if (strcmp (L->Name, Name) == 0) {
/* Entry found */
return L->Module;
}
L = L->Next;
if (strcmp (L->Name, Name) == 0) {
/* Entry found */
return L->Module;
}
L = L->Next;
}
/* Not found */

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* exports.h */
/* exports.h */
/* */
/* Duplicate export checking for the ar65 archiver */
/* Duplicate export checking for the ar65 archiver */
/* */
/* */
/* */
@@ -49,7 +49,7 @@ struct ObjData;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* extract.c */
/* extract.c */
/* */
/* Object file extraction for the ar65 archiver */
/* Object file extraction for the ar65 archiver */
/* */
/* */
/* */
@@ -43,7 +43,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -55,10 +55,10 @@ void ExtractObjFiles (int argc, char* argv [])
/* Check the argument count */
if (argc <= 0) {
Error ("No library name given");
Error ("No library name given");
}
if (argc <= 1) {
Error ("No object files to extract");
Error ("No object files to extract");
}
/* Open the library, read the index */
@@ -67,8 +67,8 @@ void ExtractObjFiles (int argc, char* argv [])
/* Extract the object files */
I = 1;
while (I < argc) {
ObjExtract (argv [I]);
++I;
ObjExtract (argv [I]);
++I;
}
/* Create a new library file and close the old one */

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* extract.h */
/* extract.h */
/* */
/* Object file extraction for the ar65 archiver */
/* Object file extraction for the ar65 archiver */
/* */
/* */
/* */
@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* fileio.c */
/* fileio.c */
/* */
/* File I/O for the ar65 archiver */
/* File I/O for the ar65 archiver */
/* */
/* */
/* */
@@ -45,7 +45,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -54,7 +54,7 @@ void Write8 (FILE* F, unsigned char Val)
/* Write an 8 bit value to the file */
{
if (putc (Val, F) == EOF) {
Error ("Write error (disk full?)");
Error ("Write error (disk full?)");
}
}
@@ -89,12 +89,12 @@ void WriteVar (FILE* F, unsigned long V)
* needing 5 bytes if a 32 bit value is written to file.
*/
do {
unsigned char C = (V & 0x7F);
V >>= 7;
if (V) {
C |= 0x80;
}
Write8 (F, C);
unsigned char C = (V & 0x7F);
V >>= 7;
if (V) {
C |= 0x80;
}
Write8 (F, C);
} while (V != 0);
}
@@ -114,7 +114,7 @@ void WriteData (FILE* F, const void* Data, unsigned Size)
/* Write data to the file */
{
if (fwrite (Data, 1, Size, F) != Size) {
Error ("Write error (disk full?)");
Error ("Write error (disk full?)");
}
}
@@ -125,7 +125,7 @@ unsigned Read8 (FILE* F)
{
int C = getc (F);
if (C == EOF) {
Error ("Read error (file corrupt?)");
Error ("Read error (file corrupt?)");
}
return C;
}
@@ -162,12 +162,12 @@ unsigned long ReadVar (FILE* F)
unsigned long V = 0;
unsigned Shift = 0;
do {
/* Read one byte */
C = Read8 (F);
/* Encode it into the target value */
V |= ((unsigned long)(C & 0x7F)) << Shift;
/* Next value */
Shift += 7;
/* Read one byte */
C = Read8 (F);
/* Encode it into the target value */
V |= ((unsigned long)(C & 0x7F)) << Shift;
/* Next value */
Shift += 7;
} while (C & 0x80);
/* Return the value read */
@@ -197,7 +197,7 @@ void* ReadData (FILE* F, void* Data, unsigned Size)
/* Read data from the file */
{
if (fread (Data, 1, Size, F) != Size) {
Error ("Read error (file corrupt?)");
Error ("Read error (file corrupt?)");
}
return Data;
}

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* fileio.h */
/* fileio.h */
/* */
/* File I/O for the ar65 archiver */
/* File I/O for the ar65 archiver */
/* */
/* */
/* */
@@ -43,7 +43,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* global.c */
/* global.c */
/* */
/* Global variables for the ar65 archiver */
/* Global variables for the ar65 archiver */
/* */
/* */
/* */
@@ -38,7 +38,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* global.h */
/* global.h */
/* */
/* Global variables for the ar65 archiver */
/* Global variables for the ar65 archiver */
/* */
/* */
/* */
@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* library.c */
/* library.c */
/* */
/* Library data structures and helpers for the ar65 archiver */
/* Library data structures and helpers for the ar65 archiver */
/* */
/* */
/* */
@@ -56,20 +56,20 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
/* Name of the library file */
const char* LibName = 0;
const char* LibName = 0;
/* File descriptor for the library file */
FILE* NewLib = 0;
static FILE* Lib = 0;
FILE* NewLib = 0;
static FILE* Lib = 0;
/* The library header */
static LibHeader Header = {
static LibHeader Header = {
LIB_MAGIC,
LIB_VERSION,
0,
@@ -79,7 +79,7 @@ static LibHeader Header = {
/*****************************************************************************/
/* Writing file data structures */
/* Writing file data structures */
/*****************************************************************************/
@@ -93,11 +93,11 @@ static void ReadHeader (void)
/* Read the header fields, checking magic and version */
Header.Magic = Read32 (Lib);
if (Header.Magic != LIB_MAGIC) {
Error ("`%s' is not a valid library file", LibName);
Error ("`%s' is not a valid library file", LibName);
}
Header.Version = Read16 (Lib);
if (Header.Version != LIB_VERSION) {
Error ("Wrong data version in `%s'", LibName);
Error ("Wrong data version in `%s'", LibName);
}
Header.Flags = Read16 (Lib);
Header.IndexOffs = Read32 (Lib);
@@ -109,7 +109,7 @@ static void ReadIndexEntry (void)
/* Read one entry in the index */
{
/* Create a new entry and insert it into the list */
ObjData* O = NewObjData ();
ObjData* O = NewObjData ();
/* Module name/flags/MTime/Start/Size */
O->Name = ReadStr (Lib);
@@ -134,7 +134,7 @@ static void ReadIndex (void)
/* Read all entries in the index */
while (Count--) {
ReadIndexEntry ();
ReadIndexEntry ();
}
/* Read basic object file data from the actual entries */
@@ -151,7 +151,7 @@ static void ReadIndex (void)
/*****************************************************************************/
/* Writing file data structures */
/* Writing file data structures */
/*****************************************************************************/
@@ -200,14 +200,14 @@ static void WriteIndex (void)
/* Write the object files */
for (I = 0; I < CollCount (&ObjPool); ++I) {
WriteIndexEntry (CollConstAt (&ObjPool, I));
WriteIndexEntry (CollConstAt (&ObjPool, I));
}
}
/*****************************************************************************/
/* High level stuff */
/* High level stuff */
/*****************************************************************************/
@@ -225,32 +225,32 @@ void LibOpen (const char* Name, int MustExist, int NeedTemp)
Lib = fopen (Name, "rb");
if (Lib == 0) {
/* File does not exist */
if (MustExist) {
Error ("Library `%s' does not exist", Name);
} else {
Warning ("Library `%s' not found - will be created", Name);
}
/* File does not exist */
if (MustExist) {
Error ("Library `%s' does not exist", Name);
} else {
Warning ("Library `%s' not found - will be created", Name);
}
} else {
/* We have an existing file: Read the header */
ReadHeader ();
ReadHeader ();
/* Now read the existing index */
ReadIndex ();
/* Now read the existing index */
ReadIndex ();
}
if (NeedTemp) {
/* Create the temporary library */
NewLib = tmpfile ();
if (NewLib == 0) {
Error ("Cannot create temporary file: %s", strerror (errno));
}
/* Create the temporary library */
NewLib = tmpfile ();
if (NewLib == 0) {
Error ("Cannot create temporary file: %s", strerror (errno));
}
/* Write a dummy header to the temp file */
WriteHeader ();
/* Write a dummy header to the temp file */
WriteHeader ();
}
}
@@ -268,10 +268,10 @@ unsigned long LibCopyTo (FILE* F, unsigned long Bytes)
/* Copy loop */
while (Bytes) {
unsigned Count = (Bytes > sizeof (Buf))? sizeof (Buf) : Bytes;
ReadData (F, Buf, Count);
WriteData (NewLib, Buf, Count);
Bytes -= Count;
unsigned Count = (Bytes > sizeof (Buf))? sizeof (Buf) : Bytes;
ReadData (F, Buf, Count);
WriteData (NewLib, Buf, Count);
Bytes -= Count;
}
/* Return the start position */
@@ -290,10 +290,10 @@ void LibCopyFrom (unsigned long Pos, unsigned long Bytes, FILE* F)
/* Copy loop */
while (Bytes) {
unsigned Count = (Bytes > sizeof (Buf))? sizeof (Buf) : Bytes;
ReadData (Lib, Buf, Count);
WriteData (F, Buf, Count);
Bytes -= Count;
unsigned Count = (Bytes > sizeof (Buf))? sizeof (Buf) : Bytes;
ReadData (Lib, Buf, Count);
WriteData (F, Buf, Count);
Bytes -= Count;
}
}
@@ -313,11 +313,11 @@ static void LibCheckExports (ObjData* O)
for (I = 0; I < CollCount (&O->Exports); ++I) {
/* Get the name of the export */
const char* Name = CollConstAt (&O->Exports, I);
const char* Name = CollConstAt (&O->Exports, I);
/* Insert the name into the hash table */
Print (stdout, 1, " %s\n", Name);
ExpInsert (Name, O);
/* Insert the name into the hash table */
Print (stdout, 1, " %s\n", Name);
ExpInsert (Name, O);
}
}
@@ -331,65 +331,65 @@ void LibClose (void)
/* Do we have a temporary library? */
if (NewLib) {
unsigned I;
unsigned char Buf [4096];
size_t Count;
unsigned I;
unsigned char Buf [4096];
size_t Count;
/* Walk through the object file list, inserting exports into the
* export list checking for duplicates. Copy any data that is still
* in the old library into the new one.
*/
for (I = 0; I < CollCount (&ObjPool); ++I) {
* export list checking for duplicates. Copy any data that is still
* in the old library into the new one.
*/
for (I = 0; I < CollCount (&ObjPool); ++I) {
/* Get a pointer to the object */
ObjData* O = CollAtUnchecked (&ObjPool, I);
/* Get a pointer to the object */
ObjData* O = CollAtUnchecked (&ObjPool, I);
/* Check exports, make global export table */
LibCheckExports (O);
/* Check exports, make global export table */
LibCheckExports (O);
/* Copy data if needed */
if ((O->Flags & OBJ_HAVEDATA) == 0) {
/* Data is still in the old library */
fseek (Lib, O->Start, SEEK_SET);
O->Start = ftell (NewLib);
LibCopyTo (Lib, O->Size);
O->Flags |= OBJ_HAVEDATA;
}
}
/* Copy data if needed */
if ((O->Flags & OBJ_HAVEDATA) == 0) {
/* Data is still in the old library */
fseek (Lib, O->Start, SEEK_SET);
O->Start = ftell (NewLib);
LibCopyTo (Lib, O->Size);
O->Flags |= OBJ_HAVEDATA;
}
}
/* Write the index */
WriteIndex ();
/* Write the index */
WriteIndex ();
/* Write the updated header */
WriteHeader ();
/* Write the updated header */
WriteHeader ();
/* Close the file */
if (Lib && fclose (Lib) != 0) {
Error ("Error closing library: %s", strerror (errno));
}
/* Close the file */
if (Lib && fclose (Lib) != 0) {
Error ("Error closing library: %s", strerror (errno));
}
/* Reopen the library and truncate it */
Lib = fopen (LibName, "wb");
if (Lib == 0) {
Error ("Cannot open library `%s' for writing: %s",
LibName, strerror (errno));
}
/* Reopen the library and truncate it */
Lib = fopen (LibName, "wb");
if (Lib == 0) {
Error ("Cannot open library `%s' for writing: %s",
LibName, strerror (errno));
}
/* Copy the new library to the new one */
fseek (NewLib, 0, SEEK_SET);
while ((Count = fread (Buf, 1, sizeof (Buf), NewLib)) != 0) {
if (fwrite (Buf, 1, Count, Lib) != Count) {
Error ("Cannot write to `%s': %s", LibName, strerror (errno));
}
}
/* Copy the new library to the new one */
fseek (NewLib, 0, SEEK_SET);
while ((Count = fread (Buf, 1, sizeof (Buf), NewLib)) != 0) {
if (fwrite (Buf, 1, Count, Lib) != Count) {
Error ("Cannot write to `%s': %s", LibName, strerror (errno));
}
}
}
/* Close both files */
if (Lib && fclose (Lib) != 0) {
Error ("Problem closing `%s': %s", LibName, strerror (errno));
Error ("Problem closing `%s': %s", LibName, strerror (errno));
}
if (NewLib && fclose (NewLib) != 0) {
Error ("Problem closing temporary library file: %s", strerror (errno));
Error ("Problem closing temporary library file: %s", strerror (errno));
}
}

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* library.h */
/* library.h */
/* */
/* Library data structures and helpers for the ar65 archiver */
/* Library data structures and helpers for the ar65 archiver */
/* */
/* */
/* */
@@ -43,7 +43,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -52,12 +52,12 @@
extern const char* LibName;
/* File descriptor for the new library file */
extern FILE* NewLib;
extern FILE* NewLib;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* list.c */
/* list.c */
/* */
/* Module listing for the ar65 archiver */
/* Module listing for the ar65 archiver */
/* */
/* */
/* */
@@ -45,7 +45,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -58,10 +58,10 @@ void ListObjFiles (int argc, char* argv [])
/* Check the argument count */
if (argc <= 0) {
Error ("No library name given");
Error ("No library name given");
}
if (argc > 2) {
Error ("Too many arguments");
Error ("Too many arguments");
}
/* Open the library, read the index */
@@ -74,7 +74,7 @@ void ListObjFiles (int argc, char* argv [])
O = CollConstAt (&ObjPool, I);
/* Print the name */
printf ("%s\n", O->Name);
printf ("%s\n", O->Name);
}

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* list.h */
/* list.h */
/* */
/* Module listing for the ar65 archiver */
/* Module listing for the ar65 archiver */
/* */
/* */
/* */
@@ -39,7 +39,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,34 +1,34 @@
/*****************************************************************************/
/* */
/* main.c */
/* */
/* Main program for the ar65 archiver */
/* */
/* */
/* */
/* */
/* main.c */
/* */
/* Main program for the ar65 archiver */
/* */
/* */
/* */
/* (C) 1998-2012, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
@@ -52,7 +52,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -83,54 +83,54 @@ int main (int argc, char* argv [])
/* We must have a file name */
if (ArgCount < 2) {
Usage ();
Usage ();
}
/* Check the parameters */
I = 1;
while (I < ArgCount) {
/* Get the argument */
const char* Arg = ArgVec [I];
/* Get the argument */
const char* Arg = ArgVec [I];
/* Check for an option */
if (strlen (Arg) != 1) {
Usage ();
}
switch (Arg [0]) {
/* Check for an option */
if (strlen (Arg) != 1) {
Usage ();
}
switch (Arg [0]) {
case 'a':
AddObjFiles (ArgCount - I - 1, &ArgVec[I+1]);
break;
case 'a':
AddObjFiles (ArgCount - I - 1, &ArgVec[I+1]);
break;
case 'd':
DelObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
break;
case 'd':
DelObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
break;
case 'l':
ListObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
break;
case 'l':
ListObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
break;
case 'v':
++Verbosity;
break;
case 'v':
++Verbosity;
break;
case 'x':
ExtractObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
break;
case 'x':
ExtractObjFiles (ArgCount - I - 1, &ArgVec [I+1]);
break;
case 'V':
fprintf (stderr, "ar65 V%s\n", GetVersionAsString ());
break;
case 'V':
fprintf (stderr, "ar65 V%s\n", GetVersionAsString ());
break;
default:
fprintf (stderr, "Unknown option: %s\n", Arg);
Usage ();
default:
fprintf (stderr, "Unknown option: %s\n", Arg);
Usage ();
}
}
/* Next argument */
++I;
/* Next argument */
++I;
}
/* Return an apropriate exit code */

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* objdata.c */
/* objdata.c */
/* */
/* Handling object file data for the ar65 archiver */
/* Handling object file data for the ar65 archiver */
/* */
/* */
/* */
@@ -47,7 +47,7 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
@@ -58,7 +58,7 @@ Collection ObjPool = STATIC_COLLECTION_INITIALIZER;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -70,12 +70,12 @@ ObjData* NewObjData (void)
ObjData* O = xmalloc (sizeof (ObjData));
/* Initialize the data */
O->Name = 0;
O->Name = 0;
O->Flags = 0;
O->MTime = 0;
O->Start = 0;
O->Size = 0;
O->Flags = 0;
O->MTime = 0;
O->Start = 0;
O->Size = 0;
O->Strings = EmptyCollection;
O->Exports = EmptyCollection;
@@ -134,9 +134,9 @@ ObjData* FindObjData (const char* Module)
ObjData* O = CollAtUnchecked (&ObjPool, I);
/* Did we find it? */
if (strcmp (O->Name, Module) == 0) {
return O;
}
if (strcmp (O->Name, Module) == 0) {
return O;
}
}
return 0;
}
@@ -153,15 +153,15 @@ void DelObjData (const char* Module)
ObjData* O = CollAtUnchecked (&ObjPool, I);
/* Did we find it? */
if (strcmp (O->Name, Module) == 0) {
if (strcmp (O->Name, Module) == 0) {
/* Free the entry */
/* Free the entry */
CollDelete (&ObjPool, I);
FreeObjData (O);
FreeObjData (O);
/* Done */
return;
}
/* Done */
return;
}
}
/* Not found! */

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* objdata.h */
/* objdata.h */
/* */
/* Handling object file data for the ar65 archiver */
/* Handling object file data for the ar65 archiver */
/* */
/* */
/* */
@@ -45,32 +45,32 @@
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
/* Values for the Flags field */
#define OBJ_HAVEDATA 0x0001 /* The object data is in the tmp file */
#define OBJ_HAVEDATA 0x0001 /* The object data is in the tmp file */
/* Internal structure holding object file data */
typedef struct ObjData ObjData;
struct ObjData {
char* Name; /* Module name */
char* Name; /* Module name */
/* Index entry */
unsigned Flags;
unsigned long MTime; /* Modifiation time of object file */
unsigned long Start; /* Start offset of data in library */
unsigned long Size; /* Size of data in library */
unsigned Flags;
unsigned long MTime; /* Modifiation time of object file */
unsigned long Start; /* Start offset of data in library */
unsigned long Size; /* Size of data in library */
/* Object file header */
ObjHeader Header;
/* Basic data needed for simple checks */
Collection Strings; /* Strings from the object file */
Collection Exports; /* Exports list from object file */
Collection Exports; /* Exports list from object file */
};
@@ -81,7 +81,7 @@ extern Collection ObjPool;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@@ -1,34 +1,34 @@
/*****************************************************************************/
/* */
/* objfile.c */
/* */
/* Object file handling for the ar65 archiver */
/* */
/* */
/* */
/* */
/* objfile.c */
/* */
/* Object file handling for the ar65 archiver */
/* */
/* */
/* */
/* (C) 1998-2012, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
@@ -55,7 +55,7 @@
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/
@@ -68,7 +68,7 @@ static const char* GetModule (const char* Name)
/* Must not end with a path separator */
if (*Module == 0) {
Error ("Cannot make module name from `%s'", Name);
Error ("Cannot make module name from `%s'", Name);
}
/* Done */
@@ -80,21 +80,21 @@ static const char* GetModule (const char* Name)
static void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name)
/* Read the header of the object file checking the signature */
{
H->Magic = Read32 (Obj);
H->Magic = Read32 (Obj);
if (H->Magic != OBJ_MAGIC) {
Error ("`%s' is not an object file", Name);
Error ("`%s' is not an object file", Name);
}
H->Version = Read16 (Obj);
H->Version = Read16 (Obj);
if (H->Version != OBJ_VERSION) {
Error ("Object file `%s' has wrong version", Name);
Error ("Object file `%s' has wrong version", Name);
}
H->Flags = Read16 (Obj);
H->Flags = Read16 (Obj);
H->OptionOffs = Read32 (Obj);
H->OptionSize = Read32 (Obj);
H->FileOffs = Read32 (Obj);
H->FileSize = Read32 (Obj);
H->SegOffs = Read32 (Obj);
H->SegSize = Read32 (Obj);
H->SegOffs = Read32 (Obj);
H->SegSize = Read32 (Obj);
H->ImportOffs = Read32 (Obj);
H->ImportSize = Read32 (Obj);
H->ExportOffs = Read32 (Obj);
@@ -124,23 +124,23 @@ static void SkipExpr (FILE* F)
/* Handle then different expression nodes */
switch (Op) {
case EXPR_NULL:
break;
case EXPR_NULL:
break;
case EXPR_LITERAL:
/* 32 bit literal value */
(void) Read32 (F);
break;
/* 32 bit literal value */
(void) Read32 (F);
break;
case EXPR_SYMBOL:
/* Variable seized symbol index */
(void) ReadVar (F);
break;
/* Variable seized symbol index */
(void) ReadVar (F);
break;
case EXPR_SECTION:
/* 8 bit segment number */
(void) Read8 (F);
break;
/* 8 bit segment number */
(void) Read8 (F);
break;
default:
/* What's left are unary and binary nodes */
@@ -236,7 +236,7 @@ void ObjAdd (const char* Name)
/* Open the object file */
FILE* Obj = fopen (Name, "rb");
if (Obj == 0) {
Error ("Could not open `%s': %s", Name, strerror (errno));
Error ("Could not open `%s': %s", Name, strerror (errno));
}
/* Get the modification time of the object file. There a race condition
@@ -248,7 +248,7 @@ void ObjAdd (const char* Name)
* here.
*/
if (FileStat (Name, &StatBuf) != 0) {
Error ("Cannot stat object file `%s': %s", Name, strerror (errno));
Error ("Cannot stat object file `%s': %s", Name, strerror (errno));
}
/* Read and check the header */
@@ -260,16 +260,16 @@ void ObjAdd (const char* Name)
/* Check if we already have a module with this name */
O = FindObjData (Module);
if (O == 0) {
/* Not found, create a new entry */
O = NewObjData ();
/* Not found, create a new entry */
O = NewObjData ();
} else {
/* Found - check the file modification times of the internal copy
* and the external one.
*/
if (difftime ((time_t)O->MTime, StatBuf.st_mtime) > 0.0) {
Warning ("Replacing module `%s' by older version in library `%s'",
/* Found - check the file modification times of the internal copy
* and the external one.
*/
if (difftime ((time_t)O->MTime, StatBuf.st_mtime) > 0.0) {
Warning ("Replacing module `%s' by older version in library `%s'",
O->Name, LibName);
}
}
/* Free data */
ClearObjData (O);
@@ -277,8 +277,8 @@ void ObjAdd (const char* Name)
/* Initialize the object module data structure */
O->Name = xstrdup (Module);
O->Flags = OBJ_HAVEDATA;
O->MTime = (unsigned long) StatBuf.st_mtime;
O->Flags = OBJ_HAVEDATA;
O->MTime = (unsigned long) StatBuf.st_mtime;
O->Start = 0;
/* Determine the file size. Note: Race condition here */
@@ -313,13 +313,13 @@ void ObjExtract (const char* Name)
/* Bail out if the module does not exist */
if (O == 0) {
Error ("Module `%s' not found in library `%s'", Module, LibName);
Error ("Module `%s' not found in library `%s'", Module, LibName);
}
/* Open the output file */
Obj = fopen (Name, "w+b");
if (Obj == 0) {
Error ("Cannot open target file `%s': %s", Name, strerror (errno));
Error ("Cannot open target file `%s': %s", Name, strerror (errno));
}
/* Copy the complete object file data from the library to the new object
@@ -329,12 +329,12 @@ void ObjExtract (const char* Name)
/* Close the file */
if (fclose (Obj) != 0) {
Error ("Problem closing object file `%s': %s", Name, strerror (errno));
Error ("Problem closing object file `%s': %s", Name, strerror (errno));
}
/* Set access and modification time */
if (SetFileTimes (Name, O->MTime) != 0) {
Error ("Cannot set mod time on `%s': %s", Name, strerror (errno));
Error ("Cannot set mod time on `%s': %s", Name, strerror (errno));
}
}

View File

@@ -1,8 +1,8 @@
/*****************************************************************************/
/* */
/* objfile.h */
/* objfile.h */
/* */
/* Object file handling for the ar65 archiver */
/* Object file handling for the ar65 archiver */
/* */
/* */
/* */
@@ -53,7 +53,7 @@ struct ObjData;
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/