diff --git a/CMakeLists.txt b/CMakeLists.txt index bf94e53..62c2e8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,8 +68,6 @@ set(SOURCES_COMMON src/std/aprint.c src/std/malloc.c src/std/print.c - src/std/string.c - src/std/string-ext.c src/tmu/inth-etmu.s src/tmu/inth-tmu.s src/tmu/sleep.c diff --git a/include/gint/defs/util.h b/include/gint/defs/util.h index 8182ece..f129a0f 100644 --- a/include/gint/defs/util.h +++ b/include/gint/defs/util.h @@ -34,12 +34,6 @@ 0; \ }) -/* abs() (without double evaluation) */ -#define abs(s) ({ \ - GAUTOTYPE _s = (s); \ - _s < 0 ? -s : s; \ -}) - /* swap() - exchange two variables of the same type */ #define swap(a, b) ({ \ GAUTOTYPE _tmp = (a); \ diff --git a/src/render/dline.c b/src/render/dline.c index 6e37afb..098fd76 100644 --- a/src/render/dline.c +++ b/src/render/dline.c @@ -41,7 +41,7 @@ void dline(int x1, int y1, int x2, int y2, int color) int dx = x2 - x1, dy = y2 - y1; int sx = sgn(dx), sy = sgn(dy); - dx = abs(dx), dy = abs(dy); + dx = (dx >= 0 ? dx : -dx), dy = (dy >= 0 ? dy : -dy); dpixel(x1, y1, color); diff --git a/src/std/string-ext.c b/src/std/string-ext.c deleted file mode 100644 index f6de513..0000000 --- a/src/std/string-ext.c +++ /dev/null @@ -1,12 +0,0 @@ -//--- -// gint:std:string-ext: Extensions to the standard for -//--- - -#include -#include - -GWEAK char *strchrnul(char const *s, int c) -{ - while(*s && *s != c) s++; - return (char *)s; -} diff --git a/src/std/string.c b/src/std/string.c deleted file mode 100644 index 1fbf5b1..0000000 --- a/src/std/string.c +++ /dev/null @@ -1,53 +0,0 @@ -//--- -// gint:core:string - replicas of a few string functions -//--- - -#include -#include -#include -#include - -GWEAK size_t strlen(char const *str) -{ - int len = 0; - while(str[len]) len++; - return len; -} - -GWEAK char *strncpy(char *dst, char const *src, size_t n) -{ - size_t i = 0; - while(i < n && (dst[i] = src[i])) i++; - return dst; -} - -GWEAK char *strcat(char *dest, char const *src) -{ - unsigned long fin_dest = strlen(dest); - unsigned int i; - for (i = 0 ; i <= strlen(src) ; i++) dest[fin_dest + i] = src[i]; - return dest; -} - -GWEAK int strcmp(char const *s1, char const *s2) -{ - while(*s1 && *s1 == *s2) s1++, s2++; - return *s1 - *s2; -} - -GWEAK char *strchr(char const *s, int c) -{ - while(*s && *s != c) s++; - return (*s) ? (char *)s : NULL; -} - -GWEAK char *strrchr(char const *s, int c) -{ - char const *found = NULL; - while(*s) - { - if(*s == c) found = s; - s++; - } - return (char *)found; -}