Text-CPP

 view release on metacpan or  search on metacpan

cpptrad.c  view on Meta::CPAN


      if (c == '/' && skip_comments)
	{
	  const uchar *tmp = skip_escaped_newlines (pfile, cur);
	  if (*tmp == '*')
	    {
	      pfile->out.cur = out;
	      cur = copy_comment (pfile, tmp, false /* in_define */);
	      out = pfile->out.cur;
	      continue;
	    }
	}

      out--;
      if (c == '\\' && is_vspace (*cur))
	{
	  cur = skip_escaped_newlines (pfile, cur - 1);
	  continue;
	}

      break;
    }

  pfile->out.cur = out;
  return cur - 1;
}

/* Lexes and outputs an identifier starting at CUR, which is assumed
   to point to a valid first character of an identifier.  Returns
   the hashnode, and updates out.cur.  */
static cpp_hashnode *
lex_identifier (pfile, cur)
     cpp_reader *pfile;
     const uchar *cur;
{
  size_t len;
  uchar *out = pfile->out.cur;
  cpp_hashnode *result;

  do
    {
      do
	*out++ = *cur++;
      while (is_numchar (*cur));
      cur = skip_escaped_newlines (pfile, cur);
    }
  while (is_numchar (*cur));

  CUR (pfile->context) = cur;
  len = out - pfile->out.cur;
  result = (cpp_hashnode *) ht_lookup (pfile->hash_table, pfile->out.cur,
				       len, HT_ALLOC);
  pfile->out.cur = out;
  return result;
}

/* Overlays the true file buffer temporarily with text of length LEN
   starting at START.  The true buffer is restored upon calling
   restore_buff().  */
void
_cpp_overlay_buffer (pfile, start, len)
     cpp_reader *pfile;
     const uchar *start;
     size_t len;
{
  cpp_buffer *buffer = pfile->buffer;

  pfile->overlaid_buffer = buffer;
  buffer->saved_cur = buffer->cur;
  buffer->saved_rlimit = buffer->rlimit;

  buffer->cur = start;
  buffer->rlimit = start + len;

  pfile->saved_line = pfile->line;
}

/* Restores a buffer overlaid by _cpp_overlay_buffer().  */
void
_cpp_remove_overlay (pfile)
     cpp_reader *pfile;
{
  cpp_buffer *buffer = pfile->overlaid_buffer;

  buffer->cur = buffer->saved_cur;
  buffer->rlimit = buffer->saved_rlimit;

  pfile->line = pfile->saved_line;
}

/* Reads a logical line into the output buffer.  Returns TRUE if there
   is more text left in the buffer.  */
bool
_cpp_read_logical_line_trad (pfile)
     cpp_reader *pfile;
{
  do
    {
      if (pfile->buffer->cur == pfile->buffer->rlimit)
	{
	  bool stop = true;

	  /* Don't pop the last buffer.  */
	  if (pfile->buffer->prev)
	    {
	      stop = pfile->buffer->return_at_eof;
	      _cpp_pop_buffer (pfile);
	    }

	  if (stop)
	    return false;
	}

      scan_out_logical_line (pfile, NULL);
    }
  while (pfile->state.skipping);

  return true;
}

/* Set up state for finding the opening '(' of a function-like
   macro.  */
static void
maybe_start_funlike (pfile, node, start, macro)
     cpp_reader *pfile;
     cpp_hashnode *node;
     const uchar *start;
     struct fun_macro *macro;
{
  unsigned int n = node->value.macro->paramc + 1;

  if (macro->buff)
    _cpp_release_buff (pfile, macro->buff);
  macro->buff = _cpp_get_buff (pfile, n * sizeof (size_t));
  macro->args = (size_t *) BUFF_FRONT (macro->buff);
  macro->node = node;
  macro->offset = start - pfile->out.base;
  macro->argc = 0;
}



( run in 1.423 second using v1.01-cache-2.11-cpan-39bf76dae61 )