Structure While Statement -- Form I

        goto test;
        do {
                /* loop */
                ...
test:
        } while(cond);

        while(cond) {
                /* loop */
                ...
        }

Motivation

While statements are translated by compilers into one of the three following possible forms: the condition succeeds the loop body, precedes it, or both. This refactoring recovers the original control structures when the former form is used. It requires the Structure Do While Statement refactoring to be applied first.

Mechanics

Structure While Statement -- Form II

        while(1) {
                if(cond)
                        break;
                /* rest */
                ...
        }

        while(!cond) {
                /* rest */
                ...
        }

Motivation

As previously mentioned, While statements are translated by compilers into one of several possible forms. This refactoring recovers the original control structures where the condition precedes the loop body. It requires that the Structure Infinite Loop and Structure Break Statement refactorings are applied first.

Mechanics

Structure While Statement -- Form III

        if(cond) {
                do {
                        /* loop */
                        ...
                } while(cond);
        }

        while(cond) {
                /* loop */
                ...
        }

Motivation

As previously mentioned, While statements are translated by compilers into one of several possible forms. This refactoring recovers the original control structures where the condition both precedes and succeeds the loop body. It requires that the Structure If Statement and Structure Do-While Statement refactorings are applied first.

Mechanics