comparison src/misc1.c @ 8724:e6d1608ca601 v7.4.1651

commit https://github.com/vim/vim/commit/780d4c3fff3c06baa3135a9f9739c56a0c280a94 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 25 17:21:19 2016 +0100 patch 7.4.1651 Problem: Some dead (MSDOS) code remains. Solution: Remove the unused lines. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Fri, 25 Mar 2016 17:30:12 +0100
parents 24b43dd167eb
children e600e696c0a1
comparison
equal deleted inserted replaced
8723:47ba605ff98f 8724:e6d1608ca601
9735 pstrcmp(const void *a, const void *b) 9735 pstrcmp(const void *a, const void *b)
9736 { 9736 {
9737 return (pathcmp(*(char **)a, *(char **)b, -1)); 9737 return (pathcmp(*(char **)a, *(char **)b, -1));
9738 } 9738 }
9739 9739
9740 # ifndef WIN3264
9741 static void
9742 namelowcpy(
9743 char_u *d,
9744 char_u *s)
9745 {
9746 while (*s)
9747 *d++ = TOLOWER_LOC(*s++);
9748 *d = NUL;
9749 }
9750 # endif
9751
9752 /* 9740 /*
9753 * Recursively expand one path component into all matching files and/or 9741 * Recursively expand one path component into all matching files and/or
9754 * directories. Adds matches to "gap". Handles "*", "?", "[a-z]", "**", etc. 9742 * directories. Adds matches to "gap". Handles "*", "?", "[a-z]", "**", etc.
9755 * Return the number of matches found. 9743 * Return the number of matches found.
9756 * "path" has backslashes before chars that are not to be expanded, starting 9744 * "path" has backslashes before chars that are not to be expanded, starting
9775 int starts_with_dot; 9763 int starts_with_dot;
9776 int matches; 9764 int matches;
9777 int len; 9765 int len;
9778 int starstar = FALSE; 9766 int starstar = FALSE;
9779 static int stardepth = 0; /* depth for "**" expansion */ 9767 static int stardepth = 0; /* depth for "**" expansion */
9780 #ifdef WIN3264
9781 WIN32_FIND_DATA fb; 9768 WIN32_FIND_DATA fb;
9782 HANDLE hFind = (HANDLE)0; 9769 HANDLE hFind = (HANDLE)0;
9783 # ifdef FEAT_MBYTE 9770 # ifdef FEAT_MBYTE
9784 WIN32_FIND_DATAW wfb; 9771 WIN32_FIND_DATAW wfb;
9785 WCHAR *wn = NULL; /* UCS-2 name, NULL when not used. */ 9772 WCHAR *wn = NULL; /* UCS-2 name, NULL when not used. */
9786 # endif 9773 # endif
9787 #else
9788 struct ffblk fb;
9789 #endif
9790 char_u *matchname; 9774 char_u *matchname;
9791 int ok; 9775 int ok;
9792 9776
9793 /* Expanding "**" may take a long time, check for CTRL-C. */ 9777 /* Expanding "**" may take a long time, check for CTRL-C. */
9794 if (stardepth > 0) 9778 if (stardepth > 0)
9825 s = p + 1; 9809 s = p + 1;
9826 } 9810 }
9827 else if (path_end >= path + wildoff 9811 else if (path_end >= path + wildoff
9828 && vim_strchr((char_u *)"*?[~", *path_end) != NULL) 9812 && vim_strchr((char_u *)"*?[~", *path_end) != NULL)
9829 e = p; 9813 e = p;
9830 #ifdef FEAT_MBYTE 9814 # ifdef FEAT_MBYTE
9831 if (has_mbyte) 9815 if (has_mbyte)
9832 { 9816 {
9833 len = (*mb_ptr2len)(path_end); 9817 len = (*mb_ptr2len)(path_end);
9834 STRNCPY(p, path_end, len); 9818 STRNCPY(p, path_end, len);
9835 p += len; 9819 p += len;
9836 path_end += len; 9820 path_end += len;
9837 } 9821 }
9838 else 9822 else
9839 #endif 9823 # endif
9840 *p++ = *path_end++; 9824 *p++ = *path_end++;
9841 } 9825 }
9842 e = p; 9826 e = p;
9843 *e = NUL; 9827 *e = NUL;
9844 9828
9895 --stardepth; 9879 --stardepth;
9896 } 9880 }
9897 9881
9898 /* Scan all files in the directory with "dir/ *.*" */ 9882 /* Scan all files in the directory with "dir/ *.*" */
9899 STRCPY(s, "*.*"); 9883 STRCPY(s, "*.*");
9900 #ifdef WIN3264
9901 # ifdef FEAT_MBYTE 9884 # ifdef FEAT_MBYTE
9902 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) 9885 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
9903 { 9886 {
9904 /* The active codepage differs from 'encoding'. Attempt using the 9887 /* The active codepage differs from 'encoding'. Attempt using the
9905 * wide function. If it fails because it is not implemented fall back 9888 * wide function. If it fails because it is not implemented fall back
9919 9902
9920 if (wn == NULL) 9903 if (wn == NULL)
9921 # endif 9904 # endif
9922 hFind = FindFirstFile((LPCSTR)buf, &fb); 9905 hFind = FindFirstFile((LPCSTR)buf, &fb);
9923 ok = (hFind != INVALID_HANDLE_VALUE); 9906 ok = (hFind != INVALID_HANDLE_VALUE);
9924 #else
9925 /* If we are expanding wildcards we try both files and directories */
9926 ok = (findfirst((char *)buf, &fb,
9927 (*path_end != NUL || (flags & EW_DIR)) ? FA_DIREC : 0) == 0);
9928 #endif
9929 9907
9930 while (ok) 9908 while (ok)
9931 { 9909 {
9932 #ifdef WIN3264
9933 # ifdef FEAT_MBYTE 9910 # ifdef FEAT_MBYTE
9934 if (wn != NULL) 9911 if (wn != NULL)
9935 p = utf16_to_enc(wfb.cFileName, NULL); /* p is allocated here */ 9912 p = utf16_to_enc(wfb.cFileName, NULL); /* p is allocated here */
9936 else 9913 else
9937 # endif 9914 # endif
9938 p = (char_u *)fb.cFileName; 9915 p = (char_u *)fb.cFileName;
9939 #else
9940 p = (char_u *)fb.ff_name;
9941 #endif
9942 /* Ignore entries starting with a dot, unless when asked for. Accept 9916 /* Ignore entries starting with a dot, unless when asked for. Accept
9943 * all entries found with "matchname". */ 9917 * all entries found with "matchname". */
9944 if ((p[0] != '.' || starts_with_dot 9918 if ((p[0] != '.' || starts_with_dot
9945 || ((flags & EW_DODOT) 9919 || ((flags & EW_DODOT)
9946 && p[1] != NUL && (p[1] != '.' || p[2] != NUL))) 9920 && p[1] != NUL && (p[1] != '.' || p[2] != NUL)))
9948 || (regmatch.regprog != NULL 9922 || (regmatch.regprog != NULL
9949 && vim_regexec(&regmatch, p, (colnr_T)0)) 9923 && vim_regexec(&regmatch, p, (colnr_T)0))
9950 || ((flags & EW_NOTWILD) 9924 || ((flags & EW_NOTWILD)
9951 && fnamencmp(path + (s - buf), p, e - s) == 0))) 9925 && fnamencmp(path + (s - buf), p, e - s) == 0)))
9952 { 9926 {
9953 #ifdef WIN3264
9954 STRCPY(s, p); 9927 STRCPY(s, p);
9955 #else
9956 namelowcpy(s, p);
9957 #endif
9958 len = (int)STRLEN(buf); 9928 len = (int)STRLEN(buf);
9959 9929
9960 if (starstar && stardepth < 100) 9930 if (starstar && stardepth < 100)
9961 { 9931 {
9962 /* For "**" in the pattern first go deeper in the tree to 9932 /* For "**" in the pattern first go deeper in the tree to
9984 if (mch_getperm(buf) >= 0) /* add existing file */ 9954 if (mch_getperm(buf) >= 0) /* add existing file */
9985 addfile(gap, buf, flags); 9955 addfile(gap, buf, flags);
9986 } 9956 }
9987 } 9957 }
9988 9958
9989 #ifdef WIN3264
9990 # ifdef FEAT_MBYTE 9959 # ifdef FEAT_MBYTE
9991 if (wn != NULL) 9960 if (wn != NULL)
9992 { 9961 {
9993 vim_free(p); 9962 vim_free(p);
9994 ok = FindNextFileW(hFind, &wfb); 9963 ok = FindNextFileW(hFind, &wfb);
9995 } 9964 }
9996 else 9965 else
9997 # endif 9966 # endif
9998 ok = FindNextFile(hFind, &fb); 9967 ok = FindNextFile(hFind, &fb);
9999 #else
10000 ok = (findnext(&fb) == 0);
10001 #endif
10002 9968
10003 /* If no more matches and no match was used, try expanding the name 9969 /* If no more matches and no match was used, try expanding the name
10004 * itself. Finds the long name of a short filename. */ 9970 * itself. Finds the long name of a short filename. */
10005 if (!ok && matchname != NULL && gap->ga_len == start_len) 9971 if (!ok && matchname != NULL && gap->ga_len == start_len)
10006 { 9972 {
10007 STRCPY(s, matchname); 9973 STRCPY(s, matchname);
10008 #ifdef WIN3264
10009 FindClose(hFind); 9974 FindClose(hFind);
10010 # ifdef FEAT_MBYTE 9975 # ifdef FEAT_MBYTE
10011 if (wn != NULL) 9976 if (wn != NULL)
10012 { 9977 {
10013 vim_free(wn); 9978 vim_free(wn);
10017 } 9982 }
10018 if (wn == NULL) 9983 if (wn == NULL)
10019 # endif 9984 # endif
10020 hFind = FindFirstFile((LPCSTR)buf, &fb); 9985 hFind = FindFirstFile((LPCSTR)buf, &fb);
10021 ok = (hFind != INVALID_HANDLE_VALUE); 9986 ok = (hFind != INVALID_HANDLE_VALUE);
10022 #else
10023 ok = (findfirst((char *)buf, &fb,
10024 (*path_end != NUL || (flags & EW_DIR)) ? FA_DIREC : 0) == 0);
10025 #endif
10026 vim_free(matchname); 9987 vim_free(matchname);
10027 matchname = NULL; 9988 matchname = NULL;
10028 } 9989 }
10029 } 9990 }
10030 9991
10031 #ifdef WIN3264
10032 FindClose(hFind); 9992 FindClose(hFind);
10033 # ifdef FEAT_MBYTE 9993 # ifdef FEAT_MBYTE
10034 vim_free(wn); 9994 vim_free(wn);
10035 # endif 9995 # endif
10036 #endif
10037 vim_free(buf); 9996 vim_free(buf);
10038 vim_regfree(regmatch.regprog); 9997 vim_regfree(regmatch.regprog);
10039 vim_free(matchname); 9998 vim_free(matchname);
10040 9999
10041 matches = gap->ga_len - start_len; 10000 matches = gap->ga_len - start_len;