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

Re: [tortoisesvn] r20596 committed - I can't see why, but adding brackets around the content of the if clau...

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: Sun, 12 Dec 2010 10:56:40 +0100

On 12.12.2010 10:53, Simon Large wrote:
> On 11 December 2010 15:04,<tortoisesvn_at_googlecode.com> wrote:
>> Revision: 20596
>> Author: tortoisesvn
>> Date: Sat Dec 11 07:04:12 2010
>> Log: I can't see why, but adding brackets around the content of the if
>> clause makes this work. Without them, the else path is never called. Maybe
>> I just can't see why, or this is in fact a bug in the compiler.
>> http://code.google.com/p/tortoisesvn/source/detail?r=20596
>>
>> Modified:
>> /trunk/src/Utils/TempFile.cpp
>>
>> =======================================
>> --- /trunk/src/Utils/TempFile.cpp Thu Nov 25 11:40:09 2010
>> +++ /trunk/src/Utils/TempFile.cpp Sat Dec 11 07:04:12 2010
>> @@ -99,8 +99,10 @@
>> {
>> DeleteFile(tempfile.GetWinPath());
>> if (CreateDirectory (tempfile.GetWinPath(), NULL) == FALSE)
>> + {
>> if (GetLastError() != ERROR_ALREADY_EXISTS)
>> return CTSVNPath();
>> + }
>> else
>> succeeded = true;
>> }
>
> It's known as the 'dangling else' problem. 'else' always attaches to
> the last 'if' unless there are braces to disambiguate, so the original
> expression looked like:
>
> if (CreateDirectory (tempfile.GetWinPath(), NULL) == FALSE)
> {
> if (GetLastError() != ERROR_ALREADY_EXISTS)
> {
> return CTSVNPath();
> }
> else
> {
> succeeded = true;
> }
> }

Argh! I knew that, but I guess I was staring at the code too long so I
just didn't see it.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net
------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2690081
To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].
Received on 2010-12-12 10:56:49 CET

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

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