~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to pico/file.c

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2008-09-23 12:17:56 UTC
  • mfrom: (2.1.8 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080923121756-6u4x8bwq89qlzt32
Tags: 2.00+dfsg-2
Update to package description: note that Alpine is no longer in
alpha. (Closes: #499640)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#if     !defined(lint) && !defined(DOS)
2
 
static char rcsid[] = "$Id: file.c 848 2007-12-06 19:57:49Z hubert@u.washington.edu $";
 
2
static char rcsid[] = "$Id: file.c 1080 2008-06-11 17:21:24Z hubert@u.washington.edu $";
3
3
#endif
4
4
 
5
5
/*
212
212
                    dir[0] = '\0';
213
213
                    fn = file_split(dir, sizeof(dir), fname, 0);
214
214
 
215
 
                    if(!pico_fncomplete(dir, sizeof(dir), fn, sizeof(fname)-(fn-fname)))
 
215
                    if(!pico_fncomplete(dir, fn, sizeof(fname)-(fn-fname)))
216
216
                      (*term.t_beep)();
217
217
                }
218
218
 
650
650
                        dir[sizeof(dir)-1] = '\0';
651
651
                    }
652
652
 
653
 
                    if(!pico_fncomplete(dir, sizeof(dir), fn, sizeof(fname)-(fn-fname)))
 
653
                    if(!pico_fncomplete(dir, fn, sizeof(fname)-(fn-fname)))
654
654
                      (*term.t_beep)();
655
655
                }
656
656
 
1004
1004
 * pico_fncomplete - pico's function to complete the given file name
1005
1005
 */
1006
1006
int
1007
 
pico_fncomplete(char *dir, size_t dirlen, char *fn, size_t fnlen)
 
1007
pico_fncomplete(char *dirarg, char *fn, size_t fnlen)
1008
1008
{
1009
 
    char *p, *dlist, tmp[NLINE], dtmp[NLINE];
 
1009
    char *p, *dlist, tmp[NLINE], dir[NLINE];
1010
1010
    int   n, i, match = -1;
1011
1011
#ifdef  DOS
1012
1012
#define FILECMP(x, y)   (toupper((unsigned char)(x))\
1015
1015
#define FILECMP(x, y)   ((x) == (y))
1016
1016
#endif
1017
1017
 
1018
 
    strncpy(dtmp, dir, sizeof(dtmp));
1019
 
    dtmp[sizeof(dtmp)-1] = '\0';
1020
 
    pfnexpand(dir = dtmp, sizeof(dtmp));
 
1018
    strncpy(dir, dirarg, sizeof(dir));
 
1019
    dir[sizeof(dir)-1] = '\0';
 
1020
    pfnexpand(dir, sizeof(dir));
1021
1021
    if(*fn && (dlist = p = getfnames(dir, fn, &n, NULL, 0))){
1022
1022
        memset(tmp, 0, sizeof(tmp));
1023
1023
        while(n--){                     /* any names in it */
1049
1049
        strncpy(fn, tmp, fnlen);
1050
1050
        fn[fnlen-1] = '\0';
1051
1051
        if(match == 1){
1052
 
          if ((strlen(dir)+strlen(S_FILESEP)+strlen(fn)) < dirlen){
1053
 
            strncat(dir, S_FILESEP, dirlen-strlen(dir)-1);
1054
 
            dir[dirlen-1] = '\0';
1055
 
            strncat(dir, fn, dirlen-strlen(dir)-1);
1056
 
            dir[dirlen-1] = '\0';
 
1052
          if ((strlen(dir)+strlen(S_FILESEP)+strlen(fn)) < sizeof(dir)){
 
1053
            strncat(dir, S_FILESEP, sizeof(dir)-strlen(dir)-1);
 
1054
            dir[sizeof(dir)-1] = '\0';
 
1055
            strncat(dir, fn, sizeof(dir)-strlen(dir)-1);
 
1056
            dir[sizeof(dir)-1] = '\0';
1057
1057
            if(isdir(dir, NULL, NULL)){
1058
1058
                strncat(fn, S_FILESEP, fnlen-strlen(fn)-1);
1059
1059
                fn[fnlen-1] = '\0';