Files
makronix/xsrc/external/mit/imake/dist/revpath.c
T
lotherkandClaude Opus 5.5 c1c0713359 xsrc: import NetBSD xsrc 99aacae30 raw (no .git), its commit in xsrc/BASE
X is the base's again (Konrad, 2026-11-13): the X from pkgsrc in the
makronix set did not start anywhere (no input driver, no keymap, no
"fixed" font; dtlogin "The X-server can not be started on display :0").
Same commit as before the removal in e7bd6d940 (PINS then).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:13:37 +00:00

47 lines
873 B
C

/*
* Copyright 1999 by The XFree86 Project, Inc.
*/
/*
* Reverse a pathname. It returns a relative path that can be used to undo
* 'cd argv[1]'.
*
* It is impossible to do this in general, but this handles the cases that
* come up in imake. Maybe imake should use an absolute path for $(TOP)
* instead of a relative path so that this problem can be avoided?
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
int levels = 0;
char *p;
/* Silently ignore invalid usage */
if (argc != 2)
exit(0);
/* Split the path and count the levels */
p = strtok(argv[1], "/");
while (p) {
if (strcmp(p, ".") == 0)
;
else if (strcmp(p, "..") == 0)
levels--;
else
levels++;
p = strtok(NULL, "/");
}
while (levels-- > 0)
printf("../");
printf("\n");
exit(0);
}