From 6f82d0e8f9756938f04071892206a5af85e676f0 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Fri, 13 Jul 2012 17:49:56 +0000 Subject: This commit was manufactured by cvs2git to create tag 'eric_g2k12'. --- src/regress/lib/libc/basename/Makefile | 3 - src/regress/lib/libc/basename/basename_test.c | 79 --------------------------- 2 files changed, 82 deletions(-) delete mode 100644 src/regress/lib/libc/basename/Makefile delete mode 100644 src/regress/lib/libc/basename/basename_test.c (limited to 'src/regress/lib/libc/basename') diff --git a/src/regress/lib/libc/basename/Makefile b/src/regress/lib/libc/basename/Makefile deleted file mode 100644 index 958b06fd11..0000000000 --- a/src/regress/lib/libc/basename/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PROG=basename_test - -.include diff --git a/src/regress/lib/libc/basename/basename_test.c b/src/regress/lib/libc/basename/basename_test.c deleted file mode 100644 index 34e138c726..0000000000 --- a/src/regress/lib/libc/basename/basename_test.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2007 Bret S. Lambert - * - * Public domain. - */ - -#include - -#include -#include -#include -#include -#include - -int -main(void) -{ - char path[2 * MAXPATHLEN]; - const char *dir = "junk/"; - const char *fname = "file.name.ext"; - char *str; - int i; - - /* Test normal functioning */ - strlcpy(path, "/", sizeof(path)); - strlcat(path, dir, sizeof(path)); - strlcat(path, fname, sizeof(path)); - str = basename(path); - if (strcmp(str, fname) != 0) - goto fail; - - /* - * There are four states that require special handling: - * - * 1) path is NULL - * 2) path is the empty string - * 3) path is composed entirely of slashes - * 4) the resulting name is larger than MAXPATHLEN - * - * The first two cases require that a pointer - * to the string "." be returned. - * - * The third case requires that a pointer - * to the string "/" be returned. - * - * The final case requires that NULL be returned - * and errno * be set to ENAMETOOLONG. - */ - /* Case 1 */ - str = basename(NULL); - if (strcmp(str, ".") != 0) - goto fail; - - /* Case 2 */ - strlcpy(path, "", sizeof(path)); - str = basename(path); - if (strcmp(str, ".") != 0) - goto fail; - - /* Case 3 */ - for (i = 0; i < MAXPATHLEN - 1; i++) - strlcat(path, "/", sizeof(path)); /* path cleared above */ - str = basename(path); - if (strcmp(str, "/") != 0) - goto fail; - - /* Case 4 */ - strlcpy(path, "/", sizeof(path)); - strlcat(path, dir, sizeof(path)); - for (i = 0; i <= MAXPATHLEN; i += sizeof(fname)) - strlcat(path, fname, sizeof(path)); - str = basename(path); - if (str != NULL || errno != ENAMETOOLONG) - goto fail; - - return (0); -fail: - return (1); -} -- cgit v1.2.3-55-g6feb