[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH v2] Remove warning 'format not a string literal' in libsvn_client

From: Daniel Näslund <daniel_at_longitudo.com>
Date: Thu, 5 Nov 2009 19:09:57 +0100

On Thu, Nov 05, 2009 at 11:19:37AM +0000, Julian Foad wrote:
[[[
* subversion/libsvn_client/diff.c
  (display_prop_diffs): Remove warnings about 'format not a string
    literal'.

* subversion/libsvn_client/export.c
  (copy_one_versioned_file): Remove warnings about 'format not a string
    literal'.

Patch by: Daniel Näslund <daniel_at_longitudo.com>
          Julian Foad
]]]

> For this bit:
>
> > if (! original_value)
> > - header_fmt = _("Added: %s%s");
> > + SVN_ERR(file_printf_from_utf8(file, encoding, "Added: %s%s",
> > + propchange->name, APR_EOL_STR));
> > else if (! propchange->value)
> > - header_fmt = _("Deleted: %s%s");
> > + SVN_ERR(file_printf_from_utf8(file, encoding, "Deleted: %s%s",
> > + propchange->name, APR_EOL_STR));
> > else
> > - header_fmt = _("Modified: %s%s");
> > - SVN_ERR(file_printf_from_utf8(file, encoding, header_fmt,
> > + SVN_ERR(file_printf_from_utf8(file, encoding, "Modified: %s%s",
> > propchange->name, APR_EOL_STR));
>
> consider writing:
>
> if (! original_value)
> action = _("Added");
> else if (! propchange->value)
> action = _("Deleted");
> else
> action = _("Modified");
> SVN_ERR(file_printf_from_utf8(file, encoding,
> "%s: %s" APR_EOL_STR,
> action, propchange->name));
>
> and similarly, in the other bit, you could do:
>
> [... suffix = "M" or "" ...]
>
> SVN_ERR(svn_subst_build_keywords2
> (&kw, keywords->data,
> - apr_psprintf(scratch_pool, fmt, changed_rev),
> + apr_psprintf(scratch_pool, "%ld%s",
> + changed_rev, suffix),
> entry->url, tm, author, scratch_pool));

That was so much better. Very few lines in the previous patch but I
managed to screw up a couple of localisation strings and do some heavy
code duplication. Not bad.

I've run the export_tests and diff_tests. They pass.

/Daniel

Received on 2009-11-05 19:10:21 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.