Daniel Shahaf wrote:
> Philip Martin wrote on Wed, Sep 22, 2010 at 11:47:19 +0100:
> > Daniel Shahaf <d...@daniel.shahaf.name> writes:
> > > minval is an apr_uint64_t, so shouldn't the format string use 
> > > APR_UINT64_FMT?
> > 
> > See this thread
> > 
> > http://svn.haxx.se/dev/archive-2010-09/0295.shtml
> 
> and subversion/libsvn_fs_fs/rep-cache.c:153

Which is one of the ways it can be done when a pool is available:

> return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
>          apr_psprintf(pool,
>                       _("Representation key for checksum '%%s' exists "
>                         "in filesystem '%%s' with a different value "
>                         "(%%ld,%%%s,%%%s,%%%s) than what we were about "
>                         "to store (%%ld,%%%s,%%%s,%%%s)"),
>                       APR_OFF_T_FMT, SVN_FILESIZE_T_FMT,
>                       SVN_FILESIZE_T_FMT, APR_OFF_T_FMT,
>                       SVN_FILESIZE_T_FMT, SVN_FILESIZE_T_FMT),
>          svn_checksum_to_cstring_display(rep->sha1_checksum, pool),
>          fs->path, old_rep->revision, old_rep->offset, old_rep->size,
>          old_rep->expanded_size, rep->revision, rep->offset, rep->size,
>          rep->expanded_size);

That's one way to do it.  I'd prefer to format the various fields into
one or more non-localized strings and then include those strings in the
final localized string.  For example:

  /* Return a string containing the interesting fields of REP as a
     comma-separated tuple, allocated in POOL. */
  static char *
  rep_tuple_psprintf(const rep_t *rep, apr_pool_t *pool)
  {
    return apr_psprintf(pool,
                        "%ld,%" APR_OFF_T_FMT ",%" SVN_FILESIZE_T_FMT
                                              ",%" SVN_FILESIZE_T_FMT,
                        rep->revision, rep->offset, rep->size,
                        rep->expanded_size);
  }

followed by

  return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
    apr_psprintf(pool,
                 _("Representation key for checksum '%%s' exists "
                   "in filesystem '%%s' with a different value "
                   "(%s) than what we were about to store (%s)"),
                 svn_checksum_to_cstring_display(rep->sha1_checksum, pool),
                 fs->path, old_rep, rep);

- Julian


Reply via email to