Compare commits

...

10 Commits

Author SHA1 Message Date
kdx
4bd9f50bd4 fix geadline 2023-07-26 12:53:38 +02:00
cc965024d6 Update wiki/strcpy.md 2023-07-26 10:28:27 +00:00
2421c51116 Add wiki/strcpy 2023-07-26 10:28:14 +00:00
78bc62c044 Add wiki/strcat.md 2023-07-26 10:26:06 +00:00
57de93e799 Add wiki/strlen.md 2023-07-26 10:20:13 +00:00
9a23536491 remove: useless func strchri 2023-07-26 12:13:10 +02:00
54370e872e auto check if file.input exist 2023-07-26 12:05:04 +02:00
106d2da5a0 add: geadline test 2023-07-26 10:20:02 +02:00
c41ebf6ff5 use insane new feature of golem 2023-07-26 09:57:11 +02:00
a84415a953 Merge pull request 'geadline2' (#5) from kdx/IronGOLEM:master into master
Reviewed-on: starnakin/IronGOLEM#5
2023-07-25 07:53:38 +00:00
10 changed files with 75 additions and 32 deletions

View File

@ -26,11 +26,7 @@ define HEADER_SIZE = 5;
🗿 Is used to check invalid write
🗿 If a case doesn't equal to 0 it is an invalid write
define LOCATION_INITIALISED = 0;
define LOCATION_USED = 1;
define LOCATION_SIZE = 2;
define LOCATION_PREV = 3;
define LOCATION_NEXT = 4;
enum LOCATION_INITIALISED, LOCATION_USED, LOCATION_SIZE, LOCATION_PREV, LOCATION_NEXT;
define LOCATION_DATA = HEADER_SIZE + PADDING_SIZE;
galloc_setup_header(ptr, used, size, next_block, prev_block)

View File

@ -89,6 +89,8 @@ geadline2(prompt, text)
esccode('D');
}
}
} else if (c == '\n') {
return buf;
} else {
size = size + 1;
if (size >= capacity) {
@ -115,16 +117,11 @@ geadline2(prompt, text)
esccode('D');
}
i = i + 1;
if (c == '\n')
return buf;
}
}
}
geadline(prompt)
{
geadline2(prompt, NULL);
}
geadline(prompt) => geadline2(prompt, NULL);
esccode(c)
{

View File

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

View File

@ -6,7 +6,12 @@ tester()
cat src/*.🗿 tests/$val.🗿 tests/test.🗿 >tmp.🗿
golemc tmp.🗿 > tmp.asm
orgaasm tmp.asm tmp.rom
orgaemu tmp.rom
if [ -f tests/$val.input ]
then
orgaemu tmp.rom < tests/$val.input
else
orgaemu tmp.rom
fi
echo
done
}

3
tests/geadline.input Normal file
View File

@ -0,0 +1,3 @@
yo
bozo
zboo

18
tests/geadline.🗿 Normal file
View File

@ -0,0 +1,18 @@
main()
{
local ptr;
name = "geadline";
ptr = geadline("");
test_str(ptr, "yo", "");
ptr = geadline("");
test_str(ptr, "bozo", "");
ptr = geadline("");
test_str(ptr, "bozo", "arrow");
ptr = geadline("");
test_num(ptr, 0, "");
}

View File

@ -1,8 +0,0 @@
main()
{
name = "strchri";
test_num(strchri("bozoman", 'm'), 4, "");
test_num(strchri("bozoman", 'v'), 0 - 1, "");
test_num(strchri("", 'v'), 0 - 1, "");
}

14
wiki/strcat.md Normal file
View File

@ -0,0 +1,14 @@
# STRCAT
Strcat (string concatenate) is a function that takes two chars lists as a parameter and write the second at this end of the first (like strcat in C)
## params
1. chars list
2. chars list
## example
```
strcat("y", "o") "y" => "yo"
strcat("y", "") "y" => "y"
strcat("", "o") "" => "o"
strcat("hello ", "world!") => "hello world!"
```

14
wiki/strcpy.md Normal file
View File

@ -0,0 +1,14 @@
# STRCPY
Strcpy (string copy) is a function that takes two chars lists as a parameter and write the second in the first (like strcpy in C)
## params
1. chars list
2. chars list
## example
```
strcpy("y", "o") "y" => "o"
strcpy("y", "") "y" => ""
strcpy("", "o") "" => "o"
strcpy("hello ", "world!") => "world!"
```

16
wiki/strlen.md Normal file
View File

@ -0,0 +1,16 @@
# STRLEN
Strlen (string length) is a function that takes an chars list as a parameter and return an length (like strlen in C)
## params
1. char list
## return
number
## example
```
strlen("ab") => 2
strlen(NULL) => 0
strlen("") => 0
strlen("j'ai les cramptés") => 17
```