How flows goes, here

Hi,
I'm looking into this expect of code, here is one function, I can't get how the flows goes with if where you can see "cout ##1,2,3. I expect that I'll see ##1 and either one of ##2 or ##3. But reality shows that it's not the case. I stunned. I get that <return> will get me out of the function..
How the flow will go in when IF#1 will be True and False. Why during execution debug/nodebug I see only one cout ##1?

Tx
M


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
static void run_term_filter()
{    
    bool in_execute = false;
    for (;;)   
    {
        if (change_respons) {
            ++gCurrentCharNo;
        }
        else {
            in_prepare = false;
        }
        cout << " ##1 ==============..." << endl;
        if (!(szSql = getPntrFromrespons(change_respons,  respons)))  //IF#1
              cout << " ##2 ==============..." << endl;
              return;          //fff
        cout << " ##3 ==============..." << endl;
            
#if defined(LINUX)
#else
        add_history(szSql);
#endif
        if (empty_global_filter()) {
            strip_escape_chars(szSql);
        }
        if (szSql[0] != '\0')
        {         
            if (commandIsExit(szSql)) {
                puts_output(szSql);
                break;
            }
            if (!bInMultiCommentFormat)
            {
                checkCommandIsPrepareOrExecute(&in_prepare, &in_execute);
            }
            cc1= 0;        //fff  reset loop-counter
            process_filter((const char *)szSql, &in_string, &change_respons, pname, in_execute);
        }
        else {
            if (global_query_exits()) {
                change_prompt= 1;
            }
            else {                                       
                 ++cc1;                                   
                   if ( cc1 > 4)    {
                      print_usage("Invalid ryba supplied.");
                 }
            }
        }
    }
}    
The return is deceptively indented. It makes it seem like it's inside the if statement, when in reality it's outside and will execute unconditionally.
Topic archived. No new replies allowed.