TheGNUGeneralPublicLicenseisoftenshippedwithGNUsoftware,and isgenerallykeptinafilecalledCOPYINGorLICENSE.Ifyoudonot haveacopyofthelicense,writetotheFreeSoftwareFoundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */
#define READLINE_LIBRARY
#ifdefined (HAVE_CONFIG_H) # include "config_readline.h" #endif
#include <stdio.h> #ifdefined (HAVE_STDLIB_H) # include <stdlib.h> #else # include "ansi_stdlib.h" #endif/* HAVE_STDLIB_H */
#ifdefined (HAVE_UNISTD_H) # ifdef _MINIX # include <sys/types.h> # endif # include <unistd.h> #endif
#include"history.h" #include"histlib.h"
/* The list of alternate characters that can delimit a history search
string. */ char *history_search_delimiter_chars = (char *)NULL;
/* Search the history for STRING, starting at history_offset. IfDIRECTION<0,thenthesearchisthroughpreviousentries,else throughsubsequent.IfANCHOREDisnon-zero,thestringmust appearatthebeginningofahistoryline,otherwise,thestring mayappearanywhereintheline.Ifthestringisfound,then current_history()isthehistoryentry,andthevalueofthis functionistheoffsetinthelineofthathistoryentrythatthe stringwasfoundin.Otherwise,nothingischanged,anda-1is
returned. */
staticint
history_search_internal (string, direction, anchored) constchar *string; int direction, anchored;
{ registerint i, reverse; registerchar *line; registerint line_index; int string_len;
HIST_ENTRY **the_history; /* local */
i = history_offset;
reverse = (direction < 0);
/* Take care of trivial cases first. */ if (string == 0 || *string == '\0') return (-1);
if (!history_length || ((i >= history_length) && !reverse)) return (-1);
if (reverse && (i >= history_length))
i = history_length - 1;
#define NEXT_LINE() do { if (reverse) i--; else i++; } while (0)
the_history = history_list ();
string_len = strlen (string); while (1)
{ /* Search each line in the history list for STRING. */
/* At limit for direction? */ if ((reverse && i < 0) || (!reverse && i == history_length)) return (-1);
line = the_history[i]->line;
line_index = strlen (line);
/* If STRING is longer than line, no match. */ if (string_len > line_index)
{
NEXT_LINE (); continue;
}
while (line_index < limit)
{ if (STREQN (string, line + line_index, string_len))
{
history_offset = i; return (line_index);
}
line_index++;
}
}
NEXT_LINE ();
}
}
/* Do a non-anchored search for STRING through the history in DIRECTION. */ int
history_search (string, direction) constchar *string; int direction;
{ return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
}
/* Do an anchored search for string through the history in DIRECTION. */ int
history_search_prefix (string, direction) constchar *string; int direction;
{ return (history_search_internal (string, direction, ANCHORED_SEARCH));
}
/* Search for STRING in the history list. DIR is < 0 for searching backwards.POSisanabsoluteindexintothehistorylistat
which point to begin searching. */ int
history_search_pos (string, dir, pos) constchar *string; int dir, pos;
{ int ret, old;
old = where_history ();
history_set_pos (pos); if (history_search (string, dir) == -1)
{
history_set_pos (old); return (-1);
}
ret = where_history ();
history_set_pos (old); return ret;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.