version 1.3, 2004/06/16 07:43:54 |
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__) || defined(__APPLE_CC__) |
#if defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__APPLE_CC__) || defined(__INTERIX) || defined(ANDROID) |
#include <regex.h> |
#include <regex.h> |
regex_t Re_pat; |
regex_t Re_pat; |
#define re_comp(p) (regcomp(&Re_pat,(p), REG_EXTENDED|REG_NOSUB)) |
#define re_comp(p) (regcomp(&Re_pat,(p), REG_EXTENDED|REG_NOSUB)) |
Line 36 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 89 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 132 getPreviousHistory() |
|
Line 124 getPreviousHistory() |
|
return (getCurrentHistory ()); |
return (getCurrentHistory ()); |
} |
} |
|
|
char * |
char * getNextHistory() |
getNextHistory() |
|
{ |
{ |
|
|
if (HistorySize <= 0) |
if (HistorySize <= 0) |
Line 146 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 170 getOldestHistory() |
|
Line 160 getOldestHistory() |
|
return (cp ? cp : ""); |
return (cp ? cp : ""); |
} |
} |
|
|
char * |
char * getYoungestHistory() |
getYoungestHistory() |
|
{ |
{ |
register char *cp; |
register char *cp; |
|
|
Line 182 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 202 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 276 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; |
|
|
Line 300 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; |
|
|
Line 326 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 377 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 392 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 419 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 440 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 478 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 515 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 547 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]; |