]> granicus.if.org Git - yasm/commitdiff
Add some (optional through configure) additional warning flags. Add options
authorPeter Johnson <peter@tortall.net>
Wed, 3 Oct 2001 01:44:47 +0000 (01:44 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 3 Oct 2001 01:44:47 +0000 (01:44 -0000)
to configure to enable profiling and enable -Werror.  Make changes to ensure
everything builds with all additional warnings and -Werror enabled.  Most of
these changes consist of adding "const" modifiers for functions that get
constant literal strings.

svn path=/trunk/yasm/; revision=252

47 files changed:
check/check.c
check/check.h
check/check_impl.h
check/check_log.c
check/check_log.h
check/check_msg.c
check/check_msg.h
check/check_print.c
check/check_run.c
check/error.c
check/error.h
configure.ac
configure.in
frontends/yasm/yasm-options.h
frontends/yasm/yasm.c
libyasm/bitvect.c
libyasm/bitvect.h
libyasm/bytecode.c
libyasm/bytecode.h
libyasm/errwarn.c
libyasm/errwarn.h
libyasm/linemgr.c
libyasm/linemgr.h
libyasm/symrec.c
libyasm/tests/bytecode_test.c
libyasm/tests/floatnum_test.c
modules/parsers/nasm/bison.y.in
modules/parsers/nasm/nasm-bison.y
modules/parsers/nasm/token.l.in
src/bitvect.c
src/bitvect.h
src/bytecode.c
src/bytecode.h
src/errwarn.c
src/errwarn.h
src/globals.c
src/globals.h
src/linemgr.c
src/linemgr.h
src/main.c
src/options.h
src/parsers/nasm/bison.y.in
src/parsers/nasm/nasm-bison.y
src/parsers/nasm/token.l.in
src/symrec.c
src/tests/bytecode_test.c
src/tests/floatnum_test.c

index 829c95f36ef5df47c9ed3d2503e3f6d0d979c8d1..44df732fa45b797f2645b31c7d41ae684988d33a 100644 (file)
@@ -37,7 +37,7 @@
 extern int nofork_exit_status;
 #endif
 
-Suite *suite_create (char *name)
+Suite *suite_create (const char *name)
 {
   Suite *s;
   s = emalloc (sizeof(Suite)); /* freed in suite_free */
@@ -61,7 +61,7 @@ void suite_free (Suite *s)
   free(s);
 }
 
-TCase *tcase_create (char *name)
+TCase *tcase_create (const char *name)
 {
   TCase *tc = emalloc (sizeof(TCase)); /*freed in tcase_free */
   if (name == NULL)
@@ -93,7 +93,7 @@ void suite_add_tcase (Suite *s, TCase *tc)
   list_add_end (s->tclst, tc);
 }
 
-void tcase_add_test_ (TCase *tc, TFun fn, char *name)
+void tcase_add_test_ (TCase *tc, TFun fn, const char *name)
 {
   TF * tf;
   if (tc == NULL || fn == NULL || name == NULL)
@@ -111,7 +111,7 @@ void tcase_set_fixture (TCase *tc, SFun setup, SFun teardown)
 }
 
 
-void tcase_fn_start (int msqid, char *fname, char *file, int line)
+void tcase_fn_start (int msqid, const char *fname, const char *file, int line)
 {
   send_last_loc_msg (msqid, file, line);
 }
@@ -121,7 +121,8 @@ void mark_point_ (int msqid, char *file, int line)
   send_last_loc_msg (msqid, file, line);
 }
 
-int fail_unless_ (int msqid, int result, char *file, int line, char * msg)
+int fail_unless_ (int msqid, int result, const char *file, int line,
+                 const char * msg)
 {
   if (line > MAXLINE)
     eprintf ("Line number %d too large to use", line);
index 0f6047ac1a6c2b6acc74cb2a093b874949ef9efb..cb9130c8cfd3802fa0afa5575722223f4c8aeced 100644 (file)
@@ -105,14 +105,14 @@ typedef void (*TFun) (int);
 typedef void (*SFun) (void);
 
 /*! Create a test suite */
-Suite *suite_create (char *name);
+Suite *suite_create (const char *name);
 
 /*! Free a test suite
   (For the moment, this also frees all contained test cases) */
 void suite_free (Suite *s);
 
 /*! Create a test case */
-TCase *tcase_create (char *name);
+TCase *tcase_create (const char *name);
 
 /*! Free a test case
   (Note that as it stands, one will normally free the contaning suite) */
@@ -126,7 +126,7 @@ void suite_add_tcase (Suite *s, TCase *tc);
 #define tcase_add_test(tc,tf) tcase_add_test_(tc,tf,"" # tf "")
 /*! Add a test function to a test case
   (function version -- use this when the macro won't work */
-void tcase_add_test_ (TCase *tc, TFun tf, char *fname);
+void tcase_add_test_ (TCase *tc, TFun tf, const char *fname);
 
 /*!
 
@@ -138,7 +138,7 @@ test functions, and so must not exit or signal (e.g., segfault)
 void tcase_set_fixture(TCase *tc, SFun setup, SFun teardown);
 
 /*! Internal function to mark the start of a test function */
-void tcase_fn_start (int msqid, char *fname, char *file, int line);
+void tcase_fn_start (int msqid, const char *fname, const char *file, int line);
 
 /*! Start a unit test with START_TEST(unit_name), end with END_TEST
   One must use braces within a START_/END_ pair to declare new variables */
@@ -156,7 +156,8 @@ static void testname__ (int msqid__)\
   if(fail_unless_(msqid__,result,__FILE__,__LINE__,msg)) return;
   
 /*! Non macro version of #fail_unless, with more complicated interface */
-int fail_unless_ (int msqid, int result, char *file, int line, char *msg);
+int fail_unless_ (int msqid, int result, const char *file, int line,
+                 const char *msg);
 
 /*! Always fail */
 #define fail(msg) fail_unless_(msqid__,0,__FILE__,__LINE__,msg)
@@ -208,7 +209,7 @@ int tr_lno (TestResult *tr);
 /*! File name at which failure occured */
 char *tr_lfile (TestResult *tr);
 /*! Test case in which unit test was run */
-char *tr_tcname (TestResult *tr);
+const char *tr_tcname (TestResult *tr);
 
 /*! Creates an SRunner for the given suite */
 SRunner *srunner_create (Suite *s);
index 1fd74208c0d1f56591ab8086d2bda3876c88fbdc..814f39c5855a9d7656fbb39099c572fbf3da0dc5 100644 (file)
@@ -33,16 +33,16 @@ enum {
 
 typedef struct TF {
   TFun fn;
-  char *name;
+  const char *name;
 } TF;
 
 struct Suite {
-  char *name;
+  const char *name;
   List *tclst; /* List of test cases */
 };
 
 struct TCase {
-  char *name;
+  const char *name;
   List *tflst; /* list of test functions */
   SFun setup;
   SFun teardown;
@@ -58,8 +58,8 @@ struct TestResult {
   int rtype;     /* Type of result */
   char *file;    /* File where the test occured */
   int line;      /* Line number where the test occurred */
-  char *tcname;  /* Test case that generated the result */
-  char *tfname;  /* Test function that generated the result */
+  const char *tcname;  /* Test case that generated the result */
+  const char *tfname;  /* Test function that generated the result */
   char *msg;     /* Failure message */
 };
 
index 67bd900d7eb757b8b32f67b600088273729d475b..07b4b8f46f958abf29f0b8b64c9f0b473c26e529 100644 (file)
@@ -52,13 +52,13 @@ char *srunner_log_fname (SRunner *sr)
   return sr->log_fname;
 }
 
-void srunner_register_lfun (SRunner *sr, FILE *lfile, int close,
+void srunner_register_lfun (SRunner *sr, FILE *lfile, int doclose,
                            LFun lfun, enum print_verbosity printmode)
 {
   Log *l = emalloc (sizeof(Log));
   l->lfile = lfile;
   l->lfun = lfun;
-  l->close = close;
+  l->close = doclose;
   l->mode = printmode;
   list_add_end (sr->loglst, l);
   return;
index a7205d7db3c4ec5f92bf6161cc4559b0496a0302..ad67bc9e5eea36e02cd8945d310c893b35f0135c 100644 (file)
@@ -13,7 +13,7 @@ void stdout_lfun (SRunner *sr, FILE *file, enum print_verbosity,
 void lfile_lfun (SRunner *sr, FILE *file, enum print_verbosity,
                  void *obj, enum cl_event evt);
 
-void srunner_register_lfun (SRunner *sr, FILE *lfile, int close,
+void srunner_register_lfun (SRunner *sr, FILE *lfile, int doclose,
                            LFun lfun, enum print_verbosity);
 
 FILE *srunner_open_lfile (SRunner *sr);
index d88d7820ff873f8af4f410772b44d03cc6c5809d..edc50dcef9f5fb52dd3cc7d7d07f75092c2ec591 100644 (file)
@@ -55,10 +55,10 @@ enum {
   LASTLOCMSG = 1,
   FAILUREMSG = 2
 };
-static LastLocMsg *create_last_loc_msg (char *file, int line);
-static FailureMsg *create_failure_msg (char *msg);
+static LastLocMsg *create_last_loc_msg (const char *file, int line);
+static FailureMsg *create_failure_msg (const char *msg);
 
-static FailureMsg *create_failure_msg (char *msg)
+static FailureMsg *create_failure_msg (const char *msg)
 {
   FailureMsg *m = emalloc (sizeof(FailureMsg));
   m->message_type = (long int) FAILUREMSG;
@@ -67,7 +67,7 @@ static FailureMsg *create_failure_msg (char *msg)
 }
 
 
-static LastLocMsg *create_last_loc_msg (char *file, int line)
+static LastLocMsg *create_last_loc_msg (const char *file, int line)
 {
   LastLocMsg *m = emalloc (sizeof(LastLocMsg));
   m->message_type = (long int) LASTLOCMSG;
@@ -112,7 +112,7 @@ int last_loc_line (LastLocMsg *msg)
 }
 
 
-void send_last_loc_msg (int msqid, char * file, int line)
+void send_last_loc_msg (int msqid, const char * file, int line)
 {
 #ifdef USE_FORKWAITMSG
   int rval;
@@ -148,7 +148,7 @@ void delete_msq (int msqid)
 }
 
 
-void send_failure_msg (int msqid, char *msg)
+void send_failure_msg (int msqid, const char *msg)
 {
 #ifdef USE_FORKWAITMSG
   int rval;
index 76ab94ad68097fbb0fffc641d289890a7e7ffff4..0a7e5e51a6ea3c13656851e2eed490b5bbee95c8 100644 (file)
@@ -37,8 +37,8 @@ typedef struct FailureMsg {
 int create_msq (void);
 void delete_msq (int msqid);
 
-void send_failure_msg (int msqid, char *msg);
-void send_last_loc_msg (int msqid, char * file, int line);
+void send_failure_msg (int msqid, const char *msg);
+void send_last_loc_msg (int msqid, const char * file, int line);
 
 /* malloc'd return value which caller is responsible for
    freeing in each of the next two functions */
index 85fd44af1804ca1a28a240dec0deee61dcc2073b..9dc658ef31fe62818f418b9d8fe947e30f7cc88b 100644 (file)
@@ -28,7 +28,7 @@ static void srunner_fprint_summary (FILE *file, SRunner *sr, int print_mode);
 static void srunner_fprint_results (FILE *file, SRunner *sr, int print_mode);
 
 static int percent_passed (TestStats *t);
-static char *rtype_to_string (int rtype);
+static const char *rtype_to_string (int rtype);
 
 void srunner_print (SRunner *sr, int print_mode)
 {
@@ -67,7 +67,7 @@ static void srunner_fprint_results (FILE *file, SRunner *sr, int print_mode)
 
 void tr_fprint (FILE *file, TestResult *tr, int print_mode)
 {
-  char *exact_msg;
+  const char *exact_msg;
   exact_msg = (tr->rtype == CRERROR) ? "(after this point) ": "";
   if ((print_mode >= CRVERBOSE && tr->rtype == CRPASS) ||
       (tr->rtype != CRPASS && print_mode >= CRNORMAL)) {
@@ -88,7 +88,7 @@ static int percent_passed (TestStats *t)
                   (float) t->n_checked * 100);
 }
 
-static char *rtype_to_string (int rtype)
+static const char *rtype_to_string (int rtype)
 {
   switch (rtype) {
   case CRPASS:
index 90673fc9b8a8944028be609616d7f8bbfad8df2a..ec4eee99008e96bedbffb0f2c52f5bac3324894b 100644 (file)
@@ -66,9 +66,10 @@ int nofork_exit_status;
 
 static void srunner_run_tcase (SRunner *sr, TCase *tc);
 static void srunner_add_failure (SRunner *sr, TestResult *tf);
-static TestResult *tfun_run (int msqid, char *tcname, TF *tf);
-static TestResult *receive_result_info (int msqid, int status, char *tcname,
-                                       char *tfname);
+static TestResult *tfun_run (int msqid, const char *tcname, TF *tf);
+static TestResult *receive_result_info (int msqid, int status,
+                                       const char *tcname,
+                                       const char *tfname);
 static void receive_last_loc_info (int msqid, TestResult *tr);
 static void receive_failure_info (int msqid, int status, TestResult *tr);
 static List *srunner_resultlst (SRunner *sr);
@@ -113,8 +114,7 @@ void srunner_free (SRunner *sr)
   for (list_front(l); !list_at_end(l); list_advance(l)) {
     tr = list_val(l);
     free(tr->file);
-    if (tr->rtype == CRFAILURE || tr->rtype == CRERROR)
-      free(tr->msg);
+    free(tr->msg);
     free(tr);
   }
   list_free (sr->resultlst);
@@ -222,9 +222,8 @@ static void receive_failure_info (int msqid, int status, TestResult *tr)
     
     if (WEXITSTATUS(status) == 0) {
       tr->rtype = CRPASS;
-      /* TODO: It would be cleaner to strdup this &
-        not special case the free...*/
-      tr->msg = "Test passed";
+      tr->msg = emalloc(strlen("Test passed") + 1);
+      strcpy (tr->msg, "Test passed");
     }
     else {
       
@@ -246,7 +245,8 @@ static void receive_failure_info (int msqid, int status, TestResult *tr)
 #else
   if (status == 0) {
     tr->rtype = CRPASS;
-    tr->msg = "Test passed";
+    tr->msg = emalloc(strlen("Test passed") + 1);
+    strcpy (tr->msg, "Test passed");
   }
   else {
     fmsg = receive_failure_msg (msqid);
@@ -264,8 +264,8 @@ static void receive_failure_info (int msqid, int status, TestResult *tr)
 #endif
 }
 
-static TestResult *receive_result_info (int msqid, int status, char *tcname,
-                                       char *tfname)
+static TestResult *receive_result_info (int msqid, int status,
+                                       const char *tcname, const char *tfname)
 {
   TestResult *tr = emalloc (sizeof(TestResult));
 
@@ -276,7 +276,7 @@ static TestResult *receive_result_info (int msqid, int status, char *tcname,
   return tr;
 }
 
-static TestResult *tfun_run (int msqid, char *tcname, TF *tfun)
+static TestResult *tfun_run (int msqid, const char *tcname, TF *tfun)
 {
 #ifdef USE_FORKWAITMSG
   pid_t pid;
@@ -370,7 +370,7 @@ int tr_rtype (TestResult *tr)
   return tr->rtype;
 }
 
-char *tr_tcname (TestResult *tr)
+const char *tr_tcname (TestResult *tr)
 {
   return tr->tcname;
 }
index 4a486804c119c3ae23f6cb60b11735fad9e88113..e67030d6754424b2b538fbb139d4dd6d4516524a 100644 (file)
@@ -32,7 +32,7 @@
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
-void eprintf (char *fmt, ...)
+void eprintf (const char *fmt, ...)
 {
   va_list args;
   fflush(stdout);
index da089b29dfc96a2083cfbece5c2432ee3eb2864b..1fb3f1073acb70319dfadfac0f8b94633e8e559c 100644 (file)
@@ -24,7 +24,7 @@
 
 /* Print error message and die
    If fmt ends in colon, include system error information */
-void eprintf (char *fmt, ...);
+void eprintf (const char *fmt, ...);
 /* malloc or die */
 void *emalloc(size_t n);
 void *erealloc(void *, size_t n);
index 5f26f7d8737c3894c3ded730db93357575e4da94..8340ae3c1ad919120bc1aafd0410a5bbb3d481a6 100644 (file)
@@ -9,7 +9,7 @@ AM_CONFIG_HEADER(config.h)
 AM_INIT_AUTOMAKE(yasm, 0.0.1)
 
 AC_ARG_ENABLE(dev,
-[  --enable-dev    Enable full development build capability],
+[  --enable-dev        Enable full development build capability],
 [case "${enableval}" in
   yes) dev=true ;;
   no)  dev=false ;;
@@ -17,8 +17,32 @@ AC_ARG_ENABLE(dev,
 esac],[dev=false])
 AM_CONDITIONAL(DEV, test x$dev = xtrue)
 
+AC_ARG_ENABLE(morewarn,
+[  --enable-morewarn   Enable lots of extra GCC warnings],
+[case "${enableval}" in
+  yes) morewarn=true ;;
+  no)  morewarn=false ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for --enable-morewarn) ;;
+esac],[morewarn=false])
+
+AC_ARG_ENABLE(warnerror,
+[  --enable-warnerror  Treat GCC warnings as errors],
+[case "${enableval}" in
+  yes) warnerror=true ;;
+  no)  warnerror=false ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for --enable-warnerror) ;;
+esac],[warnerror=false])
+
+AC_ARG_ENABLE(profiling,
+[  --enable-profiling  Enable profiling (requires GCC)],
+[case "${enableval}" in
+  yes) profiling=true ;;
+  no)  profiling=false ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for --enable-profiling) ;;
+esac],[profiling=false])
+
 AC_ARG_ENABLE(check,
-[  --disable-check Disable building of test suite and make check],
+[  --disable-check     Disable building of test suite and make check],
 [case "${enableval}" in
   yes) check=true ;;
   no)  check=false ;;
@@ -32,8 +56,20 @@ if ${dev}; then
        DEVFLAGS="-g"
 fi
 
+if ${morewarn}; then
+       MOREWARNFLAGS="-Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings"
+fi
+
+if ${warnerror}; then
+       WARNERRORFLAGS="-Werror"
+fi
+
+if ${profiling}; then
+       PROFILINGFLAGS="-pg"
+fi
+
 if test "$GCC" = yes; then
-       ANSI_CFLAGS="-ansi -pedantic -Wall $DEVFLAGS"
+       ANSI_CFLAGS="-ansi -pedantic -Wall $MOREWARNFLAGS $WARNERRORFLAGS $DEVFLAGS $PROFILINGFLAGS"
 else
        ANSI_CFLAGS="$DEVFLAGS"
 fi
index 5f26f7d8737c3894c3ded730db93357575e4da94..8340ae3c1ad919120bc1aafd0410a5bbb3d481a6 100644 (file)
@@ -9,7 +9,7 @@ AM_CONFIG_HEADER(config.h)
 AM_INIT_AUTOMAKE(yasm, 0.0.1)
 
 AC_ARG_ENABLE(dev,
-[  --enable-dev    Enable full development build capability],
+[  --enable-dev        Enable full development build capability],
 [case "${enableval}" in
   yes) dev=true ;;
   no)  dev=false ;;
@@ -17,8 +17,32 @@ AC_ARG_ENABLE(dev,
 esac],[dev=false])
 AM_CONDITIONAL(DEV, test x$dev = xtrue)
 
+AC_ARG_ENABLE(morewarn,
+[  --enable-morewarn   Enable lots of extra GCC warnings],
+[case "${enableval}" in
+  yes) morewarn=true ;;
+  no)  morewarn=false ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for --enable-morewarn) ;;
+esac],[morewarn=false])
+
+AC_ARG_ENABLE(warnerror,
+[  --enable-warnerror  Treat GCC warnings as errors],
+[case "${enableval}" in
+  yes) warnerror=true ;;
+  no)  warnerror=false ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for --enable-warnerror) ;;
+esac],[warnerror=false])
+
+AC_ARG_ENABLE(profiling,
+[  --enable-profiling  Enable profiling (requires GCC)],
+[case "${enableval}" in
+  yes) profiling=true ;;
+  no)  profiling=false ;;
+  *) AC_MSG_ERROR(bad value ${enableval} for --enable-profiling) ;;
+esac],[profiling=false])
+
 AC_ARG_ENABLE(check,
-[  --disable-check Disable building of test suite and make check],
+[  --disable-check     Disable building of test suite and make check],
 [case "${enableval}" in
   yes) check=true ;;
   no)  check=false ;;
@@ -32,8 +56,20 @@ if ${dev}; then
        DEVFLAGS="-g"
 fi
 
+if ${morewarn}; then
+       MOREWARNFLAGS="-Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Winline -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings"
+fi
+
+if ${warnerror}; then
+       WARNERRORFLAGS="-Werror"
+fi
+
+if ${profiling}; then
+       PROFILINGFLAGS="-pg"
+fi
+
 if test "$GCC" = yes; then
-       ANSI_CFLAGS="-ansi -pedantic -Wall $DEVFLAGS"
+       ANSI_CFLAGS="-ansi -pedantic -Wall $MOREWARNFLAGS $WARNERRORFLAGS $DEVFLAGS $PROFILINGFLAGS"
 else
        ANSI_CFLAGS="$DEVFLAGS"
 fi
index 121f9e64a948ba3b03a94e52113e3ab164eb50db..0d4648835930ed85165b335616bc10a2e723cdf7 100644 (file)
  */
 typedef struct opt_option_s
 {
-    char sopt;         /* short option letter if present, 0 otherwise */
-    char *lopt;                /* long option name if present, NULL otherwise */
-    int takes_param;   /* !=0 if option requires parameter, 0 if not */
+    char sopt;                 /* short option letter if present, 0 otherwise */
+    const char *lopt;          /* long option name if present, NULL otherwise */
+    int takes_param;           /* !=0 if option requires parameter, 0 if not */
     int (*handler) (char *cmd, char *param, int extra);
-    int extra;         /* extra value for handler */
-    char *description; /* description to use in help_msg() */
-    char *param_desc;  /* optional description for the param taken */
+    int extra;                 /* extra value for handler */
+    const char *description;   /* description to use in help_msg() */
+    const char *param_desc;    /* optional description for the param taken */
                        /*  (short - will be printed after option sopt/lopt) */
 } opt_option;
 
index 435ec46bb7d57b5c839cf976537b91281f6655d7..fd7a4993d7d0c758b4a0d65d886f38d661f3c625 100644 (file)
@@ -62,7 +62,6 @@ static int files_open = 0;
 static FILE *in;
 
 /* Forward declarations: cmd line parser handlers */
-int not_an_option_handler(char *param);
 int opt_option_handler(char *cmd, char *param, int extra);
 int opt_format_handler(char *cmd, char *param, int extra);
 /* Fake handlers: remove them */
@@ -118,7 +117,7 @@ main(int argc, char *argv[])
     if (!files_open)
     {
        in = stdin;
-       filename = strdup("<STDIN>");
+       in_filename = strdup("<STDIN>");
     }
 
     /* Get initial BITS setting from object format */
@@ -129,8 +128,8 @@ main(int argc, char *argv[])
     if (OutputAllErrorWarning() > 0)
        return EXIT_FAILURE;
 
-    if (filename)
-       free(filename);
+    if (in_filename)
+       free(in_filename);
     return EXIT_SUCCESS;
 }
 
@@ -142,7 +141,7 @@ not_an_option_handler(char *param)
 {
     if (files_open > 0) {
        WarningNow("can open only one input file, only latest file will be processed");
-       free(filename);
+       free(in_filename);
        fclose(in);
     }
 
@@ -151,7 +150,7 @@ not_an_option_handler(char *param)
        ErrorNow(_("could not open file `%s'"), param);
        return 1;
     }
-    filename = strdup(param);
+    in_filename = strdup(param);
 
     files_open++;
     return 0;
index 2f5474321ec255fee84b3e15f315d7d8864b9a48..ca391ff543a224b372d58cd100dff2909c5f44cf 100644 (file)
@@ -319,9 +319,9 @@ N_word BitVector_Mask(N_int bits)           /* bit vector mask (unused bits) */
     return(mask);
 }
 
-charptr BitVector_Version(void)
+const char * BitVector_Version(void)
 {
-    return((charptr)"6.0");
+    return("6.0");
 }
 
 N_int BitVector_Word_Bits(void)
@@ -1783,7 +1783,7 @@ ErrCode BitVector_from_Enum(wordptr addr, charptr string)
     N_word  bits = bits_(addr);
     N_word  state = 1;
     N_word  token;
-    N_word  index;
+    N_word  indx;
     N_word  start;
 
     if (bits > 0)
@@ -1795,8 +1795,8 @@ ErrCode BitVector_from_Enum(wordptr addr, charptr string)
             /* separate because isdigit() is likely a macro! */
             if (isdigit(token) != 0)
             {
-                string += BIT_VECTOR_str2int(string,&index);
-                if (index < bits) token = (N_word) '0';
+                string += BIT_VECTOR_str2int(string,&indx);
+                if (indx < bits) token = (N_word) '0';
                 else error = ErrCode_Indx;
             }
             else string++;
@@ -1821,15 +1821,15 @@ ErrCode BitVector_from_Enum(wordptr addr, charptr string)
                     switch (token)
                     {
                         case (N_word) '-':
-                            start = index;
+                            start = indx;
                             state = 3;
                             break;
                         case (N_word) ',':
-                            BIT_VECTOR_SET_BIT(addr,index)
+                            BIT_VECTOR_SET_BIT(addr,indx)
                             state = 5;
                             break;
                         case (N_word) '\0':
-                            BIT_VECTOR_SET_BIT(addr,index)
+                            BIT_VECTOR_SET_BIT(addr,indx)
                             state = 0;
                             break;
                         default:
@@ -1841,10 +1841,10 @@ ErrCode BitVector_from_Enum(wordptr addr, charptr string)
                     switch (token)
                     {
                         case (N_word) '0':
-                            if (start < index)
-                                BitVector_Interval_Fill(addr,start,index);
-                            else if (start == index)
-                                BIT_VECTOR_SET_BIT(addr,index)
+                            if (start < indx)
+                                BitVector_Interval_Fill(addr,start,indx);
+                            else if (start == indx)
+                                BIT_VECTOR_SET_BIT(addr,indx)
                             else error = ErrCode_Ordr;
                             state = 4;
                             break;
@@ -1889,36 +1889,36 @@ void BitVector_Dispose(charptr string)
     if (string != NULL) free((voidptr) string);
 }
 
-void BitVector_Bit_Off(wordptr addr, N_int index)           /* X = X \ {x}   */
+void BitVector_Bit_Off(wordptr addr, N_int indx)            /* X = X \ {x}   */
 {
-    if (index < bits_(addr)) BIT_VECTOR_CLR_BIT(addr,index)
+    if (indx < bits_(addr)) BIT_VECTOR_CLR_BIT(addr,indx)
 }
 
-void BitVector_Bit_On(wordptr addr, N_int index)            /* X = X + {x}   */
+void BitVector_Bit_On(wordptr addr, N_int indx)             /* X = X + {x}   */
 {
-    if (index < bits_(addr)) BIT_VECTOR_SET_BIT(addr,index)
+    if (indx < bits_(addr)) BIT_VECTOR_SET_BIT(addr,indx)
 }
 
-boolean BitVector_bit_flip(wordptr addr, N_int index)   /* X=(X+{x})\(X*{x}) */
+boolean BitVector_bit_flip(wordptr addr, N_int indx)    /* X=(X+{x})\(X*{x}) */
 {
     N_word mask;
 
-    if (index < bits_(addr)) return( BIT_VECTOR_FLP_BIT(addr,index,mask) );
-    else                     return( FALSE );
+    if (indx < bits_(addr)) return( BIT_VECTOR_FLP_BIT(addr,indx,mask) );
+    else                    return( FALSE );
 }
 
-boolean BitVector_bit_test(wordptr addr, N_int index)       /* {x} in X ?    */
+boolean BitVector_bit_test(wordptr addr, N_int indx)        /* {x} in X ?    */
 {
-    if (index < bits_(addr)) return( BIT_VECTOR_TST_BIT(addr,index) );
-    else                     return( FALSE );
+    if (indx < bits_(addr)) return( BIT_VECTOR_TST_BIT(addr,indx) );
+    else                    return( FALSE );
 }
 
-void BitVector_Bit_Copy(wordptr addr, N_int index, boolean bit)
+void BitVector_Bit_Copy(wordptr addr, N_int indx, boolean bit)
 {
-    if (index < bits_(addr))
+    if (indx < bits_(addr))
     {
-        if (bit) BIT_VECTOR_SET_BIT(addr,index)
-        else     BIT_VECTOR_CLR_BIT(addr,index)
+        if (bit) BIT_VECTOR_SET_BIT(addr,indx)
+        else     BIT_VECTOR_CLR_BIT(addr,indx)
     }
 }
 
index 6509881e9bf89431831403fb9e29adcf12552140..7fbc2ce566206cb4b3516a82b04659710e7ca2da 100644 (file)
@@ -114,7 +114,7 @@ N_word  BitVector_Mask  (N_int bits);       /* bit vector mask (unused bits) */
 
 /* ===> CLASS METHODS: <=== */
 
-charptr BitVector_Version    (void);               /* returns version string */
+const char * BitVector_Version    (void);          /* returns version string */
 
 N_int   BitVector_Word_Bits  (void);    /* returns # of bits in machine word */
 N_int   BitVector_Long_Bits  (void);   /* returns # of bits in unsigned long */
@@ -193,13 +193,13 @@ void    BitVector_Dispose (charptr string);
 
 /* ===> bit vector bit operations, functions & tests: */
 
-void    BitVector_Bit_Off (wordptr addr, N_int index);      /* X = X \ {x}   */
-void    BitVector_Bit_On  (wordptr addr, N_int index);      /* X = X + {x}   */
-boolean BitVector_bit_flip(wordptr addr, N_int index);  /* X=(X+{x})\(X*{x}) */
+void    BitVector_Bit_Off (wordptr addr, N_int indx);      /* X = X \ {x}   */
+void    BitVector_Bit_On  (wordptr addr, N_int indx);      /* X = X + {x}   */
+boolean BitVector_bit_flip(wordptr addr, N_int indx);  /* X=(X+{x})\(X*{x}) */
 
-boolean BitVector_bit_test(wordptr addr, N_int index);      /* {x} in X ?    */
+boolean BitVector_bit_test(wordptr addr, N_int indx);      /* {x} in X ?    */
 
-void    BitVector_Bit_Copy(wordptr addr, N_int index, boolean bit);
+void    BitVector_Bit_Copy(wordptr addr, N_int indx, boolean bit);
 
 /* ===> bit vector bit shift & rotate functions: */
 
index 01695afea39b38753222d7bf0df1528d64b96ee7..f031635f894b253324a82058b61738f00f09950d 100644 (file)
@@ -274,7 +274,7 @@ bytecode_new_common(void)
 
     bc->len = 0;
 
-    bc->filename = strdup(filename);
+    bc->filename = strdup(in_filename);
     bc->lineno = line_number;
 
     bc->offset = 0;
@@ -576,7 +576,7 @@ bytecodes_append(bytecodehead *headp, bytecode *bc)
 }
 
 dataval *
-dataval_new_expr(expr *exp)
+dataval_new_expr(expr *expn)
 {
     dataval *retval = malloc(sizeof(dataval));
 
@@ -584,7 +584,7 @@ dataval_new_expr(expr *exp)
        Fatal(FATAL_NOMEM);
 
     retval->type = DV_EXPR;
-    retval->data.exp = exp;
+    retval->data.expn = expn;
 
     return retval;
 }
@@ -629,7 +629,7 @@ dataval_print(datavalhead *head)
                break;
            case DV_EXPR:
                printf(" Expr=");
-               expr_print(cur->data.exp);
+               expr_print(cur->data.expn);
                printf("\n");
                break;
            case DV_FLOAT:
index 01a0ac19657a5a9ba5053386fd8b5b97906d5258..05d39de35d657159c33621276b1b93dfb10ed5f6 100644 (file)
@@ -57,7 +57,7 @@ typedef struct dataval_s {
     enum { DV_EMPTY, DV_EXPR, DV_FLOAT, DV_STRING } type;
 
     union {
-       struct expr_s *exp;
+       struct expr_s *expn;
        struct floatnum_s *flt;
        char *str_val;
     } data;
@@ -231,7 +231,7 @@ void bytecode_print(bytecode *bc);
  */
 bytecode *bytecodes_append(bytecodehead *headp, bytecode *bc);
 
-dataval *dataval_new_expr(struct expr_s *exp);
+dataval *dataval_new_expr(struct expr_s *expn);
 dataval *dataval_new_float(struct floatnum_s *flt);
 dataval *dataval_new_string(char *str_val);
 
index 377da658d28c776d0a1415f913af831a8ebf8e82..f6a24d5455ac30a049444e476c8d767cdf8e2da3 100644 (file)
@@ -59,7 +59,7 @@ static unsigned int warning_count = 0;
  * When adding a string here, keep errwarn.h in sync! */
 
 /* Fatal error messages.  Match up with fatal_num enum in errwarn.h. */
-static char *fatal_msgs[] = {
+static const char *fatal_msgs[] = {
     N_("unknown"),
     N_("out of memory")
 };
@@ -116,7 +116,7 @@ conv_unprint(char ch)
 
 /* Parser error handler.  Moves error into our error handling system. */
 void
-ParserError(char *s)
+ParserError(const char *s)
 {
     Error("%s %s", _("parser error:"), s);
     previous_error_parser = 1;
@@ -125,7 +125,7 @@ ParserError(char *s)
 /* Report an internal error.  Essentially a fatal error with trace info.
  * Exit immediately because it's essentially an assert() trap. */
 void
-InternalError(unsigned int line, char *file, char *message)
+InternalError(unsigned int line, const char *file, const char *message)
 {
     fprintf(stderr, _("INTERNAL ERROR at %s, line %d: %s\n"), file, line,
            message);
@@ -153,7 +153,7 @@ Fatal(fatal_num num)
  * argument types.  Does not print the error, only stores it for
  * OutputAllErrorWarning() to print. */
 void
-Error(char *fmt, ...)
+Error(const char *fmt, ...)
 {
     va_list ap;
     errwarn *we;
@@ -177,7 +177,7 @@ Error(char *fmt, ...)
            Fatal(FATAL_NOMEM);
 
        we->type = WE_ERROR;
-       we->filename = strdup(filename);
+       we->filename = strdup(in_filename);
        if (!we->filename)
            Fatal(FATAL_NOMEM);
        we->line = line_number;
@@ -200,7 +200,7 @@ Error(char *fmt, ...)
  * argument types.  Does not print the warning, only stores it for
  * OutputAllErrorWarning() to print. */
 void
-Warning(char *fmt, ...)
+Warning(const char *fmt, ...)
 {
     va_list ap;
     errwarn *we;
@@ -215,7 +215,7 @@ Warning(char *fmt, ...)
        Fatal(FATAL_NOMEM);
 
     we->type = WE_WARNING;
-    we->filename = strdup(filename);
+    we->filename = strdup(in_filename);
     if (!we->filename)
        Fatal(FATAL_NOMEM);
     we->line = line_number;
@@ -234,7 +234,7 @@ Warning(char *fmt, ...)
 }
 
 void
-ErrorNow(char *fmt, ...)
+ErrorNow(const char *fmt, ...)
 {
     va_list ap;
 
@@ -245,7 +245,7 @@ ErrorNow(char *fmt, ...)
 }
 
 void
-WarningNow(char *fmt, ...)
+WarningNow(const char *fmt, ...)
 {
     va_list ap;
 
@@ -257,13 +257,13 @@ WarningNow(char *fmt, ...)
 }
 
 void
-ErrorAt(char *filename, unsigned long line, char *fmt, ...)
+ErrorAt(const char *filename, unsigned long line, const char *fmt, ...)
 {
     /* TODO */
 }
 
 void
-WarningAt(char *filename, unsigned long line, char *fmt, ...)
+WarningAt(const char *filename, unsigned long line, const char *fmt, ...)
 {
     /* TODO */
 }
index cb701f9569c692d810be5f384028eb1e785bfc20..6a7d9ece1f371c10845b52186cac4f49a30039e9 100644 (file)
@@ -32,27 +32,27 @@ typedef enum {
 
 char *conv_unprint(char ch);
 
-void ParserError(char *);
+void ParserError(const char *);
 
-void InternalError(unsigned int line, char *file, char *message);
+void InternalError(unsigned int line, const char *file, const char *message);
 
 void Fatal(fatal_num);
-void Error(char *, ...);
-void Warning(char *, ...);
+void Error(const char *, ...);
+void Warning(const char *, ...);
 
 /* Use Error() and Warning() instead of ErrorAt() and WarningAt() when being
  * called in line order from a parser.  The *At() functions are much slower,
  * at least in the current implementation.
  */
-void ErrorAt(char *filename, unsigned long line, char *, ...);
-void WarningAt(char *filename, unsigned long line, char *, ...);
+void ErrorAt(const char *filename, unsigned long line, const char *, ...);
+void WarningAt(const char *filename, unsigned long line, const char *, ...);
 
 /* These two functions immediately output the error or warning, with no file
  * or line information.  They should be used for errors and warnings outside
  * the parser stage (at program startup, for instance).
  */
-void ErrorNow(char *, ...);
-void WarningNow(char *, ...);
+void ErrorNow(const char *, ...);
+void WarningNow(const char *, ...);
 
 /* Returns total number of errors to this point in assembly. */
 unsigned int OutputAllErrorWarning(void);
index 92aa3e8905758131b9994455ebaec11eb6d05926..4af39630c2b52fe7e16dc84b8f00f04bf62f06b1 100644 (file)
@@ -29,7 +29,7 @@
 
 RCSID("$IdPath$");
 
-char *filename = (char *)NULL;
+char *in_filename = (char *)NULL;
 unsigned int line_number = 1;
 unsigned char mode_bits = 0;
 unsigned int asm_options = 0;
index 4cae3b833e2ff89f4f8a9d3a77096e129629d645..373d1dd8c2fa10359ea34351fa7c1fda87f9a667 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef YASM_GLOBALS_H
 #define YASM_GLOBALS_H
 
-extern char *filename;
+extern char *in_filename;
 extern unsigned int line_number;
 extern unsigned char mode_bits;
 extern unsigned int asm_options;
index 5d545632395a09f43f104e1db66dba4102bcc4fd..2283f0d566f2f4645cdf25926b3fcfb407a3074a 100644 (file)
@@ -71,7 +71,7 @@ symrec_get_or_new(const char *name)
     if (!rec->name)
        Fatal(FATAL_NOMEM);
     rec->type = SYM_UNKNOWN;
-    rec->filename = strdup(filename);
+    rec->filename = strdup(in_filename);
     rec->line = line_number;
     rec->status = SYM_NOSTATUS;
     rec->visibility = SYM_LOCAL;
index 9d333b5feadf1d32d6eb623a95c7f7d8ca393358..708cc0943773bb8fec217dc174f529094c6b9012 100644 (file)
@@ -1,7 +1,14 @@
 /* $IdPath$
  *
  */
-#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+#endif
+
 #include "check.h"
 
 #include "util.h"
@@ -37,7 +44,8 @@ START_TEST(test_effaddr_new_reg)
 }
 END_TEST
 
-Suite *bytecode_suite(void)
+static Suite *
+bytecode_suite(void)
 {
     Suite *s = suite_create("bytecode");
     TCase *tc_conversion = tcase_create("Conversion");
@@ -48,7 +56,8 @@ Suite *bytecode_suite(void)
     return s;
 }
 
-int main(void)
+int
+main(void)
 {
     int nf;
     Suite *s = bytecode_suite();
index d94797c6cb7ac2838465250cfd4c9533cc842217..f3f6f99cae1cc308c92bce11f059c7f9e59d152c 100644 (file)
@@ -1,7 +1,14 @@
 /* $IdPath$
  *
  */
-#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+#endif
+
 #include "check.h"
 
 #include "bitvect.h"
 #include "floatnum.h"
 
 floatnum *flt;
-void get_family_setup(void)
+static void
+get_family_setup(void)
 {
 
     flt = malloc(sizeof(floatnum));
     flt->mantissa = BitVector_Create(80, TRUE);
 }
 
-void get_family_teardown(void)
+static void
+get_family_teardown(void)
 {
     BitVector_Destroy(flt->mantissa);
     free(flt);
 }
 
-void pi_setup(void)
+static void
+pi_setup(void)
 {
     /* test value: 3.141592653589793 */
     /* 80-bit little endian mantissa: C6 0D E9 BD 68 21 A2 DA 0F C9 */
@@ -86,7 +96,8 @@ START_TEST(test_get_extended_pi)
 }
 END_TEST
 
-Suite *bytecode_suite(void)
+static Suite *
+floatnum_suite(void)
 {
     Suite *s = suite_create("floatnum");
     TCase *tc_get_single = tcase_create("get_single");
@@ -108,10 +119,11 @@ Suite *bytecode_suite(void)
     return s;
 }
 
-int main(void)
+int
+main(void)
 {
     int nf;
-    Suite *s = bytecode_suite();
+    Suite *s = floatnum_suite();
     SRunner *sr = srunner_create(s);
     BitVector_Boot();
     srunner_run_all(sr, CRNORMAL);
index 9b633fbd622dc3ea355b9c97cf5e4aa80b182a19..f0c66ad82ac859c57c187a3c24876d853f3297e8 100644 (file)
@@ -52,7 +52,7 @@ RCSID("$IdPath$");
 void init_table(void);
 extern int nasm_parser_lex(void);
 static unsigned long ConvertCharConstToInt(char *);
-void nasm_parser_error(char *);
+void nasm_parser_error(const char *);
 
 extern objfmt *nasm_parser_objfmt;
 extern sectionhead nasm_parser_sections;
@@ -471,7 +471,7 @@ ConvertCharConstToInt(char *cc)
 }
 
 void
-nasm_parser_error(char *s)
+nasm_parser_error(const char *s)
 {
     ParserError(s);
 }
index 9b633fbd622dc3ea355b9c97cf5e4aa80b182a19..f0c66ad82ac859c57c187a3c24876d853f3297e8 100644 (file)
@@ -52,7 +52,7 @@ RCSID("$IdPath$");
 void init_table(void);
 extern int nasm_parser_lex(void);
 static unsigned long ConvertCharConstToInt(char *);
-void nasm_parser_error(char *);
+void nasm_parser_error(const char *);
 
 extern objfmt *nasm_parser_objfmt;
 extern sectionhead nasm_parser_sections;
@@ -471,7 +471,7 @@ ConvertCharConstToInt(char *cc)
 }
 
 void
-nasm_parser_error(char *s)
+nasm_parser_error(const char *s)
 {
     ParserError(s);
 }
index 4f4b72b2df447f16fa8474b1ef8a82740f5c7842..43c95f593f27f941b594d5d6590681981cc81401 100644 (file)
@@ -49,6 +49,8 @@ RCSID("$IdPath$");
 
 #define yylval nasm_parser_lval
 
+int nasm_parser_lex(void);
+
 extern int (*nasm_parser_yyinput) (char *buf, int max_size);
 #undef YY_INPUT
 #define YY_INPUT(b, r, ms)     (r = nasm_parser_yyinput(b, ms))
index 2f5474321ec255fee84b3e15f315d7d8864b9a48..ca391ff543a224b372d58cd100dff2909c5f44cf 100644 (file)
@@ -319,9 +319,9 @@ N_word BitVector_Mask(N_int bits)           /* bit vector mask (unused bits) */
     return(mask);
 }
 
-charptr BitVector_Version(void)
+const char * BitVector_Version(void)
 {
-    return((charptr)"6.0");
+    return("6.0");
 }
 
 N_int BitVector_Word_Bits(void)
@@ -1783,7 +1783,7 @@ ErrCode BitVector_from_Enum(wordptr addr, charptr string)
     N_word  bits = bits_(addr);
     N_word  state = 1;
     N_word  token;
-    N_word  index;
+    N_word  indx;
     N_word  start;
 
     if (bits > 0)
@@ -1795,8 +1795,8 @@ ErrCode BitVector_from_Enum(wordptr addr, charptr string)
             /* separate because isdigit() is likely a macro! */
             if (isdigit(token) != 0)
             {
-                string += BIT_VECTOR_str2int(string,&index);
-                if (index < bits) token = (N_word) '0';
+                string += BIT_VECTOR_str2int(string,&indx);
+                if (indx < bits) token = (N_word) '0';
                 else error = ErrCode_Indx;
             }
             else string++;
@@ -1821,15 +1821,15 @@ ErrCode BitVector_from_Enum(wordptr addr, charptr string)
                     switch (token)
                     {
                         case (N_word) '-':
-                            start = index;
+                            start = indx;
                             state = 3;
                             break;
                         case (N_word) ',':
-                            BIT_VECTOR_SET_BIT(addr,index)
+                            BIT_VECTOR_SET_BIT(addr,indx)
                             state = 5;
                             break;
                         case (N_word) '\0':
-                            BIT_VECTOR_SET_BIT(addr,index)
+                            BIT_VECTOR_SET_BIT(addr,indx)
                             state = 0;
                             break;
                         default:
@@ -1841,10 +1841,10 @@ ErrCode BitVector_from_Enum(wordptr addr, charptr string)
                     switch (token)
                     {
                         case (N_word) '0':
-                            if (start < index)
-                                BitVector_Interval_Fill(addr,start,index);
-                            else if (start == index)
-                                BIT_VECTOR_SET_BIT(addr,index)
+                            if (start < indx)
+                                BitVector_Interval_Fill(addr,start,indx);
+                            else if (start == indx)
+                                BIT_VECTOR_SET_BIT(addr,indx)
                             else error = ErrCode_Ordr;
                             state = 4;
                             break;
@@ -1889,36 +1889,36 @@ void BitVector_Dispose(charptr string)
     if (string != NULL) free((voidptr) string);
 }
 
-void BitVector_Bit_Off(wordptr addr, N_int index)           /* X = X \ {x}   */
+void BitVector_Bit_Off(wordptr addr, N_int indx)            /* X = X \ {x}   */
 {
-    if (index < bits_(addr)) BIT_VECTOR_CLR_BIT(addr,index)
+    if (indx < bits_(addr)) BIT_VECTOR_CLR_BIT(addr,indx)
 }
 
-void BitVector_Bit_On(wordptr addr, N_int index)            /* X = X + {x}   */
+void BitVector_Bit_On(wordptr addr, N_int indx)             /* X = X + {x}   */
 {
-    if (index < bits_(addr)) BIT_VECTOR_SET_BIT(addr,index)
+    if (indx < bits_(addr)) BIT_VECTOR_SET_BIT(addr,indx)
 }
 
-boolean BitVector_bit_flip(wordptr addr, N_int index)   /* X=(X+{x})\(X*{x}) */
+boolean BitVector_bit_flip(wordptr addr, N_int indx)    /* X=(X+{x})\(X*{x}) */
 {
     N_word mask;
 
-    if (index < bits_(addr)) return( BIT_VECTOR_FLP_BIT(addr,index,mask) );
-    else                     return( FALSE );
+    if (indx < bits_(addr)) return( BIT_VECTOR_FLP_BIT(addr,indx,mask) );
+    else                    return( FALSE );
 }
 
-boolean BitVector_bit_test(wordptr addr, N_int index)       /* {x} in X ?    */
+boolean BitVector_bit_test(wordptr addr, N_int indx)        /* {x} in X ?    */
 {
-    if (index < bits_(addr)) return( BIT_VECTOR_TST_BIT(addr,index) );
-    else                     return( FALSE );
+    if (indx < bits_(addr)) return( BIT_VECTOR_TST_BIT(addr,indx) );
+    else                    return( FALSE );
 }
 
-void BitVector_Bit_Copy(wordptr addr, N_int index, boolean bit)
+void BitVector_Bit_Copy(wordptr addr, N_int indx, boolean bit)
 {
-    if (index < bits_(addr))
+    if (indx < bits_(addr))
     {
-        if (bit) BIT_VECTOR_SET_BIT(addr,index)
-        else     BIT_VECTOR_CLR_BIT(addr,index)
+        if (bit) BIT_VECTOR_SET_BIT(addr,indx)
+        else     BIT_VECTOR_CLR_BIT(addr,indx)
     }
 }
 
index 6509881e9bf89431831403fb9e29adcf12552140..7fbc2ce566206cb4b3516a82b04659710e7ca2da 100644 (file)
@@ -114,7 +114,7 @@ N_word  BitVector_Mask  (N_int bits);       /* bit vector mask (unused bits) */
 
 /* ===> CLASS METHODS: <=== */
 
-charptr BitVector_Version    (void);               /* returns version string */
+const char * BitVector_Version    (void);          /* returns version string */
 
 N_int   BitVector_Word_Bits  (void);    /* returns # of bits in machine word */
 N_int   BitVector_Long_Bits  (void);   /* returns # of bits in unsigned long */
@@ -193,13 +193,13 @@ void    BitVector_Dispose (charptr string);
 
 /* ===> bit vector bit operations, functions & tests: */
 
-void    BitVector_Bit_Off (wordptr addr, N_int index);      /* X = X \ {x}   */
-void    BitVector_Bit_On  (wordptr addr, N_int index);      /* X = X + {x}   */
-boolean BitVector_bit_flip(wordptr addr, N_int index);  /* X=(X+{x})\(X*{x}) */
+void    BitVector_Bit_Off (wordptr addr, N_int indx);      /* X = X \ {x}   */
+void    BitVector_Bit_On  (wordptr addr, N_int indx);      /* X = X + {x}   */
+boolean BitVector_bit_flip(wordptr addr, N_int indx);  /* X=(X+{x})\(X*{x}) */
 
-boolean BitVector_bit_test(wordptr addr, N_int index);      /* {x} in X ?    */
+boolean BitVector_bit_test(wordptr addr, N_int indx);      /* {x} in X ?    */
 
-void    BitVector_Bit_Copy(wordptr addr, N_int index, boolean bit);
+void    BitVector_Bit_Copy(wordptr addr, N_int indx, boolean bit);
 
 /* ===> bit vector bit shift & rotate functions: */
 
index 01695afea39b38753222d7bf0df1528d64b96ee7..f031635f894b253324a82058b61738f00f09950d 100644 (file)
@@ -274,7 +274,7 @@ bytecode_new_common(void)
 
     bc->len = 0;
 
-    bc->filename = strdup(filename);
+    bc->filename = strdup(in_filename);
     bc->lineno = line_number;
 
     bc->offset = 0;
@@ -576,7 +576,7 @@ bytecodes_append(bytecodehead *headp, bytecode *bc)
 }
 
 dataval *
-dataval_new_expr(expr *exp)
+dataval_new_expr(expr *expn)
 {
     dataval *retval = malloc(sizeof(dataval));
 
@@ -584,7 +584,7 @@ dataval_new_expr(expr *exp)
        Fatal(FATAL_NOMEM);
 
     retval->type = DV_EXPR;
-    retval->data.exp = exp;
+    retval->data.expn = expn;
 
     return retval;
 }
@@ -629,7 +629,7 @@ dataval_print(datavalhead *head)
                break;
            case DV_EXPR:
                printf(" Expr=");
-               expr_print(cur->data.exp);
+               expr_print(cur->data.expn);
                printf("\n");
                break;
            case DV_FLOAT:
index 01a0ac19657a5a9ba5053386fd8b5b97906d5258..05d39de35d657159c33621276b1b93dfb10ed5f6 100644 (file)
@@ -57,7 +57,7 @@ typedef struct dataval_s {
     enum { DV_EMPTY, DV_EXPR, DV_FLOAT, DV_STRING } type;
 
     union {
-       struct expr_s *exp;
+       struct expr_s *expn;
        struct floatnum_s *flt;
        char *str_val;
     } data;
@@ -231,7 +231,7 @@ void bytecode_print(bytecode *bc);
  */
 bytecode *bytecodes_append(bytecodehead *headp, bytecode *bc);
 
-dataval *dataval_new_expr(struct expr_s *exp);
+dataval *dataval_new_expr(struct expr_s *expn);
 dataval *dataval_new_float(struct floatnum_s *flt);
 dataval *dataval_new_string(char *str_val);
 
index 377da658d28c776d0a1415f913af831a8ebf8e82..f6a24d5455ac30a049444e476c8d767cdf8e2da3 100644 (file)
@@ -59,7 +59,7 @@ static unsigned int warning_count = 0;
  * When adding a string here, keep errwarn.h in sync! */
 
 /* Fatal error messages.  Match up with fatal_num enum in errwarn.h. */
-static char *fatal_msgs[] = {
+static const char *fatal_msgs[] = {
     N_("unknown"),
     N_("out of memory")
 };
@@ -116,7 +116,7 @@ conv_unprint(char ch)
 
 /* Parser error handler.  Moves error into our error handling system. */
 void
-ParserError(char *s)
+ParserError(const char *s)
 {
     Error("%s %s", _("parser error:"), s);
     previous_error_parser = 1;
@@ -125,7 +125,7 @@ ParserError(char *s)
 /* Report an internal error.  Essentially a fatal error with trace info.
  * Exit immediately because it's essentially an assert() trap. */
 void
-InternalError(unsigned int line, char *file, char *message)
+InternalError(unsigned int line, const char *file, const char *message)
 {
     fprintf(stderr, _("INTERNAL ERROR at %s, line %d: %s\n"), file, line,
            message);
@@ -153,7 +153,7 @@ Fatal(fatal_num num)
  * argument types.  Does not print the error, only stores it for
  * OutputAllErrorWarning() to print. */
 void
-Error(char *fmt, ...)
+Error(const char *fmt, ...)
 {
     va_list ap;
     errwarn *we;
@@ -177,7 +177,7 @@ Error(char *fmt, ...)
            Fatal(FATAL_NOMEM);
 
        we->type = WE_ERROR;
-       we->filename = strdup(filename);
+       we->filename = strdup(in_filename);
        if (!we->filename)
            Fatal(FATAL_NOMEM);
        we->line = line_number;
@@ -200,7 +200,7 @@ Error(char *fmt, ...)
  * argument types.  Does not print the warning, only stores it for
  * OutputAllErrorWarning() to print. */
 void
-Warning(char *fmt, ...)
+Warning(const char *fmt, ...)
 {
     va_list ap;
     errwarn *we;
@@ -215,7 +215,7 @@ Warning(char *fmt, ...)
        Fatal(FATAL_NOMEM);
 
     we->type = WE_WARNING;
-    we->filename = strdup(filename);
+    we->filename = strdup(in_filename);
     if (!we->filename)
        Fatal(FATAL_NOMEM);
     we->line = line_number;
@@ -234,7 +234,7 @@ Warning(char *fmt, ...)
 }
 
 void
-ErrorNow(char *fmt, ...)
+ErrorNow(const char *fmt, ...)
 {
     va_list ap;
 
@@ -245,7 +245,7 @@ ErrorNow(char *fmt, ...)
 }
 
 void
-WarningNow(char *fmt, ...)
+WarningNow(const char *fmt, ...)
 {
     va_list ap;
 
@@ -257,13 +257,13 @@ WarningNow(char *fmt, ...)
 }
 
 void
-ErrorAt(char *filename, unsigned long line, char *fmt, ...)
+ErrorAt(const char *filename, unsigned long line, const char *fmt, ...)
 {
     /* TODO */
 }
 
 void
-WarningAt(char *filename, unsigned long line, char *fmt, ...)
+WarningAt(const char *filename, unsigned long line, const char *fmt, ...)
 {
     /* TODO */
 }
index cb701f9569c692d810be5f384028eb1e785bfc20..6a7d9ece1f371c10845b52186cac4f49a30039e9 100644 (file)
@@ -32,27 +32,27 @@ typedef enum {
 
 char *conv_unprint(char ch);
 
-void ParserError(char *);
+void ParserError(const char *);
 
-void InternalError(unsigned int line, char *file, char *message);
+void InternalError(unsigned int line, const char *file, const char *message);
 
 void Fatal(fatal_num);
-void Error(char *, ...);
-void Warning(char *, ...);
+void Error(const char *, ...);
+void Warning(const char *, ...);
 
 /* Use Error() and Warning() instead of ErrorAt() and WarningAt() when being
  * called in line order from a parser.  The *At() functions are much slower,
  * at least in the current implementation.
  */
-void ErrorAt(char *filename, unsigned long line, char *, ...);
-void WarningAt(char *filename, unsigned long line, char *, ...);
+void ErrorAt(const char *filename, unsigned long line, const char *, ...);
+void WarningAt(const char *filename, unsigned long line, const char *, ...);
 
 /* These two functions immediately output the error or warning, with no file
  * or line information.  They should be used for errors and warnings outside
  * the parser stage (at program startup, for instance).
  */
-void ErrorNow(char *, ...);
-void WarningNow(char *, ...);
+void ErrorNow(const char *, ...);
+void WarningNow(const char *, ...);
 
 /* Returns total number of errors to this point in assembly. */
 unsigned int OutputAllErrorWarning(void);
index 92aa3e8905758131b9994455ebaec11eb6d05926..4af39630c2b52fe7e16dc84b8f00f04bf62f06b1 100644 (file)
@@ -29,7 +29,7 @@
 
 RCSID("$IdPath$");
 
-char *filename = (char *)NULL;
+char *in_filename = (char *)NULL;
 unsigned int line_number = 1;
 unsigned char mode_bits = 0;
 unsigned int asm_options = 0;
index 4cae3b833e2ff89f4f8a9d3a77096e129629d645..373d1dd8c2fa10359ea34351fa7c1fda87f9a667 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef YASM_GLOBALS_H
 #define YASM_GLOBALS_H
 
-extern char *filename;
+extern char *in_filename;
 extern unsigned int line_number;
 extern unsigned char mode_bits;
 extern unsigned int asm_options;
index 92aa3e8905758131b9994455ebaec11eb6d05926..4af39630c2b52fe7e16dc84b8f00f04bf62f06b1 100644 (file)
@@ -29,7 +29,7 @@
 
 RCSID("$IdPath$");
 
-char *filename = (char *)NULL;
+char *in_filename = (char *)NULL;
 unsigned int line_number = 1;
 unsigned char mode_bits = 0;
 unsigned int asm_options = 0;
index 4cae3b833e2ff89f4f8a9d3a77096e129629d645..373d1dd8c2fa10359ea34351fa7c1fda87f9a667 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef YASM_GLOBALS_H
 #define YASM_GLOBALS_H
 
-extern char *filename;
+extern char *in_filename;
 extern unsigned int line_number;
 extern unsigned char mode_bits;
 extern unsigned int asm_options;
index 435ec46bb7d57b5c839cf976537b91281f6655d7..fd7a4993d7d0c758b4a0d65d886f38d661f3c625 100644 (file)
@@ -62,7 +62,6 @@ static int files_open = 0;
 static FILE *in;
 
 /* Forward declarations: cmd line parser handlers */
-int not_an_option_handler(char *param);
 int opt_option_handler(char *cmd, char *param, int extra);
 int opt_format_handler(char *cmd, char *param, int extra);
 /* Fake handlers: remove them */
@@ -118,7 +117,7 @@ main(int argc, char *argv[])
     if (!files_open)
     {
        in = stdin;
-       filename = strdup("<STDIN>");
+       in_filename = strdup("<STDIN>");
     }
 
     /* Get initial BITS setting from object format */
@@ -129,8 +128,8 @@ main(int argc, char *argv[])
     if (OutputAllErrorWarning() > 0)
        return EXIT_FAILURE;
 
-    if (filename)
-       free(filename);
+    if (in_filename)
+       free(in_filename);
     return EXIT_SUCCESS;
 }
 
@@ -142,7 +141,7 @@ not_an_option_handler(char *param)
 {
     if (files_open > 0) {
        WarningNow("can open only one input file, only latest file will be processed");
-       free(filename);
+       free(in_filename);
        fclose(in);
     }
 
@@ -151,7 +150,7 @@ not_an_option_handler(char *param)
        ErrorNow(_("could not open file `%s'"), param);
        return 1;
     }
-    filename = strdup(param);
+    in_filename = strdup(param);
 
     files_open++;
     return 0;
index 121f9e64a948ba3b03a94e52113e3ab164eb50db..0d4648835930ed85165b335616bc10a2e723cdf7 100644 (file)
  */
 typedef struct opt_option_s
 {
-    char sopt;         /* short option letter if present, 0 otherwise */
-    char *lopt;                /* long option name if present, NULL otherwise */
-    int takes_param;   /* !=0 if option requires parameter, 0 if not */
+    char sopt;                 /* short option letter if present, 0 otherwise */
+    const char *lopt;          /* long option name if present, NULL otherwise */
+    int takes_param;           /* !=0 if option requires parameter, 0 if not */
     int (*handler) (char *cmd, char *param, int extra);
-    int extra;         /* extra value for handler */
-    char *description; /* description to use in help_msg() */
-    char *param_desc;  /* optional description for the param taken */
+    int extra;                 /* extra value for handler */
+    const char *description;   /* description to use in help_msg() */
+    const char *param_desc;    /* optional description for the param taken */
                        /*  (short - will be printed after option sopt/lopt) */
 } opt_option;
 
index 9b633fbd622dc3ea355b9c97cf5e4aa80b182a19..f0c66ad82ac859c57c187a3c24876d853f3297e8 100644 (file)
@@ -52,7 +52,7 @@ RCSID("$IdPath$");
 void init_table(void);
 extern int nasm_parser_lex(void);
 static unsigned long ConvertCharConstToInt(char *);
-void nasm_parser_error(char *);
+void nasm_parser_error(const char *);
 
 extern objfmt *nasm_parser_objfmt;
 extern sectionhead nasm_parser_sections;
@@ -471,7 +471,7 @@ ConvertCharConstToInt(char *cc)
 }
 
 void
-nasm_parser_error(char *s)
+nasm_parser_error(const char *s)
 {
     ParserError(s);
 }
index 9b633fbd622dc3ea355b9c97cf5e4aa80b182a19..f0c66ad82ac859c57c187a3c24876d853f3297e8 100644 (file)
@@ -52,7 +52,7 @@ RCSID("$IdPath$");
 void init_table(void);
 extern int nasm_parser_lex(void);
 static unsigned long ConvertCharConstToInt(char *);
-void nasm_parser_error(char *);
+void nasm_parser_error(const char *);
 
 extern objfmt *nasm_parser_objfmt;
 extern sectionhead nasm_parser_sections;
@@ -471,7 +471,7 @@ ConvertCharConstToInt(char *cc)
 }
 
 void
-nasm_parser_error(char *s)
+nasm_parser_error(const char *s)
 {
     ParserError(s);
 }
index 4f4b72b2df447f16fa8474b1ef8a82740f5c7842..43c95f593f27f941b594d5d6590681981cc81401 100644 (file)
@@ -49,6 +49,8 @@ RCSID("$IdPath$");
 
 #define yylval nasm_parser_lval
 
+int nasm_parser_lex(void);
+
 extern int (*nasm_parser_yyinput) (char *buf, int max_size);
 #undef YY_INPUT
 #define YY_INPUT(b, r, ms)     (r = nasm_parser_yyinput(b, ms))
index 5d545632395a09f43f104e1db66dba4102bcc4fd..2283f0d566f2f4645cdf25926b3fcfb407a3074a 100644 (file)
@@ -71,7 +71,7 @@ symrec_get_or_new(const char *name)
     if (!rec->name)
        Fatal(FATAL_NOMEM);
     rec->type = SYM_UNKNOWN;
-    rec->filename = strdup(filename);
+    rec->filename = strdup(in_filename);
     rec->line = line_number;
     rec->status = SYM_NOSTATUS;
     rec->visibility = SYM_LOCAL;
index 9d333b5feadf1d32d6eb623a95c7f7d8ca393358..708cc0943773bb8fec217dc174f529094c6b9012 100644 (file)
@@ -1,7 +1,14 @@
 /* $IdPath$
  *
  */
-#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+#endif
+
 #include "check.h"
 
 #include "util.h"
@@ -37,7 +44,8 @@ START_TEST(test_effaddr_new_reg)
 }
 END_TEST
 
-Suite *bytecode_suite(void)
+static Suite *
+bytecode_suite(void)
 {
     Suite *s = suite_create("bytecode");
     TCase *tc_conversion = tcase_create("Conversion");
@@ -48,7 +56,8 @@ Suite *bytecode_suite(void)
     return s;
 }
 
-int main(void)
+int
+main(void)
 {
     int nf;
     Suite *s = bytecode_suite();
index d94797c6cb7ac2838465250cfd4c9533cc842217..f3f6f99cae1cc308c92bce11f059c7f9e59d152c 100644 (file)
@@ -1,7 +1,14 @@
 /* $IdPath$
  *
  */
-#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+#endif
+
 #include "check.h"
 
 #include "bitvect.h"
 #include "floatnum.h"
 
 floatnum *flt;
-void get_family_setup(void)
+static void
+get_family_setup(void)
 {
 
     flt = malloc(sizeof(floatnum));
     flt->mantissa = BitVector_Create(80, TRUE);
 }
 
-void get_family_teardown(void)
+static void
+get_family_teardown(void)
 {
     BitVector_Destroy(flt->mantissa);
     free(flt);
 }
 
-void pi_setup(void)
+static void
+pi_setup(void)
 {
     /* test value: 3.141592653589793 */
     /* 80-bit little endian mantissa: C6 0D E9 BD 68 21 A2 DA 0F C9 */
@@ -86,7 +96,8 @@ START_TEST(test_get_extended_pi)
 }
 END_TEST
 
-Suite *bytecode_suite(void)
+static Suite *
+floatnum_suite(void)
 {
     Suite *s = suite_create("floatnum");
     TCase *tc_get_single = tcase_create("get_single");
@@ -108,10 +119,11 @@ Suite *bytecode_suite(void)
     return s;
 }
 
-int main(void)
+int
+main(void)
 {
     int nf;
-    Suite *s = bytecode_suite();
+    Suite *s = floatnum_suite();
     SRunner *sr = srunner_create(s);
     BitVector_Boot();
     srunner_run_all(sr, CRNORMAL);