The world's most popular open source database
#include <config.h>#include <stdlib.h>#include "el.h"Include dependency graph for hist.c:

Go to the source code of this file.
Functions | |
| protected int | hist_init (EditLine *el) |
| protected void | hist_end (EditLine *el) |
| protected int | hist_set (EditLine *el, hist_fun_t fun, ptr_t ptr) |
| protected el_action_t | hist_get (EditLine *el) |
| protected int | hist_command (EditLine *el, int argc, const char **argv) |
| protected int | hist_enlargebuf (EditLine *el, size_t oldsz, size_t newsz) |
| protected int hist_command | ( | EditLine * | el, | |
| int | argc, | |||
| const char ** | argv | |||
| ) |
Definition at line 149 of file hist.c.
References el, editline::el_history, editline::el_outfile, el_history_t::ev, H_SETSIZE, H_SETUNIQUE, HIST_LAST, HIST_PREV, history(), int(), NULL, HistEvent::num, el_history_t::ref, strcmp(), and strtol().
00150 { 00151 const char *str; 00152 int num; 00153 HistEvent ev; 00154 00155 if (el->el_history.ref == NULL) 00156 return (-1); 00157 00158 if (argc == 1 || strcmp(argv[1], "list") == 0) { 00159 /* List history entries */ 00160 00161 for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el)) 00162 (void) fprintf(el->el_outfile, "%d %s", 00163 el->el_history.ev.num, str); 00164 return (0); 00165 } 00166 00167 if (argc != 3) 00168 return (-1); 00169 00170 num = (int)strtol(argv[2], NULL, 0); 00171 00172 if (strcmp(argv[1], "size") == 0) 00173 return history(el->el_history.ref, &ev, H_SETSIZE, num); 00174 00175 if (strcmp(argv[1], "unique") == 0) 00176 return history(el->el_history.ref, &ev, H_SETUNIQUE, num); 00177 00178 return -1; 00179 }
Here is the call graph for this function:

| protected void hist_end | ( | EditLine * | el | ) |
Definition at line 65 of file hist.c.
References el_history_t::buf, el, el_free, editline::el_history, and NULL.
Referenced by el_end().
00066 { 00067 00068 el_free((ptr_t) el->el_history.buf); 00069 el->el_history.buf = NULL; 00070 }
Here is the caller graph for this function:

Definition at line 187 of file hist.c.
References el_history_t::buf, el, editline::el_history, el_history_t::last, memset, realloc, and el_history_t::sz.
Referenced by ch_enlargebufs().
00188 { 00189 char *newbuf; 00190 00191 newbuf = realloc(el->el_history.buf, newsz); 00192 if (!newbuf) 00193 return 0; 00194 00195 (void) memset(&newbuf[oldsz], '\0', newsz - oldsz); 00196 00197 el->el_history.last = newbuf + 00198 (el->el_history.last - el->el_history.buf); 00199 el->el_history.buf = newbuf; 00200 el->el_history.sz = newsz; 00201 00202 return 1; 00203 }
Here is the caller graph for this function:

| protected el_action_t hist_get | ( | EditLine * | el | ) |
Definition at line 91 of file hist.c.
References el_history_t::buf, el_line_t::buffer, CC_ERROR, CC_REFRESH, el_line_t::cursor, el, editline::el_history, editline::el_line, editline::el_map, el_history_t::eventno, h, HIST_FIRST, HIST_NEXT, KSHVI, el_history_t::last, el_line_t::lastchar, el_line_t::limit, MAP_VI, NULL, el_history_t::ref, strlcpy, strlen(), el_history_t::sz, and el_map_t::type.
Referenced by ed_next_history(), ed_prev_history(), ed_search_next_history(), ed_search_prev_history(), vi_to_history_line(), and vi_undo_line().
00092 { 00093 const char *hp; 00094 int h; 00095 00096 if (el->el_history.eventno == 0) { /* if really the current line */ 00097 (void) strncpy(el->el_line.buffer, el->el_history.buf, 00098 el->el_history.sz); 00099 el->el_line.lastchar = el->el_line.buffer + 00100 (el->el_history.last - el->el_history.buf); 00101 00102 #ifdef KSHVI 00103 if (el->el_map.type == MAP_VI) 00104 el->el_line.cursor = el->el_line.buffer; 00105 else 00106 #endif /* KSHVI */ 00107 el->el_line.cursor = el->el_line.lastchar; 00108 00109 return (CC_REFRESH); 00110 } 00111 if (el->el_history.ref == NULL) 00112 return (CC_ERROR); 00113 00114 hp = HIST_FIRST(el); 00115 00116 if (hp == NULL) 00117 return (CC_ERROR); 00118 00119 for (h = 1; h < el->el_history.eventno; h++) 00120 if ((hp = HIST_NEXT(el)) == NULL) { 00121 el->el_history.eventno = h; 00122 return (CC_ERROR); 00123 } 00124 (void) strlcpy(el->el_line.buffer, hp, 00125 (size_t)(el->el_line.limit - el->el_line.buffer)); 00126 el->el_line.lastchar = el->el_line.buffer + strlen(el->el_line.buffer); 00127 00128 if (el->el_line.lastchar > el->el_line.buffer 00129 && el->el_line.lastchar[-1] == '\n') 00130 el->el_line.lastchar--; 00131 if (el->el_line.lastchar > el->el_line.buffer 00132 && el->el_line.lastchar[-1] == ' ') 00133 el->el_line.lastchar--; 00134 #ifdef KSHVI 00135 if (el->el_map.type == MAP_VI) 00136 el->el_line.cursor = el->el_line.buffer; 00137 else 00138 #endif /* KSHVI */ 00139 el->el_line.cursor = el->el_line.lastchar; 00140 00141 return (CC_REFRESH); 00142 }
Here is the call graph for this function:

Here is the caller graph for this function:

| protected int hist_init | ( | EditLine * | el | ) |
Definition at line 47 of file hist.c.
References el_history_t::buf, el, EL_BUFSIZ, editline::el_history, el_malloc, el_history_t::fun, el_history_t::last, NULL, el_history_t::ref, and el_history_t::sz.
Referenced by el_init().
00048 { 00049 00050 el->el_history.fun = NULL; 00051 el->el_history.ref = NULL; 00052 el->el_history.buf = (char *) el_malloc(EL_BUFSIZ); 00053 el->el_history.sz = EL_BUFSIZ; 00054 if (el->el_history.buf == NULL) 00055 return (-1); 00056 el->el_history.last = el->el_history.buf; 00057 return (0); 00058 }
Here is the caller graph for this function:

| protected int hist_set | ( | EditLine * | el, | |
| hist_fun_t | fun, | |||
| ptr_t | ptr | |||
| ) |
Definition at line 77 of file hist.c.
References el, editline::el_history, el_history_t::fun, and el_history_t::ref.
Referenced by el_get(), and el_set().
00078 { 00079 00080 el->el_history.ref = ptr; 00081 el->el_history.fun = fun; 00082 return (0); 00083 }
Here is the caller graph for this function:

1.4.7

