]> Trent Huber's Code - thus.git/commitdiff
Remove needless break statements, clean up input.c
authorTrent Huber <trentmhuber@gmail.com>
Thu, 15 Jan 2026 09:05:19 +0000 (04:05 -0500)
committerTrent Huber <trentmhuber@gmail.com>
Thu, 15 Jan 2026 09:05:19 +0000 (04:05 -0500)
src/input.c

index 1505b7695dbeb8b2011b37d8c6fd3a2d14bcaab5..4e20c023700c75db3a13bc16acbec35cd9d8d45f 100644 (file)
@@ -146,16 +146,16 @@ int userinput(struct context *c) {
        prompt();
        while ((current = getchar()) != '\n') switch (current) {
        default:
-           if (current >= ' ' && current <= '~') {
-               if (end - start == MAXCHARS) break;
-               memmove(cursor + 1, cursor, end - cursor);
-               *cursor = current;
-               *++end = '\0';
-
-               oldcursor = cursor + 1;
-               while (cursor != end) moveright();
-               while (cursor != oldcursor) moveleft();
-           }
+           if (current < ' ' || current > '~' || end - start == MAXCHARS) break;
+
+           memmove(cursor + 1, cursor, end - cursor);
+           *cursor = current;
+           *++end = '\0';
+
+           oldcursor = cursor + 1;
+           while (cursor != end) moveright();
+           while (cursor != oldcursor) moveleft();
+
            break;
        case EOF:
            if (sigwinch) {
@@ -205,7 +205,6 @@ int userinput(struct context *c) {
                        break;
                    case RIGHT:
                        current = FORWARD;
-                       break;
                    } else if ((current = getchar()) >= '0' && current <= '6')
                        current = getchar();
                }
@@ -232,7 +231,6 @@ int userinput(struct context *c) {
                    break;
                case RIGHT:
                    if (cursor < end) moveright();
-                   break;
                }
            }
            switch (current) {
@@ -243,11 +241,11 @@ int userinput(struct context *c) {
            case BACKWARD:
                while (cursor != start && *(cursor - 1) == ' ') moveleft();
                while (cursor != start && *(cursor - 1) != ' ') moveleft();
-               break;
            }
            break;
        case DEL:
            if (cursor == start) break;
+
            memmove(oldcursor = cursor - 1, cursor, end - cursor);
            *(end - 1) = ' ';
 
@@ -256,8 +254,6 @@ int userinput(struct context *c) {
            while (cursor != oldcursor) moveleft();
 
            *--end = '\0';
-
-           break;
        }
        newline();
    }