src/cforth/linenoise.c
int linenoiseRaw(char *buf, size_t buflen, const char *prompt) {
    int count;

    if (buflen == 0) {
        errno = EINVAL;
        return -1;
    }
    /* keyboard_raw() will fail if stdin is not a TTY/console */
    if (!keyboard_raw()) {
        if (fgets(buf, buflen, stdin) == NULL) return -1;
        count = strlen(buf);
        if (count && buf[count-1] == '\n') {
            count--;
            buf[count] = '\0';
        }
    } else {
        count = linenoiseEdit(buf, buflen, prompt);
        printf("\n");
    }
    return count;
}
/* This function calls the line editing function linenoiseEdit() using
 * the STDIN file descriptor set in raw mode. */
This function calls the line editing function linenoiseEdit() using
the STDIN file descriptor set in raw mode.
This function calls the line editing function linenoiseEdit () using the STDIN file descriptor set in raw mode .
int linenoiseRaw(char *buf, size_t buflen, const char *prompt) {
    int count;
    if (buflen == 0) {
        errno = EINVAL;
        return -1;
    }
    if (!keyboard_raw()) {
        if (fgets(buf, buflen, stdin) == NULL) return -1;
        count = strlen(buf);
        if (count && buf[count-1] == '\n') {
            count--;
            buf[count] = '\0';
        }
    } else {
        count = linenoiseEdit(buf, buflen, prompt);
        printf("\n");
    }
    return count;
}
int linenoiseRaw ( char * buf , size_t buflen , const char * prompt ) { int count ; if ( buflen == 0 ) { errno = EINVAL ; return -1 ; } if ( ! keyboard_raw ( ) ) { if ( fgets ( buf , buflen , stdin ) == NULL ) return -1 ; count = strlen ( buf ) ; if ( count && buf [ count - 1 ] == ' \n ' ) { count -- ; buf [ count ] = ' \0 ' ; } } else { count = linenoiseEdit ( buf , buflen , prompt ) ; printf ( " \n " ) ; } return count ; }
This function calls the line editing function linenoiseEdit() using
 the STDIN file descriptor set in raw mode.
This function calls the line editing function linenoiseEdit () using the STDIN file descriptor set in raw mode .
/* keyboard_raw() will fail if stdin is not a TTY/console */