mystring.c (b97fa2ef508bb1cc99621edb8b6d03845b55b8bd) | mystring.c (afb033d5c4f01a464f57fe8e68d741246d9df492) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 * |
36 * $Id$ | 36 * $Id: mystring.c,v 1.7 1997/02/22 13:58:38 peter Exp $ |
37 */ 38 39#ifndef lint 40static char const sccsid[] = "@(#)mystring.c 8.2 (Berkeley) 5/4/95"; 41#endif /* not lint */ 42 43/* 44 * String functions. --- 26 unchanged lines hidden (view full) --- 71/* 72 * scopyn - copy a string from "from" to "to", truncating the string 73 * if necessary. "To" is always nul terminated, even if 74 * truncation is performed. "Size" is the size of "to". 75 */ 76 77void 78scopyn(from, to, size) | 37 */ 38 39#ifndef lint 40static char const sccsid[] = "@(#)mystring.c 8.2 (Berkeley) 5/4/95"; 41#endif /* not lint */ 42 43/* 44 * String functions. --- 26 unchanged lines hidden (view full) --- 71/* 72 * scopyn - copy a string from "from" to "to", truncating the string 73 * if necessary. "To" is always nul terminated, even if 74 * truncation is performed. "Size" is the size of "to". 75 */ 76 77void 78scopyn(from, to, size) |
79 register char const *from; 80 register char *to; 81 register int size; | 79 char const *from; 80 char *to; 81 int size; |
82 { 83 84 while (--size > 0) { 85 if ((*to++ = *from++) == '\0') 86 return; 87 } 88 *to = '\0'; 89} 90 91 92/* 93 * prefix -- see if pfx is a prefix of string. 94 */ 95 96int 97prefix(pfx, string) | 82 { 83 84 while (--size > 0) { 85 if ((*to++ = *from++) == '\0') 86 return; 87 } 88 *to = '\0'; 89} 90 91 92/* 93 * prefix -- see if pfx is a prefix of string. 94 */ 95 96int 97prefix(pfx, string) |
98 register char const *pfx; 99 register char const *string; | 98 char const *pfx; 99 char const *string; |
100 { 101 while (*pfx) { 102 if (*pfx++ != *string++) 103 return 0; 104 } 105 return 1; 106} 107 --- 16 unchanged lines hidden (view full) --- 124 125 126/* 127 * Check for a valid number. This should be elsewhere. 128 */ 129 130int 131is_number(p) | 100 { 101 while (*pfx) { 102 if (*pfx++ != *string++) 103 return 0; 104 } 105 return 1; 106} 107 --- 16 unchanged lines hidden (view full) --- 124 125 126/* 127 * Check for a valid number. This should be elsewhere. 128 */ 129 130int 131is_number(p) |
132 register const char *p; | 132 const char *p; |
133 { 134 do { 135 if (! is_digit(*p)) 136 return 0; 137 } while (*++p != '\0'); 138 return 1; 139} | 133 { 134 do { 135 if (! is_digit(*p)) 136 return 0; 137 } while (*++p != '\0'); 138 return 1; 139} |