diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:51:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:51:56 +0000 |
commit | c77311c90aa045796b3adcd021e69901022f4649 (patch) | |
tree | 3a6c4cc9271c6f7f7c24feff0d1aea286eed0a06 /examples/rlbasic.c | |
parent | Initial commit. (diff) | |
download | readline-c77311c90aa045796b3adcd021e69901022f4649.tar.xz readline-c77311c90aa045796b3adcd021e69901022f4649.zip |
Adding upstream version 8.2.upstream/8.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | examples/rlbasic.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/rlbasic.c b/examples/rlbasic.c new file mode 100644 index 0000000..1ce4da9 --- /dev/null +++ b/examples/rlbasic.c @@ -0,0 +1,37 @@ +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> +#include <string.h> + +#ifdef HAVE_LOCALE_H +# include <locale.h> +#endif + +#if defined (READLINE_LIBRARY) +# include "readline.h" +# include "history.h" +#else +# include <readline/readline.h> +# include <readline/history.h> +#endif + +int +main (int c, char **v) +{ + char *input; + +#ifdef HAVE_SETLOCALE + setlocale (LC_ALL, ""); +#endif + + for (;;) { + input = readline ((char *)NULL); + if (input == 0) + break; + printf ("%s\n", input); + if (strcmp (input, "exit") == 0) + break; + free (input); + } + exit (0); +} |