Mercurial > vim
comparison src/misc1.c @ 2487:7ec9ada2cd81 vim73
Make :find completion consistent between Unix and MS-Windows. Add a test.
(Nazri Ramliy)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 04 Aug 2010 17:07:20 +0200 |
parents | 734196b073e0 |
children | a847363bf06e |
comparison
equal
deleted
inserted
replaced
2486:075efa5e166d | 2487:7ec9ada2cd81 |
---|---|
9319 char_u *buf; | 9319 char_u *buf; |
9320 char_u *p; | 9320 char_u *p; |
9321 | 9321 |
9322 ga_init2(gap, (int)sizeof(char_u *), 1); | 9322 ga_init2(gap, (int)sizeof(char_u *), 1); |
9323 | 9323 |
9324 if ((buf = alloc((int)(MAXPATHL))) == NULL) | 9324 if ((buf = alloc((int)MAXPATHL)) == NULL) |
9325 return; | 9325 return; |
9326 | 9326 |
9327 while (*path_option != NUL) | 9327 while (*path_option != NUL) |
9328 { | 9328 { |
9329 copy_option_part(&path_option, buf, MAXPATHL, " ,"); | 9329 copy_option_part(&path_option, buf, MAXPATHL, " ,"); |
9562 remove_duplicates(gap); | 9562 remove_duplicates(gap); |
9563 } | 9563 } |
9564 } | 9564 } |
9565 | 9565 |
9566 /* | 9566 /* |
9567 * Calls globpath() or mch_expandpath() with 'path' values for the given | 9567 * Calls globpath() with 'path' values for the given pattern and stores the |
9568 * pattern and stores the result in gap. | 9568 * result in "gap". |
9569 * Returns the total number of matches. | 9569 * Returns the total number of matches. |
9570 */ | 9570 */ |
9571 static int | 9571 static int |
9572 expand_in_path(gap, pattern, flags) | 9572 expand_in_path(gap, pattern, flags) |
9573 garray_T *gap; | 9573 garray_T *gap; |
9574 char_u *pattern; | 9574 char_u *pattern; |
9575 int flags; /* EW_* flags */ | 9575 int flags; /* EW_* flags */ |
9576 { | 9576 { |
9577 char_u **path_list; | |
9578 char_u *curdir; | 9577 char_u *curdir; |
9579 garray_T path_ga; | 9578 garray_T path_ga; |
9580 int i; | |
9581 # ifdef WIN3264 | |
9582 char_u *file_pattern; | |
9583 # else | |
9584 char_u *files = NULL; | 9579 char_u *files = NULL; |
9585 char_u *s; /* start */ | 9580 char_u *s; /* start */ |
9586 char_u *e; /* end */ | 9581 char_u *e; /* end */ |
9587 char_u *paths = NULL; | 9582 char_u *paths = NULL; |
9588 # endif | |
9589 | 9583 |
9590 if ((curdir = alloc((unsigned)MAXPATHL)) == NULL) | 9584 if ((curdir = alloc((unsigned)MAXPATHL)) == NULL) |
9591 return 0; | 9585 return 0; |
9592 mch_dirname(curdir, MAXPATHL); | 9586 mch_dirname(curdir, MAXPATHL); |
9593 | 9587 |
9594 expand_path_option(curdir, &path_ga); | 9588 expand_path_option(curdir, &path_ga); |
9595 vim_free(curdir); | 9589 vim_free(curdir); |
9596 if (path_ga.ga_len == 0) | 9590 if (path_ga.ga_len == 0) |
9597 return 0; | 9591 return 0; |
9598 path_list = (char_u **)(path_ga.ga_data); | 9592 |
9599 # ifdef WIN3264 | 9593 paths = ga_concat_strings(&path_ga); |
9600 if ((file_pattern = alloc((unsigned)MAXPATHL)) == NULL) | 9594 ga_clear_strings(&path_ga); |
9595 if (paths == NULL) | |
9601 return 0; | 9596 return 0; |
9602 for (i = 0; i < path_ga.ga_len; i++) | |
9603 { | |
9604 if (STRLEN(path_list[i]) + STRLEN(pattern) + 2 > MAXPATHL) | |
9605 continue; | |
9606 STRCPY(file_pattern, path_list[i]); | |
9607 STRCAT(file_pattern, "/"); | |
9608 STRCAT(file_pattern, pattern); | |
9609 mch_expandpath(gap, file_pattern, EW_DIR|EW_ADDSLASH|EW_FILE); | |
9610 } | |
9611 vim_free(file_pattern); | |
9612 # else | |
9613 for (i = 0; i < path_ga.ga_len; i++) | |
9614 { | |
9615 if (paths == NULL) | |
9616 { | |
9617 if ((paths = alloc((unsigned)(STRLEN(path_list[i]) + 1))) == NULL) | |
9618 return 0; | |
9619 STRCPY(paths, path_list[i]); | |
9620 } | |
9621 else | |
9622 { | |
9623 if ((paths = realloc(paths, (int)(STRLEN(paths) | |
9624 + STRLEN(path_list[i]) + 2))) == NULL) | |
9625 return 0; | |
9626 STRCAT(paths, ","); | |
9627 STRCAT(paths, path_list[i]); | |
9628 } | |
9629 } | |
9630 | 9597 |
9631 files = globpath(paths, pattern, 0); | 9598 files = globpath(paths, pattern, 0); |
9632 vim_free(paths); | 9599 vim_free(paths); |
9633 | |
9634 if (files == NULL) | 9600 if (files == NULL) |
9635 return 0; | 9601 return 0; |
9636 | 9602 |
9637 /* Copy each path in files into gap */ | 9603 /* Copy each path in files into gap */ |
9638 s = e = files; | 9604 s = e = files; |
9652 addfile(gap, s, flags); | 9618 addfile(gap, s, flags); |
9653 e++; | 9619 e++; |
9654 s = e; | 9620 s = e; |
9655 } | 9621 } |
9656 } | 9622 } |
9657 | |
9658 vim_free(files); | 9623 vim_free(files); |
9659 # endif | |
9660 | 9624 |
9661 return gap->ga_len; | 9625 return gap->ga_len; |
9662 } | 9626 } |
9663 #endif | 9627 #endif |
9664 | 9628 |
9795 */ | 9759 */ |
9796 if (mch_has_exp_wildcard(p)) | 9760 if (mch_has_exp_wildcard(p)) |
9797 { | 9761 { |
9798 #if defined(FEAT_SEARCHPATH) | 9762 #if defined(FEAT_SEARCHPATH) |
9799 if (*p != '.' && !vim_ispathsep(*p) && (flags & EW_PATH)) | 9763 if (*p != '.' && !vim_ispathsep(*p) && (flags & EW_PATH)) |
9764 { | |
9765 /* recursiveness is OK here */ | |
9766 recursive = FALSE; | |
9800 add_pat = expand_in_path(&ga, p, flags); | 9767 add_pat = expand_in_path(&ga, p, flags); |
9768 recursive = TRUE; | |
9769 } | |
9801 else | 9770 else |
9802 #endif | 9771 #endif |
9803 add_pat = mch_expandpath(&ga, p, flags); | 9772 add_pat = mch_expandpath(&ga, p, flags); |
9804 } | 9773 } |
9805 } | 9774 } |