Authors: Christian Thalinger
- $Id: options.c 1223 2004-06-30 19:13:00Z twisti $
+ $Id: options.c 1546 2004-11-18 12:25:04Z twisti $
*/
-#include "global.h"
+#include <string.h>
+#include "options.h"
+#include "types.h"
/* command line option */
-bool verbose = false;
+bool opt_verbose = false;
bool compileall = false;
bool runverbose = false; /* trace all method invocation */
bool verboseexception = false;
bool showddatasegment = false; /* generate data segment listing */
bool showintermediate = false; /* generate intermediate code listing */
+bool useinliningm = false; /* use method inlining */
bool useinlining = false; /* use method inlining */
bool inlinevirtuals = false; /* inline unique virtual methods */
bool inlineexceptions = false; /* inline methods, that contain excptions */
bool opt_eager = false;
+int opt_ind = 1; /* index of processed arguments */
+char *opt_arg; /* this one exports the option argument */
+
+
+/* get_opt *********************************************************************
+
+ DOCUMENT ME!!!
+
+*******************************************************************************/
+
+int get_opt(int argc, char **argv, opt_struct *opts)
+{
+ char *a;
+ int i;
+
+ if (opt_ind >= argc)
+ return OPT_DONE;
+
+ a = argv[opt_ind];
+ if (a[0] != '-')
+ return OPT_DONE;
+
+ for (i = 0; opts[i].name; i++) {
+ if (!opts[i].arg) {
+ if (strcmp(a + 1, opts[i].name) == 0) { /* boolean option found */
+ opt_ind++;
+ return opts[i].value;
+ }
+
+ } else {
+ if (strcmp(a + 1, opts[i].name) == 0) { /* parameter option found */
+ opt_ind++;
+ if (opt_ind < argc) {
+ opt_arg = argv[opt_ind];
+ opt_ind++;
+ return opts[i].value;
+ }
+ return OPT_ERROR;
+
+ } else {
+ size_t l = strlen(opts[i].name);
+ if (strlen(a + 1) > l) {
+ if (memcmp(a + 1, opts[i].name, l) == 0) {
+ opt_ind++;
+ opt_arg = a + 1 + l;
+ return opts[i].value;
+ }
+ }
+ }
+ }
+ } /* end for */
+
+ return OPT_ERROR;
+}
+
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where