| version 1.1, 2002/09/03 00:41:44 |
version 1.7, 2020/11/01 10:28:22 |
| Line 7 static char rcsid[]= |
|
| Line 7 static char rcsid[]= |
|
| |
|
| #include <stdio.h> |
#include <stdio.h> |
| #include <stdlib.h> |
#include <stdlib.h> |
| |
#include <string.h> |
| #include <unistd.h> |
#include <unistd.h> |
| #include <ctype.h> |
#include <ctype.h> |
| #include "fep_defs.h" |
#include "fep_defs.h" |
| #include "fep_glob.h" |
#include "fep_glob.h" |
| #include "fep_funcs.h" |
#include "fep_funcs.h" |
| |
|
| #if defined(__FreeBSD__) || defined(__CYGWIN__) |
#if defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__APPLE_CC__) || defined(__INTERIX) || defined(ANDROID) |
| #define re_comp regcomp |
#include <regex.h> |
| #define re_exec regexec |
regex_t Re_pat; |
| |
#define re_comp(p) (regcomp(&Re_pat,(p), REG_EXTENDED|REG_NOSUB)) |
| |
#define re_exec(p) (!regexec(&Re_pat, (p), 0 , NULL, 0)) |
| |
#else |
| |
char *re_comp(); |
| #endif |
#endif |
| |
|
| char **HistoryTable; |
char **HistoryTable; |
| Line 32 char *getYoungestHistory(); |
|
| Line 37 char *getYoungestHistory(); |
|
| char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
| int argc; |
int argc; |
| |
|
| init_hist(size) |
void init_hist(int size) |
| int size; |
|
| { |
{ |
| char *itoa(); |
char *itoa(); |
| |
|
|
|
| set_var ("history", itoa (HistorySize)); |
set_var ("history", itoa (HistorySize)); |
| } |
} |
| |
|
| char * |
char * itoa (int i) |
| itoa (i) |
|
| int i; |
|
| { |
{ |
| static char buf[64]; |
static char buf[64]; |
| |
|
|
|
| return (buf); |
return (buf); |
| } |
} |
| |
|
| addHistory(string) |
void addHistory(char *string) |
| char *string; |
|
| { |
{ |
| char *allocAndCopyThere(); |
char *allocAndCopyThere(); |
| char *prev; |
char *prev; |
| Line 85 addHistory(string) |
|
| Line 86 addHistory(string) |
|
| CurrentHist = TailOfHist; |
CurrentHist = TailOfHist; |
| } |
} |
| |
|
| void |
void resetCurrentHistory() |
| resetCurrentHistory() |
|
| { |
{ |
| CurrentHist = TailOfHist; |
CurrentHist = TailOfHist; |
| } |
} |
| |
|
| char * |
char * getHistory(int num) |
| getHistory(num) |
|
| int num; |
|
| { |
{ |
| if (HistorySize <= 0) |
if (HistorySize <= 0) |
| return (0); |
return (0); |
|
|
| } |
} |
| } |
} |
| |
|
| char * |
char * getCurrentHistory() |
| getCurrentHistory() |
|
| { |
{ |
| return (getHistory (CurrentHist)); |
return (getHistory (CurrentHist)); |
| } |
} |
| |
|
| char * |
char * getPreviousHistory() |
| getPreviousHistory() |
|
| { |
{ |
| if (HistorySize <= 0) |
if (HistorySize <= 0) |
| return (0); |
return (0); |
| Line 128 getPreviousHistory() |
|
| Line 124 getPreviousHistory() |
|
| return (getCurrentHistory ()); |
return (getCurrentHistory ()); |
| } |
} |
| |
|
| char * |
char * getNextHistory() |
| getNextHistory() |
|
| { |
{ |
| |
|
| if (HistorySize <= 0) |
if (HistorySize <= 0) |
| Line 142 getNextHistory() |
|
| Line 137 getNextHistory() |
|
| return (getCurrentHistory ()); |
return (getCurrentHistory ()); |
| } |
} |
| |
|
| getOldestHistNum() |
int getOldestHistNum() |
| { |
{ |
| |
|
| return (TopOfHist); |
return (TopOfHist); |
| } |
} |
| |
|
| getYoungestHistNum() |
int getYoungestHistNum() |
| { |
{ |
| |
|
| return (TailOfHist-1); |
return (TailOfHist-1); |
| } |
} |
| |
|
| char * |
char * getOldestHistory() |
| getOldestHistory() |
|
| { |
{ |
| register char *cp; |
register char *cp; |
| |
|
| Line 166 getOldestHistory() |
|
| Line 160 getOldestHistory() |
|
| return (cp ? cp : ""); |
return (cp ? cp : ""); |
| } |
} |
| |
|
| char * |
char * getYoungestHistory() |
| getYoungestHistory() |
|
| { |
{ |
| register char *cp; |
register char *cp; |
| |
|
| Line 178 getYoungestHistory() |
|
| Line 171 getYoungestHistory() |
|
| return (cp ? cp : ""); |
return (cp ? cp : ""); |
| } |
} |
| |
|
| getCurrentHistNum() |
int getCurrentHistNum() |
| { |
{ |
| return (CurrentHist); |
return (CurrentHist); |
| } |
} |
| |
|
| char * |
char * allocAndCopyThere(char *string) |
| allocAndCopyThere(string) |
|
| char *string; |
|
| { |
{ |
| register char *cp; |
register char *cp; |
| |
|
| Line 198 allocAndCopyThere(string) |
|
| Line 189 allocAndCopyThere(string) |
|
| return(cp); |
return(cp); |
| } |
} |
| |
|
| char * |
char * historyExtract(char *string) |
| historyExtract(string) |
|
| char *string; |
|
| { |
{ |
| char *search_reverse_history(); |
char *search_reverse_history(); |
| |
|
| Line 272 historyExtract(string) |
|
| Line 261 historyExtract(string) |
|
| return ((char *) 0); |
return ((char *) 0); |
| } |
} |
| |
|
| char * |
char * search_reverse_history (char *string) |
| search_reverse_history (string) |
|
| char *string; |
|
| { |
{ |
| register int i; |
register int i; |
| char *re_comp(); |
|
| |
|
| if (string != NULL) { |
if (string != NULL) { |
| set_var ("search-string", string); |
set_var ("search-string", string); |
| Line 297 search_reverse_history (string) |
|
| Line 283 search_reverse_history (string) |
|
| return ((char *) 0); |
return ((char *) 0); |
| } |
} |
| |
|
| char * |
char * search_forward_history (char *string) |
| search_forward_history (string) |
|
| char *string; |
|
| { |
{ |
| register int i; |
register int i; |
| char *re_comp(); |
|
| |
|
| if (string != NULL) { |
if (string != NULL) { |
| if (re_comp(string) != (char *)0) |
if (re_comp(string) != (char *)0) |
| Line 324 search_forward_history (string) |
|
| Line 307 search_forward_history (string) |
|
| /* |
/* |
| * Change history table size. |
* Change history table size. |
| */ |
*/ |
| changeHistorySize(newsize) |
int changeHistorySize(int newsize) |
| int newsize; |
|
| { |
{ |
| char **newHistTable; |
char **newHistTable; |
| register int newTop, i; |
register int newTop, i; |
| Line 375 changeHistorySize(newsize) |
|
| Line 357 changeHistorySize(newsize) |
|
| /* |
/* |
| * Built-in function "fep-history" |
* Built-in function "fep-history" |
| */ |
*/ |
| fep_history (comline) |
void fep_history (char *comline) |
| char *comline; |
|
| { |
{ |
| int num; |
int num; |
| |
|
| Line 390 fep_history (comline) |
|
| Line 371 fep_history (comline) |
|
| hist_showHistory (num); |
hist_showHistory (num); |
| } |
} |
| |
|
| hist_showHistory (num) |
void hist_showHistory (int num) |
| int num; |
|
| { |
{ |
| register int from, to, i; |
register int from, to, i; |
| char *cp; |
char *cp; |
| Line 417 hist_showHistory (num) |
|
| Line 397 hist_showHistory (num) |
|
| } |
} |
| } |
} |
| |
|
| char * |
char * mk_home_relative (char *cp) |
| mk_home_relative (cp) |
|
| char *cp; |
|
| { |
{ |
| static char buf[256]; |
static char buf[256]; |
| |
|
| Line 438 mk_home_relative (cp) |
|
| Line 416 mk_home_relative (cp) |
|
| return (buf); |
return (buf); |
| } |
} |
| |
|
| fep_save_history (comline) |
void fep_save_history (char *comline) |
| char *comline; |
|
| { |
{ |
| char *file; |
char *file; |
| char **argp; |
char **argp; |
| Line 476 fep_save_history (comline) |
|
| Line 453 fep_save_history (comline) |
|
| |
|
| #define MAXSAVEHIST 512 |
#define MAXSAVEHIST 512 |
| |
|
| save_history (file, num) |
void save_history (char *file, int num) |
| char *file; |
|
| int num; |
|
| { |
{ |
| int old, new; |
int old, new; |
| FILE *fp, *fopen(); |
FILE *fp, *fopen(); |
| Line 513 save_history (file, num) |
|
| Line 488 save_history (file, num) |
|
| return; |
return; |
| } |
} |
| |
|
| fep_read_history (comline) |
void fep_read_history (char *comline) |
| char *comline; |
|
| { |
{ |
| char *file; |
char *file; |
| char **argp; |
char **argp; |
| Line 545 fep_read_history (comline) |
|
| Line 519 fep_read_history (comline) |
|
| read_history (file); |
read_history (file); |
| } |
} |
| |
|
| read_history (file) |
void read_history (char *file) |
| char *file; |
|
| { |
{ |
| FILE *fp; |
FILE *fp; |
| char line [MAXCMDLEN]; |
char line [MAXCMDLEN]; |