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)
{
local i = 0;
local sign = 0;
local out = 0;
local i;
local sign;
local out;
out = 0;
sign = 0;
i = 0;
loop {
if ([str + i] == '-')
sign = sign == 0;
else if ([str + i] != '+')
break;
i++;
i = i + 1;
}
loop {
if ([str + i] == 0 | isdigit([str + i]) == 0)
break;
out = out * 10 + [str + i] - '0';
i++;
i = i + 1;
}
if (sign)
return (0 - out);

View File

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

View File

@ -1,10 +1,11 @@
memset(tab, size, value)
{
local i = 0;
local i;
i = 0;
loop {
if (i == size)
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)
{
local i = 0;
local i;
i = 0;
loop {
if ([str + i] == 0)
return;
putchar([str + i]);
i++;
i = i + 1;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,12 +2,12 @@ strncmp(s1, s2, n)
{
local i;
if (n-- == 0)
if (n == 0)
return (0);
i = 0;
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]);
i++;
}

View File

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