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

Re: [PATCH] extend svn_subst_translate_string() to record whether re-encoding and/or line ending translation were performed (v. 3)

From: Daniel Trebbien <dtrebbien_at_gmail.com>
Date: Sat, 13 Nov 2010 14:52:30 -0800

> The only difference between translate_newline() and translate_newline_alt()
> is the lines of code from here to the end of the function.  I think you
> could keep translate_newline() as is, and just move these checks elsewhere
> (to a new function or to the caller; I haven't thought about this in
> detail).
>
> In any case, please avoid the code duplication if possible.  (Function
> pointers are nice, but sometimes just a way to shoot yourself in the
> foot.)  If you're unsure what approach to take, do brainstorm on-list
> before sending a new iteration of the patch.  (That saves time to you
> and to us)

After thinking about this problem some more, I thought about using a
macro solution. I define a macro that is able to output the
definitions of the two variants of translate_newline():
translate_newline() and translate_newline_alt(). This way, duplicate
code is avoided, but it is like having duplicate code where each copy
is slightly different.

Do you like this idea? I have attached C code that I have tested. In
this sample, the macro that outputs the definitions of
translate_newline() and translate_newline_alt() is called
DEFINE_TRANSLATE_NEWLINE_FN.

Received on 2010-11-13 23:53:09 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.