dirname.c (56bcbf00e27de12298bc3d6de9d6925b6f431145) | dirname.c (22626efa0f96cbca4edae882e46cb56b1879706b) |
---|---|
1/* 2 * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#if 0 29#ifndef lint 30static char rcsid[] = "$OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $"; 31#endif /* not lint */ 32#endif | 1/* 2 * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#if 0 29#ifndef lint 30static char rcsid[] = "$OpenBSD: dirname.c,v 1.4 1999/05/30 17:10:30 espie Exp $"; 31#endif /* not lint */ 32#endif |
33 | |
34#include <sys/cdefs.h> 35__FBSDID("$FreeBSD$"); 36 37#include <errno.h> 38#include <libgen.h> 39#include <string.h> 40#include <sys/param.h> 41 42char * 43dirname(path) 44 const char *path; 45{ 46 static char bname[MAXPATHLEN]; | 33#include <sys/cdefs.h> 34__FBSDID("$FreeBSD$"); 35 36#include <errno.h> 37#include <libgen.h> 38#include <string.h> 39#include <sys/param.h> 40 41char * 42dirname(path) 43 const char *path; 44{ 45 static char bname[MAXPATHLEN]; |
47 register const char *endp; | 46 const char *endp; |
48 49 /* Empty or NULL string gets treated as "." */ 50 if (path == NULL || *path == '\0') { 51 (void)strcpy(bname, "."); 52 return(bname); 53 } 54 55 /* Strip trailing slashes */ --- 26 unchanged lines hidden --- | 47 48 /* Empty or NULL string gets treated as "." */ 49 if (path == NULL || *path == '\0') { 50 (void)strcpy(bname, "."); 51 return(bname); 52 } 53 54 /* Strip trailing slashes */ --- 26 unchanged lines hidden --- |