home *** CD-ROM | disk | FTP | other *** search
- /*
- File: string.c
-
- Author: Bruce Kritt
-
- Description:
- */
-
- #include "char.h"
- #include "string.h"
-
- int str_len(char* string)
- {
- char* p = string;
-
- while (*p++);
-
- --p;
-
- return (p - string);
-
- } // end function str_len()
-
- void str_copy(char* lhs,char* rhs)
- {
- while (*lhs++ = *rhs++);
-
- return;
- }
-
- int str_comp(char* lhs,char* rhs)
- {
- while (*lhs == *rhs && *lhs && *lhs)
- {
- ++lhs;
- ++rhs;
- }
-
- return (*lhs - *rhs);
-
- } // end function str_comp()
-
- void str_cat(char* base,char* add)
- {
- while (*base++);
-
- --base;
-
- str_copy(base,add);
-
- return;
-
- } // end function str_cat()
-
- void str_trim(char* string) // new
- {
- char* end = string + str_len(string) - 1;
-
- do
- {
- if (end < string) break;
-
- if (!is_space(*end)) break;
-
- --end;
- }
- while (1);
-
- *++end = 0;
-
- char* begin = string;
-
- do
- {
- if (*begin == 0) break;
-
- if (!is_space(*begin)) break;
-
- ++begin;
- }
- while (1);
-
- str_copy(string,begin);
-
- return;
-
- } // end function str_trim()
- /*
- void str_trim(char* string) // old
- {
- char* end = string + str_len(string);
-
- while (is_space(*--end));
-
- *++end = 0;
-
- char* begin = string;
-
- while (is_space(*begin++));
-
- --begin;
-
- str_copy(string,begin);
-
- return;
-
- } // end function str_trim()
- */
- void str_rc(char* string)
- {
- char* from = string;
- char* to = string;
-
- do
- {
- if (*from != ',') *to++ = *from;
- }
- while (*from++);
-
- return;
-
- } // end function str_rc()
-