diff options
author | Eduardo Chappa <chappa@washington.edu> | 2016-05-13 21:19:43 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2016-05-13 21:19:43 -0600 |
commit | dbb9b8a9c80985dec59650cc9b7a5ec638d4d19a (patch) | |
tree | c57cbd37f0e5931b726192caeddedf86339e6ad0 /pith | |
parent | 398178c265ff68ceeafa6a84089bc01ae949e314 (diff) | |
download | alpine-dbb9b8a9c80985dec59650cc9b7a5ec638d4d19a.tar.xz |
* Simplify some of the code for the new option for extra directories
for save of attachments or export of files.
Diffstat (limited to 'pith')
-rw-r--r-- | pith/hist.c | 44 | ||||
-rw-r--r-- | pith/hist.h | 2 |
2 files changed, 3 insertions, 43 deletions
diff --git a/pith/hist.c b/pith/hist.c index 9d5022c9..0776305f 100644 --- a/pith/hist.c +++ b/pith/hist.c @@ -60,55 +60,17 @@ free_hist(HISTORY_S **history) char * hist_in_pos(int pos, char **list, int llen, HISTORY_S *hist, int n) { - char *p; - int i; - if(pos < 0 || pos > llen + n) return NULL; if(pos < llen) return list[pos]; - hist->curindex = hist->origindex; /* reset history */ - for(i = 0; i < n-1; i++) - p = get_prev_hist_dir(hist); - p = get_prev_hist_dir(hist); - for(i = 0; i < pos - llen; i++) - p = get_next_hist_dir(hist); - return p; -} - - -char * -get_next_hist_dir(HISTORY_S *history) -{ - return get_next_hist(history, NULL, 0, NULL); + hist->curindex = (hist->origindex + n - pos + llen) % hist->histsize; + return((hist->hist[hist->curindex] && hist->hist[hist->curindex]->str) + ? hist->hist[hist->curindex]->str : NULL); } - -char * -get_prev_hist_dir(HISTORY_S *history) -{ - int nextcurindex; - - if(!(history && history->histsize > 0)) - return NULL; - - nextcurindex = (history->curindex + 1) % history->histsize; - - /* already at start of history */ - if(nextcurindex == history->origindex - || !(history->hist[nextcurindex] && history->hist[nextcurindex]->str - && history->hist[nextcurindex]->str[0])) - return NULL; - - history->curindex = nextcurindex; - - return((history->hist[history->curindex] && history->hist[history->curindex]->str) - ? history->hist[history->curindex]->str : NULL); -} - - char * get_prev_hist(HISTORY_S *history, char *savethis, unsigned saveflags, void *cntxt) { diff --git a/pith/hist.h b/pith/hist.h index 65082998..d34961f9 100644 --- a/pith/hist.h +++ b/pith/hist.h @@ -43,8 +43,6 @@ void init_hist(HISTORY_S **, int); void free_hist(HISTORY_S **); char *get_prev_hist(HISTORY_S *, char *, unsigned, void *); char *get_next_hist(HISTORY_S *, char *, unsigned, void *); -char *get_prev_hist_dir(HISTORY_S *); -char *get_next_hist_dir(HISTORY_S *); char *hist_in_pos(int, char **, int, HISTORY_S *, int); void save_hist(HISTORY_S *, char *, unsigned, void *); int items_in_hist(HISTORY_S *); |