Subject:
gpvc -I argument
From:
Don Wooton ####@####.####
Date:
13 Feb 2007 20:35:57 +0000
Message-Id: <20070213203518.GC7268@snuggle.org>
Attached is a patch to add a new -I<path> argument to gpvc.
Usage: gpdasm [options] file
Options: [defaults in brackets after descriptions]
-a, --all Display all information in .cod file.
-d, --directory Display directory header.
-l, --listing Display source listing.
-m, --message Display debug message area.
-h, --help Show this usage message.
-r, --rom Display rom.
-s, --symbols Display symbols.
-v, --version Show version.
-I, --include <path> Source include path.
Report bugs to:
<URL:http://gputils.sourceforge.net/>
*** orig/gputils/dump.c 2007-02-13 12:34:04.000000000 -0500
--- new/gputils/dump.c 2007-02-13 15:02:01.000000000 -0500
***************
*** 20,25 ****
--- 20,26 ----
Boston, MA 02111-1307, USA. */
#include "stdhdr.h"
+ #include "limits.h"
#include "libgputils.h"
#include "gpvc.h"
***************
*** 345,350 ****
--- 346,387 ----
* Source files
*/
+ FILE *
+ open_source_file(const char *name)
+ {
+ FILE *fp;
+
+ fp = fopen(name, "rt");
+ if (fp != NULL)
+ return fp;
+
+ if (include_path)
+ {
+ char *path;
+ char *dir;
+
+ path = strdup(include_path);
+ if (!path)
+ return NULL;
+
+ dir = strtok(path, ":");
+ while (dir) {
+ char new_name[PATH_MAX];
+ snprintf(new_name, sizeof(new_name), "%s/%s", dir, name);
+ fp = fopen(new_name, "rt");
+ if (fp != NULL) {
+ free(path);
+ return fp;
+ }
+ dir = strtok(NULL, ":");
+ }
+
+ free(path);
+ }
+
+ return NULL;
+ }
+
void dump_source_files( void )
{
#define FILE_SIZE 64
***************
*** 379,385 ****
}
printf("%s\n",source_file_names[number_of_source_files]);
source_files[number_of_source_files] =
! fopen(source_file_names[number_of_source_files],"rt");
if (source_files[number_of_source_files] == NULL) {
perror(source_file_names[number_of_source_files]);
exit(1);
--- 416,422 ----
}
printf("%s\n",source_file_names[number_of_source_files]);
source_files[number_of_source_files] =
! open_source_file(source_file_names[number_of_source_files]);
if (source_files[number_of_source_files] == NULL) {
perror(source_file_names[number_of_source_files]);
exit(1);
*** orig/gputils/gpvc.c 2007-02-13 12:38:15.000000000 -0500
--- new/gputils/gpvc.c 2007-02-13 12:44:08.000000000 -0500
***************
*** 32,37 ****
--- 32,38 ----
char *source_file_names[MAX_SOURCE_FILES];
FILE *source_files[MAX_SOURCE_FILES];
DirBlockInfo main_dir;
+ const char *include_path = NULL;
int byte_addr;
***************
*** 84,104 ****
{
printf("Usage: gpdasm [options] file\n");
printf("Options: [defaults in brackets after descriptions]\n");
! printf(" -a, --all Display all information in .cod file.\n");
! printf(" -d, --directory Display directory header.\n");
! printf(" -l, --listing Display source listing.\n");
! printf(" -m, --message Display debug message area.\n");
! printf(" -h, --help Show this usage message.\n");
! printf(" -r, --rom Display rom.\n");
! printf(" -s, --symbols Display symbols.\n");
! printf(" -v, --version Show version.\n");
printf("\n");
printf("Report bugs to:\n");
printf("%s\n", PACKAGE_BUGREPORT);
exit(0);
}
! #define GET_OPTIONS "?adhlmrsv"
/* Used: adhlmrsv */
static struct option longopts[] =
--- 85,106 ----
{
printf("Usage: gpdasm [options] file\n");
printf("Options: [defaults in brackets after descriptions]\n");
! printf(" -a, --all Display all information in .cod file.\n");
! printf(" -d, --directory Display directory header.\n");
! printf(" -l, --listing Display source listing.\n");
! printf(" -m, --message Display debug message area.\n");
! printf(" -h, --help Show this usage message.\n");
! printf(" -r, --rom Display rom.\n");
! printf(" -s, --symbols Display symbols.\n");
! printf(" -v, --version Show version.\n");
! printf(" -I, --include <path> Source include path.\n");
printf("\n");
printf("Report bugs to:\n");
printf("%s\n", PACKAGE_BUGREPORT);
exit(0);
}
! #define GET_OPTIONS "?adhlmrsvI:"
/* Used: adhlmrsv */
static struct option longopts[] =
***************
*** 111,116 ****
--- 113,119 ----
{ "rom", 0, 0, 'r' },
{ "symbols", 0, 0, 's' },
{ "version", 0, 0, 'v' },
+ { "include", 1, 0, 'I' },
{ 0, 0, 0, 0 }
};
***************
*** 161,166 ****
--- 164,172 ----
case 'm':
display_flags |= DISPLAY_MESS;
break;
+ case 'I':
+ include_path = optarg;
+ break;
case 'v':
fprintf(stderr, "%s\n", GPVC_VERSION_STRING);
exit(0);
*** orig/gputils/gpvc.h 2007-02-13 15:01:01.000000000 -0500
--- new/gputils/gpvc.h 2007-02-13 12:45:18.000000000 -0500
***************
*** 35,40 ****
--- 35,41 ----
extern char *source_file_names[MAX_SOURCE_FILES];
extern FILE *source_files[MAX_SOURCE_FILES];
extern DirBlockInfo main_dir;
+ extern const char *include_path;
extern int byte_addr;