1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 /* All Rights Reserved */ 24 25 26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8.2.1 */ 27 /* 28 * UNIX shell 29 */ 30 31 #include "defs.h" 32 33 34 /* ======== general purpose string handling ======== */ 35 36 37 unsigned char * 38 movstr(a, b) 39 register unsigned char *a, *b; 40 { 41 while (*b++ = *a++); 42 return(--b); 43 } 44 45 any(c, s) 46 wchar_t c; 47 unsigned char *s; 48 { 49 register unsigned int d; 50 51 while (d = *s++) 52 { 53 if (d == c) 54 return(TRUE); 55 } 56 return(FALSE); 57 } 58 59 int anys(c, s) 60 unsigned char *c, *s; 61 { 62 wchar_t f, e; 63 register wchar_t d; 64 register int n; 65 if((n = mbtowc(&f, (char *)c, MULTI_BYTE_MAX)) <= 0) 66 return(FALSE); 67 d = f; 68 while(1) { 69 if((n = mbtowc(&e, (char *)s, MULTI_BYTE_MAX)) <= 0) 70 return(FALSE); 71 if(d == e) 72 return(TRUE); 73 s += n; 74 } 75 } 76 77 int cf(s1, s2) 78 register unsigned char *s1, *s2; 79 { 80 while (*s1++ == *s2) 81 if (*s2++ == 0) 82 return(0); 83 return(*--s1 - *s2); 84 } 85 86 int length(as) 87 unsigned char *as; 88 { 89 register unsigned char *s; 90 91 if (s = as) 92 while (*s++); 93 return(s - as); 94 } 95 96 unsigned char * 97 movstrn(a, b, n) 98 register unsigned char *a, *b; 99 register int n; 100 { 101 while ((n-- > 0) && *a) 102 *b++ = *a++; 103 104 return(b); 105 } 106