home *** CD-ROM | disk | FTP | other *** search
- /* string.c - special string handling routines
-
- Copyright (c) 1984 by JMI Software Consultants, Inc.
- */
- #include "acom.h"
-
- /* strlen(s) returns the length of the string s
- */
-
- INT strlen(s)
- FAST TEXT *s;
- {
- FAST TEXT *t;
-
- for (t = s; *t++; )
- ;
- return (t - s - 1);
- }
-
- /* strcpy(s1, s2) will copy the string s2 to s1.
- */
-
- TEXT *strcpy(s1, s2)
- FAST TEXT *s1, *s2;
- {
- while (*s1++ = *s2++)
- ;
- return (s1 - 1);
- }
-
- /* strcmp compares two strings.
- It returns the first difference encountered.
- */
-
- INT strcmp(s1, s2)
- FAST TEXT *s1, *s2;
- {
- FAST COUNT d;
-
- for (; !(d = tolower(*s1) - tolower(*s2)) && *s1; ++s1, ++s2)
- ;
- return (d);
- }
-
- /* strcat(s1, s2) will concatenate string s2 onto string s1.
- */
-
- TEXT *strcat(s1, s2)
- FAST TEXT *s1, *s2;
- {
- FAST TEXT *orig_s1;
-
- orig_s1 = s1;
- while (*s1)
- s1++;
- while (*s2)
- *s1++ = *s2++;
- *s1 = NULLCH;
- return (orig_s1);
- }
-
- /* lookup -- look up a string in a table
- */
-
- INT lookup(s, tab)
- TEXT *s, **tab;
- {
- TEXT string[80];
- INT i;
-
- for (i = 0; string[i] = tolower(*s); ++i)
- ++s;
- for (i = 0; tab[i]; ++i)
- if (strcmp(string, tab[i]) == 0)
- return (i);
- return (-1);
- }
-
- /* namcpy.c -- copy filename up to the last period
- */
-
- TEXT *namcpy(buf, name)
- TEXT *buf, *name;
- {
- TEXT *s, *t;
-
- s = t = buf;
- while (*buf = *name++)
- {
- if (*buf == '.')
- s = buf;
- ++buf;
- }
- if (s - t)
- return(s);
- else
- return(buf);
- }