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 */
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)
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)
}
-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);
}
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);
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) */
#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);
/*!
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 */
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)
/*! 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);
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;
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 */
};
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;
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);
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;
}
-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;
}
-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;
}
-void send_failure_msg (int msqid, char *msg)
+void send_failure_msg (int msqid, const char *msg)
{
#ifdef USE_FORKWAITMSG
int rval;
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 */
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)
{
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)) {
(float) t->n_checked * 100);
}
-static char *rtype_to_string (int rtype)
+static const char *rtype_to_string (int rtype)
{
switch (rtype) {
case CRPASS:
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);
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);
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 {
#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);
#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));
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;
return tr->rtype;
}
-char *tr_tcname (TestResult *tr)
+const char *tr_tcname (TestResult *tr)
{
return tr->tcname;
}
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);
/* 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);
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 ;;
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 ;;
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
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 ;;
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 ;;
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
*/
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;
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 */
if (!files_open)
{
in = stdin;
- filename = strdup("<STDIN>");
+ in_filename = strdup("<STDIN>");
}
/* Get initial BITS setting from object format */
if (OutputAllErrorWarning() > 0)
return EXIT_FAILURE;
- if (filename)
- free(filename);
+ if (in_filename)
+ free(in_filename);
return EXIT_SUCCESS;
}
{
if (files_open > 0) {
WarningNow("can open only one input file, only latest file will be processed");
- free(filename);
+ free(in_filename);
fclose(in);
}
ErrorNow(_("could not open file `%s'"), param);
return 1;
}
- filename = strdup(param);
+ in_filename = strdup(param);
files_open++;
return 0;
return(mask);
}
-charptr BitVector_Version(void)
+const char * BitVector_Version(void)
{
- return((charptr)"6.0");
+ return("6.0");
}
N_int BitVector_Word_Bits(void)
N_word bits = bits_(addr);
N_word state = 1;
N_word token;
- N_word index;
+ N_word indx;
N_word start;
if (bits > 0)
/* 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++;
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:
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;
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)
}
}
/* ===> 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 */
/* ===> 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: */
bc->len = 0;
- bc->filename = strdup(filename);
+ bc->filename = strdup(in_filename);
bc->lineno = line_number;
bc->offset = 0;
}
dataval *
-dataval_new_expr(expr *exp)
+dataval_new_expr(expr *expn)
{
dataval *retval = malloc(sizeof(dataval));
Fatal(FATAL_NOMEM);
retval->type = DV_EXPR;
- retval->data.exp = exp;
+ retval->data.expn = expn;
return retval;
}
break;
case DV_EXPR:
printf(" Expr=");
- expr_print(cur->data.exp);
+ expr_print(cur->data.expn);
printf("\n");
break;
case DV_FLOAT:
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;
*/
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);
* 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")
};
/* 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;
/* 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);
* 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;
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;
* 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;
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;
}
void
-ErrorNow(char *fmt, ...)
+ErrorNow(const char *fmt, ...)
{
va_list ap;
}
void
-WarningNow(char *fmt, ...)
+WarningNow(const char *fmt, ...)
{
va_list ap;
}
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 */
}
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);
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;
#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;
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;
/* $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"
}
END_TEST
-Suite *bytecode_suite(void)
+static Suite *
+bytecode_suite(void)
{
Suite *s = suite_create("bytecode");
TCase *tc_conversion = tcase_create("Conversion");
return s;
}
-int main(void)
+int
+main(void)
{
int nf;
Suite *s = bytecode_suite();
/* $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 */
}
END_TEST
-Suite *bytecode_suite(void)
+static Suite *
+floatnum_suite(void)
{
Suite *s = suite_create("floatnum");
TCase *tc_get_single = tcase_create("get_single");
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);
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;
}
void
-nasm_parser_error(char *s)
+nasm_parser_error(const char *s)
{
ParserError(s);
}
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;
}
void
-nasm_parser_error(char *s)
+nasm_parser_error(const char *s)
{
ParserError(s);
}
#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))
return(mask);
}
-charptr BitVector_Version(void)
+const char * BitVector_Version(void)
{
- return((charptr)"6.0");
+ return("6.0");
}
N_int BitVector_Word_Bits(void)
N_word bits = bits_(addr);
N_word state = 1;
N_word token;
- N_word index;
+ N_word indx;
N_word start;
if (bits > 0)
/* 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++;
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:
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;
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)
}
}
/* ===> 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 */
/* ===> 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: */
bc->len = 0;
- bc->filename = strdup(filename);
+ bc->filename = strdup(in_filename);
bc->lineno = line_number;
bc->offset = 0;
}
dataval *
-dataval_new_expr(expr *exp)
+dataval_new_expr(expr *expn)
{
dataval *retval = malloc(sizeof(dataval));
Fatal(FATAL_NOMEM);
retval->type = DV_EXPR;
- retval->data.exp = exp;
+ retval->data.expn = expn;
return retval;
}
break;
case DV_EXPR:
printf(" Expr=");
- expr_print(cur->data.exp);
+ expr_print(cur->data.expn);
printf("\n");
break;
case DV_FLOAT:
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;
*/
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);
* 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")
};
/* 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;
/* 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);
* 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;
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;
* 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;
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;
}
void
-ErrorNow(char *fmt, ...)
+ErrorNow(const char *fmt, ...)
{
va_list ap;
}
void
-WarningNow(char *fmt, ...)
+WarningNow(const char *fmt, ...)
{
va_list ap;
}
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 */
}
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);
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;
#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;
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;
#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;
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 */
if (!files_open)
{
in = stdin;
- filename = strdup("<STDIN>");
+ in_filename = strdup("<STDIN>");
}
/* Get initial BITS setting from object format */
if (OutputAllErrorWarning() > 0)
return EXIT_FAILURE;
- if (filename)
- free(filename);
+ if (in_filename)
+ free(in_filename);
return EXIT_SUCCESS;
}
{
if (files_open > 0) {
WarningNow("can open only one input file, only latest file will be processed");
- free(filename);
+ free(in_filename);
fclose(in);
}
ErrorNow(_("could not open file `%s'"), param);
return 1;
}
- filename = strdup(param);
+ in_filename = strdup(param);
files_open++;
return 0;
*/
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;
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;
}
void
-nasm_parser_error(char *s)
+nasm_parser_error(const char *s)
{
ParserError(s);
}
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;
}
void
-nasm_parser_error(char *s)
+nasm_parser_error(const char *s)
{
ParserError(s);
}
#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))
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;
/* $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"
}
END_TEST
-Suite *bytecode_suite(void)
+static Suite *
+bytecode_suite(void)
{
Suite *s = suite_create("bytecode");
TCase *tc_conversion = tcase_create("Conversion");
return s;
}
-int main(void)
+int
+main(void)
{
int nf;
Suite *s = bytecode_suite();
/* $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 */
}
END_TEST
-Suite *bytecode_suite(void)
+static Suite *
+floatnum_suite(void)
{
Suite *s = suite_create("floatnum");
TCase *tc_get_single = tcase_create("get_single");
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);