#include "string.h" #include "arena.h" char *memset( void *s, int c, int n ) { char *p; p = s; while( n > 0 ) { *p = c; p++; n--; } return s; } char *strcat( char *d, char *s ) { char *p; for( p = d; *p != '\0'; p++ ); while( *s ) { *p = *s; p++; s++; } *p = '\0'; return d; } char *strcat_c( char *s, int c ) { char *p; for( p = s; *p != '\0'; p++ ); *p++ = (char)c; *p = '\0'; return s; } char *strcpy( char *d, char *s ) { char *p; p = d; while( *s ) { *p = *s; p++; s++; } *p = '\0'; return d; } int strlen( char *s ) { char *p; int len; p = s; len = 0; while( *p ) { p++; len++; } return len; } int strcmp( char *s1, char *s2 ) { while( *s1 && *s2 && *s1 == *s2 ) { s1++; s2++; } return *s1 - *s2; } char *strdup( char *s ) { char *p; p = (char *)allocate( strlen( s ) + 1 ); if( !p ) { return 0; } strcpy( p, s ); return p; }