#include <stdlib.h>
#endif
+
+// PENDING: Straighten this out into configure
+#include <time.h> // all compilers need this
#ifdef __MINGW32__
#include <time.h>
#else
#ifndef VMS
#ifndef USG
#if !defined(_MSC_VER)
+// PENDING
+#include <time.h>
#include <sys/time.h> /* for __DATE__ and __TIME__ */
#include <sys/resource.h>
#else
static void add_import ();
static void append_include_chain ();
-static void make_undef ();
static void make_assertion ();
static void path_include ();
static void initialize_builtins ();
static void initialize_char_syntax ();
-static void dump_arg_n ();
-static void dump_defn_1 ();
extern void delete_macro ();
-static void trigraph_pcp ();
static int finclude ();
static void validate_else ();
static int comp_def_part ();
extern void fancy_abort ();
-static void pipe_closed ();
-static void print_containing_files ();
static int lookup_import ();
static int redundant_include_p ();
-static is_system_include ();
+static int is_system_include (cpp_reader *, char *);
static struct file_name_map *read_name_map ();
static char *read_filename_string ();
static int open_include_file ();
-static int check_preconditions ();
-static void pcfinclude ();
-static void pcstring_used ();
static int check_macro_name ();
static int compare_defs ();
static int compare_token_lists ();
U_CHAR *str)
{
cpp_buffer *ip;
- struct directive *kt;
- U_CHAR *buf, *p, *q;
+/* struct directive *kt; */
+ U_CHAR *buf, *p /*, *q */ ;
/* Copy the entire option so we can modify it. */
buf = (U_CHAR *) alloca (strlen (str) + 1);
strcpy ((char *) buf, str);
+
+#if 0
/* Scan for any backslash-newline and remove it. */
p = q = buf;
while (*p) {
-#if 0
if (*p == '\\' && p[1] == '\n')
p += 2;
else
-#endif
*q++ = *p++;
}
*q = 0;
+#endif
p = buf;
if (!is_idstart[*p]) {
if (macro->type == T_DISABLED)
macro->type = T_MACRO;
if (macro->type != T_MACRO || pbuf->buf != macro->value.defn->expansion)
- free (pbuf->buf);
+ Safe_free (pbuf->buf);
return 0;
}
{
if (pbuf->buf)
{
- free (pbuf->buf);
+ Safe_free (pbuf->buf);
pbuf->buf = 0;
}
return 0;
}
-static void
-newline_fix (
- cpp_reader *pfile)
-{
-#if 1
- NEWLINE_FIX;
-#else
- register U_CHAR *p = bp;
-
- /* First count the backslash-newline pairs here. */
-
- while (p[0] == '\\' && p[1] == '\n')
- p += 2;
-
- /* What follows the backslash-newlines is not embarrassing. */
-
- if (*p != '/' && *p != '*')
- return;
-
- /* Copy all potentially embarrassing characters
- that follow the backslash-newline pairs
- down to where the pairs originally started. */
-
- while (*p == '*' || *p == '/')
- *bp++ = *p++;
-
- /* Now write the same number of pairs after the embarrassing chars. */
- while (bp < p) {
- *bp++ = '\\';
- *bp++ = '\n';
- }
-#endif
-}
-
/* Assuming we have read '/'.
If this is the start of a comment (followed by '*' or '/'),
skip to the end of the comment, and return ' '.
cpp_reader *pfile,
long *linep)
{
- int c;
+ int c = 0;
while (PEEKC() == '\\' && PEEKN(1) == '\n')
{
if (linep)
{ int c;
register struct directive *kt;
int ident_length;
- long after_ident;
+ long after_ident = 0;
U_CHAR *ident, *line_end;
long old_written = CPP_WRITTEN (pfile);
}
}
/* now everything from bp before limit is the definition. */
- defn = collect_expansion (pfile, bp, limit, -1, NULL_PTR);
+ defn = collect_expansion (pfile, bp, limit, -1,(struct arglist *) NULL_PTR);
defn->args.argnames = (U_CHAR *) "";
}
cpp_buffer *next_buf = CPP_PREV_BUFFER (buf);
(*buf->cleanup) (buf, pfile);
CPP_BUFFER (pfile) = next_buf;
- free (buf);
+ Safe_free (buf);
return next_buf;
#endif
}
int length)
{
register cpp_buffer *ip;
- cpp_buffer obuf;
U_CHAR *limit = buf + length;
U_CHAR *buf1;
#if 0
+ cpp_buffer obuf;
int odepth = indepth;
#endif
int conditional,
enum file_change_code file_change)
{
- int len;
- char *line_cmd_buf, *line_end;
+/* int len;*/
+/* char *line_cmd_buf, *line_end;*/
long line, col;
cpp_buffer *ip = CPP_BUFFER (pfile);
CPP_PUTS_Q (pfile, sharp_line, sizeof(sharp_line)-1);
}
- sprintf (CPP_PWRITTEN (pfile), "%d ", line+2);
+ sprintf (CPP_PWRITTEN (pfile), "%ld ", line+2);
CPP_ADJUST_WRITTEN (pfile, strlen (CPP_PWRITTEN (pfile)));
// modification for SDC51
if (*ip->nominal_fname == '\0')
- quote_string (pfile,"standard input");
+ quote_string (pfile,"standard input");
else
- quote_string (pfile, ip->nominal_fname);
+ quote_string (pfile, ip->nominal_fname);
if (file_change != same_file) {
CPP_PUTC_Q (pfile, ' ');
CPP_PUTC_Q (pfile, file_change == enter_file ? '1' : '2');
int rest_args)
{
int paren = 0;
- enum cpp_token token;
- long arg_start = CPP_WRITTEN (pfile);
+ enum cpp_token token = CPP_EOF;
+ /* long arg_start = CPP_WRITTEN (pfile); */
char save_put_out_comments = CPP_OPTIONS (pfile)->put_out_comments;
CPP_OPTIONS (pfile)->put_out_comments = 0;
cpp_reader *pfile)
{
char *buf;
- int i, len;
+ int /* i, */ len;
int true_indepth;
cpp_buffer *ip = NULL;
struct tm *timebuf;
adjust_position (CPP_LINE_BASE (ip), ip->cur, &line, &col);
buf = (char *) alloca (10);
- sprintf (buf, "%d", line);
+ sprintf (buf, "%ld", line);
}
break;
if (!is_idstart[*ip->cur])
goto oops;
- if (hp = cpp_lookup (pfile, ip->cur, -1, -1))
+ if ((hp = cpp_lookup (pfile, ip->cur, -1, -1)) != 0)
{
#if 0
if (pcp_outfile && pcp_inside_if
if (nargs >= 0)
{
- enum cpp_token token;
+ enum cpp_token token = CPP_EOF;
args = (struct argdata *) alloca ((nargs + 1) * sizeof (struct argdata));
int skip_dirs = (keyword->type == T_INCLUDE_NEXT);
char *fname; /* Dynamically allocated fname buffer */
char *pcftry;
- char *pcfname;
+/* char *pcfname;*/
U_CHAR *fbeg, *fend; /* Beginning and end of fname */
enum cpp_token token;
int f; /* file number */
- int retried = 0; /* Have already tried macro
- expanding the include line*/
int angle_brackets = 0; /* 0 for "...", 1 for <...> */
- int pcf = -1;
+ /* int pcf = -1; */
char *pcfbuf;
- char *pcfbuflimit;
+/* char *pcfbuflimit;*/
int pcfnum;
f= -1; /* JF we iz paranoid! */
{
struct tokenlist_list *next = tail->next;
free_token_list (tail->tokens);
- free (tail);
+ Safe_free (tail);
tail = next;
}
if (hp == *hp->bucket_hdr)
*hp->bucket_hdr = hp->next;
- free (hp);
+ Safe_free (hp);
}
\f
/* Convert a character string literal into a nul-terminated string.
long old_written = CPP_WRITTEN (pfile);
enum file_change_code file_change = same_file;
enum cpp_token token;
- int i;
+/* int i;*/
token = get_directive_token (pfile);
U_CHAR *buf, U_CHAR *limit)
{
/* long old_written = CPP_WRITTEN (pfile);*/
- int len;
+/* int len;*/
/* Allow #ident in system headers, since that's not user's fault. */
if (CPP_PEDANTIC (pfile) && !CPP_BUFFER (pfile)->system_header_p)
int any)
{
int c;
- int at_beg_of_line = 1;
struct directive *kt;
IF_STACK_FRAME *save_if_stack = pfile->if_stack; /* don't pop past here */
#if 0
U_CHAR *beg_of_line = bp;
#endif
register int ident_length;
- U_CHAR *ident, *after_ident;
+ U_CHAR *ident /*, *after_ident */ ;
struct parse_marker line_start_mark;
parse_set_mark (&line_start_mark, pfile);
temp = pfile->if_stack;
pfile->if_stack = temp->next;
- free (temp);
+ Safe_free (temp);
break;
default: ;
}
}
}
}
- free (temp);
+ Safe_free (temp);
output_line_command (pfile, 1, same_file);
}
return 0;
cpp_reader *pfile)
{
register int c, c2, c3;
- long old_written;
+ long old_written = 0;
long start_line, start_column;
enum cpp_token token;
struct cpp_options *opts = CPP_OPTIONS (pfile);
if (opts->put_out_comments)
{
cpp_buffer *pbuf = CPP_BUFFER (pfile);
- long dummy;
+ /* long dummy; */
U_CHAR *start = pbuf->buf + start_mark.position;
int len = pbuf->cur - start;
CPP_RESERVE(pfile, 1 + len);
strcpy (ptr->map_to, dirname);
ptr->map_to[dirlen] = '/';
strcpy (ptr->map_to + dirlen + 1, to);
- free (to);
+ Safe_free (to);
}
ptr->map_next = map_list_ptr->map_list_map;
p = filename;
if (searchptr
&& searchptr->fname
- && strlen (searchptr->fname) == p - filename
+ && (int) strlen (searchptr->fname) == p - filename
&& ! strncmp (searchptr->fname, filename, p - filename))
{
/* FILENAME is in SEARCHPTR, which we've already checked. */
long i;
int length;
cpp_buffer *fp; /* For input stack frame */
- int missing_newline = 0;
+ /* int missing_newline = 0; # KILL */
if (file_size_and_mode (f, &st_mode, &st_size) < 0)
{
indepth--;
input_file_stack_tick++;
- free (fp->buf);
+ Safe_free (fp->buf);
#endif
return 1;
cpp_perror_with_name (pfile, fname);
close (f);
- free (fp->buf);
+ Safe_free (fp->buf);
return 1;
}
for (pend = opts->pending; pend; )
{
struct cpp_pending *next = pend->next;
- free (pend);
+ Safe_free (pend);
pend = next;
}
opts->pending = NULL;
char *p;
if (argv[i][2] != 0)
+ {
p = argv[i] + 2;
- else if (i + 1 == argc)
- fatal ("Assertion missing after -A option");
- else
- p = argv[++i];
+ }
+ else
+ {
+ if (++i == argc)
+ {
+ fatal ("Assertion missing after -A option");
+ }
+ p = argv[i];
+ }
if (!strcmp (p, "-")) {
struct cpp_pending **ptr;
Let's include also any that were specified earlier
on the command line. That way we can get rid of any
that were passed automatically in from GCC. */
- int j;
+ /* int j; */
opts->inhibit_predefs = 1;
for (ptr = &opts->pending; *ptr != NULL; )
{
&& (pend->cmd[1] == 'D' || pend->cmd[1] == 'A'))
{
*ptr = pend->next;
- free (pend);
+ Safe_free (pend);
}
else
ptr = &pend->next;
if (pfile->token_buffer)
{
- free (pfile->token_buffer);
+ Safe_free (pfile->token_buffer);
pfile->token_buffer = NULL;
}
if (pfile->deps_buffer)
{
- free (pfile->deps_buffer);
+ Safe_free (pfile->deps_buffer);
pfile->deps_buffer = NULL;
pfile->deps_allocated_size = 0;
}
{
IF_STACK_FRAME *temp = pfile->if_stack;
pfile->if_stack = temp->next;
- free (temp);
+ Safe_free (temp);
}
while (pfile->dont_repeat_files)
{
struct file_name_list *temp = pfile->dont_repeat_files;
pfile->dont_repeat_files = temp->next;
- free (temp->fname);
- free (temp);
+ Safe_free (temp->fname);
+ Safe_free (temp);
}
while (pfile->all_include_files)
{
struct file_name_list *temp = pfile->all_include_files;
pfile->all_include_files = temp->next;
- free (temp->fname);
- free (temp);
+ Safe_free (temp->fname);
+ Safe_free (temp);
}
for (i = IMPORT_HASH_SIZE; --i >= 0; )
while (imp)
{
struct import_file *next = imp->next;
- free (imp->name);
- free (imp);
+ Safe_free (imp->name);
+ Safe_free (imp);
imp = next;
}
pfile->import_hash_table[i] = 0;
else
hp->value = tail->next;
free_token_list (tail->tokens);
- free (tail);
+ Safe_free (tail);
} else {
prev = tail;
}
{
struct arglist *temp;
long name_written = CPP_WRITTEN (pfile);
- int eofp = 0; int c;
+ int c;
cpp_skip_hspace (pfile);
{
while (tokens) {
struct arglist *next = tokens->next;
- free (tokens->name);
- free (tokens);
+ Safe_free (tokens->name);
+ Safe_free (tokens);
tokens = next;
}
}
else
result = check_assertion (pfile,
pfile->token_buffer + name_start, name_length,
- 0, NULL_PTR);
+ 0, (struct arglist *)NULL_PTR);
CPP_ADJUST_WRITTEN (pfile, - name_length); /* pop */
return result;
}
char *msg;
char *arg1, *arg2, *arg3;
{
- int i;
cpp_buffer *ip = cpp_file_buffer (pfile);
cpp_print_containing_files (pfile);
char *msg;
char *arg1, *arg2, *arg3;
{
- int i;
cpp_buffer *ip;
if (CPP_OPTIONS (pfile)->inhibit_warnings)
cpp_reader *pfile,
char *name)
{
- int i;
-
-
cpp_buffer *ip = cpp_file_buffer (pfile);
cpp_print_containing_files (pfile);