xref: /netbsd-src/lib/libedit/TEST/rl1.c (revision e7df8a22279419eece65f98d76baf45f6828efff)
1*e7df8a22Schristos /*	$NetBSD: rl1.c,v 1.2 2016/02/29 00:54:19 christos Exp $	*/
2b3543150Schristos 
3b3543150Schristos /*-
4b3543150Schristos  * Copyright (c) 2010 The NetBSD Foundation, Inc.
5b3543150Schristos  * All rights reserved.
6b3543150Schristos  *
7b3543150Schristos  * This code is derived from software contributed to The NetBSD Foundation
8b3543150Schristos  * by Christos Zoulas.
9b3543150Schristos  *
10b3543150Schristos  * Redistribution and use in source and binary forms, with or without
11b3543150Schristos  * modification, are permitted provided that the following conditions
12b3543150Schristos  * are met:
13b3543150Schristos  * 1. Redistributions of source code must retain the above copyright
14b3543150Schristos  *    notice, this list of conditions and the following disclaimer.
15b3543150Schristos  * 2. Redistributions in binary form must reproduce the above copyright
16b3543150Schristos  *    notice, this list of conditions and the following disclaimer in the
17b3543150Schristos  *    documentation and/or other materials provided with the distribution.
18b3543150Schristos  *
19b3543150Schristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20b3543150Schristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21b3543150Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22b3543150Schristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23b3543150Schristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24b3543150Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25b3543150Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26b3543150Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27b3543150Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28b3543150Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29b3543150Schristos  * POSSIBILITY OF SUCH DAMAGE.
30b3543150Schristos  */
31b3543150Schristos 
32b3543150Schristos #include <sys/cdefs.h>
33b3543150Schristos #if !defined(lint)
34*e7df8a22Schristos __RCSID("$NetBSD: rl1.c,v 1.2 2016/02/29 00:54:19 christos Exp $");
35b3543150Schristos #endif /* not lint  */
36b3543150Schristos 
37b3543150Schristos /*
38b3543150Schristos  * test.c: A little test program
39b3543150Schristos  */
40b3543150Schristos #include <stdio.h>
41b3543150Schristos #include <readline/readline.h>
42b3543150Schristos 
43b3543150Schristos int
main(int argc,char * argv[])44b3543150Schristos main(int argc, char *argv[])
45b3543150Schristos {
46b3543150Schristos 	char *p;
47b3543150Schristos 	while ((p = readline("hi$")) != NULL) {
48b3543150Schristos 		add_history(p);
49b3543150Schristos 		printf("%d %s\n", history_length, p);
50b3543150Schristos 	}
51b3543150Schristos 	return 0;
52b3543150Schristos }
53