buf[0] = '-'; /* good heavens... */
if (np == &buf[NUMSIZE+1]) {
lexerror("floating constant too long");
- ptok->tk_fval = Salloc("0.0", 5) + 1;
+ ptok->tk_fval = Salloc("0.0",(unsigned) 5) + 1;
}
else
- ptok->tk_fval = Salloc(buf, np - buf) + 1;
+ ptok->tk_fval = Salloc(buf,(unsigned) (np - buf)) + 1;
return ptok->tk_symb = FLOATING;
#endif NOFLOAT
}
{
register int ch;
register int str_size;
- register char *str = Malloc(str_size = ISTRSIZE);
+ register char *str = Malloc((unsigned) (str_size = ISTRSIZE));
register int pos = 0;
LoadChar(ch);
}
str[pos++] = ch;
if (pos == str_size)
- str = Srealloc(str, str_size += RSTRSIZE);
+ str = Srealloc(str, (unsigned) (str_size += RSTRSIZE));
LoadChar(ch);
}
str[pos++] = '\0'; /* for filenames etc. */
/* $Header$ */
/* Align To Word boundary Definition */
-extern int word_align; /* align of a word */
+extern arith word_size;
-#define ATW(arg) ((((arg) + word_align - 1) / word_align) * word_align)
+#define ATW(arg) ((((arg) + word_size - 1) / word_size) * word_size)
#include "arith.h"
#include "sizes.h"
#include "atw.h"
+#include "align.h"
#ifndef STB
#include "label.h"
#include "stack.h"
+extern arith tmp_pointer_var();
#endif STB
/* Because EM does not support the loading and storing of
#include "specials.h"
#include "atw.h"
#include "assert.h"
+#include "align.h"
label lab_count = 1;
label datlab_count = 1;
error("size of %s unknown", text);
size = (arith)0;
}
- C_bss_cst(align(size, word_align), (arith)0, 1);
+ C_bss_cst(ATW(size), (arith)0, 1);
}
break;
case EXTERN:
warning("actual array of size 0");
*/
C_df_dnam(idf->id_text);
- C_bss_cst(align(size, word_align), (arith)0, 1);
+ C_bss_cst(ATW(size), (arith)0, 1);
}
formal_cvt(df)
int size = (int) expr->ex_type->tp_size;
ASSERT(expr->ex_class == Value);
+ if (expr->ex_type->tp_fund == POINTER) {
+ /* why warn on "ptr-3" ?
+ This quick hack fixes it
+ */
+ uns = 0;
+ }
if (uns) {
if (o1 & ~full_mask[size])
expr_warning(expr,
SkipRestOfLine();
return;
}
- do_line(tk.tk_ival);
+ do_line((unsigned int) tk.tk_ival);
EoiForNewline = 0;
SkipEscNewline = 0;
}
notch = new_idf();
notch->next = *hook;
*hook = notch; /* hooked in */
- notch->id_text = Salloc(tg, size);
+ notch->id_text = Salloc(tg, (unsigned) size);
#ifndef NOPP
notch->id_resmac = 0;
#endif NOPP
error("multiple initialization of %s", idf->id_text);
if (def->df_sc == TYPEDEF) {
warning("typedef cannot be initialized");
- def->df_sc == EXTERN; /* ??? *//* What else ? */
+ def->df_sc = EXTERN; /* ??? *//* What else ? */
}
def->df_initialized = 1;
}
char *symbol2str();
char *long2str();
+char *strncpy();
struct expr *do_array(), *do_struct(), *IVAL();
extern char options[];
if (tp->tp_size == (arith)-1) {
/* set the dimension */
tp = *tpp = construct_type(ARRAY, tp->tp_up, length);
- ntopad = align(tp->tp_size, word_align) - tp->tp_size;
+ ntopad = align(tp->tp_size, word_size) - tp->tp_size;
}
else {
arith dim = tp->tp_size / tp->tp_up->tp_size;
length = dim;
}
}
- ntopad = align(dim, word_align) - length;
+ ntopad = align(dim, word_size) - length;
}
/* throw out the characters of the already prepared string */
- s = Malloc((int) (length + ntopad));
+ s = Malloc((unsigned) (length + ntopad));
clear(s, (int) (length + ntopad));
strncpy(s, ex->SG_VALUE, (int) length);
+ free(ex->SG_VALUE);
str_cst(s, (int) (length + ntopad));
free(s);
}
char *nmlist = 0;
#ifdef USE_TMP
+extern char *strcpy(), *strcat();
extern char *mktemp(); /* library routine */
char *tmpfdir = "/tmp"; /* where to keep the temporary file */
static char *tmpfname = "/Cem.XXXXXX";
fatal("use: %s source destination [namelist]", prog_name);
break;
}
- source = strcmp(argv[0], "-") ? argv[0] : 0;
+ if (strcmp(argv[0], "-"))
+ FileName = source = argv[0];
+ else {
+ source = 0;
+ FileName = "standard input";
+ }
#ifdef USE_TMP
if (! options['N']) {
if (destination && strcmp(destination, "-") == 0)
destination = 0;
if (!InsertFile(source, (char **) 0, &result)) /* read the source file */
- fatal("%s: no source file %s\n", prog_name,
- source ? source : "stdin");
+ fatal("%s: no source file %s\n", prog_name, FileName);
File_Inserted = 1;
init();
- FileName = source;
LineNumber = 0;
#ifndef NOPP
WorkingDir = getwdir(source);
sys_close(fp_dst);
}
#endif USE_TMP
+
+No_Mem()
+{
+ fatal("out of memory");
+}
+
+C_failed()
+{
+ fatal("write failed");
+}