src/cline.c

changeset 97
7b0357fdb304
parent 95
8a20001544c1
equal deleted inserted replaced
96:eca455ac32c2 97:7b0357fdb304
110 if (arg[j] == badfs) { 110 if (arg[j] == badfs) {
111 arg[j] = fs; 111 arg[j] = fs;
112 } 112 }
113 } 113 }
114 /* make path absolute */ 114 /* make path absolute */
115 { 115 settings->excludeDirs->items[i] = make_path_absolute(arg);
116 char *ap = make_path_absolute(arg);
117 free(arg);
118 arg = ap;
119 arglen = strlen(ap);
120 }
121 /* make path canonical */
122 char *canonical = malloc(arglen+1);
123 size_t canonicallen = 0;
124 for (size_t j = 0 ; j < arglen ; j++) {
125 canonical[canonicallen++] = arg[j];
126 if (arg[j] == fs) {
127 /* collapse consecutive separators */
128 while (arg[j+1] == fs) j++;
129 } else if (arg[j] == '.') {
130 if (arg[j+1] == fs) {
131 /* skip '.' segments */
132 canonicallen--;
133 j++;
134 } else if (arg[j+1] == '.' && arg[j+2] == fs) {
135 /* trace back '..' segment */
136 canonicallen -= 2;
137 while (canonical[canonicallen-1] != fs) canonicallen--;
138 j+=2;
139 }
140 }
141 }
142 canonical[canonicallen] = '\0';
143 settings->excludeDirs->items[i] = canonical;
144 free(arg); 116 free(arg);
145 } 117 }
146 } 118 }
147 119
148 /* tell the string list to free the items */ 120 /* tell the string list to free the items */

mercurial