//
char * path_tail(char * name)
{
- char * temp = max(strrchr(name,'/'), max(strrchr(name,':'), strrchr(name, 92)));
+// char * temp = MAX(strrchr(name, '/'), MAX(strrchr(name, ':'), strrchr(name, '\\')));
+ char * temp = strrchr(name, PATH_DELIMITER);
+ // Return what was passed in if path delimiter was not found
if (temp == NULL)
- temp = (name - 1);
+ return name;
return temp + 1;
}
{
if (plist == NULL)
{
- plist = new_ofile(); // First time object record allocation
- plast = plist; // Update last object record pointer
+ plist = new_ofile(); // First time object record allocation
+ plast = plist; // Update last object record pointer
}
else
{
- plast->o_next = new_ofile(); // Next object record allocation
- plast = plast->o_next; // Update last object record pointer
+ plast->o_next = new_ofile(); // Next object record allocation
+ plast = plast->o_next; // Update last object record pointer
}
if (plast == NULL)
{
- printf("Out of memory.\n"); // Error if memory allocation fails
+ printf("Out of memory.\n"); // Error if memory allocation fails
return 1;
}
- if (strlen(path_tail(fname)) > FNLEN-1)
+ if (strlen(path_tail(fname)) > FNLEN - 1)
{ // Error on excessive filename length
printf("File name too long: %s (sorry!)\n",fname);
return 1;
}
- strcpy(plast->o_name, path_tail(fname)); // Store filename, not path
- *plast->o_arname = 0; // No archive name for this file
- plast->o_image = ptr; // Store data pointer
- plast->o_flags = O_USED; // File is used
- plast->o_next = NULL; // Initialise next record pointer
+ strcpy(plast->o_name, path_tail(fname)); // Store filename, not path
+ *plast->o_arname = 0; // No archive name for this file
+ plast->o_image = ptr; // Store data pointer
+ plast->o_flags = O_USED; // File is used
+ plast->o_next = NULL; // Initialise next record pointer
- return 0; // Return without errors
+ return 0; // Return without errors
}
#ifdef WIN32
//#define _OPEN_FLAGS _O_BINARY|_O_RDWR
#define _OPEN_FLAGS _O_BINARY|_O_RDONLY
-#define _BACKSLASH '\\'
+#define PATH_DELIMITER '\\'
#ifdef _MSC_VER
#if _MSC_VER > 1000
#pragma warning(disable:4996)
#ifdef __GCCUNIX__
//#define _OPEN_FLAGS O_RDWR
#define _OPEN_FLAGS O_RDONLY
-#define _BACKSLASH '/'
+#define PATH_DELIMITER '/'
#include <sys/fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#define warn(x, f) printf("Warning: repeated flag `%c'%s\n", x, f ? "; previous one(s) ignored." : ".")
// Macro for max: good because longs, shorts, or pointers can be compared
-#ifndef max
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#endif // max
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
// Macro to swap the 16-bit words of a 32-bit integer
#define _SWAPWORD(x) (((unsigned)(x) >> 16) | ((unsigned)(x) << 16))