Imported from ../bash-2.04.tar.gz.
This commit is contained in:
		
					parent
					
						
							
								b72432fdcc
							
						
					
				
			
			
				commit
				
					
						bb70624e96
					
				
			
		
					 387 changed files with 28522 additions and 9334 deletions
				
			
		|  | @ -2,15 +2,9 @@ | |||
|  * rl - command-line interface to read a line from the standard input | ||||
|  *      (or another fd) using readline. | ||||
|  * | ||||
|  * usage: rl [-p prompt] [-u unit] [-d default] | ||||
|  * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars] | ||||
|  */ | ||||
| 
 | ||||
| /*
 | ||||
|  * Remove the next line if you're compiling this against an installed | ||||
|  * libreadline.a | ||||
|  */ | ||||
| #define READLINE_LIBRARY | ||||
| 
 | ||||
| #if defined (HAVE_CONFIG_H) | ||||
| #  include <config.h> | ||||
| #endif | ||||
|  | @ -18,8 +12,14 @@ | |||
| #include <stdio.h> | ||||
| #include <sys/types.h> | ||||
| #include "posixstat.h" | ||||
| #include "readline.h" | ||||
| #include "history.h" | ||||
| 
 | ||||
| #if defined (READLINE_LIBRARY) | ||||
| #  include "readline.h" | ||||
| #  include "history.h" | ||||
| #else | ||||
| #  include <readline/readline.h> | ||||
| #  include <readline/history.h> | ||||
| #endif | ||||
| 
 | ||||
| extern int optind; | ||||
| extern char *optarg; | ||||
|  | @ -40,22 +40,24 @@ set_deftext () | |||
|       deftext = (char *)NULL; | ||||
|       rl_startup_hook = (Function *)NULL; | ||||
|     } | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| static void | ||||
| usage() | ||||
| { | ||||
|   fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default]\n", | ||||
|   fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n", | ||||
| 		progname, progname); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| main (argc, argv) | ||||
|      int argc; | ||||
|      char **argv; | ||||
| { | ||||
|   char *temp, *prompt; | ||||
|   struct stat sb; | ||||
|   int opt, fd; | ||||
|   int opt, fd, nch; | ||||
|   FILE *ifp; | ||||
| 
 | ||||
|   progname = strrchr(argv[0], '/'); | ||||
|  | @ -66,10 +68,10 @@ main (argc, argv) | |||
| 
 | ||||
|   /* defaults */ | ||||
|   prompt = "readline$ "; | ||||
|   fd = 0; | ||||
|   fd = nch = 0; | ||||
|   deftext = (char *)0; | ||||
| 
 | ||||
|   while ((opt = getopt(argc, argv, "p:u:d:")) != EOF) | ||||
|   while ((opt = getopt(argc, argv, "p:u:d:n:")) != EOF) | ||||
|     { | ||||
|       switch (opt) | ||||
| 	{ | ||||
|  | @ -87,6 +89,14 @@ main (argc, argv) | |||
| 	case 'd': | ||||
| 	  deftext = optarg; | ||||
| 	  break; | ||||
| 	case 'n': | ||||
| 	  nch = atoi(optarg); | ||||
| 	  if (nch < 0) | ||||
| 	    { | ||||
| 	      fprintf (stderr, "%s: bad value for -n: `%s'\n", progname, optarg); | ||||
| 	      exit (2); | ||||
| 	    } | ||||
| 	  break; | ||||
| 	default: | ||||
| 	  usage (); | ||||
| 	  exit (2); | ||||
|  | @ -107,6 +117,9 @@ main (argc, argv) | |||
|   if (deftext && *deftext) | ||||
|     rl_startup_hook = set_deftext; | ||||
| 
 | ||||
|   if (nch > 0) | ||||
|     rl_num_chars_to_read = nch; | ||||
| 
 | ||||
|   temp = readline (prompt); | ||||
| 
 | ||||
|   /* Test for EOF. */ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jari Aalto
				Jari Aalto