- All tests passing
- Updated README and image - Added itoa to stdlib - Implemented modulus math for bcc which has none in the stdlib - Updated the build scripts to work on Ubuntu 22 - Added bochsrc with some useful overrides (new bochs bios in ubuntu is broken, use the legacy) - Made most of stdlib compile and run under GNU C for testing - Improved the tokenizer so it will return tokens of more than one character - Moved the basic parser from using void pointers to store values to using basic_value unions to represent possible types - Added tests for the basic tokenizer
This commit is contained in:
17
src/string.c
17
src/string.c
@@ -15,15 +15,15 @@ size_t strlen(char *ptr)
|
||||
return ptr2 - ptr;
|
||||
}
|
||||
|
||||
void *memset(void *s, int c, size_t n)
|
||||
void *memset(void *s, char c, size_t n)
|
||||
{
|
||||
int *d = (int *)s;
|
||||
char *d = (char *)s;
|
||||
if ( s == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
while ( (d - (int *)s) <= n ) {
|
||||
while ( (d - (char *)s) < n ) {
|
||||
*d = c;
|
||||
d += sizeof(int);
|
||||
d += sizeof(char);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@@ -31,16 +31,17 @@ void *memset(void *s, int c, size_t n)
|
||||
void *memcpy(void *dest, void *src, size_t n)
|
||||
{
|
||||
int i = 0;
|
||||
char *d = dest;
|
||||
char *s = src;
|
||||
char *d = (char *)dest;
|
||||
char *s = (char *)src;
|
||||
|
||||
if ( d == NULL || s == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
for ( i = 0 ; i < n ; i++ ) {
|
||||
*d++ = *s++;
|
||||
*d = *s;
|
||||
d += 1;
|
||||
s += 1;
|
||||
}
|
||||
*d = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user