FreeBSD/contrib/subversion/subversion/libsvn_wc/questions.c
/* Set *MODIFIED_P to TRUE if (after translation) VERSIONED_FILE_ABSPATH
 * (of VERSIONED_FILE_SIZE bytes) differs from PRISTINE_STREAM (of
 * PRISTINE_SIZE bytes), else to FALSE if not.
 *
 * If EXACT_COMPARISON is FALSE, translate VERSIONED_FILE_ABSPATH's EOL
 * style and keywords to repository-normal form according to its properties,
 * and compare the result with PRISTINE_STREAM.  If EXACT_COMPARISON is
 * TRUE, translate PRISTINE_STREAM's EOL style and keywords to working-copy
 * form according to VERSIONED_FILE_ABSPATH's properties, and compare the
 * result with VERSIONED_FILE_ABSPATH.
 *
 * HAS_PROPS should be TRUE if the file had properties when it was not
 * modified, otherwise FALSE.
 *
 * PROPS_MOD should be TRUE if the file's properties have been changed,
 * otherwise FALSE.
 *
 * PRISTINE_STREAM will be closed before a successful return.
 *
 * DB is a wc_db; use SCRATCH_POOL for temporary allocation.
 */
Set *MODIFIED_P to TRUE if (after translation) VERSIONED_FILE_ABSPATH
(of VERSIONED_FILE_SIZE bytes) differs from PRISTINE_STREAM (of
PRISTINE_SIZE bytes), else to FALSE if not.

If EXACT_COMPARISON is FALSE, translate VERSIONED_FILE_ABSPATH's EOL
style and keywords to repository-normal form according to its properties,
and compare the result with PRISTINE_STREAM.  If EXACT_COMPARISON is
TRUE, translate PRISTINE_STREAM's EOL style and keywords to working-copy
form according to VERSIONED_FILE_ABSPATH's properties, and compare the
result with VERSIONED_FILE_ABSPATH.

HAS_PROPS should be TRUE if the file had properties when it was not
modified, otherwise FALSE.

PROPS_MOD should be TRUE if the file's properties have been changed,
otherwise FALSE.

PRISTINE_STREAM will be closed before a successful return.

DB is a wc_db; use SCRATCH_POOL for temporary allocation.
Set * MODIFIED_P to TRUE if ( after translation ) VERSIONED_FILE_ABSPATH ( of VERSIONED_FILE_SIZE bytes ) differs from PRISTINE_STREAM ( of PRISTINE_SIZE bytes ) else to FALSE if not . If EXACT_COMPARISON is FALSE translate VERSIONED_FILE_ABSPATH ' s EOL style and keywords to repository - normal form according to its properties and compare the result with PRISTINE_STREAM . If EXACT_COMPARISON is TRUE translate PRISTINE_STREAM ' s EOL style and keywords to working - copy form according to VERSIONED_FILE_ABSPATH ' s properties and compare the result with VERSIONED_FILE_ABSPATH . HAS_PROPS should be TRUE if the file had properties when it was not modified otherwise FALSE . PROPS_MOD should be TRUE if the file ' s properties have been changed otherwise FALSE . PRISTINE_STREAM will be closed before a successful return . DB is a wc_db ; use SCRATCH_POOL for temporary allocation .
static svn_error_t *
compare_and_verify(svn_boolean_t *modified_p,
                   svn_wc__db_t *db,
                   const char *versioned_file_abspath,
                   svn_filesize_t versioned_file_size,
                   svn_stream_t *pristine_stream,
                   svn_filesize_t pristine_size,
                   svn_boolean_t has_props,
                   svn_boolean_t props_mod,
                   svn_boolean_t exact_comparison,
                   apr_pool_t *scratch_pool)
{
  svn_boolean_t same;
  svn_subst_eol_style_t eol_style;
  const char *eol_str;
  apr_hash_t *keywords;
  svn_boolean_t special = FALSE;
  svn_boolean_t need_translation;
  svn_stream_t *v_stream; 
  SVN_ERR_ASSERT(svn_dirent_is_absolute(versioned_file_abspath));
  if (props_mod)
    has_props = TRUE; 
  if (has_props)
    {
      SVN_ERR(svn_wc__get_translate_info(&eol_style, &eol_str,
                                         &keywords,
                                         &special,
                                         db, versioned_file_abspath, NULL,
                                         !exact_comparison,
                                         scratch_pool, scratch_pool));
      need_translation = svn_subst_translation_required(eol_style, eol_str,
                                                        keywords, special,
                                                        TRUE);
    }
  else
    need_translation = FALSE;
  if (! need_translation
      && (versioned_file_size != pristine_size))
    {
      *modified_p = TRUE;
      return svn_error_trace(svn_stream_close(pristine_stream));
    }
  if (special && need_translation)
    {
      SVN_ERR(svn_subst_read_specialfile(&v_stream, versioned_file_abspath,
                                          scratch_pool, scratch_pool));
    }
  else
    {
      apr_file_t *file;
      SVN_ERR(svn_io_file_open(&file, versioned_file_abspath, APR_READ,
                               APR_OS_DEFAULT, scratch_pool));
      v_stream = svn_stream_from_aprfile2(file, FALSE, scratch_pool);
      if (need_translation)
        {
          if (!exact_comparison)
            {
              if (eol_style == svn_subst_eol_style_native)
                eol_str = SVN_SUBST_NATIVE_EOL_STR;
              else if (eol_style != svn_subst_eol_style_fixed
                       && eol_style != svn_subst_eol_style_none)
                return svn_error_create(SVN_ERR_IO_UNKNOWN_EOL,
                                        svn_stream_close(v_stream), NULL);
              v_stream = svn_subst_stream_translated(v_stream,
                                                     eol_str,
                                                     TRUE ,
                                                     keywords,
                                                     FALSE ,
                                                     scratch_pool);
            }
          else
            {
              pristine_stream = svn_subst_stream_translated(pristine_stream,
                                                            eol_str, FALSE,
                                                            keywords, TRUE,
                                                            scratch_pool);
            }
        }
    }
  SVN_ERR(svn_stream_contents_same2(&same, pristine_stream, v_stream,
                                    scratch_pool));
  *modified_p = (! same);
  return SVN_NO_ERROR;
}
static svn_error_t * compare_and_verify ( svn_boolean_t * modified_p , svn_wc__db_t * db , const char * versioned_file_abspath , svn_filesize_t versioned_file_size , svn_stream_t * pristine_stream , svn_filesize_t pristine_size , svn_boolean_t has_props , svn_boolean_t props_mod , svn_boolean_t exact_comparison , apr_pool_t * scratch_pool ) { svn_boolean_t same ; svn_subst_eol_style_t eol_style ; const char * eol_str ; apr_hash_t * keywords ; svn_boolean_t special = FALSE ; svn_boolean_t need_translation ; svn_stream_t * v_stream ; SVN_ERR_ASSERT ( svn_dirent_is_absolute ( versioned_file_abspath ) ) ; if ( props_mod ) has_props = TRUE ; if ( has_props ) { SVN_ERR ( svn_wc__get_translate_info ( & eol_style , & eol_str , & keywords , & special , db , versioned_file_abspath , NULL , ! exact_comparison , scratch_pool , scratch_pool ) ) ; need_translation = svn_subst_translation_required ( eol_style , eol_str , keywords , special , TRUE ) ; } else need_translation = FALSE ; if ( ! need_translation && ( versioned_file_size != pristine_size ) ) { * modified_p = TRUE ; return svn_error_trace ( svn_stream_close ( pristine_stream ) ) ; } if ( special && need_translation ) { SVN_ERR ( svn_subst_read_specialfile ( & v_stream , versioned_file_abspath , scratch_pool , scratch_pool ) ) ; } else { apr_file_t * file ; SVN_ERR ( svn_io_file_open ( & file , versioned_file_abspath , APR_READ , APR_OS_DEFAULT , scratch_pool ) ) ; v_stream = svn_stream_from_aprfile2 ( file , FALSE , scratch_pool ) ; if ( need_translation ) { if ( ! exact_comparison ) { if ( eol_style == svn_subst_eol_style_native ) eol_str = SVN_SUBST_NATIVE_EOL_STR ; else if ( eol_style != svn_subst_eol_style_fixed && eol_style != svn_subst_eol_style_none ) return svn_error_create ( SVN_ERR_IO_UNKNOWN_EOL , svn_stream_close ( v_stream ) , NULL ) ; v_stream = svn_subst_stream_translated ( v_stream , eol_str , TRUE , keywords , FALSE , scratch_pool ) ; } else { pristine_stream = svn_subst_stream_translated ( pristine_stream , eol_str , FALSE , keywords , TRUE , scratch_pool ) ; } } } SVN_ERR ( svn_stream_contents_same2 ( & same , pristine_stream , v_stream , scratch_pool ) ) ; * modified_p = ( ! same ) ; return SVN_NO_ERROR ; }
Set *MODIFIED_P to TRUE if (after translation) VERSIONED_FILE_ABSPATH
 (of VERSIONED_FILE_SIZE bytes) differs from PRISTINE_STREAM (of
 PRISTINE_SIZE bytes), else to FALSE if not.
Set * MODIFIED_P to TRUE if ( after translation ) VERSIONED_FILE_ABSPATH ( of VERSIONED_FILE_SIZE bytes ) differs from PRISTINE_STREAM ( of PRISTINE_SIZE bytes ) else to FALSE if not .
/* versioned_file */ /* Maybe it didn't have properties; but it has now */ /* ### Why did we open the pristine? */ /* ### Other checks possible? */ /* Reading files is necessary. */ /* We don't use APR-level buffering because the comparison function
       * will do its own buffering. */ /* Wrap file stream to detranslate into normal form,
               * "repairing" the EOL style if it is inconsistent. */ /* repair */ /* expand */ /* Wrap base stream to translate into working copy form, and
               * arrange to throw an error if its EOL style is inconsistent. */