- (defun readline (&key (prompt "") (history t))
- "Read a line from current TTY with line-editing."
- (with-cstring (c-prompt prompt)
- (let ((str (string-trim
- *whitespace*
- (convert-from-cstring (libreadline::readline c-prompt)))))
- (when (and history (not (string= "" str)))
- (add-history str))))))
+(defun readline (&key (prompt "") (history t))
+ "Read a line from current TTY with line-editing."
+ (with-cstring (c-prompt prompt)
+ (let* ((char* (libreadline::readline c-prompt))
+ (str (string-trim *whitespace*
+ (convert-from-foreign-string char*))))
+ (free-foreign-object char*)
+ (when (and history (not (string= "" str)))
+ (add-history str))
+ str)))