- flag = TFOLDER;
- }
-
- if (*name == '/'
- || (flag == TFOLDER
- && (strncmp (name, CWD, NCWD)
- && strcmp (name, DOT)
- && strcmp (name, DOTDOT)
- && strncmp (name, PWD, NPWD))))
- return getcpy (name);
-
- if (pwds == NULL)
- pwds = pwd ();
-
- if (strcmp (name, DOT) == 0 || strcmp (name, CWD) == 0)
- return getcpy (pwds);
-
- ep = pwds + strlen (pwds);
- if ((cp = strrchr(pwds, '/')) == NULL)
- cp = ep;
- else
- if (cp == pwds)
- cp++;
-
- if (strncmp (name, CWD, NCWD) == 0)
- name += NCWD;
-
- if (strcmp (name, DOTDOT) == 0 || strcmp (name, PWD) == 0) {
- snprintf (buffer, sizeof(buffer), "%.*s", cp - pwds, pwds);
- return getcpy (buffer);
- }
-
- if (strncmp (name, PWD, NPWD) == 0)
- name += NPWD;
- else
- cp = ep;
-
- snprintf (buffer, sizeof(buffer), "%.*s/%s", cp - pwds, pwds, name);
- return getcpy (buffer);
+
+ ep = pwds + strlen(pwds);
+ if ((cp = strrchr(pwds, '/')) == NULL) {
+ cp = ep;
+ } else if (cp == pwds) {
+ cp++;
+ }
+
+ if (strncmp(name, "./", 2) == 0) {
+ name += 2;
+ }
+
+ if (strcmp(name, "..") == 0 || strcmp(name, "../") == 0) {
+ snprintf(buffer, sizeof(buffer), "%.*s",
+ (int)(cp - pwds), pwds);
+ return getcpy(buffer);
+ }
+
+ if (strncmp(name, "../", 3) == 0) {
+ name += 3;
+ } else {
+ cp = ep;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%.*s/%s",
+ (int)(cp - pwds), pwds, name);
+ return getcpy(buffer);