Clean up cmd4.c

Fixes some compiler warnings.  In some while statements, switches some
continues to breaks and moves the return statement outside the loop.

Line 1499 (original) duplicates line 1502 so is deleted.  Likewise 2210
duplicates 2213 and 2890 duplicates 2893,