# include <time.h>
# else
# ifndef VMS
-# ifndef USG
+/*
+** evans 2002-07-03: exception for WATCOM 10.6 compiler suggest by Adam Clarke
+*/
+# if !defined (USG) && !defined (__WATCOMC__)
# include <time.h> /* Reported by Paul Smith */
# include <sys/time.h>
# include <sys/resource.h>
/*@function static void cppReader_putCharQ (cppReader *p_file, char p_ch)
modifies *p_file; @*/
# define cppReader_putCharQ(PFILE, CH) (*(PFILE)->limit++ = (CH))
-
+/*
+static void cppReader_putCharQ (cppReader *p_file, char p_ch)
+{
+ fprintf (stderr, "put char: %c\n", p_ch);
+ (*(p_file)->limit++ = (p_ch));
+}
+*/
/* Append character CH to PFILE's output buffer. Make space if need be. */
/*@function static void cppReader_putChar (sef cppReader *p_file, char p_ch)
buf--;
memset ((char *) buf, 0, sizeof (*buf));
+ DPRINTF (("Pushing buffer: %s", cstring_copyLength (buffer, length)));
CPPBUFFER (pfile) = buf;
buf->if_stack = pfile->if_stack;
char *limit = buf + length;
char *buf1, *p1, *p2;
+ DPRINTF (("Expand to buffer: %s", cstring_copyLength (buf, length)));
+
/* evans - 2001-08-26
** length is unsigned - this doesn't make sense
if (length < 0)
cppBuffer_getLineAndColumn (cppReader_fileBuffer (pfile), &end_line, &end_column);
DPRINTF (("Expand macro: %d:%d", end_line, end_column));
-
+
/* If macro wants zero args, we parsed the arglist for checking only.
Read directly from the macro definition. */
/* Now put the expansion on the input stack
so our caller will commence reading from it. */
DPRINTF (("Pushing expansion: %s", cstring_copyLength (xbuf, xbuf_len)));
-
+
if (end_line != start_line)
{
/* xbuf must have enough newlines */
DPRINTF (("Pushing expansion: %s", cstring_copyLength (xbuf, xbuf_len)));
push_macro_expansion (pfile, xbuf, xbuf_len, hp);
+ DPRINTF (("After pushing expansion: %s", cstring_copyLength (xbuf, xbuf_len)));
cppReader_getBufferSafe (pfile)->has_escapes = 1;
/* Pop the space we've used in the token_buffer for argument expansion. */
cppReader_setWritten (pfile, old_written);
-
+ DPRINTF (("Done set written"));
+
/* Recursive macro use sometimes works traditionally.
#define foo(x,y) bar (x (y,0), y)
foo (foo, baz) */
|| xbuf[2] == '\"'))
{
llassert (mbuf->cur != NULL);
+ DPRINTF (("Eating: %c", xbuf[2]));
mbuf->cur += 2;
}
+
}
cppBuffer_getLineAndColumn (cppReader_fileBuffer (pfile),
&start_line, &start_column);
c = skip_comment (pfile, &newlines);
-
+ DPRINTF (("c = %c", c));
if (opts->put_out_comments && (c == '/' || c == EOF))
{
assertSet (&start_mark);
&start_line, &start_column);
old_written = cpplib_getWritten (pfile);
string:
+ DPRINTF (("Put char: %c", c));
cppReader_putChar (pfile, c);
while (TRUE)
{
int cc = cppReader_getC (pfile);
+ DPRINTF (("cc: %c", c));
if (cc == EOF)
{
if (cppBuffer_isMacro (CPPBUFFER (pfile)))
}
/*@loopbreak@*/ break;
}
+ DPRINTF (("putting char: %c", cc));
cppReader_putChar (pfile, cc);
switch (cc)
{
return CPP_OTHER;
case '@':
+ DPRINTF (("Macro @!"));
if (cppReader_getBufferSafe (pfile)->has_escapes)
{
c = cppReader_getC (pfile);
+ DPRINTF (("got c: %c", c));
if (c == '-')
{
if (pfile->output_escapes)
struct parse_marker macro_mark;
int is_macro_call;
+ DPRINTF (("Arglist macro!"));
+
+ parseSetMark (¯o_mark, pfile);
+
while (cppBuffer_isMacro (CPPBUFFER (pfile)))
{
cppBuffer *next_buf;
cppSkipHspace (pfile);
if (cppReader_peekC (pfile) != EOF)
{
+ DPRINTF (("Peeking!"));
/*@loopbreak@*/ break;
}
CPPBUFFER (pfile) = next_buf;
}
- parseSetMark (¯o_mark, pfile);
+ /* parseSetMark (¯o_mark, pfile); */
for (;;)
{
cppSkipHspace (pfile);
c = cppReader_peekC (pfile);
+ DPRINTF (("c: %c", c));
is_macro_call = c == '(';
if (c != '\n')
/*@loopbreak@*/ break;
if (!is_macro_call)
{
+ DPRINTF (("not macro call!"));
return CPP_NAME;
}
}
+
/* This is now known to be a macro call. */
/* it might not actually be a macro. */
pmark->buf = pbuf;
pmark->position = pbuf->cur - pbuf->buf;
+ DPRINTF (("set mark: %d / %s", pmark->position, pbuf->cur));
}
/* Cleanup PMARK - we no longer need it. */
llassert (pbuf->buf != NULL);
pbuf->cur = pbuf->buf + pmark->position;
+ DPRINTF (("goto mark: %d / %s", pmark->position, pbuf->cur));
}
/* Reset PMARK to point to the current position of PFILE. (Same
}
pmark->position = pbuf->cur - pbuf->buf;
+ DPRINTF (("move mark: %s", pmark->position));
}
void cpplib_initializeReader (cppReader *pfile) /* Must be done after library is loaded. */