OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libcpp/] [errors.c] - Diff between revs 816 and 826

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 826
/* Default error handlers for CPP Library.
/* Default error handlers for CPP Library.
   Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998, 1999, 2000,
   Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998, 1999, 2000,
   2001, 2002, 2004, 2008, 2009 Free Software Foundation, Inc.
   2001, 2002, 2004, 2008, 2009 Free Software Foundation, Inc.
   Written by Per Bothner, 1994.
   Written by Per Bothner, 1994.
   Based on CCCP program by Paul Rubin, June 1986
   Based on CCCP program by Paul Rubin, June 1986
   Adapted to ANSI C, Richard Stallman, Jan 1987
   Adapted to ANSI C, Richard Stallman, Jan 1987
 
 
This program is free software; you can redistribute it and/or modify it
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
Free Software Foundation; either version 3, or (at your option) any
later version.
later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3.  If not see
along with this program; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.
 
 
 In other words, you are welcome to use, share and improve this program.
 In other words, you are welcome to use, share and improve this program.
 You are forbidden to forbid anyone else to use, share and improve
 You are forbidden to forbid anyone else to use, share and improve
 what you give them.   Help stamp out software-hoarding!  */
 what you give them.   Help stamp out software-hoarding!  */
 
 
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
#include "cpplib.h"
#include "cpplib.h"
#include "internal.h"
#include "internal.h"
 
 
/* Print an error at the location of the previously lexed token.  */
/* Print an error at the location of the previously lexed token.  */
bool
bool
cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
{
{
  source_location src_loc;
  source_location src_loc;
  va_list ap;
  va_list ap;
  bool ret;
  bool ret;
 
 
  va_start (ap, msgid);
  va_start (ap, msgid);
 
 
  if (CPP_OPTION (pfile, traditional))
  if (CPP_OPTION (pfile, traditional))
    {
    {
      if (pfile->state.in_directive)
      if (pfile->state.in_directive)
        src_loc = pfile->directive_line;
        src_loc = pfile->directive_line;
      else
      else
        src_loc = pfile->line_table->highest_line;
        src_loc = pfile->line_table->highest_line;
    }
    }
  /* We don't want to refer to a token before the beginning of the
  /* We don't want to refer to a token before the beginning of the
     current run -- that is invalid.  */
     current run -- that is invalid.  */
  else if (pfile->cur_token == pfile->cur_run->base)
  else if (pfile->cur_token == pfile->cur_run->base)
    {
    {
      if (pfile->cur_run->prev != NULL)
      if (pfile->cur_run->prev != NULL)
        src_loc = pfile->cur_run->prev->limit->src_loc;
        src_loc = pfile->cur_run->prev->limit->src_loc;
      else
      else
        src_loc = 0;
        src_loc = 0;
    }
    }
  else
  else
    {
    {
      src_loc = pfile->cur_token[-1].src_loc;
      src_loc = pfile->cur_token[-1].src_loc;
    }
    }
 
 
  if (!pfile->cb.error)
  if (!pfile->cb.error)
    abort ();
    abort ();
  ret = pfile->cb.error (pfile, level, src_loc, 0, _(msgid), &ap);
  ret = pfile->cb.error (pfile, level, src_loc, 0, _(msgid), &ap);
 
 
  va_end (ap);
  va_end (ap);
  return ret;
  return ret;
}
}
 
 
/* Print an error at a specific location.  */
/* Print an error at a specific location.  */
bool
bool
cpp_error_with_line (cpp_reader *pfile, int level,
cpp_error_with_line (cpp_reader *pfile, int level,
                     source_location src_loc, unsigned int column,
                     source_location src_loc, unsigned int column,
                     const char *msgid, ...)
                     const char *msgid, ...)
{
{
  va_list ap;
  va_list ap;
  bool ret;
  bool ret;
 
 
  va_start (ap, msgid);
  va_start (ap, msgid);
 
 
  if (!pfile->cb.error)
  if (!pfile->cb.error)
    abort ();
    abort ();
  ret = pfile->cb.error (pfile, level, src_loc, column, _(msgid), &ap);
  ret = pfile->cb.error (pfile, level, src_loc, column, _(msgid), &ap);
 
 
  va_end (ap);
  va_end (ap);
  return ret;
  return ret;
}
}
 
 
bool
bool
cpp_errno (cpp_reader *pfile, int level, const char *msgid)
cpp_errno (cpp_reader *pfile, int level, const char *msgid)
{
{
  if (msgid[0] == '\0')
  if (msgid[0] == '\0')
    msgid = _("stdout");
    msgid = _("stdout");
 
 
  return cpp_error (pfile, level, "%s: %s", msgid, xstrerror (errno));
  return cpp_error (pfile, level, "%s: %s", msgid, xstrerror (errno));
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.