expand.c revision db397771158a0b9b33b5ab2dee8593e03ee5e994
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1995 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* UNIX shell
*
*/
#include "defs.h"
#include <dirent.h>
/*
* globals (file name generation)
*
* "*" in params matches r.e ".*"
* "?" in params matches r.e. "."
* "[...]" in params matches character class
* "[...a-z...]" in params matches a through z.
*
*/
static void addg(unsigned char *, unsigned char *, unsigned char *,
unsigned char *);
int
{
int count;
unsigned char *rescan = 0;
unsigned char *slashsav = 0;
unsigned char *s, *cs;
unsigned char *s2 = 0;
int len;
return (0);
/*
* check for meta chars
*/
{
slash = 0;
open = 0;
do
{
len = 1;
}
switch (wc) {
case 0:
break;
else
return (0);
case '/':
slash++;
open = 0;
continue;
case '[':
open++;
continue;
case ']':
if (open == 0)
continue;
case '?':
case '*':
continue;
else
cs--;
break;
case '\\':
cs++;
default:
continue;
}
break;
} while (TRUE);
}
for (;;) {
if (cs == s) {
s = (unsigned char *)nullstr;
break;
} else if (*--cs == '/') {
*cs = 0;
if (s == cs)
s = (unsigned char *)"/";
else {
/*
* push trimmed copy of directory prefix
* onto stack
*/
s = s2;
}
break;
}
}
dir++;
/* Let s point to original string because it will be trimmed later */
if (s2)
s = as;
count = 0;
if (*cs == 0)
/* check for rescan */
if (dir) {
unsigned char *rs;
struct dirent *e;
do /* find next / in as */
{
if (*rs == '/') {
*rs = 0;
gchain = 0;
}
} while (*rs++);
continue;
slashsav);
count++;
}
}
if (rescan) {
if (count) {
count = 0;
while (rchain) {
slash + 1);
}
}
*rescan = '/';
}
}
if (slashsav)
*slashsav = '/';
return (count);
}
static void
unsigned char *as4)
{
int c;
int len;
if (as4) {
while (c = *s1++) {
*s2++ = c;
}
/*
* Restore first slash before the first metacharacter
* if as1 is not "/"
*/
*s2++ = '/';
}
}
/* add matched entries, plus extra \\ to escape \\'s */
for (;;) {
len = 1;
}
if (wc == 0) {
break;
}
if (wc == '\\') {
*s2++ = '\\';
*s2++ = '\\';
s1++;
continue;
}
}
*s2++ = '/';
do
{
}
}
}
void
{
}