X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=utils%2Fdirname%2Fdirname.c;fp=utils%2Fdirname%2Fdirname.c;h=0000000000000000000000000000000000000000;hb=4476699b7c7de3abf9f6da71ed409b2c032dc50f;hp=c490a56bf37fe9cfce403abf1867bbb4fc08b0d6;hpb=2e838897cc574a9147bcf0b1681aeeaa44001fce;p=pdutils diff --git a/utils/dirname/dirname.c b/utils/dirname/dirname.c deleted file mode 100644 index c490a56..0000000 --- a/utils/dirname/dirname.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * dirname.c - return the directory portion of a pathname - * - * Version: 2008-1.01 - * Build: c89 -o dirname dirname.c - * Source: - * Spec: - * - * This is free and unencumbered software released into the public domain, - * provided "as is", without warranty of any kind, express or implied. See the - * file UNLICENSE and the website for further details. - */ - - -#define _POSIX_SOURCE - -#include -#include - -#define USAGE "usage: dirname string\n" - - -int main(int argc, char **argv) -{ - char *head, *tail; - - setlocale (LC_ALL, ""); - - if (argc != 2) - { - fprintf(stderr, USAGE); - return(1); - } - - head = tail = argv[1]; - while (*tail) - tail++; - - while (tail > head && tail[-1] == '/') - tail--; - while (tail > head && tail[-1] != '/') - tail--; - while (tail > head && tail[-1] == '/') - tail--; - - if (head == tail) - printf(*head == '/' ? "/\n" : ".\n"); - else - printf("%.*s\n", (tail - head), head); - - return(0); -}