Alien-SVN

 view release on metacpan or  search on metacpan

src/subversion/subversion/libsvn_subr/error.c  view on Meta::CPAN

  apr_pool_cleanup_register(pool, tmp_err,
                            err_abort,
                            apr_pool_cleanup_null);
#endif

  return new_err;
}

void
svn_error_clear(svn_error_t *err)
{
  if (err)
    {
#if defined(SVN_DEBUG)
      while (err->child)
        err = err->child;
      apr_pool_cleanup_kill(err->pool, err, err_abort);
#endif
      svn_pool_destroy(err->pool);
    }
}

svn_boolean_t
svn_error__is_tracing_link(svn_error_t *err)
{
#ifdef SVN_ERR__TRACING
  /* ### A strcmp()?  Really?  I think it's the best we can do unless
     ### we add a boolean field to svn_error_t that's set only for
     ### these "placeholder error chain" items.  Not such a bad idea,
     ### really...  */
  return (err && err->message && !strcmp(err->message, error_tracing_link));
#else
  return FALSE;
#endif
}

svn_error_t *
svn_error_purge_tracing(svn_error_t *err)
{
#ifdef SVN_ERR__TRACING
  svn_error_t *new_err = NULL, *new_err_leaf = NULL;

  if (! err)
    return SVN_NO_ERROR;

  do
    {
      svn_error_t *tmp_err;

      /* Skip over any trace-only links. */
      while (err && svn_error__is_tracing_link(err))
        err = err->child;

      /* The link must be a real link in the error chain, otherwise an
         error chain with trace only links would map into SVN_NO_ERROR. */
      if (! err)
        return svn_error_create(
                 SVN_ERR_ASSERTION_ONLY_TRACING_LINKS,
                 svn_error_compose_create(
                   svn_error__malfunction(TRUE, __FILE__, __LINE__,
                                          NULL /* ### say something? */),
                   err),
                 NULL);

      /* Copy the current error except for its child error pointer
         into the new error.  Share any message and source filename
         strings from the error. */
      tmp_err = apr_palloc(err->pool, sizeof(*tmp_err));
      *tmp_err = *err;
      tmp_err->child = NULL;

      /* Add a new link to the new chain (creating the chain if necessary). */
      if (! new_err)
        {
          new_err = tmp_err;
          new_err_leaf = tmp_err;
        }
      else
        {
          new_err_leaf->child = tmp_err;
          new_err_leaf = tmp_err;
        }

      /* Advance to the next link in the original chain. */
      err = err->child;
    } while (err);

  return new_err;
#else  /* SVN_ERR__TRACING */
  return err;
#endif /* SVN_ERR__TRACING */
}

/* ### The logic around omitting (sic) apr_err= in maintainer mode is tightly
   ### coupled to the current sole caller.*/
static void
print_error(svn_error_t *err, FILE *stream, const char *prefix)
{
  char errbuf[256];
  const char *err_string;
  svn_error_t *temp_err = NULL;  /* ensure initialized even if
                                    err->file == NULL */
  /* Pretty-print the error */
  /* Note: we can also log errors here someday. */

#ifdef SVN_DEBUG
  /* Note: err->file is _not_ in UTF-8, because it's expanded from
           the __FILE__ preprocessor macro. */
  const char *file_utf8;

  if (err->file
      && !(temp_err = svn_utf_cstring_to_utf8(&file_utf8, err->file,
                                              err->pool)))
    svn_error_clear(svn_cmdline_fprintf(stream, err->pool,
                                        "%s:%ld", err->file, err->line));
  else
    {
      svn_error_clear(svn_cmdline_fputs(SVN_FILE_LINE_UNDEFINED,
                                        stream, err->pool));
      svn_error_clear(temp_err);
    }



( run in 0.512 second using v1.01-cache-2.11-cpan-483215c6ad5 )