Mercurial > hg > toybox
annotate toys/posix/dirname.c @ 1665:5d003cc2fa16 draft
Lift the basename/libgen.h shenanigans back out of portability.c and make it a static inline in portability.h, and prototype dirname() while we're at it.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 18 Jan 2015 13:44:24 -0600 |
parents | aafd2f28245a |
children |
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:
653
diff
changeset
|
1 /* dirname.c - show directory portion of path |
387
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 * |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 * Copyright 2011 Rob Landley <rob@landley.net> |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 * |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 * See http://opengroup.org/onlinepubs/9699919799/utilities/dirname.html |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 USE_DIRNAME(NEWTOY(dirname, "<1", TOYFLAG_USR|TOYFLAG_BIN)) |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 config DIRNAME |
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:
653
diff
changeset
|
10 bool "dirname" |
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:
653
diff
changeset
|
11 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:
653
diff
changeset
|
12 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:
653
diff
changeset
|
13 usage: dirname PATH |
387
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 |
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:
653
diff
changeset
|
15 Show directory portion of path. |
387
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
16 */ |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 #include "toys.h" |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 void dirname_main(void) |
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 { |
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:
653
diff
changeset
|
22 puts(dirname(*toys.optargs)); |
387
67b0ded3c56c
Add dirname, and typo fixes to wc header.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 } |