dummy commit, get CVS off the branch.

This commit is contained in:
Andrew Cagney 2002-08-24 00:11:12 +00:00
parent 2ba146cd6f
commit 56f65f858d
13 changed files with 0 additions and 6625 deletions

View File

@ -1,113 +0,0 @@
/* compat.c -- backwards compatibility functions. */
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <stdio.h>
#include "rlstdc.h"
#include "rltypedefs.h"
extern void rl_free_undo_list PARAMS((void));
extern int rl_maybe_save_line PARAMS((void));
extern int rl_maybe_unsave_line PARAMS((void));
extern int rl_maybe_replace_line PARAMS((void));
extern int rl_crlf PARAMS((void));
extern int rl_ding PARAMS((void));
extern int rl_alphabetic PARAMS((int));
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
extern char *rl_username_completion_function PARAMS((const char *, int));
extern char *rl_filename_completion_function PARAMS((const char *, int));
/* Provide backwards-compatible entry points for old function names. */
void
free_undo_list ()
{
rl_free_undo_list ();
}
int
maybe_replace_line ()
{
return rl_maybe_replace_line ();
}
int
maybe_save_line ()
{
return rl_maybe_save_line ();
}
int
maybe_unsave_line ()
{
return rl_maybe_unsave_line ();
}
int
ding ()
{
return rl_ding ();
}
int
crlf ()
{
return rl_crlf ();
}
int
alphabetic (c)
int c;
{
return rl_alphabetic (c);
}
char **
completion_matches (s, f)
const char *s;
rl_compentry_func_t *f;
{
return rl_completion_matches (s, f);
}
char *
username_completion_function (s, i)
const char *s;
int i;
{
return rl_username_completion_function (s, i);
}
char *
filename_completion_function (s, i)
const char *s;
int i;
{
return rl_filename_completion_function (s, i);
}

View File

@ -1,660 +0,0 @@
HISTORY(3) HISTORY(3)
NNAAMMEE
history - GNU History Library
CCOOPPYYRRIIGGHHTT
The GNU History Library is Copyright (C) 1989-2002 by the
Free Software Foundation, Inc.
DDEESSCCRRIIPPTTIIOONN
Many programs read input from the user a line at a time.
The GNU History library is able to keep track of those
lines, associate arbitrary data with each line, and uti-
lize information from previous lines in composing new
ones.
HHIISSTTOORRYY EEXXPPAANNSSIIOONN
The history library supports a history expansion feature
that is identical to the history expansion in bbaasshh.. This
section describes what syntax features are available.
History expansions introduce words from the history list
into the input stream, making it easy to repeat commands,
insert the arguments to a previous command into the cur-
rent input line, or fix errors in previous commands
quickly.
History expansion is usually performed immediately after a
complete line is read. It takes place in two parts. The
first is to determine which line from the history list to
use during substitution. The second is to select portions
of that line for inclusion into the current one. The line
selected from the history is the _e_v_e_n_t, and the portions
of that line that are acted upon are _w_o_r_d_s. Various _m_o_d_i_-
_f_i_e_r_s are available to manipulate the selected words. The
line is broken into words in the same fashion as bbaasshh does
when reading input, so that several words that would oth-
erwise be separated are considered one word when sur-
rounded by quotes (see the description of hhiissttoorryy__ttookk--
eenniizzee(()) below). History expansions are introduced by the
appearance of the history expansion character, which is !!
by default. Only backslash (\\) and single quotes can
quote the history expansion character.
EEvveenntt DDeessiiggnnaattoorrss
An event designator is a reference to a command line entry
in the history list.
!! Start a history substitution, except when followed
by a bbllaannkk, newline, = or (.
!!_n Refer to command line _n.
!!--_n Refer to the current command line minus _n.
!!!! Refer to the previous command. This is a synonym
for `!-1'.
GNU History 4.3 2002 January 31 1
HISTORY(3) HISTORY(3)
!!_s_t_r_i_n_g
Refer to the most recent command starting with
_s_t_r_i_n_g.
!!??_s_t_r_i_n_g[[??]]
Refer to the most recent command containing _s_t_r_i_n_g.
The trailing ?? may be omitted if _s_t_r_i_n_g is followed
immediately by a newline.
^^_s_t_r_i_n_g_1^^_s_t_r_i_n_g_2^^
Quick substitution. Repeat the last command,
replacing _s_t_r_i_n_g_1 with _s_t_r_i_n_g_2. Equivalent to
``!!:s/_s_t_r_i_n_g_1/_s_t_r_i_n_g_2/'' (see MMooddiiffiieerrss below).
!!## The entire command line typed so far.
WWoorrdd DDeessiiggnnaattoorrss
Word designators are used to select desired words from the
event. A :: separates the event specification from the
word designator. It may be omitted if the word designator
begins with a ^^, $$, **, --, or %%. Words are numbered from
the beginning of the line, with the first word being
denoted by 0 (zero). Words are inserted into the current
line separated by single spaces.
00 ((zzeerroo))
The zeroth word. For the shell, this is the com-
mand word.
_n The _nth word.
^^ The first argument. That is, word 1.
$$ The last argument.
%% The word matched by the most recent `?_s_t_r_i_n_g?'
search.
_x--_y A range of words; `-_y' abbreviates `0-_y'.
** All of the words but the zeroth. This is a synonym
for `_1_-_$'. It is not an error to use ** if there is
just one word in the event; the empty string is
returned in that case.
xx** Abbreviates _x_-_$.
xx-- Abbreviates _x_-_$ like xx**, but omits the last word.
If a word designator is supplied without an event specifi-
cation, the previous command is used as the event.
MMooddiiffiieerrss
After the optional word designator, there may appear a
sequence of one or more of the following modifiers, each
preceded by a `:'.
hh Remove a trailing file name component, leaving only
the head.
tt Remove all leading file name components, leaving
the tail.
rr Remove a trailing suffix of the form _._x_x_x, leaving
the basename.
ee Remove all but the trailing suffix.
pp Print the new command but do not execute it.
GNU History 4.3 2002 January 31 2
HISTORY(3) HISTORY(3)
qq Quote the substituted words, escaping further sub-
stitutions.
xx Quote the substituted words as with qq, but break
into words at bbllaannkkss and newlines.
ss//_o_l_d//_n_e_w//
Substitute _n_e_w for the first occurrence of _o_l_d in
the event line. Any delimiter can be used in place
of /. The final delimiter is optional if it is the
last character of the event line. The delimiter
may be quoted in _o_l_d and _n_e_w with a single back-
slash. If & appears in _n_e_w, it is replaced by _o_l_d.
A single backslash will quote the &. If _o_l_d is
null, it is set to the last _o_l_d substituted, or, if
no previous history substitutions took place, the
last _s_t_r_i_n_g in a !!??_s_t_r_i_n_g[[??]] search.
&& Repeat the previous substitution.
gg Cause changes to be applied over the entire event
line. This is used in conjunction with `::ss' (e.g.,
`::ggss//_o_l_d//_n_e_w//') or `::&&'. If used with `::ss', any
delimiter can be used in place of /, and the final
delimiter is optional if it is the last character
of the event line.
PPRROOGGRRAAMMMMIINNGG WWIITTHH HHIISSTTOORRYY FFUUNNCCTTIIOONNSS
This section describes how to use the History library in
other programs.
IInnttrroodduuccttiioonn ttoo HHiissttoorryy
The programmer using the History library has available
functions for remembering lines on a history list, associ-
ating arbitrary data with a line, removing lines from the
list, searching through the list for a line containing an
arbitrary text string, and referencing any line in the
list directly. In addition, a history _e_x_p_a_n_s_i_o_n function
is available which provides for a consistent user inter-
face across different programs.
The user using programs written with the History library
has the benefit of a consistent user interface with a set
of well-known commands for manipulating the text of previ-
ous lines and using that text in new commands. The basic
history manipulation commands are identical to the history
substitution provided by bbaasshh.
If the programmer desires, he can use the Readline
library, which includes some history manipulation by
default, and has the added advantage of command line edit-
ing.
Before declaring any functions using any functionality the
History library provides in other code, an application
writer should include the file _<_r_e_a_d_l_i_n_e_/_h_i_s_t_o_r_y_._h_> in any
file that uses the History library's features. It sup-
plies extern declarations for all of the library's public
GNU History 4.3 2002 January 31 3
HISTORY(3) HISTORY(3)
functions and variables, and declares all of the public
data structures.
HHiissttoorryy SSttoorraaggee
The history list is an array of history entries. A his-
tory entry is declared as follows:
_t_y_p_e_d_e_f _v_o_i_d _* hhiissttddaattaa__tt;;
typedef struct _hist_entry {
char *line;
histdata_t data;
} HIST_ENTRY;
The history list itself might therefore be declared as
_H_I_S_T___E_N_T_R_Y _*_* tthhee__hhiissttoorryy__lliisstt;;
The state of the History library is encapsulated into a
single structure:
/*
* A structure used to pass around the current state of the history.
*/
typedef struct _hist_state {
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
int offset; /* The location pointer within this array. */
int length; /* Number of elements within this array. */
int size; /* Number of slots allocated to this array. */
int flags;
} HISTORY_STATE;
If the flags member includes HHSS__SSTTIIFFLLEEDD, the history has
been stifled.
HHiissttoorryy FFuunnccttiioonnss
This section describes the calling sequence for the vari-
ous functions exported by the GNU History library.
IInniittiiaalliizziinngg HHiissttoorryy aanndd SSttaattee MMaannaaggeemmeenntt
This section describes functions used to initialize and
manage the state of the History library when you want to
use the history functions in your program.
_v_o_i_d uussiinngg__hhiissttoorryy (_v_o_i_d)
Begin a session in which the history functions might be
used. This initializes the interactive variables.
_H_I_S_T_O_R_Y___S_T_A_T_E _* hhiissttoorryy__ggeett__hhiissttoorryy__ssttaattee (_v_o_i_d)
Return a structure describing the current state of the
input history.
_v_o_i_d hhiissttoorryy__sseett__hhiissttoorryy__ssttaattee (_H_I_S_T_O_R_Y___S_T_A_T_E _*_s_t_a_t_e)
GNU History 4.3 2002 January 31 4
HISTORY(3) HISTORY(3)
Set the state of the history list according to _s_t_a_t_e.
HHiissttoorryy LLiisstt MMaannaaggeemmeenntt
These functions manage individual entries on the history
list, or set parameters managing the list itself.
_v_o_i_d aadddd__hhiissttoorryy (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g)
Place _s_t_r_i_n_g at the end of the history list. The associ-
ated data field (if any) is set to NNUULLLL.
_H_I_S_T___E_N_T_R_Y _* rreemmoovvee__hhiissttoorryy (_i_n_t _w_h_i_c_h)
Remove history entry at offset _w_h_i_c_h from the history.
The removed element is returned so you can free the line,
data, and containing structure.
_H_I_S_T___E_N_T_R_Y _* rreeppllaaccee__hhiissttoorryy__eennttrryy (_i_n_t _w_h_i_c_h_, _c_o_n_s_t _c_h_a_r
_*_l_i_n_e_, _h_i_s_t_d_a_t_a___t _d_a_t_a)
Make the history entry at offset _w_h_i_c_h have _l_i_n_e and _d_a_t_a.
This returns the old entry so you can dispose of the data.
In the case of an invalid _w_h_i_c_h, a NNUULLLL pointer is
returned.
_v_o_i_d cclleeaarr__hhiissttoorryy (_v_o_i_d)
Clear the history list by deleting all the entries.
_v_o_i_d ssttiiffllee__hhiissttoorryy (_i_n_t _m_a_x)
Stifle the history list, remembering only the last _m_a_x
entries.
_i_n_t uunnssttiiffllee__hhiissttoorryy (_v_o_i_d)
Stop stifling the history. This returns the previously-
set maximum number of history entries (as set by ssttii--
ffllee__hhiissttoorryy(())). history was stifled. The value is posi-
tive if the history was stifled, negative if it wasn't.
_i_n_t hhiissttoorryy__iiss__ssttiifflleedd (_v_o_i_d)
Returns non-zero if the history is stifled, zero if it is
not.
IInnffoorrmmaattiioonn AAbboouutt tthhee HHiissttoorryy LLiisstt
These functions return information about the entire his-
tory list or individual list entries.
_H_I_S_T___E_N_T_R_Y _*_* hhiissttoorryy__lliisstt (_v_o_i_d)
Return a NNUULLLL terminated array of _H_I_S_T___E_N_T_R_Y _* which is
the current input history. Element 0 of this list is the
beginning of time. If there is no history, return NNUULLLL.
_i_n_t wwhheerree__hhiissttoorryy (_v_o_i_d)
Returns the offset of the current history element.
_H_I_S_T___E_N_T_R_Y _* ccuurrrreenntt__hhiissttoorryy (_v_o_i_d)
GNU History 4.3 2002 January 31 5
HISTORY(3) HISTORY(3)
Return the history entry at the current position, as
determined by wwhheerree__hhiissttoorryy(()). If there is no entry
there, return a NNUULLLL pointer.
_H_I_S_T___E_N_T_R_Y _* hhiissttoorryy__ggeett (_i_n_t _o_f_f_s_e_t)
Return the history entry at position _o_f_f_s_e_t, starting from
hhiissttoorryy__bbaassee. If there is no entry there, or if _o_f_f_s_e_t is
greater than the history length, return a NNUULLLL pointer.
_i_n_t hhiissttoorryy__ttoottaall__bbyytteess (_v_o_i_d)
Return the number of bytes that the primary history
entries are using. This function returns the sum of the
lengths of all the lines in the history.
MMoovviinngg AArroouunndd tthhee HHiissttoorryy LLiisstt
These functions allow the current index into the history
list to be set or changed.
_i_n_t hhiissttoorryy__sseett__ppooss (_i_n_t _p_o_s)
Set the current history offset to _p_o_s, an absolute index
into the list. Returns 1 on success, 0 if _p_o_s is less
than zero or greater than the number of history entries.
_H_I_S_T___E_N_T_R_Y _* pprreevviioouuss__hhiissttoorryy (_v_o_i_d)
Back up the current history offset to the previous history
entry, and return a pointer to that entry. If there is no
previous entry, return a NNUULLLL pointer.
_H_I_S_T___E_N_T_R_Y _* nneexxtt__hhiissttoorryy (_v_o_i_d)
Move the current history offset forward to the next his-
tory entry, and return the a pointer to that entry. If
there is no next entry, return a NNUULLLL pointer.
SSeeaarrcchhiinngg tthhee HHiissttoorryy LLiisstt
These functions allow searching of the history list for
entries containing a specific string. Searching may be
performed both forward and backward from the current his-
tory position. The search may be _a_n_c_h_o_r_e_d, meaning that
the string must match at the beginning of the history
entry.
_i_n_t hhiissttoorryy__sseeaarrcchh (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g_, _i_n_t _d_i_r_e_c_t_i_o_n)
Search the history for _s_t_r_i_n_g, starting at the current
history offset. If _d_i_r_e_c_t_i_o_n is less than 0, then the
search is through previous entries, otherwise through sub-
sequent entries. If _s_t_r_i_n_g is found, then the current
history index is set to that history entry, and the value
returned is the offset in the line of the entry where
_s_t_r_i_n_g was found. Otherwise, nothing is changed, and a -1
is returned.
_i_n_t hhiissttoorryy__sseeaarrcchh__pprreeffiixx (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g_, _i_n_t
GNU History 4.3 2002 January 31 6
HISTORY(3) HISTORY(3)
_d_i_r_e_c_t_i_o_n)
Search the history for _s_t_r_i_n_g, starting at the current
history offset. The search is anchored: matching lines
must begin with _s_t_r_i_n_g. If _d_i_r_e_c_t_i_o_n is less than 0, then
the search is through previous entries, otherwise through
subsequent entries. If _s_t_r_i_n_g is found, then the current
history index is set to that entry, and the return value
is 0. Otherwise, nothing is changed, and a -1 is
returned.
_i_n_t hhiissttoorryy__sseeaarrcchh__ppooss (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g_, _i_n_t _d_i_r_e_c_t_i_o_n_,
_i_n_t _p_o_s)
Search for _s_t_r_i_n_g in the history list, starting at _p_o_s, an
absolute index into the list. If _d_i_r_e_c_t_i_o_n is negative,
the search proceeds backward from _p_o_s, otherwise forward.
Returns the absolute index of the history element where
_s_t_r_i_n_g was found, or -1 otherwise.
MMaannaaggiinngg tthhee HHiissttoorryy FFiillee
The History library can read the history from and write it
to a file. This section documents the functions for man-
aging a history file.
_i_n_t rreeaadd__hhiissttoorryy (_c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e)
Add the contents of _f_i_l_e_n_a_m_e to the history list, a line
at a time. If _f_i_l_e_n_a_m_e is NNUULLLL, then read from _~_/_._h_i_s_-
_t_o_r_y. Returns 0 if successful, or eerrrrnnoo if not.
_i_n_t rreeaadd__hhiissttoorryy__rraannggee (_c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e_, _i_n_t _f_r_o_m_,
_i_n_t _t_o)
Read a range of lines from _f_i_l_e_n_a_m_e, adding them to the
history list. Start reading at line _f_r_o_m and end at _t_o.
If _f_r_o_m is zero, start at the beginning. If _t_o is less
than _f_r_o_m, then read until the end of the file. If _f_i_l_e_-
_n_a_m_e is NNUULLLL, then read from _~_/_._h_i_s_t_o_r_y. Returns 0 if
successful, or eerrrrnnoo if not.
_i_n_t wwrriittee__hhiissttoorryy (_c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e)
Write the current history to _f_i_l_e_n_a_m_e, overwriting _f_i_l_e_-
_n_a_m_e if necessary. If _f_i_l_e_n_a_m_e is NNUULLLL, then write the
history list to _~_/_._h_i_s_t_o_r_y. Returns 0 on success, or
eerrrrnnoo on a read or write error.
_i_n_t aappppeenndd__hhiissttoorryy (_i_n_t _n_e_l_e_m_e_n_t_s_, _c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e)
Append the last _n_e_l_e_m_e_n_t_s of the history list to _f_i_l_e_n_a_m_e.
If _f_i_l_e_n_a_m_e is NNUULLLL, then append to _~_/_._h_i_s_t_o_r_y. Returns 0
on success, or eerrrrnnoo on a read or write error.
_i_n_t hhiissttoorryy__ttrruunnccaattee__ffiillee (_c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e_, _i_n_t
_n_l_i_n_e_s)
Truncate the history file _f_i_l_e_n_a_m_e, leaving only the last
_n_l_i_n_e_s lines. If _f_i_l_e_n_a_m_e is NNUULLLL, then _~_/_._h_i_s_t_o_r_y is
GNU History 4.3 2002 January 31 7
HISTORY(3) HISTORY(3)
truncated. Returns 0 on success, or eerrrrnnoo on failure.
HHiissttoorryy EExxppaannssiioonn
These functions implement history expansion.
_i_n_t hhiissttoorryy__eexxppaanndd (_c_h_a_r _*_s_t_r_i_n_g_, _c_h_a_r _*_*_o_u_t_p_u_t)
Expand _s_t_r_i_n_g, placing the result into _o_u_t_p_u_t, a pointer
to a string. Returns:
0 If no expansions took place (or, if the only
change in the text was the removal of escape
characters preceding the history expansion
character);
1 if expansions did take place;
-1 if there was an error in expansion;
2 if the returned line should be displayed,
but not executed, as with the ::pp modifier.
If an error ocurred in expansion, then _o_u_t_p_u_t contains a
descriptive error message.
_c_h_a_r _* ggeett__hhiissttoorryy__eevveenntt (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g_, _i_n_t _*_c_i_n_d_e_x_,
_i_n_t _q_c_h_a_r)
Returns the text of the history event beginning at _s_t_r_i_n_g
+ _*_c_i_n_d_e_x. _*_c_i_n_d_e_x is modified to point to after the
event specifier. At function entry, _c_i_n_d_e_x points to the
index into _s_t_r_i_n_g where the history event specification
begins. _q_c_h_a_r is a character that is allowed to end the
event specification in addition to the ``normal'' termi-
nating characters.
_c_h_a_r _*_* hhiissttoorryy__ttookkeenniizzee (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g)
Return an array of tokens parsed out of _s_t_r_i_n_g, much as
the shell might. The tokens are split on the characters
in the hhiissttoorryy__wwoorrdd__ddeelliimmiitteerrss variable, and shell quoting
conventions are obeyed.
_c_h_a_r _* hhiissttoorryy__aarrgg__eexxttrraacctt (_i_n_t _f_i_r_s_t_, _i_n_t _l_a_s_t_, _c_o_n_s_t
_c_h_a_r _*_s_t_r_i_n_g)
Extract a string segment consisting of the _f_i_r_s_t through
_l_a_s_t arguments present in _s_t_r_i_n_g. Arguments are split
using hhiissttoorryy__ttookkeenniizzee(()).
HHiissttoorryy VVaarriiaabblleess
This section describes the externally-visible variables
exported by the GNU History Library.
_i_n_t hhiissttoorryy__bbaassee
The logical offset of the first entry in the history list.
_i_n_t hhiissttoorryy__lleennggtthh
The number of entries currently stored in the history
list.
GNU History 4.3 2002 January 31 8
HISTORY(3) HISTORY(3)
_i_n_t hhiissttoorryy__mmaaxx__eennttrriieess
The maximum number of history entries. This must be
changed using ssttiiffllee__hhiissttoorryy(()).
_c_h_a_r hhiissttoorryy__eexxppaannssiioonn__cchhaarr
The character that introduces a history event. The
default is !!. Setting this to 0 inhibits history expan-
sion.
_c_h_a_r hhiissttoorryy__ssuubbsstt__cchhaarr
The character that invokes word substitution if found at
the start of a line. The default is ^^.
_c_h_a_r hhiissttoorryy__ccoommmmeenntt__cchhaarr
During tokenization, if this character is seen as the
first character of a word, then it and all subsequent
characters up to a newline are ignored, suppressing his-
tory expansion for the remainder of the line. This is
disabled by default.
_c_h_a_r _* hhiissttoorryy__wwoorrdd__ddeelliimmiitteerrss
The characters that separate tokens for hhiissttoorryy__ttookk--
eenniizzee(()). The default value is "" \\tt\\nn(())<<>>;;&&||"".
_c_h_a_r _* hhiissttoorryy__nnoo__eexxppaanndd__cchhaarrss
The list of characters which inhibit history expansion if
found immediately following hhiissttoorryy__eexxppaannssiioonn__cchhaarr. The
default is space, tab, newline, \\rr, and ==.
_c_h_a_r _* hhiissttoorryy__sseeaarrcchh__ddeelliimmiitteerr__cchhaarrss
The list of additional characters which can delimit a his-
tory search string, in addition to space, tab, _: and _? in
the case of a substring search. The default is empty.
_i_n_t hhiissttoorryy__qquuootteess__iinnhhiibbiitt__eexxppaannssiioonn
If non-zero, single-quoted words are not scanned for the
history expansion character. The default value is 0.
_r_l___l_i_n_e_b_u_f___f_u_n_c___t _* hhiissttoorryy__iinnhhiibbiitt__eexxppaannssiioonn__ffuunnccttiioonn
This should be set to the address of a function that takes
two arguments: a cchhaarr ** (_s_t_r_i_n_g) and an iinntt index into
that string (_i). It should return a non-zero value if the
history expansion starting at _s_t_r_i_n_g_[_i_] should not be per-
formed; zero if the expansion should be done. It is
intended for use by applications like bbaasshh that use the
history expansion character for additional purposes. By
default, this variable is set to NNUULLLL.
FFIILLEESS
_~_/_._h_i_s_t_o_r_y
Default filename for reading and writing saved his-
tory
GNU History 4.3 2002 January 31 9
HISTORY(3) HISTORY(3)
SSEEEE AALLSSOO
_T_h_e _G_n_u _R_e_a_d_l_i_n_e _L_i_b_r_a_r_y, Brian Fox and Chet Ramey
_T_h_e _G_n_u _H_i_s_t_o_r_y _L_i_b_r_a_r_y, Brian Fox and Chet Ramey
_b_a_s_h(1)
_r_e_a_d_l_i_n_e(3)
AAUUTTHHOORRSS
Brian Fox, Free Software Foundation
bfox@gnu.org
Chet Ramey, Case Western Reserve University
chet@ins.CWRU.Edu
BBUUGG RREEPPOORRTTSS
If you find a bug in the hhiissttoorryy library, you should
report it. But first, you should make sure that it really
is a bug, and that it appears in the latest version of the
hhiissttoorryy library that you have.
Once you have determined that a bug actually exists, mail
a bug report to _b_u_g_-_r_e_a_d_l_i_n_e@_g_n_u_._o_r_g. If you have a fix,
you are welcome to mail that as well! Suggestions and
`philosophical' bug reports may be mailed to _b_u_g_-_r_e_a_d_-
_l_i_n_e@_g_n_u_._o_r_g or posted to the Usenet newsgroup
ggnnuu..bbaasshh..bbuugg.
Comments and bug reports concerning this manual page
should be directed to _c_h_e_t_@_i_n_s_._C_W_R_U_._E_d_u.
GNU History 4.3 2002 January 31 10

View File

@ -1,640 +0,0 @@
.\"
.\" MAN PAGE COMMENTS to
.\"
.\" Chet Ramey
.\" Information Network Services
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Thu Jan 31 16:08:07 EST 2002
.\"
.TH HISTORY 3 "2002 January 31" "GNU History 4.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
.\"
.de FN
\fI\|\\$1\|\fP
..
.ds lp \fR\|(\fP
.ds rp \fR\|)\fP
.\" FnN return-value fun-name N arguments
.de Fn1
\fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3\fP\\*(rp
.br
..
.de Fn2
.if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4\fP\\*(rp
.if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4\fP\\*(rp
.br
..
.de Fn3
.if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4,\|\\$5\fP\|\\*(rp
.if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4, \\$5\fP\\*(rp
.br
..
.de Vb
\fI\\$1\fP \fB\\$2\fP
.br
..
.SH NAME
history \- GNU History Library
.SH COPYRIGHT
.if t The GNU History Library is Copyright \(co 1989-2002 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2002 by the Free Software Foundation, Inc.
.SH DESCRIPTION
Many programs read input from the user a line at a time. The GNU
History library is able to keep track of those lines, associate arbitrary
data with each line, and utilize information from previous lines in
composing new ones.
.PP
.SH "HISTORY EXPANSION"
.PP
The history library supports a history expansion feature that
is identical to the history expansion in
.BR bash.
This section describes what syntax features are available.
.PP
History expansions introduce words from the history list into
the input stream, making it easy to repeat commands, insert the
arguments to a previous command into the current input line, or
fix errors in previous commands quickly.
.PP
History expansion is usually performed immediately after a complete line
is read.
It takes place in two parts.
The first is to determine which line from the history list
to use during substitution.
The second is to select portions of that line for inclusion into
the current one.
The line selected from the history is the \fIevent\fP,
and the portions of that line that are acted upon are \fIwords\fP.
Various \fImodifiers\fP are available to manipulate the selected words.
The line is broken into words in the same fashion as \fBbash\fP
does when reading input,
so that several words that would otherwise be separated
are considered one word when surrounded by quotes (see the
description of \fBhistory_tokenize()\fP below).
History expansions are introduced by the appearance of the
history expansion character, which is \^\fB!\fP\^ by default.
Only backslash (\^\fB\e\fP\^) and single quotes can quote
the history expansion character.
.SS Event Designators
.PP
An event designator is a reference to a command line entry in the
history list.
.PP
.PD 0
.TP
.B !
Start a history substitution, except when followed by a
.BR blank ,
newline, = or (.
.TP
.B !\fIn\fR
Refer to command line
.IR n .
.TP
.B !\-\fIn\fR
Refer to the current command line minus
.IR n .
.TP
.B !!
Refer to the previous command. This is a synonym for `!\-1'.
.TP
.B !\fIstring\fR
Refer to the most recent command starting with
.IR string .
.TP
.B !?\fIstring\fR\fB[?]\fR
Refer to the most recent command containing
.IR string .
The trailing \fB?\fP may be omitted if
.I string
is followed immediately by a newline.
.TP
.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
Quick substitution. Repeat the last command, replacing
.I string1
with
.IR string2 .
Equivalent to
``!!:s/\fIstring1\fP/\fIstring2\fP/''
(see \fBModifiers\fP below).
.TP
.B !#
The entire command line typed so far.
.PD
.SS Word Designators
.PP
Word designators are used to select desired words from the event.
A
.B :
separates the event specification from the word designator.
It may be omitted if the word designator begins with a
.BR ^ ,
.BR $ ,
.BR * ,
.BR \- ,
or
.BR % .
Words are numbered from the beginning of the line,
with the first word being denoted by 0 (zero).
Words are inserted into the current line separated by single spaces.
.PP
.PD 0
.TP
.B 0 (zero)
The zeroth word. For the shell, this is the command
word.
.TP
.I n
The \fIn\fRth word.
.TP
.B ^
The first argument. That is, word 1.
.TP
.B $
The last argument.
.TP
.B %
The word matched by the most recent `?\fIstring\fR?' search.
.TP
.I x\fB\-\fPy
A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
.TP
.B *
All of the words but the zeroth. This is a synonym
for `\fI1\-$\fP'. It is not an error to use
.B *
if there is just one
word in the event; the empty string is returned in that case.
.TP
.B x*
Abbreviates \fIx\-$\fP.
.TP
.B x\-
Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
.PD
.PP
If a word designator is supplied without an event specification, the
previous command is used as the event.
.SS Modifiers
.PP
After the optional word designator, there may appear a sequence of
one or more of the following modifiers, each preceded by a `:'.
.PP
.PD 0
.PP
.TP
.B h
Remove a trailing file name component, leaving only the head.
.TP
.B t
Remove all leading file name components, leaving the tail.
.TP
.B r
Remove a trailing suffix of the form \fI.xxx\fP, leaving the
basename.
.TP
.B e
Remove all but the trailing suffix.
.TP
.B p
Print the new command but do not execute it.
.TP
.B q
Quote the substituted words, escaping further substitutions.
.TP
.B x
Quote the substituted words as with
.BR q ,
but break into words at
.B blanks
and newlines.
.TP
.B s/\fIold\fP/\fInew\fP/
Substitute
.I new
for the first occurrence of
.I old
in the event line. Any delimiter can be used in place of /. The
final delimiter is optional if it is the last character of the
event line. The delimiter may be quoted in
.I old
and
.I new
with a single backslash. If & appears in
.IR new ,
it is replaced by
.IR old .
A single backslash will quote the &. If
.I old
is null, it is set to the last
.I old
substituted, or, if no previous history substitutions took place,
the last
.I string
in a
.B !?\fIstring\fR\fB[?]\fR
search.
.TP
.B &
Repeat the previous substitution.
.TP
.B g
Cause changes to be applied over the entire event line. This is
used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
or `\fB:&\fP'. If used with
`\fB:s\fP', any delimiter can be used
in place of /, and the final delimiter is optional
if it is the last character of the event line.
.PD
.SH "PROGRAMMING WITH HISTORY FUNCTIONS"
This section describes how to use the History library in other programs.
.SS Introduction to History
.PP
The programmer using the History library has available functions
for remembering lines on a history list, associating arbitrary data
with a line, removing lines from the list, searching through the list
for a line containing an arbitrary text string, and referencing any line
in the list directly. In addition, a history \fIexpansion\fP function
is available which provides for a consistent user interface across
different programs.
.PP
The user using programs written with the History library has the
benefit of a consistent user interface with a set of well-known
commands for manipulating the text of previous lines and using that text
in new commands. The basic history manipulation commands are
identical to
the history substitution provided by \fBbash\fP.
.PP
If the programmer desires, he can use the Readline library, which
includes some history manipulation by default, and has the added
advantage of command line editing.
.PP
Before declaring any functions using any functionality the History
library provides in other code, an application writer should include
the file
.FN <readline/history.h>
in any file that uses the
History library's features. It supplies extern declarations for all
of the library's public functions and variables, and declares all of
the public data structures.
.SS History Storage
.PP
The history list is an array of history entries. A history entry is
declared as follows:
.PP
.Vb "typedef void *" histdata_t;
.PP
.nf
typedef struct _hist_entry {
char *line;
histdata_t data;
} HIST_ENTRY;
.fi
.PP
The history list itself might therefore be declared as
.PP
.Vb "HIST_ENTRY **" the_history_list;
.PP
The state of the History library is encapsulated into a single structure:
.PP
.nf
/*
* A structure used to pass around the current state of the history.
*/
typedef struct _hist_state {
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
int offset; /* The location pointer within this array. */
int length; /* Number of elements within this array. */
int size; /* Number of slots allocated to this array. */
int flags;
} HISTORY_STATE;
.fi
.PP
If the flags member includes \fBHS_STIFLED\fP, the history has been
stifled.
.SH "History Functions"
.PP
This section describes the calling sequence for the various functions
exported by the GNU History library.
.SS Initializing History and State Management
This section describes functions used to initialize and manage
the state of the History library when you want to use the history
functions in your program.
.Fn1 void using_history void
Begin a session in which the history functions might be used. This
initializes the interactive variables.
.Fn1 "HISTORY_STATE *" history_get_history_state void
Return a structure describing the current state of the input history.
.Fn1 void history_set_history_state "HISTORY_STATE *state"
Set the state of the history list according to \fIstate\fP.
.SS History List Management
These functions manage individual entries on the history list, or set
parameters managing the list itself.
.Fn1 void add_history "const char *string"
Place \fIstring\fP at the end of the history list. The associated data
field (if any) is set to \fBNULL\fP.
.Fn1 "HIST_ENTRY *" remove_history "int which"
Remove history entry at offset \fIwhich\fP from the history. The
removed element is returned so you can free the line, data,
and containing structure.
.Fn3 "HIST_ENTRY *" replace_history_entry "int which" "const char *line" "histdata_t data"
Make the history entry at offset \fIwhich\fP have \fIline\fP and \fIdata\fP.
This returns the old entry so you can dispose of the data. In the case
of an invalid \fIwhich\fP, a \fBNULL\fP pointer is returned.
.Fn1 void clear_history "void"
Clear the history list by deleting all the entries.
.Fn1 void stifle_history "int max"
Stifle the history list, remembering only the last \fImax\fP entries.
.Fn1 int unstifle_history "void"
Stop stifling the history. This returns the previously-set
maximum number of history entries (as set by \fBstifle_history()\fP).
history was stifled. The value is positive if the history was
stifled, negative if it wasn't.
.Fn1 int history_is_stifled "void"
Returns non-zero if the history is stifled, zero if it is not.
.SS Information About the History List
These functions return information about the entire history list or
individual list entries.
.Fn1 "HIST_ENTRY **" history_list "void"
Return a \fBNULL\fP terminated array of \fIHIST_ENTRY *\fP which is the
current input history. Element 0 of this list is the beginning of time.
If there is no history, return \fBNULL\fP.
.Fn1 int where_history "void"
Returns the offset of the current history element.
.Fn1 "HIST_ENTRY *" current_history "void"
Return the history entry at the current position, as determined by
\fBwhere_history()\fP. If there is no entry there, return a \fBNULL\fP
pointer.
.Fn1 "HIST_ENTRY *" history_get "int offset"
Return the history entry at position \fIoffset\fP, starting from
\fBhistory_base\fP.
If there is no entry there, or if \fIoffset\fP
is greater than the history length, return a \fBNULL\fP pointer.
.Fn1 int history_total_bytes "void"
Return the number of bytes that the primary history entries are using.
This function returns the sum of the lengths of all the lines in the
history.
.SS Moving Around the History List
These functions allow the current index into the history list to be
set or changed.
.Fn1 int history_set_pos "int pos"
Set the current history offset to \fIpos\fP, an absolute index
into the list.
Returns 1 on success, 0 if \fIpos\fP is less than zero or greater
than the number of history entries.
.Fn1 "HIST_ENTRY *" previous_history "void"
Back up the current history offset to the previous history entry, and
return a pointer to that entry. If there is no previous entry, return
a \fBNULL\fP pointer.
.Fn1 "HIST_ENTRY *" next_history "void"
Move the current history offset forward to the next history entry, and
return the a pointer to that entry. If there is no next entry, return
a \fBNULL\fP pointer.
.SS Searching the History List
These functions allow searching of the history list for entries containing
a specific string. Searching may be performed both forward and backward
from the current history position. The search may be \fIanchored\fP,
meaning that the string must match at the beginning of the history entry.
.Fn2 int history_search "const char *string" "int direction"
Search the history for \fIstring\fP, starting at the current history offset.
If \fIdirection\fP is less than 0, then the search is through
previous entries, otherwise through subsequent entries.
If \fIstring\fP is found, then
the current history index is set to that history entry, and the value
returned is the offset in the line of the entry where
\fIstring\fP was found. Otherwise, nothing is changed, and a -1 is
returned.
.Fn2 int history_search_prefix "const char *string" "int direction"
Search the history for \fIstring\fP, starting at the current history
offset. The search is anchored: matching lines must begin with
\fIstring\fP. If \fIdirection\fP is less than 0, then the search is
through previous entries, otherwise through subsequent entries.
If \fIstring\fP is found, then the
current history index is set to that entry, and the return value is 0.
Otherwise, nothing is changed, and a -1 is returned.
.Fn3 int history_search_pos "const char *string" "int direction" "int pos"
Search for \fIstring\fP in the history list, starting at \fIpos\fP, an
absolute index into the list. If \fIdirection\fP is negative, the search
proceeds backward from \fIpos\fP, otherwise forward. Returns the absolute
index of the history element where \fIstring\fP was found, or -1 otherwise.
.SS Managing the History File
The History library can read the history from and write it to a file.
This section documents the functions for managing a history file.
.Fn1 int read_history "const char *filename"
Add the contents of \fIfilename\fP to the history list, a line at a time.
If \fIfilename\fP is \fBNULL\fP, then read from \fI~/.history\fP.
Returns 0 if successful, or \fBerrno\fP if not.
.Fn3 int read_history_range "const char *filename" "int from" "int to"
Read a range of lines from \fIfilename\fP, adding them to the history list.
Start reading at line \fIfrom\fP and end at \fIto\fP.
If \fIfrom\fP is zero, start at the beginning. If \fIto\fP is less than
\fIfrom\fP, then read until the end of the file. If \fIfilename\fP is
\fBNULL\fP, then read from \fI~/.history\fP. Returns 0 if successful,
or \fBerrno\fP if not.
.Fn1 int write_history "const char *filename"
Write the current history to \fIfilename\fP, overwriting \fIfilename\fP
if necessary.
If \fIfilename\fP is \fBNULL\fP, then write the history list to \fI~/.history\fP.
Returns 0 on success, or \fBerrno\fP on a read or write error.
.Fn2 int append_history "int nelements" "const char *filename"
Append the last \fInelements\fP of the history list to \fIfilename\fP.
If \fIfilename\fP is \fBNULL\fP, then append to \fI~/.history\fP.
Returns 0 on success, or \fBerrno\fP on a read or write error.
.Fn2 int history_truncate_file "const char *filename" "int nlines"
Truncate the history file \fIfilename\fP, leaving only the last
\fInlines\fP lines.
If \fIfilename\fP is \fBNULL\fP, then \fI~/.history\fP is truncated.
Returns 0 on success, or \fBerrno\fP on failure.
.SS History Expansion
These functions implement history expansion.
.Fn2 int history_expand "char *string" "char **output"
Expand \fIstring\fP, placing the result into \fIoutput\fP, a pointer
to a string. Returns:
.RS
.PD 0
.TP
0
If no expansions took place (or, if the only change in
the text was the removal of escape characters preceding the history expansion
character);
.TP
1
if expansions did take place;
.TP
-1
if there was an error in expansion;
.TP
2
if the returned line should be displayed, but not executed,
as with the \fB:p\fP modifier.
.PD
.RE
If an error ocurred in expansion, then \fIoutput\fP contains a descriptive
error message.
.Fn3 "char *" get_history_event "const char *string" "int *cindex" "int qchar"
Returns the text of the history event beginning at \fIstring\fP +
\fI*cindex\fP. \fI*cindex\fP is modified to point to after the event
specifier. At function entry, \fIcindex\fP points to the index into
\fIstring\fP where the history event specification begins. \fIqchar\fP
is a character that is allowed to end the event specification in addition
to the ``normal'' terminating characters.
.Fn1 "char **" history_tokenize "const char *string"
Return an array of tokens parsed out of \fIstring\fP, much as the
shell might.
The tokens are split on the characters in the
\fBhistory_word_delimiters\fP variable,
and shell quoting conventions are obeyed.
.Fn3 "char *" history_arg_extract "int first" "int last" "const char *string"
Extract a string segment consisting of the \fIfirst\fP through \fIlast\fP
arguments present in \fIstring\fP. Arguments are split using
\fBhistory_tokenize()\fP.
.SS History Variables
This section describes the externally-visible variables exported by
the GNU History Library.
.Vb int history_base
The logical offset of the first entry in the history list.
.Vb int history_length
The number of entries currently stored in the history list.
.Vb int history_max_entries
The maximum number of history entries. This must be changed using
\fBstifle_history()\fP.
.Vb char history_expansion_char
The character that introduces a history event. The default is \fB!\fP.
Setting this to 0 inhibits history expansion.
.Vb char history_subst_char
The character that invokes word substitution if found at the start of
a line. The default is \fB^\fP.
.Vb char history_comment_char
During tokenization, if this character is seen as the first character
of a word, then it and all subsequent characters up to a newline are
ignored, suppressing history expansion for the remainder of the line.
This is disabled by default.
.Vb "char *" history_word_delimiters
The characters that separate tokens for \fBhistory_tokenize()\fP.
The default value is \fB"\ \et\en()<>;&|"\fP.
.Vb "char *" history_no_expand_chars
The list of characters which inhibit history expansion if found immediately
following \fBhistory_expansion_char\fP. The default is space, tab, newline,
\fB\er\fP, and \fB=\fP.
.Vb "char *" history_search_delimiter_chars
The list of additional characters which can delimit a history search
string, in addition to space, tab, \fI:\fP and \fI?\fP in the case of
a substring search. The default is empty.
.Vb int history_quotes_inhibit_expansion
If non-zero, single-quoted words are not scanned for the history expansion
character. The default value is 0.
.Vb "rl_linebuf_func_t *" history_inhibit_expansion_function
This should be set to the address of a function that takes two arguments:
a \fBchar *\fP (\fIstring\fP)
and an \fBint\fP index into that string (\fIi\fP).
It should return a non-zero value if the history expansion starting at
\fIstring[i]\fP should not be performed; zero if the expansion should
be done.
It is intended for use by applications like \fBbash\fP that use the history
expansion character for additional purposes.
By default, this variable is set to \fBNULL\fP.
.SH FILES
.PD 0
.TP
.FN ~/.history
Default filename for reading and writing saved history
.PD
.SH "SEE ALSO"
.PD 0
.TP
\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
.TP
\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
.TP
\fIbash\fP(1)
.TP
\fIreadline\fP(3)
.PD
.SH AUTHORS
Brian Fox, Free Software Foundation
.br
bfox@gnu.org
.PP
Chet Ramey, Case Western Reserve University
.br
chet@ins.CWRU.Edu
.SH BUG REPORTS
If you find a bug in the
.B history
library, you should report it. But first, you should
make sure that it really is a bug, and that it appears in the latest
version of the
.B history
library that you have.
.PP
Once you have determined that a bug actually exists, mail a
bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
If you have a fix, you are welcome to mail that
as well! Suggestions and `philosophical' bug reports may be mailed
to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet
newsgroup
.BR gnu.bash.bug .
.PP
Comments and bug reports concerning
this manual page should be directed to
.IR chet@ins.CWRU.Edu .

View File

@ -1,800 +0,0 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.16.1
%%CreationDate: Mon Mar 18 10:17:27 2002
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Times-Italic
%%DocumentSuppliedResources: procset grops 1.16 1
%%Pages: 7
%%PageOrder: Ascend
%%Orientation: Portrait
%%EndComments
%%BeginProlog
%%BeginResource: procset grops 1.16 1
/setpacking where{
pop
currentpacking
true setpacking
}if
/grops 120 dict dup begin
/SC 32 def
/A/show load def
/B{0 SC 3 -1 roll widthshow}bind def
/C{0 exch ashow}bind def
/D{0 exch 0 SC 5 2 roll awidthshow}bind def
/E{0 rmoveto show}bind def
/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
/G{0 rmoveto 0 exch ashow}bind def
/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/I{0 exch rmoveto show}bind def
/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
/K{0 exch rmoveto 0 exch ashow}bind def
/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/M{rmoveto show}bind def
/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
/O{rmoveto 0 exch ashow}bind def
/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/Q{moveto show}bind def
/R{moveto 0 SC 3 -1 roll widthshow}bind def
/S{moveto 0 exch ashow}bind def
/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/SF{
findfont exch
[exch dup 0 exch 0 exch neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/MF{
findfont
[5 2 roll
0 3 1 roll
neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/level0 0 def
/RES 0 def
/PL 0 def
/LS 0 def
/MANUAL{
statusdict begin/manualfeed true store end
}bind def
/PLG{
gsave newpath clippath pathbbox grestore
exch pop add exch pop
}bind def
/BP{
/level0 save def
1 setlinecap
1 setlinejoin
72 RES div dup scale
LS{
90 rotate
}{
0 PL translate
}ifelse
1 -1 scale
}bind def
/EP{
level0 restore
showpage
}bind def
/DA{
newpath arcn stroke
}bind def
/SN{
transform
.25 sub exch .25 sub exch
round .25 add exch round .25 add exch
itransform
}bind def
/DL{
SN
moveto
SN
lineto stroke
}bind def
/DC{
newpath 0 360 arc closepath
}bind def
/TM matrix def
/DE{
TM currentmatrix pop
translate scale newpath 0 0 .5 0 360 arc closepath
TM setmatrix
}bind def
/RC/rcurveto load def
/RL/rlineto load def
/ST/stroke load def
/MT/moveto load def
/CL/closepath load def
/FL{
currentgray exch setgray fill setgray
}bind def
/BL/fill load def
/LW/setlinewidth load def
/RE{
findfont
dup maxlength 1 index/FontName known not{1 add}if dict begin
{
1 index/FID ne{def}{pop pop}ifelse
}forall
/Encoding exch def
dup/FontName exch def
currentdict end definefont pop
}bind def
/DEFS 0 def
/EBEGIN{
moveto
DEFS begin
}bind def
/EEND/end load def
/CNT 0 def
/level1 0 def
/PBEGIN{
/level1 save def
translate
div 3 1 roll div exch scale
neg exch neg exch translate
0 setgray
0 setlinecap
1 setlinewidth
0 setlinejoin
10 setmiterlimit
[]0 setdash
/setstrokeadjust where{
pop
false setstrokeadjust
}if
/setoverprint where{
pop
false setoverprint
}if
newpath
/CNT countdictstack def
userdict begin
/showpage{}def
}bind def
/PEND{
clear
countdictstack CNT sub{end}repeat
level1 restore
}bind def
end def
/setpacking where{
pop
setpacking
}if
%%EndResource
%%IncludeResource: font Times-Roman
%%IncludeResource: font Times-Bold
%%IncludeResource: font Times-Italic
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
/Times-Roman@0 ENC0/Times-Roman RE
%%EndProlog
%%Page: 1 1
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
(OR)-.18 E(Y\(3\))-.65 E/F1 10.95/Times-Bold@0 SF -.219(NA)72 84 S(ME)
.219 E F0(history \255 GNU History Library)108 96 Q F1(COPYRIGHT)72
112.8 Q F0(The GNU History Library is Cop)108 124.8 Q
(yright \251 1989-2002 by the Free Softw)-.1 E(are F)-.1 E
(oundation, Inc.)-.15 E F1(DESCRIPTION)72 141.6 Q F0(Man)108 153.6 Q
2.81(yp)-.15 G .31(rograms read input from the user a line at a time.)
-2.81 F .309(The GNU History library is able to k)5.309 F .309
(eep track of)-.1 F .024(those lines, associate arbitrary data with eac\
h line, and utilize information from pre)108 165.6 R .024
(vious lines in composing)-.25 F(ne)108 177.6 Q 2.5(wo)-.25 G(nes.)-2.5
E F1(HIST)72 199.2 Q(OR)-.197 E 2.738(YE)-.383 G(XP)-2.738 E(ANSION)-.81
E F0 .823(The history library supports a history e)108 211.2 R .822
(xpansion feature that is identical to the history e)-.15 F .822
(xpansion in)-.15 F/F2 10/Times-Bold@0 SF(bash.)3.322 E F0
(This section describes what syntax features are a)108 223.2 Q -.25(va)
-.2 G(ilable.).25 E 1.305(History e)108 240 R 1.305
(xpansions introduce w)-.15 F 1.306(ords from the history list into the\
input stream, making it easy to repeat)-.1 F .21
(commands, insert the ar)108 252 R .21(guments to a pre)-.18 F .209
(vious command into the current input line, or \214x errors in pre)-.25
F(vious)-.25 E(commands quickly)108 264 Q(.)-.65 E 1.296(History e)108
280.8 R 1.297(xpansion is usually performed immediately after a complet\
e line is read.)-.15 F 1.297(It tak)6.297 F 1.297(es place in tw)-.1 F
(o)-.1 E 2.855(parts. The)108 292.8 R .354(\214rst is to determine whic\
h line from the history list to use during substitution.)2.855 F .354
(The second is to)5.354 F .116
(select portions of that line for inclusion into the current one.)108
304.8 R .117(The line selected from the history is the)5.116 F/F3 10
/Times-Italic@0 SF -.15(ev)2.617 G(ent).15 E F0(,)A .846
(and the portions of that line that are acted upon are)108 316.8 R F3
(wor)3.346 E(ds)-.37 E F0 5.846(.V)C(arious)-6.956 E F3(modi\214er)3.346
E(s)-.1 E F0 .846(are a)3.346 F -.25(va)-.2 G .845(ilable to manipulate)
.25 F .304(the selected w)108 328.8 R 2.804(ords. The)-.1 F .304
(line is brok)2.804 F .304(en into w)-.1 F .304(ords in the same f)-.1 F
.304(ashion as)-.1 F F2(bash)2.804 E F0 .305
(does when reading input, so)2.804 F .539(that se)108 340.8 R -.15(ve)
-.25 G .539(ral w).15 F .539(ords that w)-.1 F .539
(ould otherwise be separated are considered one w)-.1 F .538
(ord when surrounded by quotes)-.1 F .307(\(see the description of)108
352.8 R F2(history_tok)2.807 E(enize\(\))-.1 E F0(belo)2.807 E 2.807
(w\). History)-.25 F -.15(ex)2.807 G .307
(pansions are introduced by the appearance of).15 F .52(the history e)
108 364.8 R .52(xpansion character)-.15 F 3.02(,w)-.4 G .52(hich is)
-3.02 F F2(!)3.853 E F0 .52(by def)3.853 F 3.02(ault. Only)-.1 F .52
(backslash \()3.02 F F2(\\).833 E F0 3.02(\)a).833 G .52
(nd single quotes can quote the)-3.02 F(history e)108 376.8 Q
(xpansion character)-.15 E(.)-.55 E F2(Ev)87 393.6 Q(ent Designators)-.1
E F0(An e)108 405.6 Q -.15(ve)-.25 G(nt designator is a reference to a \
command line entry in the history list.).15 E F2(!)108 422.4 Q F0
(Start a history substitution, e)32.67 E(xcept when follo)-.15 E
(wed by a)-.25 E F2(blank)2.5 E F0 2.5(,n)C -.25(ew)-2.5 G
(line, = or \(.).25 E F2(!)108 434.4 Q F3(n)A F0(Refer to command line)
27.67 E F3(n)2.5 E F0(.).24 E F2<21ad>108 446.4 Q F3(n)A F0
(Refer to the current command line minus)21.97 E F3(n)2.5 E F0(.).24 E
F2(!!)108 458.4 Q F0(Refer to the pre)29.34 E(vious command.)-.25 E
(This is a synon)5 E(ym for `!\2551'.)-.15 E F2(!)108 470.4 Q F3(string)
A F0(Refer to the most recent command starting with)9.33 E F3(string)2.5
E F0(.).22 E F2(!?)108 482.4 Q F3(string)A F2([?])A F0 1.057
(Refer to the most recent command containing)144 494.4 R F3(string)3.557
E F0 6.057(.T).22 G 1.057(he trailing)-6.057 F F2(?)3.557 E F0 1.057
(may be omitted if)3.557 F F3(string)3.557 E F0(is)3.557 E(follo)144
506.4 Q(wed immediately by a ne)-.25 E(wline.)-.25 E/F4 12/Times-Bold@0
SF(^)108 523.4 Q F3(string1)-5 I F4(^)5 I F3(string2)-5 I F4(^)5 I F0
2.66(Quick substitution.)144 530.4 R 2.66
(Repeat the last command, replacing)7.66 F F3(string1)5.16 E F0(with)
5.16 E F3(string2)5.16 E F0 7.66(.E).02 G(qui)-7.66 E -.25(va)-.25 G
2.66(lent to).25 F -.74(``)144 542.4 S(!!:s/).74 E F3(string1)A F0(/)A
F3(string2)A F0(/')A 2.5('\()-.74 G(see)-2.5 E F2(Modi\214ers)2.5 E F0
(belo)2.5 E(w\).)-.25 E F2(!#)108 554.4 Q F0
(The entire command line typed so f)27.67 E(ar)-.1 E(.)-.55 E F2 -.75
(Wo)87 571.2 S(rd Designators).75 E F0 -.8(Wo)108 583.2 S 1.313
(rd designators are used to select desired w).8 F 1.314(ords from the e)
-.1 F -.15(ve)-.25 G 3.814(nt. A).15 F F2(:)3.814 E F0 1.314
(separates the e)3.814 F -.15(ve)-.25 G 1.314(nt speci\214cation).15 F
.53(from the w)108 595.2 R .529(ord designator)-.1 F 5.529(.I)-.55 G
3.029(tm)-5.529 G .529(ay be omitted if the w)-3.029 F .529
(ord designator be)-.1 F .529(gins with a)-.15 F F2(^)3.029 E F0(,)A F2
($)3.029 E F0(,)A F2(*)3.029 E F0(,)A F2<ad>3.029 E F0 3.029(,o)C(r)
-3.029 E F2(%)3.029 E F0 5.529(.W)C(ords)-6.329 E 1.3
(are numbered from the be)108 607.2 R 1.3
(ginning of the line, with the \214rst w)-.15 F 1.301
(ord being denoted by 0 \(zero\).)-.1 F -.8(Wo)6.301 G 1.301(rds are).8
F(inserted into the current line separated by single spaces.)108 619.2 Q
F2 2.5(0\()108 636 S(zer)-2.5 E(o\))-.18 E F0(The zeroth w)144 648 Q 2.5
(ord. F)-.1 F(or the shell, this is the command w)-.15 E(ord.)-.1 E F3
(n)108 660 Q F0(The)31 E F3(n)2.5 E F0(th w)A(ord.)-.1 E F2(^)108 672 Q
F0(The \214rst ar)32.67 E 2.5(gument. That)-.18 F(is, w)2.5 E(ord 1.)-.1
E F2($)108 684 Q F0(The last ar)31 E(gument.)-.18 E F2(%)108 696 Q F0
(The w)26 E(ord matched by the most recent `?)-.1 E F3(string)A F0
(?' search.)A F3(x)108 708 Q F2<ad>A F3(y)A F0 2.5(Ar)21.42 G(ange of w)
-2.5 E(ords; `\255)-.1 E F3(y)A F0 2.5('a)C(bbre)-2.5 E(viates `0\255)
-.25 E F3(y)A F0('.)A(GNU History 4.3)72 768 Q(2002 January 31)131.79 E
(1)195.95 E EP
%%Page: 2 2
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
(OR)-.18 E(Y\(3\))-.65 E/F1 10/Times-Bold@0 SF(*)108 84 Q F0 .316
(All of the w)31 F .316(ords b)-.1 F .316(ut the zeroth.)-.2 F .315
(This is a synon)5.315 F .315(ym for `)-.15 F/F2 10/Times-Italic@0 SF
(1\255$)A F0 2.815('. It)B .315(is not an error to use)2.815 F F1(*)
2.815 E F0 .315(if there is)2.815 F(just one w)144 96 Q(ord in the e)-.1
E -.15(ve)-.25 G(nt; the empty string is returned in that case.).15 E F1
(x*)108 108 Q F0(Abbre)26 E(viates)-.25 E F2(x\255$)2.5 E F0(.)A F1
<78ad>108 120 Q F0(Abbre)25.3 E(viates)-.25 E F2(x\255$)2.5 E F0(lik)2.5
E(e)-.1 E F1(x*)2.5 E F0 2.5(,b)C(ut omits the last w)-2.7 E(ord.)-.1 E
(If a w)108 136.8 Q(ord designator is supplied without an e)-.1 E -.15
(ve)-.25 G(nt speci\214cation, the pre).15 E
(vious command is used as the e)-.25 E -.15(ve)-.25 G(nt.).15 E F1
(Modi\214ers)87 153.6 Q F0 .183(After the optional w)108 165.6 R .183
(ord designator)-.1 F 2.683(,t)-.4 G .184
(here may appear a sequence of one or more of the follo)-2.683 F .184
(wing modi\214ers,)-.25 F(each preceded by a `:'.)108 177.6 Q F1(h)108
194.4 Q F0(Remo)30.44 E .3 -.15(ve a t)-.15 H
(railing \214le name component, lea).15 E(ving only the head.)-.2 E F1
(t)108 206.4 Q F0(Remo)32.67 E .3 -.15(ve a)-.15 H
(ll leading \214le name components, lea).15 E(ving the tail.)-.2 E F1(r)
108 218.4 Q F0(Remo)31.56 E .3 -.15(ve a t)-.15 H(railing suf).15 E
(\214x of the form)-.25 E F2(.xxx)2.5 E F0 2.5(,l)C(ea)-2.5 E
(ving the basename.)-.2 E F1(e)108 230.4 Q F0(Remo)31.56 E .3 -.15(ve a)
-.15 H(ll b).15 E(ut the trailing suf)-.2 E(\214x.)-.25 E F1(p)108 242.4
Q F0(Print the ne)30.44 E 2.5(wc)-.25 G(ommand b)-2.5 E(ut do not e)-.2
E -.15(xe)-.15 G(cute it.).15 E F1(q)108 254.4 Q F0
(Quote the substituted w)30.44 E(ords, escaping further substitutions.)
-.1 E F1(x)108 266.4 Q F0(Quote the substituted w)31 E(ords as with)-.1
E F1(q)2.5 E F0 2.5(,b)C(ut break into w)-2.7 E(ords at)-.1 E F1(blanks)
2.5 E F0(and ne)2.5 E(wlines.)-.25 E F1(s/)108 278.4 Q F2(old)A F1(/)A
F2(ne)A(w)-.15 E F1(/)A F0(Substitute)144 290.4 Q F2(ne)2.814 E(w)-.15 E
F0 .314(for the \214rst occurrence of)2.814 F F2(old)2.814 E F0 .314
(in the e)2.814 F -.15(ve)-.25 G .314(nt line.).15 F(An)5.314 E 2.814
(yd)-.15 G .314(elimiter can be used in place)-2.814 F .616(of /.)144
302.4 R .617
(The \214nal delimiter is optional if it is the last character of the e)
5.616 F -.15(ve)-.25 G .617(nt line.).15 F .617(The delimiter may)5.617
F .75(be quoted in)144 314.4 R F2(old)3.25 E F0(and)3.25 E F2(ne)3.25 E
(w)-.15 E F0 .75(with a single backslash.)3.25 F .749(If & appears in)
5.75 F F2(ne)3.249 E(w)-.15 E F0 3.249(,i).31 G 3.249(ti)-3.249 G 3.249
(sr)-3.249 G .749(eplaced by)-3.249 F F2(old)3.249 E F0 5.749(.A).77 G
.369(single backslash will quote the &.)144 326.4 R(If)5.369 E F2(old)
2.869 E F0 .37(is null, it is set to the last)2.869 F F2(old)2.87 E F0
.37(substituted, or)2.87 F 2.87(,i)-.4 G 2.87(fn)-2.87 G 2.87(op)-2.87 G
(re)-2.87 E(vi-)-.25 E(ous history substitutions took place, the last)
144 338.4 Q F2(string)2.5 E F0(in a)2.5 E F1(!?)2.5 E F2(string)A F1
([?])A F0(search.)5 E F1(&)108 350.4 Q F0(Repeat the pre)27.67 E
(vious substitution.)-.25 E F1(g)108 362.4 Q F0 .398
(Cause changes to be applied o)31 F -.15(ve)-.15 G 2.898(rt).15 G .398
(he entire e)-2.898 F -.15(ve)-.25 G .398(nt line.).15 F .397
(This is used in conjunction with `)5.398 F F1(:s)A F0 2.897('\()C
(e.g.,)-2.897 E(`)144 374.4 Q F1(:gs/)A F2(old)A F1(/)A F2(ne)A(w)-.15 E
F1(/)A F0 1.218('\) or `)B F1(:&)A F0 3.718('. If)B 1.218(used with `)
3.718 F F1(:s)A F0 1.218(', an)B 3.718(yd)-.15 G 1.219
(elimiter can be used in place of /, and the \214nal)-3.718 F
(delimiter is optional if it is the last character of the e)144 386.4 Q
-.15(ve)-.25 G(nt line.).15 E/F3 10.95/Times-Bold@0 SF(PR)72 403.2 Q
(OGRAMMING WITH HIST)-.329 E(OR)-.197 E 2.738(YF)-.383 G(UNCTIONS)-2.738
E F0(This section describes ho)108 415.2 Q 2.5(wt)-.25 G 2.5(ou)-2.5 G
(se the History library in other programs.)-2.5 E F1(Intr)87 432 Q
(oduction to History)-.18 E F0 .797
(The programmer using the History library has a)108 444 R -.25(va)-.2 G
.796(ilable functions for remembering lines on a history list,).25 F
.307(associating arbitrary data with a line, remo)108 456 R .308
(ving lines from the list, searching through the list for a line con-)
-.15 F .303(taining an arbitrary te)108 468 R .303
(xt string, and referencing an)-.15 F 2.803(yl)-.15 G .303
(ine in the list directly)-2.803 F 5.303(.I)-.65 G 2.803(na)-5.303 G
.303(ddition, a history)-2.803 F F2 -.2(ex)2.802 G(pansion).2 E F0
(function is a)108 480 Q -.25(va)-.2 G(ilable which pro).25 E
(vides for a consistent user interf)-.15 E(ace across dif)-.1 E
(ferent programs.)-.25 E .059(The user using programs written with the \
History library has the bene\214t of a consistent user interf)108 496.8
R .059(ace with a)-.1 F .918(set of well-kno)108 508.8 R .917
(wn commands for manipulating the te)-.25 F .917(xt of pre)-.15 F .917
(vious lines and using that te)-.25 F .917(xt in ne)-.15 F 3.417(wc)-.25
G(om-)-3.417 E 4.183(mands. The)108 520.8 R 1.684(basic history manipul\
ation commands are identical to the history substitution pro)4.183 F
1.684(vided by)-.15 F F1(bash)108 532.8 Q F0(.)A .904
(If the programmer desires, he can use the Readline library)108 549.6 R
3.403(,w)-.65 G .903(hich includes some history manipulation by)-3.403 F
(def)108 561.6 Q(ault, and has the added adv)-.1 E
(antage of command line editing.)-.25 E .39(Before declaring an)108
578.4 R 2.89(yf)-.15 G .39(unctions using an)-2.89 F 2.89(yf)-.15 G .39
(unctionality the History library pro)-2.89 F .39
(vides in other code, an appli-)-.15 F .067
(cation writer should include the \214le)108 590.4 R F2(<r)4.233 E
(eadline/history)-.37 E(.h>)-.55 E F0 .067(in an)4.233 F 2.566<798c>-.15
G .066(le that uses the History library')-2.566 F 2.566(sf)-.55 G
(eatures.)-2.566 E .538(It supplies e)108 602.4 R .538
(xtern declarations for all of the library')-.15 F 3.038(sp)-.55 G .538
(ublic functions and v)-3.038 F .539(ariables, and declares all of the)
-.25 F(public data structures.)108 614.4 Q F1(History Storage)87 643.2 Q
F0(The history list is an array of history entries.)108 655.2 Q 2.5(Ah)5
G(istory entry is declared as follo)-2.5 E(ws:)-.25 E F2(typedef void *)
108 672 Q F1(histdata_t;)2.5 E F0(typedef struct _hist_entry {)108 688.8
Q(char *line;)113 700.8 Q(histdata_t data;)113 712.8 Q 2.5(}H)108 724.8
S(IST_ENTR)-2.5 E -.92(Y;)-.65 G(GNU History 4.3)72 768 Q
(2002 January 31)131.79 E(2)195.95 E EP
%%Page: 3 3
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
(OR)-.18 E(Y\(3\))-.65 E
(The history list itself might therefore be declared as)108 84 Q/F1 10
/Times-Italic@0 SF(HIST_ENTR)108 100.8 Q 2.5(Y*)-.18 G(*)-2.5 E/F2 10
/Times-Bold@0 SF(the_history_list;)2.5 E F0(The state of the History li\
brary is encapsulated into a single structure:)108 117.6 Q(/*)108 134.4
Q 2.5(*As)110.5 146.4 S
(tructure used to pass around the current state of the history)-2.5 E(.)
-.65 E(*/)110.5 158.4 Q(typedef struct _hist_state {)108 170.4 Q
(HIST_ENTR)113 182.4 Q 2.5(Y*)-.65 G
(*entries; /* Pointer to the entries themselv)-2.5 E(es. */)-.15 E
(int of)113 194.4 Q 25(fset; /*)-.25 F
(The location pointer within this array)2.5 E 2.5(.*)-.65 G(/)-2.5 E
(int length;)113 206.4 Q(/* Number of elements within this array)27.5 E
2.5(.*)-.65 G(/)-2.5 E(int size;)113 218.4 Q
(/* Number of slots allocated to this array)32.5 E 2.5(.*)-.65 G(/)-2.5
E(int \215ags;)113 230.4 Q 2.5(}H)108 242.4 S(IST)-2.5 E(OR)-.18 E(Y_ST)
-.65 E -1.11(AT)-.93 G(E;)1.11 E(If the \215ags member includes)108
259.2 Q F2(HS_STIFLED)2.5 E F0 2.5(,t)C(he history has been sti\215ed.)
-2.5 E/F3 10.95/Times-Bold@0 SF(History Functions)72 276 Q F0
(This section describes the calling sequence for the v)108 288 Q
(arious functions e)-.25 E(xported by the GNU History library)-.15 E(.)
-.65 E F2(Initializing History and State Management)87 304.8 Q F0 1.274
(This section describes functions used to initialize and manage the sta\
te of the History library when you)108 316.8 R -.1(wa)108 328.8 S
(nt to use the history functions in your program.).1 E F1(void)108 352.8
Q F2(using_history)2.5 E F0(\()4.166 E F1(void)A F0(\))1.666 E(Be)108
364.8 Q(gin a session in which the history functions might be used.)-.15
E(This initializes the interacti)5 E .3 -.15(ve v)-.25 H(ariables.)-.1 E
F1(HIST)108 388.8 Q(OR)-.18 E(Y_ST)-.18 E -.37(AT)-.5 G 2.5(E*).37 G F2
(history_get_history_state)A F0(\()4.166 E F1(void)A F0(\))1.666 E
(Return a structure describing the current state of the input history)
108 400.8 Q(.)-.65 E F1(void)108 424.8 Q F2(history_set_history_state)
2.5 E F0(\()4.166 E F1(HIST)A(OR)-.18 E(Y_ST)-.18 E -.37(AT)-.5 G 2.5
(E*).37 G(state)-2.5 E F0(\))1.666 E
(Set the state of the history list according to)108 436.8 Q F1(state)2.5
E F0(.)A F2(History List Management)87 465.6 Q F0
(These functions manage indi)108 477.6 Q(vidual entries on the history \
list, or set parameters managing the list itself.)-.25 E F1(void)108
501.6 Q F2(add_history)2.5 E F0(\()4.166 E F1(const c)A(har *string)-.15
E F0(\))1.666 E(Place)108 513.6 Q F1(string)2.5 E F0
(at the end of the history list.)2.5 E
(The associated data \214eld \(if an)5 E(y\) is set to)-.15 E F2(NULL)
2.5 E F0(.)A F1(HIST_ENTR)108 537.6 Q 2.5(Y*)-.18 G F2 -.18(re)C(mo).18
E -.1(ve)-.1 G(_history).1 E F0(\()4.166 E F1(int whic)A(h)-.15 E F0(\))
1.666 E(Remo)108 549.6 Q .352 -.15(ve h)-.15 H .052(istory entry at of)
.15 F(fset)-.25 E F1(whic)2.553 E(h)-.15 E F0 .053(from the history)
2.553 F 5.053(.T)-.65 G .053(he remo)-5.053 F -.15(ve)-.15 G 2.553(de)
.15 G .053(lement is returned so you can free the)-2.553 F
(line, data, and containing structure.)108 561.6 Q F1(HIST_ENTR)108
585.6 Q 2.5(Y*)-.18 G F2 -.18(re)C(place_history_entry).18 E F0(\()4.166
E F1(int whic)A -.834(h, const)-.15 F -.15(ch)2.5 G(ar *line).15 E 1.666
(,h)-.1 G(istdata_t data)-1.666 E F0(\))3.332 E(Mak)108 597.6 Q 2.868
(et)-.1 G .368(he history entry at of)-2.868 F(fset)-.25 E F1(whic)2.868
E(h)-.15 E F0(ha)2.868 E -.15(ve)-.2 G F1(line)3.018 E F0(and)2.868 E F1
(data)2.868 E F0 5.367(.T)C .367
(his returns the old entry so you can dispose of)-5.367 F(the data.)108
609.6 Q(In the case of an in)5 E -.25(va)-.4 G(lid).25 E F1(whic)2.5 E
(h)-.15 E F0 2.5(,a)C F2(NULL)A F0(pointer is returned.)2.5 E F1(void)
108 633.6 Q F2(clear_history)2.5 E F0(\()4.166 E F1(void)A F0(\))1.666 E
(Clear the history list by deleting all the entries.)108 645.6 Q F1
(void)108 669.6 Q F2(sti\215e_history)2.5 E F0(\()4.166 E F1(int max)A
F0(\))1.666 E(Sti\215e the history list, remembering only the last)108
681.6 Q F1(max)2.5 E F0(entries.)2.5 E F1(int)108 705.6 Q F2
(unsti\215e_history)2.5 E F0(\()4.166 E F1(void)A F0(\))1.666 E .46
(Stop sti\215ing the history)108 717.6 R 5.46(.T)-.65 G .46
(his returns the pre)-5.46 F .46
(viously-set maximum number of history entries \(as set by)-.25 F F2
(sti-)2.96 E(\215e_history\(\))108 729.6 Q F0 2.5(\). history)B -.1(wa)
2.5 G 2.5(ss).1 G 2.5(ti\215ed. The)-2.5 F -.25(va)2.5 G(lue is positi)
.25 E .3 -.15(ve i)-.25 H 2.5(ft).15 G(he history w)-2.5 E
(as sti\215ed, ne)-.1 E -.05(ga)-.15 G(ti).05 E .3 -.15(ve i)-.25 H 2.5
(fi).15 G 2.5(tw)-2.5 G(asn')-2.6 E(t.)-.18 E(GNU History 4.3)72 768 Q
(2002 January 31)131.79 E(3)195.95 E EP
%%Page: 4 4
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
(OR)-.18 E(Y\(3\))-.65 E/F1 10/Times-Italic@0 SF(int)108 84 Q/F2 10
/Times-Bold@0 SF(history_is_sti\215ed)2.5 E F0(\()4.166 E F1(void)A F0
(\))1.666 E
(Returns non-zero if the history is sti\215ed, zero if it is not.)108 96
Q F2(Inf)87 124.8 Q(ormation About the History List)-.25 E F0(These fun\
ctions return information about the entire history list or indi)108
136.8 Q(vidual list entries.)-.25 E F1(HIST_ENTR)108 160.8 Q 2.5(Y*)-.18
G(*)-2.5 E F2(history_list)2.5 E F0(\()4.166 E F1(void)A F0(\))1.666 E
.708(Return a)108 172.8 R F2(NULL)3.208 E F0 .708(terminated array of)
3.208 F F1(HIST_ENTR)3.208 E 3.208(Y*)-.18 G F0 .708
(which is the current input history)B 5.707(.E)-.65 G .707
(lement 0 of this)-5.707 F(list is the be)108 184.8 Q(ginning of time.)
-.15 E(If there is no history)5 E 2.5(,r)-.65 G(eturn)-2.5 E F2(NULL)2.5
E F0(.)A F1(int)108 208.8 Q F2(wher)2.5 E(e_history)-.18 E F0(\()4.166 E
F1(void)A F0(\))1.666 E(Returns the of)108 220.8 Q
(fset of the current history element.)-.25 E F1(HIST_ENTR)108 244.8 Q
2.5(Y*)-.18 G F2(curr)A(ent_history)-.18 E F0(\()4.166 E F1(void)A F0
(\))1.666 E 1.373
(Return the history entry at the current position, as determined by)108
256.8 R F2(wher)3.873 E(e_history\(\))-.18 E F0 6.373(.I)C 3.873(ft)
-6.373 G 1.374(here is no entry)-3.873 F(there, return a)108 268.8 Q F2
(NULL)2.5 E F0(pointer)2.5 E(.)-.55 E F1(HIST_ENTR)108 292.8 Q 2.5(Y*)
-.18 G F2(history_get)A F0(\()4.166 E F1(int of)A(fset)-.18 E F0(\))
1.666 E .288(Return the history entry at position)108 304.8 R F1(of)
2.787 E(fset)-.18 E F0 2.787(,s)C .287(tarting from)-2.787 F F2
(history_base)2.787 E F0 5.287(.I)C 2.787(ft)-5.287 G .287
(here is no entry there, or if)-2.787 F F1(of)2.787 E(fset)-.18 E F0
(is greater than the history length, return a)108 316.8 Q F2(NULL)2.5 E
F0(pointer)2.5 E(.)-.55 E F1(int)108 340.8 Q F2(history_total_bytes)2.5
E F0(\()4.166 E F1(void)A F0(\))1.666 E .391
(Return the number of bytes that the primary history entries are using.)
108 352.8 R .392(This function returns the sum of the)5.392 F
(lengths of all the lines in the history)108 364.8 Q(.)-.65 E F2(Mo)87
393.6 Q(ving Ar)-.1 E(ound the History List)-.18 E F0
(These functions allo)108 405.6 Q 2.5(wt)-.25 G(he current inde)-2.5 E
2.5(xi)-.15 G(nto the history list to be set or changed.)-2.5 E F1(int)
108 429.6 Q F2(history_set_pos)2.5 E F0(\()4.166 E F1(int pos)A F0(\))
1.666 E .79(Set the current history of)108 441.6 R .79(fset to)-.25 F F1
(pos)3.29 E F0 3.29(,a)C 3.29(na)-3.29 G .79(bsolute inde)-3.29 F 3.29
(xi)-.15 G .79(nto the list.)-3.29 F .79(Returns 1 on success, 0 if)5.79
F F1(pos)3.29 E F0 .79(is less)3.29 F
(than zero or greater than the number of history entries.)108 453.6 Q F1
(HIST_ENTR)108 477.6 Q 2.5(Y*)-.18 G F2(pr)A -.15(ev)-.18 G
(ious_history).15 E F0(\()4.166 E F1(void)A F0(\))1.666 E .207
(Back up the current history of)108 489.6 R .207(fset to the pre)-.25 F
.207(vious history entry)-.25 F 2.708(,a)-.65 G .208
(nd return a pointer to that entry)-2.708 F 5.208(.I)-.65 G 2.708(ft)
-5.208 G .208(here is)-2.708 F(no pre)108 501.6 Q(vious entry)-.25 E 2.5
(,r)-.65 G(eturn a)-2.5 E F2(NULL)2.5 E F0(pointer)2.5 E(.)-.55 E F1
(HIST_ENTR)108 525.6 Q 2.5(Y*)-.18 G F2(next_history)A F0(\()4.166 E F1
(void)A F0(\))1.666 E(Mo)108 537.6 Q 1.047 -.15(ve t)-.15 H .747
(he current history of).15 F .747(fset forw)-.25 F .746(ard to the ne)
-.1 F .746(xt history entry)-.15 F 3.246(,a)-.65 G .746
(nd return the a pointer to that entry)-3.246 F 5.746(.I)-.65 G(f)-5.746
E(there is no ne)108 549.6 Q(xt entry)-.15 E 2.5(,r)-.65 G(eturn a)-2.5
E F2(NULL)2.5 E F0(pointer)2.5 E(.)-.55 E F2(Sear)87 578.4 Q
(ching the History List)-.18 E F0 .005(These functions allo)108 590.4 R
2.505(ws)-.25 G .006(earching of the history list for entries containin\
g a speci\214c string.)-2.505 F .006(Searching may be)5.006 F 1.452
(performed both forw)108 602.4 R 1.452(ard and backw)-.1 F 1.451
(ard from the current history position.)-.1 F 1.451(The search may be)
6.451 F F1(anc)3.951 E(hor)-.15 E(ed)-.37 E F0(,)A
(meaning that the string must match at the be)108 614.4 Q
(ginning of the history entry)-.15 E(.)-.65 E F1(int)108 638.4 Q F2
(history_sear)2.5 E(ch)-.18 E F0(\()4.166 E F1(const c)A(har *string)
-.15 E 1.666(,i)-.1 G(nt dir)-1.666 E(ection)-.37 E F0(\))1.666 E .155
(Search the history for)108 650.4 R F1(string)2.655 E F0 2.656(,s)C .156
(tarting at the current history of)-2.656 F 2.656(fset. If)-.25 F F1
(dir)2.656 E(ection)-.37 E F0 .156(is less than 0, then the search)2.656
F .802(is through pre)108 662.4 R .802
(vious entries, otherwise through subsequent entries.)-.25 F(If)5.801 E
F1(string)3.301 E F0 .801(is found, then the current his-)3.301 F .064
(tory inde)108 674.4 R 2.564(xi)-.15 G 2.564(ss)-2.564 G .064
(et to that history entry)-2.564 F 2.564(,a)-.65 G .064(nd the v)-2.564
F .064(alue returned is the of)-.25 F .064
(fset in the line of the entry where)-.25 F F1(string)2.565 E F0 -.1(wa)
108 686.4 S 2.5(sf).1 G 2.5(ound. Otherwise,)-2.5 F
(nothing is changed, and a -1 is returned.)2.5 E F1(int)108 710.4 Q F2
(history_sear)2.5 E(ch_pr)-.18 E(e\214x)-.18 E F0(\()4.166 E F1(const c)
A(har *string)-.15 E 1.666(,i)-.1 G(nt dir)-1.666 E(ection)-.37 E F0(\))
1.666 E .684(Search the history for)108 722.4 R F1(string)3.183 E F0
3.183(,s)C .683(tarting at the current history of)-3.183 F 3.183
(fset. The)-.25 F .683(search is anchored: matching lines)3.183 F
(GNU History 4.3)72 768 Q(2002 January 31)131.79 E(4)195.95 E EP
%%Page: 5 5
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
(OR)-.18 E(Y\(3\))-.65 E 1.063(must be)108 84 R 1.063(gin with)-.15 F/F1
10/Times-Italic@0 SF(string)3.563 E F0 6.063(.I)C(f)-6.063 E F1(dir)
3.563 E(ection)-.37 E F0 1.064
(is less than 0, then the search is through pre)3.563 F 1.064
(vious entries, otherwise)-.25 F 1.115(through subsequent entries.)108
96 R(If)6.115 E F1(string)3.615 E F0 1.115
(is found, then the current history inde)3.615 F 3.614(xi)-.15 G 3.614
(ss)-3.614 G 1.114(et to that entry)-3.614 F 3.614(,a)-.65 G 1.114
(nd the)-3.614 F(return v)108 108 Q(alue is 0.)-.25 E
(Otherwise, nothing is changed, and a -1 is returned.)5 E F1(int)108 132
Q/F2 10/Times-Bold@0 SF(history_sear)2.5 E(ch_pos)-.18 E F0(\()4.166 E
F1(const c)A(har *string)-.15 E 1.666(,i)-.1 G(nt dir)-1.666 E -.834
(ection, int)-.37 F(pos)2.5 E F0(\))3.332 E .603(Search for)108 144 R F1
(string)3.103 E F0 .603(in the history list, starting at)3.103 F F1(pos)
3.104 E F0 3.104(,a)C 3.104(na)-3.104 G .604(bsolute inde)-3.104 F 3.104
(xi)-.15 G .604(nto the list.)-3.104 F(If)5.604 E F1(dir)3.104 E(ection)
-.37 E F0 .604(is ne)3.104 F -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G(,)
.15 E .608(the search proceeds backw)108 156 R .608(ard from)-.1 F F1
(pos)3.108 E F0 3.108(,o)C .608(therwise forw)-3.108 F 3.108
(ard. Returns)-.1 F .608(the absolute inde)3.108 F 3.108(xo)-.15 G 3.108
(ft)-3.108 G .608(he history ele-)-3.108 F(ment where)108 168 Q F1
(string)2.5 E F0 -.1(wa)2.5 G 2.5(sf).1 G(ound, or -1 otherwise.)-2.5 E
F2(Managing the History File)87 196.8 Q F0 .035(The History library can\
read the history from and write it to a \214le.)108 208.8 R .036
(This section documents the functions for)5.035 F
(managing a history \214le.)108 220.8 Q F1(int)108 244.8 Q F2 -.18(re)
2.5 G(ad_history).18 E F0(\()4.166 E F1(const c)A(har *\214lename)-.15 E
F0(\))1.666 E .151(Add the contents of)108 256.8 R F1(\214lename)2.651 E
F0 .151(to the history list, a line at a time.)2.651 F(If)5.15 E F1
(\214lename)2.65 E F0(is)2.65 E F2(NULL)2.65 E F0 2.65(,t)C .15
(hen read from)-2.65 F F1(~/.his-)2.65 E(tory)108 268.8 Q F0 5(.R)C
(eturns 0 if successful, or)-5 E F2(err)2.5 E(no)-.15 E F0(if not.)2.5 E
F1(int)108 292.8 Q F2 -.18(re)2.5 G(ad_history_range).18 E F0(\()4.166 E
F1(const c)A(har *\214lename)-.15 E 1.666(,i)-.1 G(nt fr)-1.666 E -.834
(om, int)-.45 F(to)2.5 E F0(\))3.332 E .052(Read a range of lines from)
108 304.8 R F1(\214lename)2.553 E F0 2.553(,a)C .053
(dding them to the history list.)-2.553 F .053(Start reading at line)
5.053 F F1(fr)2.553 E(om)-.45 E F0 .053(and end at)2.553 F F1(to)2.553 E
F0(.)A(If)108 316.8 Q F1(fr)2.889 E(om)-.45 E F0 .389
(is zero, start at the be)2.889 F 2.889(ginning. If)-.15 F F1(to)2.889 E
F0 .389(is less than)2.889 F F1(fr)2.889 E(om)-.45 E F0 2.889(,t)C .388
(hen read until the end of the \214le.)-2.889 F(If)5.388 E F1
(\214lename)2.888 E F0(is)108 328.8 Q F2(NULL)2.5 E F0 2.5(,t)C
(hen read from)-2.5 E F1(~/.history)2.5 E F0 5(.R)C
(eturns 0 if successful, or)-5 E F2(err)2.5 E(no)-.15 E F0(if not.)2.5 E
F1(int)108 352.8 Q F2(write_history)2.5 E F0(\()4.166 E F1(const c)A
(har *\214lename)-.15 E F0(\))1.666 E .961(Write the current history to)
108 364.8 R F1(\214lename)3.461 E F0 3.461(,o)C -.15(ve)-3.611 G
(rwriting).15 E F1(\214lename)3.461 E F0 .961(if necessary)3.461 F 5.961
(.I)-.65 G(f)-5.961 E F1(\214lename)3.462 E F0(is)3.462 E F2(NULL)3.462
E F0 3.462(,t)C .962(hen write)-3.462 F(the history list to)108 376.8 Q
F1(~/.history)2.5 E F0 5(.R)C(eturns 0 on success, or)-5 E F2(err)2.5 E
(no)-.15 E F0(on a read or write error)2.5 E(.)-.55 E F1(int)108 412.8 Q
F2(append_history)2.5 E F0(\()4.166 E F1(int nelements,)A(const c)1.666
E(har *\214lename)-.15 E F0(\))1.666 E .839(Append the last)108 424.8 R
F1(nelements)3.339 E F0 .839(of the history list to)3.339 F F1
(\214lename)3.339 E F0 5.839(.I)C(f)-5.839 E F1(\214lename)3.339 E F0
(is)3.339 E F2(NULL)3.339 E F0 3.339(,t)C .838(hen append to)-3.339 F F1
(~/.history)3.338 E F0(.)A(Returns 0 on success, or)108 436.8 Q F2(err)
2.5 E(no)-.15 E F0(on a read or write error)2.5 E(.)-.55 E F1(int)108
460.8 Q F2(history_truncate_\214le)2.5 E F0(\()4.166 E F1(const c)A
(har *\214lename)-.15 E 1.666(,i)-.1 G(nt nlines)-1.666 E F0(\))1.666 E
-.35(Tr)108 472.8 S .38(uncate the history \214le).35 F F1(\214lename)
2.88 E F0 2.88(,l)C(ea)-2.88 E .38(ving only the last)-.2 F F1(nlines)
2.881 E F0 2.881(lines. If)2.881 F F1(\214lename)2.881 E F0(is)2.881 E
F2(NULL)2.881 E F0 2.881(,t)C(hen)-2.881 E F1(~/.history)2.881 E F0(is)
2.881 E 2.5(truncated. Returns)108 484.8 R 2.5(0o)2.5 G 2.5(ns)-2.5 G
(uccess, or)-2.5 E F2(err)2.5 E(no)-.15 E F0(on f)2.5 E(ailure.)-.1 E F2
(History Expansion)87 513.6 Q F0(These functions implement history e)108
525.6 Q(xpansion.)-.15 E F1(int)108 549.6 Q F2(history_expand)2.5 E F0
(\()4.166 E F1 -.15(ch)C(ar *string).15 E 1.666(,c)-.1 G(har **output)
-1.816 E F0(\))1.666 E(Expand)108 561.6 Q F1(string)2.5 E F0 2.5(,p)C
(lacing the result into)-2.5 E F1(output)2.5 E F0 2.5(,ap)C
(ointer to a string.)-2.5 E(Returns:)5 E 31(0I)144 573.6 S 3.066(fn)-31
G 3.066(oe)-3.066 G .566(xpansions took place \(or)-3.216 F 3.065(,i)-.4
G 3.065(ft)-3.065 G .565(he only change in the te)-3.065 F .565(xt w)
-.15 F .565(as the remo)-.1 F -.25(va)-.15 G 3.065(lo).25 G 3.065(fe)
-3.065 G(scape)-3.065 E(characters preceding the history e)180 585.6 Q
(xpansion character\);)-.15 E 31(1i)144 597.6 S 2.5(fe)-31 G
(xpansions did tak)-2.65 E 2.5(ep)-.1 G(lace;)-2.5 E 25.17(-1 if)144
609.6 R(there w)2.5 E(as an error in e)-.1 E(xpansion;)-.15 E 31(2i)144
621.6 S 2.5(ft)-31 G(he returned line should be displayed, b)-2.5 E
(ut not e)-.2 E -.15(xe)-.15 G(cuted, as with the).15 E F2(:p)2.5 E F0
(modi\214er)2.5 E(.)-.55 E(If an error ocurred in e)108 633.6 Q
(xpansion, then)-.15 E F1(output)2.5 E F0(contains a descripti)2.5 E .3
-.15(ve e)-.25 H(rror message.).15 E F1 -.15(ch)108 657.6 S(ar *).15 E
F2(get_history_e)2.5 E -.1(ve)-.15 G(nt).1 E F0(\()4.166 E F1(const c)A
(har *string)-.15 E 1.666(,i)-.1 G(nt *cinde)-1.666 E -.834(x, int)-.2 F
(qc)2.5 E(har)-.15 E F0(\))3.332 E .262(Returns the te)108 669.6 R .262
(xt of the history e)-.15 F -.15(ve)-.25 G .262(nt be).15 F .263
(ginning at)-.15 F F1(string)2.763 E F0(+)2.763 E F1(*cinde)2.763 E(x)
-.2 E F0(.)A F1(*cinde)5.263 E(x)-.2 E F0 .263
(is modi\214ed to point to after the)2.763 F -2.15 -.25(ev e)108 681.6 T
.71(nt speci\214er).25 F 5.71(.A)-.55 G 3.21(tf)-5.71 G .71
(unction entry)-3.21 F(,)-.65 E F1(cinde)3.21 E(x)-.2 E F0 .709
(points to the inde)3.21 F 3.209(xi)-.15 G(nto)-3.209 E F1(string)3.209
E F0 .709(where the history e)3.209 F -.15(ve)-.25 G .709
(nt speci\214ca-).15 F .527(tion be)108 693.6 R(gins.)-.15 E F1(qc)5.527
E(har)-.15 E F0 .527(is a character that is allo)3.027 F .527
(wed to end the e)-.25 F -.15(ve)-.25 G .528
(nt speci\214cation in addition to the `).15 F(`normal')-.74 E(')-.74 E
(terminating characters.)108 705.6 Q F1 -.15(ch)108 729.6 S(ar **).15 E
F2(history_tok)2.5 E(enize)-.1 E F0(\()4.166 E F1(const c)A(har *string)
-.15 E F0(\))1.666 E(GNU History 4.3)72 768 Q(2002 January 31)131.79 E
(5)195.95 E EP
%%Page: 6 6
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
(OR)-.18 E(Y\(3\))-.65 E .239(Return an array of tok)108 84 R .239
(ens parsed out of)-.1 F/F1 10/Times-Italic@0 SF(string)2.739 E F0 2.739
(,m)C .238(uch as the shell might.)-2.739 F .238(The tok)5.238 F .238
(ens are split on the charac-)-.1 F(ters in the)108 96 Q/F2 10
/Times-Bold@0 SF(history_w)2.5 E(ord_delimiters)-.1 E F0 -.25(va)2.5 G
(riable, and shell quoting con).25 E -.15(ve)-.4 G(ntions are obe).15 E
(yed.)-.15 E F1 -.15(ch)108 120 S(ar *).15 E F2(history_ar)2.5 E
(g_extract)-.1 E F0(\()4.166 E F1(int \214r)A -.834(st, int)-.1 F -.834
(last, const)2.5 F -.15(ch)2.5 G(ar *string).15 E F0(\))3.332 E .025
(Extract a string se)108 132 R .025(gment consisting of the)-.15 F F1
<8c72>2.526 E(st)-.1 E F0(through)2.526 E F1(last)2.526 E F0(ar)2.526 E
.026(guments present in)-.18 F F1(string)2.526 E F0 5.026(.A)C -.18(rg)
-5.026 G .026(uments are split).18 F(using)108 144 Q F2(history_tok)2.5
E(enize\(\))-.1 E F0(.)A F2(History V)87 172.8 Q(ariables)-.92 E F0
(This section describes the e)108 184.8 Q(xternally-visible v)-.15 E
(ariables e)-.25 E(xported by the GNU History Library)-.15 E(.)-.65 E F1
(int)108 208.8 Q F2(history_base)2.5 E F0(The logical of)108 220.8 Q
(fset of the \214rst entry in the history list.)-.25 E F1(int)108 244.8
Q F2(history_length)2.5 E F0
(The number of entries currently stored in the history list.)108 256.8 Q
F1(int)108 280.8 Q F2(history_max_entries)2.5 E F0
(The maximum number of history entries.)108 292.8 Q
(This must be changed using)5 E F2(sti\215e_history\(\))2.5 E F0(.)A F1
-.15(ch)108 316.8 S(ar).15 E F2(history_expansion_char)2.5 E F0
(The character that introduces a history e)108 328.8 Q -.15(ve)-.25 G
2.5(nt. The).15 F(def)2.5 E(ault is)-.1 E F2(!)2.5 E F0 5(.S)C
(etting this to 0 inhibits history e)-5 E(xpansion.)-.15 E F1 -.15(ch)
108 352.8 S(ar).15 E F2(history_subst_char)2.5 E F0
(The character that in)108 364.8 Q -.2(vo)-.4 G -.1(ke).2 G 2.5(sw).1 G
(ord substitution if found at the start of a line.)-2.6 E(The def)5 E
(ault is)-.1 E F2(^)2.5 E F0(.)A F1 -.15(ch)108 388.8 S(ar).15 E F2
(history_comment_char)2.5 E F0 .117(During tok)108 400.8 R .117
(enization, if this character is seen as the \214rst character of a w)
-.1 F .117(ord, then it and all subsequent char)-.1 F(-)-.2 E .276
(acters up to a ne)108 412.8 R .276
(wline are ignored, suppressing history e)-.25 F .276
(xpansion for the remainder of the line.)-.15 F .277(This is dis-)5.276
F(abled by def)108 424.8 Q(ault.)-.1 E F1 -.15(ch)108 448.8 S(ar *).15 E
F2(history_w)2.5 E(ord_delimiters)-.1 E F0
(The characters that separate tok)108 460.8 Q(ens for)-.1 E F2
(history_tok)2.5 E(enize\(\))-.1 E F0 5(.T)C(he def)-5 E(ault v)-.1 E
(alue is)-.25 E F2 2.5("\\)2.5 G(t\\n\(\)<>;&|")-2.5 E F0(.)A F1 -.15
(ch)108 484.8 S(ar *).15 E F2(history_no_expand_chars)2.5 E F0 2.054
(The list of characters which inhibit history e)108 496.8 R 2.054
(xpansion if found immediately follo)-.15 F(wing)-.25 E F2
(history_expan-)4.554 E(sion_char)108 508.8 Q F0 5(.T)C(he def)-5 E
(ault is space, tab, ne)-.1 E(wline,)-.25 E F2(\\r)2.5 E F0 2.5(,a)C(nd)
-2.5 E F2(=)2.5 E F0(.)A F1 -.15(ch)108 532.8 S(ar *).15 E F2
(history_sear)2.5 E(ch_delimiter_chars)-.18 E F0 .401(The list of addit\
ional characters which can delimit a history search string, in addition\
to space, tab,)108 544.8 R F1(:)2.901 E F0(and)2.901 E F1(?)2.902 E F0
(in the case of a substring search.)108 556.8 Q(The def)5 E
(ault is empty)-.1 E(.)-.65 E F1(int)108 580.8 Q F2
(history_quotes_inhibit_expansion)2.5 E F0 .625
(If non-zero, single-quoted w)108 592.8 R .625
(ords are not scanned for the history e)-.1 F .624(xpansion character)
-.15 F 5.624(.T)-.55 G .624(he def)-5.624 F .624(ault v)-.1 F .624
(alue is)-.25 F(0.)108 604.8 Q F1(rl_lineb)108 628.8 Q(uf_func_t *)-.2 E
F2(history_inhibit_expansion_function)2.5 E F0 .347
(This should be set to the address of a function that tak)108 640.8 R
.348(es tw)-.1 F 2.848(oa)-.1 G -.18(rg)-2.848 G .348(uments: a).18 F F2
.348(char *)2.848 F F0(\()2.848 E F1(string)A F0 2.848(\)a)C .348(nd an)
-2.848 F F2(int)2.848 E F0(inde)2.848 E(x)-.15 E .228
(into that string \()108 652.8 R F1(i)A F0 2.728(\). It)B .227
(should return a non-zero v)2.727 F .227(alue if the history e)-.25 F
.227(xpansion starting at)-.15 F F1(string[i])2.727 E F0 .227
(should not)2.727 F .019(be performed; zero if the e)108 664.8 R .019
(xpansion should be done.)-.15 F .019
(It is intended for use by applications lik)5.019 F(e)-.1 E F2(bash)
2.519 E F0 .019(that use)2.519 F(the history e)108 676.8 Q
(xpansion character for additional purposes.)-.15 E(By def)5 E
(ault, this v)-.1 E(ariable is set to)-.25 E F2(NULL)2.5 E F0(.)A/F3
10.95/Times-Bold@0 SF(FILES)72 693.6 Q F1(~/.history)109.666 705.6 Q F0
(Def)144 717.6 Q(ault \214lename for reading and writing sa)-.1 E -.15
(ve)-.2 G 2.5(dh).15 G(istory)-2.5 E(GNU History 4.3)72 768 Q
(2002 January 31)131.79 E(6)195.95 E EP
%%Page: 7 7
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
(OR)-.18 E(Y\(3\))-.65 E/F1 10.95/Times-Bold@0 SF(SEE ALSO)72 84 Q/F2 10
/Times-Italic@0 SF(The Gnu Readline Libr)108 96 Q(ary)-.15 E F0 2.5(,B)C
(rian F)-2.5 E(ox and Chet Rame)-.15 E(y)-.15 E F2(The Gnu History Libr)
108 108 Q(ary)-.15 E F0 2.5(,B)C(rian F)-2.5 E(ox and Chet Rame)-.15 E
(y)-.15 E F2(bash)108 120 Q F0(\(1\))A F2 -.37(re)108 132 S(adline).37 E
F0(\(3\))A F1 -.548(AU)72 148.8 S(THORS).548 E F0(Brian F)108 160.8 Q
(ox, Free Softw)-.15 E(are F)-.1 E(oundation)-.15 E(bfox@gnu.or)108
172.8 Q(g)-.18 E(Chet Rame)108 189.6 Q 1.3 -.65(y, C)-.15 H(ase W).65 E
(estern Reserv)-.8 E 2.5(eU)-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E
(chet@ins.CWR)108 201.6 Q(U.Edu)-.4 E F1 -.11(BU)72 218.4 S 2.738(GR).11
G(EPOR)-2.738 E(TS)-.438 E F0 .16(If you \214nd a b)108 230.4 R .16
(ug in the)-.2 F/F3 10/Times-Bold@0 SF(history)2.66 E F0(library)2.66 E
2.66(,y)-.65 G .16(ou should report it.)-2.66 F .16
(But \214rst, you should mak)5.16 F 2.66(es)-.1 G .16
(ure that it really is)-2.66 F 2.5(ab)108 242.4 S
(ug, and that it appears in the latest v)-2.7 E(ersion of the)-.15 E F3
(history)2.5 E F0(library that you ha)2.5 E -.15(ve)-.2 G(.).15 E .704
(Once you ha)108 259.2 R 1.004 -.15(ve d)-.2 H .704(etermined that a b)
.15 F .704(ug actually e)-.2 F .704(xists, mail a b)-.15 F .705
(ug report to)-.2 F F2 -.2(bu)3.205 G(g\255r).2 E(eadline)-.37 E F0(@)A
F2(gnu.or)A(g)-.37 E F0 5.705(.I)C 3.205(fy)-5.705 G(ou)-3.205 E(ha)108
271.2 Q 1.81 -.15(ve a \214)-.2 H 1.51
(x, you are welcome to mail that as well!).15 F 1.509
(Suggestions and `philosophical' b)6.509 F 1.509(ug reports may be)-.2 F
(mailed to)108 283.2 Q F2 -.2(bu)2.5 G(g-r).2 E(eadline)-.37 E F0(@)A F2
(gnu.or)A(g)-.37 E F0(or posted to the Usenet ne)2.5 E(wsgroup)-.25 E F3
(gnu.bash.b)2.5 E(ug)-.2 E F0(.)A(Comments and b)108 300 Q
(ug reports concerning this manual page should be directed to)-.2 E F2
-.15(ch)2.5 G(et@ins.CWR).15 E -.25(U.)-.4 G(Edu).25 E F0(.).25 E
(GNU History 4.3)72 768 Q(2002 January 31)131.79 E(7)195.95 E EP
%%Trailer
end
%%EOF

File diff suppressed because it is too large Load Diff

View File

@ -1,139 +0,0 @@
/*******************************************************************************
* $Revision$
* $Date$
* $Author$
*
* Contents: A streambuf which uses the GNU readline library for line I/O
* (c) 2001 by Dimitris Vyzovitis [vyzo@media.mit.edu]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
******************************************************************************/
#ifndef _READLINEBUF_H_
#define _READLINEBUF_H_
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <readline/readline.h>
#include <readline/history.h>
#if (defined __GNUC__) && (__GNUC__ < 3)
#include <streambuf.h>
#else
#include <streambuf>
using std::streamsize;
using std::streambuf;
#endif
class readlinebuf : public streambuf {
public:
#if (defined __GNUC__) && (__GNUC__ < 3)
typedef char char_type;
typedef int int_type;
typedef streampos pos_type;
typedef streamoff off_type;
#endif
static const int_type eof = EOF; // this is -1
static const int_type not_eof = 0;
private:
const char* prompt_;
bool history_;
char* line_;
int low_;
int high_;
protected:
virtual int_type showmanyc() const { return high_ - low_; }
virtual streamsize xsgetn( char_type* buf, streamsize n ) {
int rd = n > (high_ - low_)? (high_ - low_) : n;
memcpy( buf, line_, rd );
low_ += rd;
if ( rd < n ) {
low_ = high_ = 0;
free( line_ ); // free( NULL ) is a noop
line_ = readline( prompt_ );
if ( line_ ) {
high_ = strlen( line_ );
if ( history_ && high_ ) add_history( line_ );
rd += xsgetn( buf + rd, n - rd );
}
}
return rd;
}
virtual int_type underflow() {
if ( high_ == low_ ) {
low_ = high_ = 0;
free( line_ ); // free( NULL ) is a noop
line_ = readline( prompt_ );
if ( line_ ) {
high_ = strlen( line_ );
if ( history_ && high_ ) add_history( line_ );
}
}
if ( low_ < high_ ) return line_[low_];
else return eof;
}
virtual int_type uflow() {
int_type c = underflow();
if ( c != eof ) ++low_;
return c;
}
virtual int_type pbackfail( int_type c = eof ) {
if ( low_ > 0 ) --low_;
else if ( c != eof ) {
if ( high_ > 0 ) {
char* nl = (char*)realloc( line_, high_ + 1 );
if ( nl ) {
line_ = (char*)memcpy( nl + 1, line_, high_ );
high_ += 1;
line_[0] = char( c );
} else return eof;
} else {
assert( !line_ );
line_ = (char*)malloc( sizeof( char ) );
*line_ = char( c );
high_ = 1;
}
} else return eof;
return not_eof;
}
public:
readlinebuf( const char* prompt = NULL, bool history = true )
: prompt_( prompt ), history_( history ),
line_( NULL ), low_( 0 ), high_( 0 ) {
setbuf( 0, 0 );
}
};
#endif

View File

@ -1,174 +0,0 @@
/*
* rlcat - cat(1) using readline
*
* usage: rlcat
*/
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include "posixstat.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <errno.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
extern int optind;
extern char *optarg;
static int stdcat();
static char *progname;
static int vflag;
static void
usage()
{
fprintf (stderr, "%s: usage: %s [-vEVN] [filename]\n", progname, progname);
}
int
main (argc, argv)
int argc;
char **argv;
{
char *temp;
int opt, Vflag, Nflag;
progname = strrchr(argv[0], '/');
if (progname == 0)
progname = argv[0];
else
progname++;
vflag = Vflag = Nflag = 0;
while ((opt = getopt(argc, argv, "vEVN")) != EOF)
{
switch (opt)
{
case 'v':
vflag = 1;
break;
case 'V':
Vflag = 1;
break;
case 'E':
Vflag = 0;
break;
case 'N':
Nflag = 1;
break;
default:
usage ();
exit (2);
}
}
argc -= optind;
argv += optind;
if (isatty(0) == 0 || argc || Nflag)
return stdcat(argc, argv);
rl_variable_bind ("editing-mode", Vflag ? "vi" : "emacs");
while (temp = readline (""))
{
if (*temp)
add_history (temp);
printf ("%s\n", temp);
}
return (ferror (stdout));
}
static int
fcopy(fp)
FILE *fp;
{
int c;
char *x;
while ((c = getc(fp)) != EOF)
{
if (vflag && isascii ((unsigned char)c) && isprint((unsigned char)c) == 0)
{
x = rl_untranslate_keyseq (c);
if (fputs (x, stdout) != 0)
return 1;
}
else if (putchar (c) == EOF)
return 1;
}
return (ferror (stdout));
}
int
stdcat (argc, argv)
int argc;
char **argv;
{
int i, fd, r;
char *s;
FILE *fp;
if (argc == 0)
return (fcopy(stdin));
for (i = 0, r = 1; i < argc; i++)
{
if (*argv[i] == '-' && argv[i][1] == 0)
fp = stdin;
else
{
fp = fopen (argv[i], "r");
if (fp == 0)
{
fprintf (stderr, "%s: %s: cannot open: %s\n", progname, argv[i], strerror(errno));
continue;
}
}
r = fcopy (fp);
if (fp != stdin)
fclose(fp);
}
return r;
}

View File

@ -1,337 +0,0 @@
/* mbutil.c -- readline multibyte character utility functions */
/* Copyright (C) 2001 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#include "posixjmp.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h> /* for _POSIX_VERSION */
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include <stdio.h>
#include <ctype.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
#if defined (TIOCSTAT_IN_SYS_IOCTL)
# include <sys/ioctl.h>
#endif /* TIOCSTAT_IN_SYS_IOCTL */
/* Some standard library routines. */
#include "readline.h"
#include "rlprivate.h"
#include "xmalloc.h"
/* Declared here so it can be shared between the readline and history
libraries. */
#if defined (HANDLE_MULTIBYTE)
int rl_byte_oriented = 0;
#else
int rl_byte_oriented = 1;
#endif
/* **************************************************************** */
/* */
/* Multibyte Character Utility Functions */
/* */
/* **************************************************************** */
#if defined(HANDLE_MULTIBYTE)
static int
_rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
char *string;
int seed, count, find_non_zero;
{
size_t tmp = 0;
mbstate_t ps;
int point = 0;
wchar_t wc;
memset(&ps, 0, sizeof (mbstate_t));
if (seed < 0)
seed = 0;
if (count <= 0)
return seed;
point = seed + _rl_adjust_point(string, seed, &ps);
/* if this is true, means that seed was not pointed character
started byte. So correct the point and consume count */
if (seed < point)
count --;
while (count > 0)
{
tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps);
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* invalid bytes. asume a byte represents a character */
point++;
count--;
/* reset states. */
memset(&ps, 0, sizeof(mbstate_t));
}
else if (tmp == (size_t)0)
/* found '\0' char */
break;
else
{
/* valid bytes */
point += tmp;
if (find_non_zero)
{
if (wcwidth (wc) == 0)
continue;
else
count--;
}
else
count--;
}
}
if (find_non_zero)
{
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
while (wcwidth (wc) == 0)
{
point += tmp;
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))
break;
}
}
return point;
}
static int
_rl_find_prev_mbchar_internal (string, seed, find_non_zero)
char *string;
int seed, find_non_zero;
{
mbstate_t ps;
int prev, non_zero_prev, point, length;
size_t tmp;
wchar_t wc;
memset(&ps, 0, sizeof(mbstate_t));
length = strlen(string);
if (seed < 0)
return 0;
else if (length < seed)
return length;
prev = non_zero_prev = point = 0;
while (point < seed)
{
tmp = mbrtowc (&wc, string + point, length - point, &ps);
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* in this case, bytes are invalid or shorted to compose
multibyte char, so assume that the first byte represents
a single character anyway. */
tmp = 1;
/* clear the state of the byte sequence, because
in this case effect of mbstate is undefined */
memset(&ps, 0, sizeof (mbstate_t));
}
else if (tmp == 0)
break; /* Found '\0' char. Can this happen? */
else
{
if (find_non_zero)
{
if (wcwidth (wc) != 0)
prev = point;
}
else
prev = point;
}
point += tmp;
}
return prev;
}
/* return the number of bytes parsed from the multibyte sequence starting
at src, if a non-L'\0' wide character was recognized. It returns 0,
if a L'\0' wide character was recognized. It returns (size_t)(-1),
if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
if it couldn't parse a complete multibyte character. */
int
_rl_get_char_len (src, ps)
char *src;
mbstate_t *ps;
{
size_t tmp;
tmp = mbrlen((const char *)src, (size_t)strlen (src), ps);
if (tmp == (size_t)(-2))
{
/* shorted to compose multibyte char */
memset (ps, 0, sizeof(mbstate_t));
return -2;
}
else if (tmp == (size_t)(-1))
{
/* invalid to compose multibyte char */
/* initialize the conversion state */
memset (ps, 0, sizeof(mbstate_t));
return -1;
}
else if (tmp == (size_t)0)
return 0;
else
return (int)tmp;
}
/* compare the specified two characters. If the characters matched,
return 1. Otherwise return 0. */
int
_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
char *buf1, *buf2;
mbstate_t *ps1, *ps2;
int pos1, pos2;
{
int i, w1, w2;
if ((w1 = _rl_get_char_len (&buf1[pos1], ps1)) <= 0 ||
(w2 = _rl_get_char_len (&buf2[pos2], ps2)) <= 0 ||
(w1 != w2) ||
(buf1[pos1] != buf2[pos2]))
return 0;
for (i = 1; i < w1; i++)
if (buf1[pos1+i] != buf2[pos2+i])
return 0;
return 1;
}
/* adjust pointed byte and find mbstate of the point of string.
adjusted point will be point <= adjusted_point, and returns
differences of the byte(adjusted_point - point).
if point is invalied (point < 0 || more than string length),
it returns -1 */
int
_rl_adjust_point(string, point, ps)
char *string;
int point;
mbstate_t *ps;
{
size_t tmp = 0;
int length;
int pos = 0;
length = strlen(string);
if (point < 0)
return -1;
if (length < point)
return -1;
while (pos < point)
{
tmp = mbrlen (string + pos, length - pos, ps);
if((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* in this case, bytes are invalid or shorted to compose
multibyte char, so assume that the first byte represents
a single character anyway. */
pos++;
/* clear the state of the byte sequence, because
in this case effect of mbstate is undefined */
memset (ps, 0, sizeof (mbstate_t));
}
else
pos += tmp;
}
return (pos - point);
}
int
_rl_is_mbchar_matched (string, seed, end, mbchar, length)
char *string;
int seed, end;
char *mbchar;
int length;
{
int i;
if ((end - seed) < length)
return 0;
for (i = 0; i < length; i++)
if (string[seed + i] != mbchar[i])
return 0;
return 1;
}
#endif /* HANDLE_MULTIBYTE */
/* Find next `count' characters started byte point of the specified seed.
If flags is MB_FIND_NONZERO, we look for non-zero-width multibyte
characters. */
#undef _rl_find_next_mbchar
int
_rl_find_next_mbchar (string, seed, count, flags)
char *string;
int seed, count, flags;
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_next_mbchar_internal (string, seed, count, flags);
#else
return (seed + count);
#endif
}
/* Find previous character started byte point of the specified seed.
Returned point will be point <= seed. If flags is MB_FIND_NONZERO,
we look for non-zero-width multibyte characters. */
#undef _rl_find_prev_mbchar
int
_rl_find_prev_mbchar (string, seed, flags)
char *string;
int seed, flags;
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_prev_mbchar_internal (string, seed, flags);
#else
return ((seed == 0) ? seed : seed - 1);
#endif
}

View File

@ -1,496 +0,0 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_LOCALE_H)
# include <locale.h>
#endif
#include <stdio.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
static int rl_digit_loop PARAMS((void));
static void _rl_history_set_point PARAMS((void));
/* Forward declarations used in this file */
void _rl_free_history_entry PARAMS((HIST_ENTRY *));
/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
to preserve the value of rl_point from line to line. */
int _rl_history_preserve_point = 0;
/* Saved target point for when _rl_history_preserve_point is set. Special
value of -1 means that point is at the end of the line. */
int _rl_history_saved_point = -1;
/* **************************************************************** */
/* */
/* Numeric Arguments */
/* */
/* **************************************************************** */
/* Handle C-u style numeric args, as well as M--, and M-digits. */
static int
rl_digit_loop ()
{
int key, c, sawminus, sawdigits;
rl_save_prompt ();
RL_SETSTATE(RL_STATE_NUMERICARG);
sawminus = sawdigits = 0;
while (1)
{
if (rl_numeric_arg > 1000000)
{
sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
rl_ding ();
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 1;
}
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
RL_SETSTATE(RL_STATE_MOREINPUT);
key = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c < 0)
{
_rl_abort_internal ();
return -1;
}
/* If we see a key bound to `universal-argument' after seeing digits,
it ends the argument but is otherwise ignored. */
if (_rl_keymap[c].type == ISFUNC &&
_rl_keymap[c].function == rl_universal_argument)
{
if (sawdigits == 0)
{
rl_numeric_arg *= 4;
continue;
}
else
{
RL_SETSTATE(RL_STATE_MOREINPUT);
key = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
c = UNMETA (c);
if (_rl_digit_p (c))
{
rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0';
sawdigits = rl_explicit_arg = 1;
}
else if (c == '-' && rl_explicit_arg == 0)
{
rl_numeric_arg = sawminus = 1;
rl_arg_sign = -1;
}
else
{
/* Make M-- command equivalent to M--1 command. */
if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
rl_explicit_arg = 1;
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
/*NOTREACHED*/
}
/* Add the current digit to the argument in progress. */
int
rl_digit_argument (ignore, key)
int ignore, key;
{
rl_execute_next (key);
return (rl_digit_loop ());
}
/* What to do when you abort reading an argument. */
int
rl_discard_argument ()
{
rl_ding ();
rl_clear_message ();
_rl_init_argument ();
return 0;
}
/* Create a default argument. */
int
_rl_init_argument ()
{
rl_numeric_arg = rl_arg_sign = 1;
rl_explicit_arg = 0;
return 0;
}
/* C-u, universal argument. Multiply the current argument by 4.
Read a key. If the key has nothing to do with arguments, then
dispatch on it. If the key is the abort character then abort. */
int
rl_universal_argument (count, key)
int count, key;
{
rl_numeric_arg *= 4;
return (rl_digit_loop ());
}
/* **************************************************************** */
/* */
/* History Utilities */
/* */
/* **************************************************************** */
/* We already have a history library, and that is what we use to control
the history features of readline. This is our local interface to
the history mechanism. */
/* While we are editing the history, this is the saved
version of the original line. */
HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
/* Set the history pointer back to the last entry in the history. */
void
_rl_start_using_history ()
{
using_history ();
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Free the contents (and containing structure) of a HIST_ENTRY. */
void
_rl_free_history_entry (entry)
HIST_ENTRY *entry;
{
if (entry == 0)
return;
if (entry->line)
free (entry->line);
free (entry);
}
/* Perhaps put back the current line if it has changed. */
int
rl_maybe_replace_line ()
{
HIST_ENTRY *temp;
temp = current_history ();
/* If the current line has changed, save the changes. */
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
{
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
free (temp->line);
free (temp);
}
return 0;
}
/* Restore the _rl_saved_line_for_history if there is one. */
int
rl_maybe_unsave_line ()
{
if (_rl_saved_line_for_history)
{
rl_replace_line (_rl_saved_line_for_history->line, 0);
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
rl_point = rl_end; /* rl_replace_line sets rl_end */
}
else
rl_ding ();
return 0;
}
/* Save the current line in _rl_saved_line_for_history. */
int
rl_maybe_save_line ()
{
if (_rl_saved_line_for_history == 0)
{
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
_rl_saved_line_for_history->line = savestring (rl_line_buffer);
_rl_saved_line_for_history->data = (char *)rl_undo_list;
}
return 0;
}
int
_rl_free_saved_history_line ()
{
if (_rl_saved_line_for_history)
{
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
return 0;
}
static void
_rl_history_set_point ()
{
rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
? _rl_history_saved_point
: rl_end;
if (rl_point > rl_end)
rl_point = rl_end;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_point = 0;
#endif /* VI_MODE */
if (rl_editing_mode == emacs_mode)
rl_mark = (rl_point == rl_end ? 0 : rl_end);
}
void
rl_replace_from_history (entry, flags)
HIST_ENTRY *entry;
int flags; /* currently unused */
{
rl_replace_line (entry->line, 0);
rl_undo_list = (UNDO_LIST *)entry->data;
rl_point = rl_end;
rl_mark = 0;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
{
rl_point = 0;
rl_mark = rl_end;
}
#endif
}
/* **************************************************************** */
/* */
/* History Commands */
/* */
/* **************************************************************** */
/* Meta-< goes to the start of the history. */
int
rl_beginning_of_history (count, key)
int count, key;
{
return (rl_get_previous_history (1 + where_history (), key));
}
/* Meta-> goes to the end of the history. (The current line). */
int
rl_end_of_history (count, key)
int count, key;
{
rl_maybe_replace_line ();
using_history ();
rl_maybe_unsave_line ();
return 0;
}
/* Move down to the next history line. */
int
rl_get_next_history (count, key)
int count, key;
{
HIST_ENTRY *temp;
if (count < 0)
return (rl_get_previous_history (-count, key));
if (count == 0)
return 0;
rl_maybe_replace_line ();
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = next_history ();
if (!temp)
break;
--count;
}
if (temp == 0)
rl_maybe_unsave_line ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* Get the previous item out of our interactive history, making it the current
line. If there is no previous history, just ding. */
int
rl_get_previous_history (count, key)
int count, key;
{
HIST_ENTRY *old_temp, *temp;
if (count < 0)
return (rl_get_next_history (-count, key));
if (count == 0)
return 0;
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
/* If we don't have a line saved, then save this one. */
rl_maybe_save_line ();
/* If the current line has changed, save the changes. */
rl_maybe_replace_line ();
temp = old_temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = previous_history ();
if (temp == 0)
break;
old_temp = temp;
--count;
}
/* If there was a large argument, and we moved back to the start of the
history, that is not an error. So use the last value found. */
if (!temp && old_temp)
temp = old_temp;
if (temp == 0)
rl_ding ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* **************************************************************** */
/* */
/* Editing Modes */
/* */
/* **************************************************************** */
/* How to toggle back and forth between editing modes. */
int
rl_vi_editing_mode (count, key)
int count, key;
{
#if defined (VI_MODE)
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
rl_editing_mode = vi_mode;
rl_vi_insertion_mode (1, key);
#endif /* VI_MODE */
return 0;
}
int
rl_emacs_editing_mode (count, key)
int count, key;
{
rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
_rl_keymap = emacs_standard_keymap;
return 0;
}
/* Function for the rest of the library to use to set insert/overwrite mode. */
void
_rl_set_insert_mode (im, force)
int im, force;
{
#ifdef CURSOR_MODE
_rl_set_cursor (im, force);
#endif
rl_insert_mode = im;
}
/* Toggle overwrite mode. A positive explicit argument selects overwrite
mode. A negative or zero explicit argument selects insert mode. */
int
rl_overwrite_mode (count, key)
int count, key;
{
if (rl_explicit_arg == 0)
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
else if (count > 0)
_rl_set_insert_mode (RL_IM_OVERWRITE, 0);
else
_rl_set_insert_mode (RL_IM_INSERT, 0);
return 0;
}

View File

@ -1,108 +0,0 @@
/* rlmbutil.h -- utility functions for multibyte characters. */
/* Copyright (C) 2001 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RL_MBUTIL_H_)
#define _RL_MBUTIL_H_
#include "rlstdc.h"
/************************************************/
/* check multibyte capability for I18N code */
/************************************************/
/* For platforms which support the ISO C amendement 1 functionality we
support user defined character classes. */
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
# include <wchar.h>
# include <wctype.h>
# if defined (HAVE_MBSRTOWCS) /* system is supposed to support XPG5 */
# define HANDLE_MULTIBYTE 1
# endif
#endif
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T)
# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0)
# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0)
# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0)
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
# define mbrlen(s, n, ps) (mbrlen) (s, n, 0)
# define mbstate_t int
#endif
/* Make sure MB_LEN_MAX is at least 16 on systems that claim to be able to
handle multibyte chars (some systems define MB_LEN_MAX as 1) */
#ifdef HANDLE_MULTIBYTE
# include <limits.h>
# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16)
# undef MB_LEN_MAX
# endif
# if !defined (MB_LEN_MAX)
# define MB_LEN_MAX 16
# endif
#endif
/************************************************/
/* end of multibyte capability checks for I18N */
/************************************************/
/*
* Flags for _rl_find_prev_mbchar and _rl_find_next_mbchar:
*
* MB_FIND_ANY find any multibyte character
* MB_FIND_NONZERO find a non-zero-width multibyte character
*/
#define MB_FIND_ANY 0x00
#define MB_FIND_NONZERO 0x01
extern int _rl_find_prev_mbchar PARAMS((char *, int, int));
extern int _rl_find_next_mbchar PARAMS((char *, int, int, int));
#ifdef HANDLE_MULTIBYTE
extern int _rl_compare_chars PARAMS((char *, int, mbstate_t *, char *, int, mbstate_t *));
extern int _rl_get_char_len PARAMS((char *, mbstate_t *));
extern int _rl_adjust_point PARAMS((char *, int, mbstate_t *));
extern int _rl_read_mbchar PARAMS((char *, int));
extern int _rl_read_mbstring PARAMS((int, char *, int));
extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
#else /* !HANDLE_MULTIBYTE */
#undef MB_LEN_MAX
#undef MB_CUR_MAX
#define MB_LEN_MAX 1
#define MB_CUR_MAX 1
#define _rl_find_prev_mbchar(b, i, f) (((i) == 0) ? (i) : ((i) - 1))
#define _rl_find_next_mbchar(b, i1, i2, f) ((i1) + (i2))
#endif /* !HANDLE_MULTIBYTE */
extern int rl_byte_oriented;
#endif /* _RL_MBUTIL_H_ */

View File

@ -1,88 +0,0 @@
/* rltypedefs.h -- Type declarations for readline functions. */
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _RL_TYPEDEFS_H_
#define _RL_TYPEDEFS_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Old-style */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
/* New style. */
#if !defined (_RL_FUNCTION_TYPEDEF)
# define _RL_FUNCTION_TYPEDEF
/* Bindable functions */
typedef int rl_command_func_t PARAMS((int, int));
/* Typedefs for the completion system */
typedef char *rl_compentry_func_t PARAMS((const char *, int));
typedef char **rl_completion_func_t PARAMS((const char *, int, int));
typedef char *rl_quote_func_t PARAMS((char *, int, char *));
typedef char *rl_dequote_func_t PARAMS((char *, int));
typedef int rl_compignore_func_t PARAMS((char **));
typedef void rl_compdisp_func_t PARAMS((char **, int, int));
/* Type for input and pre-read hook functions like rl_event_hook */
typedef int rl_hook_func_t PARAMS((void));
/* Input function type */
typedef int rl_getc_func_t PARAMS((FILE *));
/* Generic function that takes a character buffer (which could be the readline
line buffer) and an index into it (which could be rl_point) and returns
an int. */
typedef int rl_linebuf_func_t PARAMS((char *, int));
/* `Generic' function pointer typedefs */
typedef int rl_intfunc_t PARAMS((int));
#define rl_ivoidfunc_t rl_hook_func_t
typedef int rl_icpfunc_t PARAMS((char *));
typedef int rl_icppfunc_t PARAMS((char **));
typedef void rl_voidfunc_t PARAMS((void));
typedef void rl_vintfunc_t PARAMS((int));
typedef void rl_vcpfunc_t PARAMS((char *));
typedef void rl_vcppfunc_t PARAMS((char **));
#endif /* _RL_FUNCTION_TYPEDEF */
#ifdef __cplusplus
}
#endif
#endif /* _RL_TYPEDEFS_H_ */

View File

@ -1,236 +0,0 @@
/*
* This is an implementation of wcwidth() and wcswidth() as defined in
* "The Single UNIX Specification, Version 2, The Open Group, 1997"
* <http://www.UNIX-systems.org/online.html>
*
* Markus Kuhn -- 2001-09-08 -- public domain
*/
#include <wchar.h>
struct interval {
unsigned short first;
unsigned short last;
};
/* auxiliary function for binary search in interval table */
static int bisearch(wchar_t ucs, const struct interval *table, int max) {
int min = 0;
int mid;
if (ucs < table[0].first || ucs > table[max].last)
return 0;
while (max >= min) {
mid = (min + max) / 2;
if (ucs > table[mid].last)
min = mid + 1;
else if (ucs < table[mid].first)
max = mid - 1;
else
return 1;
}
return 0;
}
/* The following functions define the column width of an ISO 10646
* character as follows:
*
* - The null character (U+0000) has a column width of 0.
*
* - Other C0/C1 control characters and DEL will lead to a return
* value of -1.
*
* - Non-spacing and enclosing combining characters (general
* category code Mn or Me in the Unicode database) have a
* column width of 0.
*
* - Other format characters (general category code Cf in the Unicode
* database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
*
* - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
* have a column width of 0.
*
* - Spacing characters in the East Asian Wide (W) or East Asian
* FullWidth (F) category as defined in Unicode Technical
* Report #11 have a column width of 2.
*
* - All remaining characters (including all printable
* ISO 8859-1 and WGL4 characters, Unicode control characters,
* etc.) have a column width of 1.
*
* This implementation assumes that wchar_t characters are encoded
* in ISO 10646.
*/
int wcwidth(wchar_t ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
static const struct interval combining[] = {
{ 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
{ 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
{ 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
{ 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
{ 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
{ 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
{ 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C },
{ 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 },
{ 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC },
{ 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 },
{ 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
{ 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 },
{ 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 },
{ 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 },
{ 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
{ 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
{ 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
{ 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
{ 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
{ 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA },
{ 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 },
{ 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 },
{ 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD },
{ 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
{ 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
{ 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC },
{ 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 },
{ 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 },
{ 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
{ 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 },
{ 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F },
{ 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
{ 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF },
{ 0xFFF9, 0xFFFB }
};
/* test for 8-bit control characters */
if (ucs == 0)
return 0;
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
return -1;
/* binary search in table of non-spacing characters */
if (bisearch(ucs, combining,
sizeof(combining) / sizeof(struct interval) - 1))
return 0;
/* if we arrive here, ucs is not a combining or C0/C1 control character */
return 1 +
(ucs >= 0x1100 &&
(ucs <= 0x115f || /* Hangul Jamo init. consonants */
(ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
ucs != 0x303f) || /* CJK ... Yi */
(ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
(ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
(ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
(ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
(ucs >= 0xffe0 && ucs <= 0xffe6) ||
(ucs >= 0x20000 && ucs <= 0x2ffff)));
}
int wcswidth(const wchar_t *pwcs, size_t n)
{
int w, width = 0;
for (;*pwcs && n-- > 0; pwcs++)
if ((w = wcwidth(*pwcs)) < 0)
return -1;
else
width += w;
return width;
}
/*
* The following function is the same as wcwidth(), except that
* spacing characters in the East Asian Ambiguous (A) category as
* defined in Unicode Technical Report #11 have a column width of 2.
* This experimental variant might be useful for users of CJK legacy
* encodings who want to migrate to UCS. It is not otherwise
* recommended for general use.
*/
static int wcwidth_cjk(wchar_t ucs)
{
/* sorted list of non-overlapping intervals of East Asian Ambiguous
* characters */
static const struct interval ambiguous[] = {
{ 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
{ 0x00AA, 0x00AA }, { 0x00AD, 0x00AE }, { 0x00B0, 0x00B4 },
{ 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 },
{ 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 },
{ 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED },
{ 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA },
{ 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 },
{ 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B },
{ 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 },
{ 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 },
{ 0x0148, 0x014B }, { 0x014D, 0x014D }, { 0x0152, 0x0153 },
{ 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE },
{ 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 },
{ 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA },
{ 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 },
{ 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB },
{ 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB },
{ 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0300, 0x034E },
{ 0x0360, 0x0362 }, { 0x0391, 0x03A1 }, { 0x03A3, 0x03A9 },
{ 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 }, { 0x0401, 0x0401 },
{ 0x0410, 0x044F }, { 0x0451, 0x0451 }, { 0x2010, 0x2010 },
{ 0x2013, 0x2016 }, { 0x2018, 0x2019 }, { 0x201C, 0x201D },
{ 0x2020, 0x2022 }, { 0x2024, 0x2027 }, { 0x2030, 0x2030 },
{ 0x2032, 0x2033 }, { 0x2035, 0x2035 }, { 0x203B, 0x203B },
{ 0x203E, 0x203E }, { 0x2074, 0x2074 }, { 0x207F, 0x207F },
{ 0x2081, 0x2084 }, { 0x20AC, 0x20AC }, { 0x2103, 0x2103 },
{ 0x2105, 0x2105 }, { 0x2109, 0x2109 }, { 0x2113, 0x2113 },
{ 0x2116, 0x2116 }, { 0x2121, 0x2122 }, { 0x2126, 0x2126 },
{ 0x212B, 0x212B }, { 0x2153, 0x2155 }, { 0x215B, 0x215E },
{ 0x2160, 0x216B }, { 0x2170, 0x2179 }, { 0x2190, 0x2199 },
{ 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 },
{ 0x21E7, 0x21E7 }, { 0x2200, 0x2200 }, { 0x2202, 0x2203 },
{ 0x2207, 0x2208 }, { 0x220B, 0x220B }, { 0x220F, 0x220F },
{ 0x2211, 0x2211 }, { 0x2215, 0x2215 }, { 0x221A, 0x221A },
{ 0x221D, 0x2220 }, { 0x2223, 0x2223 }, { 0x2225, 0x2225 },
{ 0x2227, 0x222C }, { 0x222E, 0x222E }, { 0x2234, 0x2237 },
{ 0x223C, 0x223D }, { 0x2248, 0x2248 }, { 0x224C, 0x224C },
{ 0x2252, 0x2252 }, { 0x2260, 0x2261 }, { 0x2264, 0x2267 },
{ 0x226A, 0x226B }, { 0x226E, 0x226F }, { 0x2282, 0x2283 },
{ 0x2286, 0x2287 }, { 0x2295, 0x2295 }, { 0x2299, 0x2299 },
{ 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF }, { 0x2312, 0x2312 },
{ 0x2329, 0x232A }, { 0x2460, 0x24BF }, { 0x24D0, 0x24E9 },
{ 0x2500, 0x254B }, { 0x2550, 0x2574 }, { 0x2580, 0x258F },
{ 0x2592, 0x2595 }, { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 },
{ 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD },
{ 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB },
{ 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF },
{ 0x2605, 0x2606 }, { 0x2609, 0x2609 }, { 0x260E, 0x260F },
{ 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 },
{ 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 },
{ 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F },
{ 0x273D, 0x273D }, { 0x3008, 0x300B }, { 0x3014, 0x3015 },
{ 0x3018, 0x301B }, { 0xFFFD, 0xFFFD }
};
/* binary search in table of non-spacing characters */
if (bisearch(ucs, ambiguous,
sizeof(ambiguous) / sizeof(struct interval) - 1))
return 2;
return wcwidth(ucs);
}
int wcswidth_cjk(const wchar_t *pwcs, size_t n)
{
int w, width = 0;
for (;*pwcs && n-- > 0; pwcs++)
if ((w = wcwidth_cjk(*pwcs)) < 0)
return -1;
else
width += w;
return width;
}

File diff suppressed because it is too large Load Diff