+ default:
+ EnableOpt (Line);
+ break;
+
+ }
+
+ }
+
+ /* Close the file, no error check here since we were just reading and
+ * this is only a debug function.
+ */
+ (void) fclose (F);
+}
+
+
+
+static void OptDisableOpt (const char* Opt attribute ((unused)), const char* Arg)
+/* Disable an optimization step */
+{
+ DisableOpt (Arg);
+}
+
+
+
+static void OptEnableOpt (const char* Opt attribute ((unused)), const char* Arg)
+/* Enable an optimization step */
+{
+ EnableOpt (Arg);
+}
+
+
+
+static void OptForgetIncPaths (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Forget all currently defined include paths */
+{
+ ForgetAllIncludePaths ();
+}
+
+
+
+static void OptHelp (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Print usage information and exit */
+{
+ Usage ();
+ exit (EXIT_SUCCESS);
+}
+
+
+
+static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
+/* Add an include search path */
+{
+ AddIncludePath (Arg, INC_SYS | INC_USER);
+}
+
+
+
+static void OptListOptSteps (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* List all optimizer steps */
+{
+ /* List the optimizer steps */
+ ListOptSteps (stdout);
+
+ /* Terminate */
+ exit (EXIT_SUCCESS);
+}
+
+
+
+static void OptMemoryModel (const char* Opt, const char* Arg)
+/* Set the memory model */
+{
+ mmodel_t M;
+
+ /* Check the current memory model */
+ if (MemoryModel != MMODEL_UNKNOWN) {
+ AbEnd ("Cannot use option `%s' twice", Opt);
+ }
+
+ /* Translate the memory model name and check it */
+ M = FindMemoryModel (Arg);
+ if (M == MMODEL_UNKNOWN) {
+ AbEnd ("Unknown memory model: %s", Arg);
+ } else if (M == MMODEL_HUGE) {
+ AbEnd ("Unsupported memory model: %s", Arg);
+ }
+
+ /* Set the memory model */
+ SetMemoryModel (M);
+}
+
+
+
+static void OptRegisterSpace (const char* Opt, const char* Arg)
+/* Handle the --register-space option */
+{
+ /* Numeric argument expected */
+ if (sscanf (Arg, "%u", &RegisterSpace) != 1 || RegisterSpace > 256) {
+ AbEnd ("Argument for option %s is invalid", Opt);
+ }
+}
+
+
+
+static void OptRegisterVars (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Handle the --register-vars option */
+{
+ IS_Set (&EnableRegVars, 1);
+}
+
+
+
+static void OptRodataName (const char* Opt attribute ((unused)), const char* Arg)
+/* Handle the --rodata-name option */
+{
+ /* Check for a valid name */
+ CheckSegName (Arg);
+
+ /* Set the name */
+ SetSegName (SEG_RODATA, Arg);
+}
+
+
+
+static void OptSignedChars (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Make default characters signed */
+{
+ IS_Set (&SignedChars, 1);
+}
+
+
+
+static void OptStandard (const char* Opt, const char* Arg)
+/* Handle the --standard option */
+{
+ /* Find the standard from the given name */
+ standard_t Std = FindStandard (Arg);
+ if (Std == STD_UNKNOWN) {
+ AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
+ } else if (IS_Get (&Standard) != STD_UNKNOWN) {
+ AbEnd ("Option %s given more than once", Opt);
+ } else {
+ IS_Set (&Standard, Std);
+ }
+}
+
+
+
+static void OptStaticLocals (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Place local variables in static storage */
+{
+ IS_Set (&StaticLocals, 1);
+}
+
+
+
+static void OptTarget (const char* Opt attribute ((unused)), const char* Arg)
+/* Set the target system */
+{
+ SetSys (Arg);
+}
+
+
+
+static void OptVerbose (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Increase verbosity */
+{
+ ++Verbosity;
+}
+
+
+
+static void OptVersion (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Print the compiler version */
+{
+ fprintf (stderr,
+ "cc65 V%s\nSVN version: %s\n",
+ GetVersionAsString (), SVNVersion);
+ exit (EXIT_SUCCESS);
+}
+
+
+
+static void OptWarning (const char* Opt attribute ((unused)), const char* Arg)
+/* Handle the -W option */
+{
+ StrBuf W = AUTO_STRBUF_INITIALIZER;
+
+ /* Arg is a list of suboptions, separated by commas */
+ while (Arg) {
+
+ const char* Pos;
+ int Enabled = 1;
+ IntStack* S;
+
+ /* The suboption may be prefixed with '-' or '+' */
+ if (*Arg == '-') {
+ Enabled = 0;
+ ++Arg;
+ } else if (*Arg == '+') {
+ /* This is the default */
+ ++Arg;
+ }
+
+ /* Get the next suboption */
+ Pos = strchr (Arg, ',');
+ if (Pos) {
+ SB_CopyBuf (&W, Arg, Pos - Arg);
+ Arg = Pos + 1;
+ } else {
+ SB_CopyStr (&W, Arg);
+ Arg = 0;
+ }
+ SB_Terminate (&W);
+
+ /* Search for the warning */
+ S = FindWarning (SB_GetConstBuf (&W));
+ if (S == 0) {
+ InvArg (Opt, SB_GetConstBuf (&W));
+ }
+ IS_Set (S, Enabled);