Better type safety.

This commit is contained in:
steve 2004-09-05 21:29:07 +00:00
parent 5f38591676
commit 4148a2a44c
3 changed files with 29 additions and 16 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: lexor.lex,v 1.43 2004/02/15 18:03:30 steve Exp $"
#ident "$Id: lexor.lex,v 1.44 2004/09/05 21:29:07 steve Exp $"
#endif
# include "config.h"
@ -91,7 +91,8 @@ static void ifdef_enter(void)
{
struct ifdef_stack_t*cur;
cur = calloc(1, sizeof(struct ifdef_stack_t));
cur = (struct ifdef_stack_t*)
calloc(1, sizeof(struct ifdef_stack_t));
cur->path = strdup(istack->path);
cur->lineno = istack->lineno;
cur->next = ifdef_stack;
@ -391,7 +392,8 @@ static void def_match()
return;
}
isp = calloc(1, sizeof(struct include_stack_t));
isp = (struct include_stack_t*)
calloc(1, sizeof(struct include_stack_t));
isp->str = cur->value;
isp->next = istack;
istack->yybs = YY_CURRENT_BUFFER;
@ -414,7 +416,8 @@ static void def_start()
void define_macro(const char*name, const char*value, int keyword)
{
struct define_t*def = malloc(sizeof(struct define_t));
struct define_t*def = (struct define_t*)
malloc(sizeof(struct define_t));
def->name = strdup(name);
def->value = strdup(value);
def->keyword = keyword;
@ -536,7 +539,7 @@ static void do_define()
}
/* Accumulate this text into the define_text string. */
define_text = realloc(define_text, define_cnt + (cp-yytext) + 1);
define_text = (char*)realloc(define_text, define_cnt + (cp-yytext) + 1);
strcpy(define_text+define_cnt, yytext);
define_cnt += cp-yytext;
}
@ -686,7 +689,8 @@ static void include_filename()
fprintf(stderr, "error: malformed `include directive. Extra junk on line?\n");
exit(1);
}
standby = malloc(sizeof(struct include_stack_t));
standby = (struct include_stack_t*)
malloc(sizeof(struct include_stack_t));
standby->path = strdup(yytext+1);
standby->path[strlen(standby->path)-1] = 0;
standby->lineno = 0;
@ -848,7 +852,8 @@ void reset_lexor(FILE*out, char*paths[])
{
unsigned idx;
struct include_stack_t*tail = 0;
struct include_stack_t*isp = malloc(sizeof(struct include_stack_t));
struct include_stack_t*isp = (struct include_stack_t*)
malloc(sizeof(struct include_stack_t));
isp->path = strdup(paths[0]);
isp->file = fopen(paths[0], "r");
isp->str = 0;
@ -872,7 +877,8 @@ void reset_lexor(FILE*out, char*paths[])
that yywrap can pull them when needed. */
file_queue = 0;
for (idx = 1 ; paths[idx] ; idx += 1) {
isp = malloc(sizeof(struct include_stack_t));
isp = (struct include_stack_t*)
malloc(sizeof(struct include_stack_t));
isp->path = strdup(paths[idx]);
isp->str = 0;
isp->next = 0;

View File

@ -17,7 +17,7 @@ const char COPYRIGHT[] =
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: main.c,v 1.18 2004/02/15 18:03:30 steve Exp $"
#ident "$Id: main.c,v 1.19 2004/09/05 21:29:08 steve Exp $"
#endif
# include "config.h"
@ -69,12 +69,12 @@ static unsigned source_cnt = 0;
void add_source_file(const char*name)
{
if (source_list == 0) {
source_list = calloc(2, sizeof(char*));
source_list = (char**)calloc(2, sizeof(char*));
source_list[0] = strdup(name);
source_list[1] = 0;
source_cnt = 1;
} else {
source_list = realloc(source_list, sizeof(char*) * (source_cnt+2));
source_list = (char**)realloc(source_list, sizeof(char*) * (source_cnt+2));
source_list[source_cnt+0] = strdup(name);
source_list[source_cnt+1] = 0;
source_cnt += 1;
@ -149,7 +149,7 @@ int main(int argc, char*argv[])
define_macro("unconnected_drive", "`unconnected_drive", 1);
define_macro("uselib", "`uselib", 1);
include_dir = malloc(sizeof(char*));
include_dir = (char**)malloc(sizeof(char*));
include_dir[0] = strdup(".");
include_cnt = 1;
@ -177,13 +177,14 @@ int main(int argc, char*argv[])
break;
case 'I':
include_dir = realloc(include_dir, (include_cnt+1)*sizeof(char*));
include_dir = (char**)realloc(include_dir,
(include_cnt+1)*sizeof(char*));
include_dir[include_cnt] = strdup(optarg);
include_cnt += 1;
break;
case 'K': {
char*buf = malloc(strlen(optarg) + 2);
char*buf = (char*)malloc(strlen(optarg) + 2);
buf[0] = '`';
strcpy(buf+1, optarg);
define_macro(optarg, buf, 1);
@ -289,6 +290,9 @@ int main(int argc, char*argv[])
/*
* $Log: main.c,v $
* Revision 1.19 2004/09/05 21:29:08 steve
* Better type safety.
*
* Revision 1.18 2004/02/15 18:03:30 steve
* Cleanup of warnings.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_user.h,v 1.34 2004/03/09 04:29:26 steve Exp $"
#ident "$Id: vpi_user.h,v 1.35 2004/09/05 21:30:16 steve Exp $"
#endif
@ -60,7 +60,7 @@ typedef struct t_vpi_systf_data {
const char *tfname;
PLI_INT32 (*calltf)(char*);
PLI_INT32 (*compiletf)(char*);
PLI_INT32 (*sizetf)();
PLI_INT32 (*sizetf)(char*);
char *user_data;
} s_vpi_systf_data, *p_vpi_systf_data;
@ -419,6 +419,9 @@ EXTERN_C_END
/*
* $Log: vpi_user.h,v $
* Revision 1.35 2004/09/05 21:30:16 steve
* Better type safety.
*
* Revision 1.34 2004/03/09 04:29:26 steve
* Define function types.
*