4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
33 #define isdot(x) ((x[0] == '.') && (!x[1] || (x[1] == '/')))
34 #define isdotdot(x) ((x[0] == '.') && (x[1] == '.') && \
35 (!x[2] || (x[2] == '/')))
43 /* remove references such as "./" and "../" and "//" */
44 for (pt
= file
; *pt
; /* void */) {
46 (void) strcpy(pt
, pt
[1] ? pt
+2 : pt
+1);
47 else if (isdotdot(pt
)) {
55 } while (isdotdot(last
));
56 --pt
; /* point to previous '/' */
60 while ((*--pt
!= '/') && (pt
> file
))
65 (void) strcpy(pt
, last
);
67 while (*pt
&& (*pt
!= '/'))
71 (void) strcpy(pt
, pt
+1);
76 if ((--pt
> file
) && (*pt
== '/'))
81 canonize_slashes(char *file
)
85 /* remove references such as "//" */
86 for (pt
= file
; *pt
; /* void */) {
87 while (*pt
&& (*pt
!= '/'))
91 (void) strcpy(pt
, pt
+1);
95 if ((--pt
> file
) && (*pt
== '/'))