/* constants */
#define BUFFER_SIZE 4096
+#define HISTORY_LEN 10
/* macros */
/* add line into history */
add_history (buffer);
- VERBOSE (INFO, fprintf (stdout, "line (%d): '%s'\n", where_history (), buffer));
- if (where_history () == 10) {
+ VERBOSE (INFO, fprintf (stdout, "line (%d/%d): '%s'\n",
+ where_history (), history_length, buffer));
+ if (history_length > HISTORY_LEN) {
HIST_ENTRY *last = remove_history (0);
if (last) {
free_history_entry (last);
}
}
} else {
- if (read (STDIN_FILENO, buffer, BUFFER_SIZE) == 0) {
- break;
- }
- nb = 0;
- char *pt = line[nb++] = buffer;
- while (*pt++ != '\0') {
- if (*pt == '\n') {
- *pt = '\0';
- line[nb++] = ++pt;
- }
- }
- VERBOSE (INFO, fprintf (stdout, "line: '%s'\n", buffer));
+ if (read (STDIN_FILENO, buffer, BUFFER_SIZE) == 0) {
+ break;
+ }
+ nb = 0;
+ char *pt = line[nb++] = buffer;
+ while (*pt++ != '\0') {
+ if (*pt == '\n') {
+ *pt = '\0';
+ line[nb++] = ++pt;
+ }
+ }
+ VERBOSE (INFO, fprintf (stdout, "line: '%s'\n", buffer));
}
/* look for end of line */