SCPs can sleep on events (XCC)
[akaros.git] / kern / src / readline.c
index 9798652..4ced81d 100644 (file)
@@ -13,13 +13,13 @@ int readline(char *buf, size_t buf_l, const char *prompt, ...)
        int i, c, echoing, retval;
        va_list ap;
 
+       spin_lock_irqsave(&readline_lock);
        va_start(ap, prompt);
        if (prompt != NULL)
                vcprintf(prompt, ap);
        va_end(ap);
 
        i = 0;
-       spin_lock_irqsave(&readline_lock);
        echoing = iscons(0);
        while (1) {
                c = getchar();
@@ -36,8 +36,10 @@ int readline(char *buf, size_t buf_l, const char *prompt, ...)
                                cputchar(c);
                        i--;
                } else if (c == '\n' || c == '\r') {
+                       /* sending a \n regardless, since the serial port gives us a \r for
+                        * carriage returns. */
                        if (echoing)
-                               cputchar(c);
+                               cputchar('\n');
                        assert(i <= buf_l - 1); /* never write to buf_l - 1 til the end */
                        buf[i++] = c;
                        retval =  i;