1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-27 00:29:31 +00:00

Fix problematic code. Use more stuff from the shared modules.

git-svn-id: svn://svn.cc65.org/cc65/trunk@72 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-06-14 10:00:55 +00:00
parent 2767f66146
commit ecdce2cd16

View File

@ -40,6 +40,7 @@
#include <errno.h> #include <errno.h>
#include "../common/cmdline.h" #include "../common/cmdline.h"
#include "../common/fname.h"
#include "../common/version.h" #include "../common/version.h"
#include "asmcode.h" #include "asmcode.h"
@ -88,7 +89,7 @@ static const char* TargetNames [] = {
static void Usage (void) static void Usage (void)
{ {
fprintf (stderr, fprintf (stderr,
"Usage: cc65 [options] file\n" "Usage: %s [options] file\n"
"Short options:\n" "Short options:\n"
" -d\t\t\tDebug mode\n" " -d\t\t\tDebug mode\n"
" -g\t\t\tAdd debug info to object file\n" " -g\t\t\tAdd debug info to object file\n"
@ -118,7 +119,8 @@ static void Usage (void)
" --signed-chars\tDefault characters are signed\n" " --signed-chars\tDefault characters are signed\n"
" --target sys\t\tSet the target system\n" " --target sys\t\tSet the target system\n"
" --verbose\t\tIncrease verbosity\n" " --verbose\t\tIncrease verbosity\n"
" --version\t\tPrint the compiler version number\n"); " --version\t\tPrint the compiler version number\n",
ProgName);
} }
@ -365,15 +367,14 @@ int main (int argc, char* argv[])
}; };
int I; int I;
char out_name [256];
/* Initialize the output file name */ /* Initialize the output file name */
out_name [0] = '\0'; const char* OutputFile = 0;
fin = NULL; fin = NULL;
/* Initialize the cmdline module */ /* Initialize the cmdline module */
InitCmdLine (argc, argv); InitCmdLine (argc, argv, "cc65");
/* Parse the command line */ /* Parse the command line */
I = 1; I = 1;
@ -411,7 +412,7 @@ int main (int argc, char* argv[])
break; break;
case 'o': case 'o':
strcpy (out_name, GetArg (&I, 2)); OutputFile = GetArg (&I, 2);
break; break;
case 't': case 't':
@ -504,19 +505,9 @@ int main (int argc, char* argv[])
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
/* Create the output file name. We should really have /* Create the output file name if it was not explicitly given */
* some checks for string overflow, but I'll drop this because of the if (OutputFile == 0) {
* additional code size it would need (as in other places). Sigh. OutputFile = MakeFilename (fin, ".s");
* #### To be removed
*/
if (out_name [0] == '\0') {
char* p;
/* No output name given, create default */
strcpy (out_name, fin);
if ((p = strrchr (out_name, '.'))) {
*p = '\0';
}
strcat (out_name, ".s");
} }
/* Go! */ /* Go! */
@ -533,7 +524,7 @@ int main (int argc, char* argv[])
} }
/* Open the file */ /* Open the file */
F = fopen (out_name, "w"); F = fopen (OutputFile, "w");
if (F == 0) { if (F == 0) {
Fatal (FAT_CANNOT_OPEN_OUTPUT, strerror (errno)); Fatal (FAT_CANNOT_OPEN_OUTPUT, strerror (errno));
} }
@ -543,7 +534,7 @@ int main (int argc, char* argv[])
/* Close the file, check for errors */ /* Close the file, check for errors */
if (fclose (F) != 0) { if (fclose (F) != 0) {
remove (out_name); remove (OutputFile);
Fatal (FAT_CANNOT_WRITE_OUTPUT); Fatal (FAT_CANNOT_WRITE_OUTPUT);
} }
} }