annotate toys/other/realpath.c @ 694:786841fdb1e0

Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
author Rob Landley <rob@landley.net>
date Tue, 13 Nov 2012 17:14:08 -0600
parents 6df4ccc0acbe
children 6cc69be43c42
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
1 /* realpath.c - Return the canonical version of a pathname
469
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 *
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 * Copyright 2012 Andre Renaud <andre@bluewatersys.com>
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 USE_REALPATH(NEWTOY(realpath, "<1", TOYFLAG_USR|TOYFLAG_BIN))
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 config REALPATH
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
8 bool "realpath"
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
9 default y
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
10 help
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
11 usage: realpath FILE...
470
7d4dbde67dfb Move realpath from loopfiles() to a for loop, so we don't get hung on read permission for file data when we just want to look at directory info.
Rob Landley <rob@landley.net>
parents: 469
diff changeset
12
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
13 Display the canonical absolute pathname
469
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 */
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
15
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 #include "toys.h"
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
17
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 void realpath_main(void)
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
20 char **s = toys.optargs;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
21
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
22 for (s = toys.optargs; *s; s++) {
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
23 if (!realpath(*s, toybuf)) {
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
24 perror_msg("cannot access '%s'", *s);
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
25 toys.exitval = 1;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
26 } else xputs(toybuf);
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
27 }
469
6378ca1da18e Realpath, by Andre Renaud.
Rob Landley <rob@landley.net>
parents:
diff changeset
28 }