Compare commits

..

No commits in common. "4f0d18ee68c4d41af778ab22cc74ddc6533e651e" and "879d6f3ea272782aea4d87f3b0140df4d588c61c" have entirely different histories.

12 changed files with 44 additions and 34 deletions

View File

@ -1,21 +1,23 @@
atoi(str) atoi(str)
{ {
local i = 0; local i;
local sign = 0; local sign;
local out = 0; local out;
out = 0;
sign = 0;
i = 0;
loop { loop {
if ([str + i] == '-') if ([str + i] == '-')
sign = sign == 0; sign = sign == 0;
else if ([str + i] != '+') else if ([str + i] != '+')
break; break;
i++; i = i + 1;
} }
loop { loop {
if ([str + i] == 0 | isdigit([str + i]) == 0) if ([str + i] == 0 | isdigit([str + i]) == 0)
break; break;
out = out * 10 + [str + i] - '0'; out = out * 10 + [str + i] - '0';
i++; i = i + 1;
} }
if (sign) if (sign)
return (0 - out); return (0 - out);

View File

@ -1,7 +1,8 @@
itoa_get_size(number) itoa_get_size(number)
{ {
local size = 0; local size;
size = 0;
if (number == 0) if (number == 0)
size++; size++;
loop loop

View File

@ -1,10 +1,11 @@
memset(tab, size, value) memset(tab, size, value)
{ {
local i = 0; local i;
i = 0;
loop { loop {
if (i == size) if (i == size)
return (tab); return (tab);
[tab + i++] = value; [tab + i] = value;
i = i + 1;
} }
} }

View File

@ -1 +1,3 @@
putchar(c) wrt c; putchar(c){
wrt c;
}

View File

@ -1,10 +1,11 @@
putstr(str) putstr(str)
{ {
local i = 0; local i;
i = 0;
loop { loop {
if ([str + i] == 0) if ([str + i] == 0)
return; return;
putchar([str + i]); putchar([str + i]);
i++; i = i + 1;
} }
} }

View File

@ -1,17 +1,18 @@
strcat(dst, src) strcat(dst, src)
{ {
local i = 0; local i;
local j = 0; local j;
i = 0;
loop { loop {
if ([dst + i] == 0) if ([dst + i] == 0)
break; break;
i++; i = i + 1;
} }
j = 0;
loop { loop {
if ([src + j] == 0) if ([src + j] == 0)
return (dst); return (dst);
[dst + i + j] = [src + j]; [dst + i + j] = [src + j];
j++; j = j + 1;
} }
} }

View File

@ -1,12 +1,12 @@
strchr(str, c) strchr(str, c)
{ {
local i = 0; local i;
i = 0;
loop { loop {
if ([str + i] == c) if ([str + i] == c)
return (str + i); return (str + i);
if ([str + i] == 0) if ([str + i] == 0)
return (0); return (0);
i++; i = i + 1;
} }
} }

View File

@ -1,8 +1,10 @@
strcmp(s1, s2) strcmp(s1, s2)
{ {
local i = 0; local i;
loop { i = 0;
loop
{
if ([s1 + i] != [s2 + i] | [s1 + i] == 0 | [s2 + i] == 0) if ([s1 + i] != [s2 + i] | [s1 + i] == 0 | [s2 + i] == 0)
return ([s1 + i] - [s2 + i]); return ([s1 + i] - [s2 + i]);
i++; i++;

View File

@ -1,11 +1,11 @@
strcpy(dst, src) strcpy(dst, src)
{ {
local i = 0; local i;
i = 0;
loop { loop {
if ([src + i] == 0) if ([src + i] == 0)
return (dst); return (dst);
[dst + i] = [src + i]; [dst + i] = [src + i];
i++; i = i + 1;
} }
} }

View File

@ -1,9 +1,9 @@
strlen(str) { strlen(str) {
local i = 0; local i;
i = 0;
loop { loop {
if ([str + i] == 0) if ([str + i] == 0)
return (i); return (i);
i++; i = i + 1;
} }
} }

View File

@ -2,12 +2,12 @@ strncmp(s1, s2, n)
{ {
local i; local i;
if (n-- == 0) if (n == 0)
return (0); return (0);
i = 0; i = 0;
loop loop
{ {
if (i == n | [s1 + i] != [s2 + i] | [s1 + i] == 0 | [s2 + i] == 0) if (i == n - 1 | [s1 + i] != [s2 + i] | [s1 + i] == 0 | [s2 + i] == 0)
return ([s1 + i] - [s2 + i]); return ([s1 + i] - [s2 + i]);
i++; i++;
} }

View File

@ -1,11 +1,11 @@
strncpy(dst, src, size) strncpy(dst, src, size)
{ {
local i = 0; local i;
i = 0;
loop { loop {
if ([src + i] == 0 | i == size) if ([src + i] == 0 | i == size)
return (dst); return (dst);
[dst + i] = [src + i]; [dst + i] = [src + i];
i++; i = i + 1;
} }
} }