8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sh / string.c
blobb9191be47a7d6706e45a3ee951e21617e41fb00b
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
24 * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
32 #pragma ident "%Z%%M% %I% %E% SMI"
34 * UNIX shell
37 #include "defs.h"
40 /* ======== general purpose string handling ======== */
43 unsigned char *
44 movstr(unsigned char *a, unsigned char *b)
46 while (*b++ = *a++);
47 return(--b);
50 int
51 any(wchar_t c, unsigned char *s)
53 unsigned int d;
55 while (d = *s++)
57 if (d == c)
58 return(TRUE);
60 return(FALSE);
63 int anys(c, s)
64 unsigned char *c, *s;
66 wchar_t f, e;
67 wchar_t d;
68 int n;
69 if((n = mbtowc(&f, (char *)c, MULTI_BYTE_MAX)) <= 0)
70 return(FALSE);
71 d = f;
72 while(1) {
73 if((n = mbtowc(&e, (char *)s, MULTI_BYTE_MAX)) <= 0)
74 return(FALSE);
75 if(d == e)
76 return(TRUE);
77 s += n;
81 int
82 cf(unsigned char *s1, unsigned char *s2)
84 while (*s1++ == *s2)
85 if (*s2++ == 0)
86 return(0);
87 return(*--s1 - *s2);
90 int length(as)
91 unsigned char *as;
93 unsigned char *s;
95 if (s = as)
96 while (*s++);
97 return(s - as);
100 unsigned char *
101 movstrn(unsigned char *a, unsigned char *b, int n)
103 while ((n-- > 0) && *a)
104 *b++ = *a++;
106 return(b);