328 skipped lines |
|
330 | | 330 | | // End SString functions |
|
|
| | 332 | | bool PropSet::caseSensitiveFilenames = false; |
| | 333 | | |
332 | | 334 | | PropSet::PropSet() { |
|
|
334 | | 336 | | for (int root = 0; root < hashRoots; root++) |
|
124 skipped lines |
459 | | 461 | | VarChain(const char*var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {} |
|
|
461 | | 463 | | bool contains(const char *testVar) const { |
|
462 | | return (var && (0 == strcmp(var, testVar))) | | 464 | | return (var && (0 == strcmp(var, testVar))) |
463 | | 465 | | || (link && link->contains(testVar)); |
|
|
|
70 skipped lines |
|
|
|
539 | | static bool IsSuffixCaseInsensitive(const char *target, const char *suffix) { | | 541 | | static bool IsSuffix(const char *target, const char *suffix, bool caseSensitive) { |
540 | | 542 | | size_t lentarget = strlen(target); |
|
541 | | 543 | | size_t lensuffix = strlen(suffix); |
|
542 | | 544 | | if (lensuffix > lentarget) |
|
|
| | 546 | | if (caseSensitive) { |
| | 547 | | for (int i = static_cast<int>(lensuffix) - 1; i >= 0; i--) { |
| | 548 | | if (target[i + lentarget - lensuffix] != suffix[i]) |
| | 549 | | return false; |
| | 550 | | } |
| | 551 | | } else { |
544 | | 552 | | for (int i = static_cast<int>(lensuffix) - 1; i >= 0; i--) { |
|
545 | | 553 | | if (MakeUpperCase(target[i + lentarget - lensuffix]) != |
|
546 | | 554 | | MakeUpperCase(suffix[i])) |
|
|
|
| | 557 | | } |
|
|
|
25 skipped lines |
577 | | 586 | | char delchr = *del; |
|
|
579 | | 588 | | if (*keyfile == '*') { |
|
580 | | if (IsSuffixCaseInsensitive(filename, keyfile + 1)) { | | 589 | | if (IsSuffix(filename, keyfile + 1, caseSensitiveFilenames)) { |
|
|
|
206 skipped lines |
|
|
|
| | 802 | | sortedNoCase = false; |
|
|
795 | | 805 | | void WordList::Set(const char *s) { |
|
796 | | 806 | | list = StringDup(s); |
|
|
| | 808 | | sortedNoCase = false; |
798 | | 809 | | words = ArrayFromWordList(list, &len, onlyLineEnds); |
|
799 | | 810 | | wordsNoCase = new char * [len + 1]; |
|
800 | | 811 | | memcpy(wordsNoCase, words, (len + 1) * sizeof (*words)); |
|
7 skipped lines |
|
809 | | 820 | | void WordList::SetFromAllocated() { |
|
|
| | 822 | | sortedNoCase = false; |
811 | | 823 | | words = ArrayFromWordList(list, &len, onlyLineEnds); |
|
812 | | 824 | | wordsNoCase = new char * [len + 1]; |
|
813 | | 825 | | memcpy(wordsNoCase, words, (len + 1) * sizeof (*words)); |
|
9 skipped lines |
823 | | 835 | | return CompareCaseInsensitive(*(char**)(a1), *(char**)(a2)); |
|
|
|
826 | | static void SortWordList(char **words, char **wordsNoCase, unsigned int len) { | | 838 | | static void SortWordList(char **words, unsigned int len) { |
827 | | 839 | | qsort(reinterpret_cast<void*>(words), len, sizeof(*words), |
|
|
| | 841 | | } |
| | 842 | | |
| | 843 | | static void SortWordListNoCase(char **wordsNoCase, unsigned int len) { |
829 | | 844 | | qsort(reinterpret_cast<void*>(wordsNoCase), len, sizeof(*wordsNoCase), |
|
830 | | 845 | | cmpStringNoCase); |
|
|
3 skipped lines |
|
|
|
838 | | SortWordList(words, wordsNoCase, len); | | 853 | | SortWordList(words, len); |
839 | | 854 | | for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++) |
|
|
841 | | 856 | | for (int l = len - 1; l >= 0; l--) { |
|
35 skipped lines |
|
|
|
| | 895 | | /** similar to InList, but word s can be a substring of keyword. |
| | 896 | | * eg. the keyword define is defined as def~ine. This means the word must start |
| | 897 | | * with def to be a keyword, but also defi, defin and define are valid. |
| | 898 | | * The marker is ~ in this case. |
| | 899 | | */ |
52 skipped lines |
| | 952 | | } |
| | 953 | | } |
| | 954 | | return false; |
| | 955 | | } |
| | 956 | | |
|
881 | | 958 | | * Returns an element (complete) of the wordlist array which has |
|
882 | | 959 | | * the same beginning as the passed string. |
|
9 skipped lines |
|
|
|
895 | | if (!sorted) { | | |
896 | | sorted = true; | | |
897 | | SortWordList(words, wordsNoCase, len); | | |
898 | | } | | |
899 | | 972 | | if (ignoreCase) { |
|
| | 973 | | if (!sortedNoCase) { |
| | 974 | | sortedNoCase = true; |
| | 975 | | SortWordListNoCase(wordsNoCase, len); |
| | 976 | | } |
900 | | 977 | | while (start <= end) { // binary searching loop |
|
901 | | 978 | | pivot = (start + end) >> 1; |
|
902 | | 979 | | word = wordsNoCase[pivot]; |
|
9 skipped lines |
912 | | 989 | | while (end < len-1 && !CompareNCaseInsensitive(wordStart, wordsNoCase[end+1], searchLen)) { |
|
|
|
915 | | | | 992 | | |
916 | | 993 | | // Finds first word in a series of equal words |
|
917 | | 994 | | for (pivot = start; pivot <= end; pivot++) { |
|
918 | | 995 | | word = wordsNoCase[pivot]; |
|
11 skipped lines |
930 | | 1007 | | end = pivot - 1; |
|
|
932 | | 1009 | | } else { // preserve the letter case |
|
| | 1010 | | if (!sorted) { |
| | 1011 | | sorted = true; |
| | 1012 | | SortWordList(words, len); |
| | 1013 | | } |
933 | | 1014 | | while (start <= end) { // binary searching loop |
|
934 | | 1015 | | pivot = (start + end) >> 1; |
|
935 | | 1016 | | word = words[pivot]; |
|
9 skipped lines |
945 | | 1026 | | while (end < len-1 && !strncmp(wordStart, words[end+1], searchLen)) { |
|
|
|
948 | | | | 1029 | | |
949 | | 1030 | | // Finds first word in a series of equal words |
|
|
951 | | 1032 | | while (pivot <= end) { |
|
68 skipped lines |
|
1021 | | 1102 | | if (0 == words) |
|
|
1023 | | if (!sorted) { | | |
1024 | | sorted = true; | | |
1025 | | SortWordList(words, wordsNoCase, len); | | |
1026 | | } | | |
1027 | | 1104 | | if (ignoreCase) { |
|
| | 1105 | | if (!sortedNoCase) { |
| | 1106 | | sortedNoCase = true; |
| | 1107 | | SortWordListNoCase(wordsNoCase, len); |
| | 1108 | | } |
1028 | | 1109 | | while (start <= end) { // Binary searching loop |
|
1029 | | 1110 | | pivot = (start + end) / 2; |
|
1030 | | 1111 | | cond = CompareNCaseInsensitive(wordStart, wordsNoCase[pivot], searchLen); |
|
22 skipped lines |
|
|
1055 | | 1136 | | } else {// Preserve the letter case |
|
| | 1137 | | if (!sorted) { |
| | 1138 | | sorted = true; |
| | 1139 | | SortWordList(words, len); |
| | 1140 | | } |
1056 | | 1141 | | while (start <= end) { // Binary searching loop |
|
1057 | | 1142 | | pivot = (start + end) / 2; |
|
1058 | | 1143 | | cond = strncmp(wordStart, words[pivot], searchLen); |
|
28 skipped lines |