new GLOBSORT variable

This commit is contained in:
Chet Ramey
2023-04-16 16:13:14 -04:00
parent 15b199c0dd
commit d06fefb2ba
36 changed files with 1811 additions and 943 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ cc_t old_vtime;
struct termios term;
int
main()
main(int c, char **v)
{
fd_set fds;
+62 -69
View File
@@ -1,6 +1,6 @@
/* fileman.c - file manager example for readline library. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2009,2023 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
@@ -61,24 +61,24 @@
# include <readline/history.h>
#endif
extern char *xmalloc PARAMS((size_t));
extern char *xmalloc (size_t);
void initialize_readline PARAMS((void));
void too_dangerous PARAMS((char *));
void initialize_readline (void);
void too_dangerous (char *);
int execute_line PARAMS((char *));
int valid_argument PARAMS((char *, char *));
int execute_line (char *);
int valid_argument (char *, char *);
/* The names of functions that actually do the manipulation. */
int com_list PARAMS((char *));
int com_view PARAMS((char *));
int com_rename PARAMS((char *));
int com_stat PARAMS((char *));
int com_pwd PARAMS((char *));
int com_delete PARAMS((char *));
int com_help PARAMS((char *));
int com_cd PARAMS((char *));
int com_quit PARAMS((char *));
int com_list (char *);
int com_view (char *);
int com_rename (char *);
int com_stat (char *);
int com_pwd (char *);
int com_delete (char *);
int com_help (char *);
int com_cd (char *);
int com_quit (char *);
/* A structure which contains information on the commands this program
can understand. */
@@ -105,8 +105,11 @@ COMMAND commands[] = {
};
/* Forward declarations. */
char *stripwhite ();
COMMAND *find_command ();
char *dupstr (char *);
int execute_line (char *);
char *stripwhite (char *);
COMMAND *find_command (char *);
/* The name of this program, as taken from argv[0]. */
char *progname;
@@ -115,8 +118,7 @@ char *progname;
int done;
char *
dupstr (s)
char *s;
dupstr (char *s)
{
char *r;
@@ -125,45 +127,9 @@ dupstr (s)
return (r);
}
int
main (argc, argv)
int argc;
char **argv;
{
char *line, *s;
progname = argv[0];
initialize_readline (); /* Bind our completer. */
/* Loop reading and executing lines until the user quits. */
for ( ; done == 0; )
{
line = readline ("FileMan: ");
if (!line)
break;
/* Remove leading and trailing whitespace from the line.
Then, if there is anything left, add it to the history list
and execute it. */
s = stripwhite (line);
if (*s)
{
add_history (s);
execute_line (s);
}
free (line);
}
exit (0);
}
/* Execute a command line. */
int
execute_line (line)
char *line;
execute_line (char *line)
{
register int i;
COMMAND *command;
@@ -202,8 +168,7 @@ execute_line (line)
/* Look up NAME as the name of a command, and return a pointer to that
command. Return a NULL pointer if NAME isn't a command name. */
COMMAND *
find_command (name)
char *name;
find_command (char *name)
{
register int i;
@@ -217,8 +182,7 @@ find_command (name)
/* Strip whitespace from the start and end of STRING. Return a pointer
into STRING. */
char *
stripwhite (string)
char *string;
stripwhite (char *string)
{
register char *s, *t;
@@ -242,14 +206,14 @@ stripwhite (string)
/* */
/* **************************************************************** */
char *command_generator PARAMS((const char *, int));
char **fileman_completion PARAMS((const char *, int, int));
char *command_generator (const char *, int);
char **fileman_completion (const char *, int, int);
/* Tell the GNU Readline library how to complete. We want to try to complete
on command names if this is the first word in the line, or on filenames
if not. */
void
initialize_readline ()
initialize_readline (void)
{
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "FileMan";
@@ -264,9 +228,7 @@ initialize_readline ()
in case we want to do some simple parsing. Return the array of matches,
or NULL if there aren't any. */
char **
fileman_completion (text, start, end)
const char *text;
int start, end;
fileman_completion (const char *text, int start, int end)
{
char **matches;
@@ -285,9 +247,7 @@ fileman_completion (text, start, end)
to start from scratch; without any state (i.e. STATE == 0), then we
start at the top of the list. */
char *
command_generator (text, state)
const char *text;
int state;
command_generator (const char *text, int state)
{
static int list_index, len;
char *name;
@@ -504,3 +464,36 @@ valid_argument (caller, arg)
return (1);
}
int
main (int argc, char **argv)
{
char *line, *s;
progname = argv[0];
initialize_readline (); /* Bind our completer. */
/* Loop reading and executing lines until the user quits. */
for ( ; done == 0; )
{
line = readline ("FileMan: ");
if (!line)
break;
/* Remove leading and trailing whitespace from the line.
Then, if there is anything left, add it to the history list
and execute it. */
s = stripwhite (line);
if (*s)
{
add_history (s);
execute_line (s);
}
free (line);
}
exit (0);
}
+35 -7
View File
@@ -1,6 +1,6 @@
/* manexamp.c -- The examples which appear in the documentation are here. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2009,2023 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
@@ -18,9 +18,35 @@
You should have received a copy of the GNU General Public License
along with Readline. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <readline/readline.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <locale.h>
#ifndef errno
extern int errno;
#endif
#if defined (READLINE_LIBRARY)
# include "readline.h"
# include "history.h"
#else
# include <readline/readline.h>
# include <readline/history.h>
#endif
/* **************************************************************** */
/* */
@@ -33,7 +59,7 @@ static char *line_read = (char *)NULL;
/* Read a string, and return a pointer to it. Returns NULL on EOF. */
char *
rl_gets ()
rl_gets (void)
{
/* If the buffer has already been allocated, return the memory
to the free pool. */
@@ -60,10 +86,11 @@ rl_gets ()
/* **************************************************************** */
/* Invert the case of the COUNT following characters. */
invert_case_line (count, key)
int count, key;
int
invert_case_line (int count, int key)
{
register int start, end;
int start, end;
int direction;
start = rl_point;
@@ -92,7 +119,7 @@ invert_case_line (count, key)
}
if (start == end)
return;
return 0;
/* Tell readline that we are modifying the line, so save the undo
information. */
@@ -108,4 +135,5 @@ invert_case_line (count, key)
/* Move point to on top of the last character changed. */
rl_point = end - direction;
return 0;
}
+3 -5
View File
@@ -46,7 +46,7 @@ cb_linehandler (char *line)
}
static char *
cb_readline ()
cb_readline (void)
{
fd_set fds;
int r, err;
@@ -102,15 +102,13 @@ else if (RL_ISSTATE (RL_STATE_NSEARCH))
}
void
sigint_sighandler (s)
int s;
sigint_sighandler (int s)
{
saw_signal = s;
}
int
sigint_handler (s)
int s;
sigint_handler (int s)
{
rl_free_line_state ();
rl_callback_sigcleanup ();
+3 -5
View File
@@ -59,7 +59,7 @@ static char *progname;
static char *deftext;
static int
set_deftext ()
set_deftext (void)
{
if (deftext)
{
@@ -71,16 +71,14 @@ set_deftext ()
}
static void
usage()
usage(void)
{
fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n",
progname, progname);
}
int
main (argc, argv)
int argc;
char **argv;
main (int argc, char **argv)
{
char *temp, *prompt;
struct stat sb;
+8 -12
View File
@@ -4,7 +4,7 @@
* usage: rlcat
*/
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2009,2023 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
@@ -64,27 +64,26 @@ extern int errno;
extern int optind;
extern char *optarg;
static int stdcat();
static int fcopy(FILE *);
static int stdcat(int, char **);
static char *progname;
static int vflag;
static void
usage()
usage(void)
{
fprintf (stderr, "%s: usage: %s [-vEVN] [filename]\n", progname, progname);
}
int
main (argc, argv)
int argc;
char **argv;
main (int argc, char **argv)
{
char *temp;
int opt, Vflag, Nflag;
#ifdef HAVE_SETLOCALE
setlocale (LC_ALL, ""):
setlocale (LC_ALL, "");
#endif
progname = strrchr(argv[0], '/');
@@ -134,8 +133,7 @@ main (argc, argv)
}
static int
fcopy(fp)
FILE *fp;
fcopy(FILE *fp)
{
int c;
char *x;
@@ -155,9 +153,7 @@ fcopy(fp)
}
int
stdcat (argc, argv)
int argc;
char **argv;
stdcat (int argc, char **argv)
{
int i, fd, r;
char *s;
+9 -10
View File
@@ -42,8 +42,7 @@ static int masterfd = -1;
static int slavefd;
void
sigint (s)
int s;
sigint (int s)
{
tty_reset (STDIN_FILENO);
close (masterfd);
@@ -53,14 +52,13 @@ sigint (s)
}
void
sigwinch (s)
int s;
sigwinch (int s)
{
rl_resize_terminal ();
}
static int
user_input()
user_input(void)
{
int size;
const int MAX = 1024;
@@ -78,7 +76,7 @@ user_input()
}
static int
readline_input()
readline_input(void)
{
const int MAX = 1024;
char *buf = (char *)malloc(MAX+1);
@@ -124,7 +122,7 @@ rlctx_send_user_command(char *line)
}
static void
custom_deprep_term_function ()
custom_deprep_term_function (void)
{
}
@@ -226,9 +224,10 @@ static enum { RESET, TCBREAK } ttystate = RESET;
*
* Returns: 0 on success, -1 on error
*/
int tty_cbreak(int fd){
int tty_cbreak(int fd)
{
struct termios buf;
int ttysavefd = -1;
int ttysavefd = -1;
if(tcgetattr(fd, &save_termios) < 0)
return -1;
@@ -316,7 +315,7 @@ int tty_reset(int fd)
}
int
main()
main(int c, char **v)
{
int val;
+2 -4
View File
@@ -4,7 +4,7 @@
/* */
/* **************************************************************** */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2009,2023 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library for
reading lines of text with interactive input and history editing.
@@ -48,10 +48,8 @@ extern void exit();
# include <readline/history.h>
#endif
extern HIST_ENTRY **history_list ();
int
main ()
main (int c, char **v)
{
char *temp, *prompt;
int done;