Compare commits
	
		
			26 Commits
		
	
	
		
			ee80b05d10
			...
			0b09f0d262
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 0b09f0d262 | |||
| 69a044b3fa | |||
| e9bf776069 | |||
| ed23a887f9 | |||
| 4bd9f50bd4 | |||
| 58f9c0cf9e | |||
| cc965024d6 | |||
| 2421c51116 | |||
| 78bc62c044 | |||
| 57de93e799 | |||
| 9a23536491 | |||
| 54370e872e | |||
| 106d2da5a0 | |||
| c41ebf6ff5 | |||
| a84415a953 | |||
| 470b97446b | |||
| 09e0d32c15 | |||
| 2b97d38b7e | |||
| cb41e69bdb | |||
| cc53b0cda5 | |||
| a432fd32c5 | |||
| 15d00356e4 | |||
| c4ce5b8566 | |||
| 1452a70b85 | |||
| 575ed7aa64 | |||
| 46d7e9c85c | 
							
								
								
									
										14
									
								
								src/aton.🗿
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/aton.🗿
									
									
									
									
									
								
							@ -1,18 +1,16 @@
 | 
			
		||||
aton(str)
 | 
			
		||||
{
 | 
			
		||||
	local i = 0;
 | 
			
		||||
	local out = 0;
 | 
			
		||||
 | 
			
		||||
	loop {
 | 
			
		||||
		if ([str + i] != '+')
 | 
			
		||||
		if ([str] != '+')
 | 
			
		||||
			break;
 | 
			
		||||
		i++;
 | 
			
		||||
		str++;
 | 
			
		||||
	}
 | 
			
		||||
	loop {
 | 
			
		||||
		if ([str + i] == 0 | isdigit([str + i]) == 0)
 | 
			
		||||
			break;
 | 
			
		||||
		out = out * 10 + [str + i] - '0';
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
		if ([str] == 0 | isdigit([str]) == 0)
 | 
			
		||||
			return out;
 | 
			
		||||
		out = out * 10 + [str] - '0';
 | 
			
		||||
		str++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								src/aton_s.🗿
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/aton_s.🗿
									
									
									
									
									
								
							@ -1,23 +1,19 @@
 | 
			
		||||
aton_s(str)
 | 
			
		||||
{
 | 
			
		||||
	local i = 0;
 | 
			
		||||
	local sign = 0;
 | 
			
		||||
	local out = 0;
 | 
			
		||||
 | 
			
		||||
	loop {
 | 
			
		||||
		if ([str + i] == '-')
 | 
			
		||||
		if ([str] == '-')
 | 
			
		||||
			sign = sign == 0;
 | 
			
		||||
		else if ([str + i] != '+')
 | 
			
		||||
		else if ([str] != '+')
 | 
			
		||||
			break;
 | 
			
		||||
		i++;
 | 
			
		||||
		str++;
 | 
			
		||||
	}
 | 
			
		||||
	loop {
 | 
			
		||||
		if ([str + i] == 0 | isdigit([str + i]) == 0)
 | 
			
		||||
			break;
 | 
			
		||||
		out = out * 10 + [str + i] - '0';
 | 
			
		||||
		i++;
 | 
			
		||||
		if ([str] == 0 | isdigit([str]) == 0)
 | 
			
		||||
			return (sign * (0 - out)) | ((sign == 0) * out);
 | 
			
		||||
		out = out * 10 + [str] - '0';
 | 
			
		||||
		str++;
 | 
			
		||||
	}
 | 
			
		||||
	if (sign)
 | 
			
		||||
		return (0 - out);
 | 
			
		||||
	return out;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
bzero(tab, size) memset(tab, size, 0);
 | 
			
		||||
bzero(tab, size) => memset(tab, size, 0);
 | 
			
		||||
 | 
			
		||||
@ -1,14 +1,11 @@
 | 
			
		||||
contain_only(to_big, to_find)
 | 
			
		||||
{
 | 
			
		||||
	local tmp;
 | 
			
		||||
 | 
			
		||||
	tmp = to_big;
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		if ([tmp] == 0)
 | 
			
		||||
		if ([to_big] == 0)
 | 
			
		||||
			return 1;
 | 
			
		||||
		if (strchr(to_find, [tmp]) == 0)
 | 
			
		||||
		if (strchr(to_find, [to_big]) == 0)
 | 
			
		||||
			return 0;
 | 
			
		||||
		tmp++;
 | 
			
		||||
		to_big++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -9,5 +9,5 @@ free_tab(tab)
 | 
			
		||||
		free([tmp]);
 | 
			
		||||
		tmp++;
 | 
			
		||||
	}
 | 
			
		||||
	free(tab);
 | 
			
		||||
	return free(tab);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
define HEAP_SIZE = 0x8000;
 | 
			
		||||
define HEAP_SIZE = 0x4000;
 | 
			
		||||
global heap[HEAP_SIZE] = 0;
 | 
			
		||||
 | 
			
		||||
define PADDING_SIZE = 4;
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										117
									
								
								src/geadline.🗿
									
									
									
									
									
								
							
							
						
						
									
										117
									
								
								src/geadline.🗿
									
									
									
									
									
								
							@ -1,49 +1,132 @@
 | 
			
		||||
geadline(prompt) {
 | 
			
		||||
geadline2(prompt, text)
 | 
			
		||||
{
 | 
			
		||||
	local capacity = 64,
 | 
			
		||||
	      size = 0,
 | 
			
		||||
	      i = 0,
 | 
			
		||||
	      c,
 | 
			
		||||
	      a,
 | 
			
		||||
	      buf;
 | 
			
		||||
	if (text) {
 | 
			
		||||
		size = strlen(text);
 | 
			
		||||
		i = size;
 | 
			
		||||
		loop {
 | 
			
		||||
			if (capacity > size)
 | 
			
		||||
				break;
 | 
			
		||||
			capacity = capacity * 2;
 | 
			
		||||
		}
 | 
			
		||||
		buf = galloc(capacity);
 | 
			
		||||
	if (prompt)
 | 
			
		||||
		putstr(prompt);
 | 
			
		||||
		if (buf == NULL)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		strcpy(buf, text);
 | 
			
		||||
	} else {
 | 
			
		||||
		buf = galloc(capacity);
 | 
			
		||||
		if (buf == NULL)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		[buf] = 0;
 | 
			
		||||
	}
 | 
			
		||||
	if (prompt)
 | 
			
		||||
		putstr(prompt);
 | 
			
		||||
	putstr(buf);
 | 
			
		||||
 | 
			
		||||
	loop {
 | 
			
		||||
		red &c;
 | 
			
		||||
		c = getchar();
 | 
			
		||||
		if ((c == 0xffff) | (c == 0x04)) {
 | 
			
		||||
			if ((size == 0) | (c == 0xffff)) {
 | 
			
		||||
				free(buf);
 | 
			
		||||
				return 0;
 | 
			
		||||
			}
 | 
			
		||||
		} else if (c == 0x007f) {
 | 
			
		||||
			if (size) {
 | 
			
		||||
		} else if (c == 0x1b) {
 | 
			
		||||
			// ESC code
 | 
			
		||||
			getchar(); // skip [
 | 
			
		||||
			c = getchar(); // value
 | 
			
		||||
 | 
			
		||||
			if ((c == 'A') & (size > 0)) {
 | 
			
		||||
				loop {
 | 
			
		||||
					if (i == 0)
 | 
			
		||||
						break;
 | 
			
		||||
					i = i - 1;
 | 
			
		||||
					esccode('D');
 | 
			
		||||
				}
 | 
			
		||||
			} else if ((c == 'B') & (i < size)) {
 | 
			
		||||
				loop {
 | 
			
		||||
					if (i >= size)
 | 
			
		||||
						break;
 | 
			
		||||
					i = i + 1;
 | 
			
		||||
					esccode('C');
 | 
			
		||||
				}
 | 
			
		||||
			} else if ((c == 'C') & (i < size)) {
 | 
			
		||||
				i = i + 1;
 | 
			
		||||
				esccode('C');
 | 
			
		||||
			} else if ((c == 'D') & (i > 0)) {
 | 
			
		||||
				i = i - 1;
 | 
			
		||||
				esccode('D');
 | 
			
		||||
			}
 | 
			
		||||
				wrt '\a';
 | 
			
		||||
		} else if (c == 0x7f) {
 | 
			
		||||
			if (i) {
 | 
			
		||||
				a = i - 1;
 | 
			
		||||
				loop {
 | 
			
		||||
					if (a >= size)
 | 
			
		||||
						break;
 | 
			
		||||
					[buf + a] = [buf + a + 1];
 | 
			
		||||
					a = a + 1;
 | 
			
		||||
				}
 | 
			
		||||
				size = size - 1;
 | 
			
		||||
				i = i - 1;
 | 
			
		||||
				[buf + size] = 0;
 | 
			
		||||
 | 
			
		||||
				wrt 0x1b;
 | 
			
		||||
				wrt 0x5b;
 | 
			
		||||
				wrt 0x44;
 | 
			
		||||
				wrt '\r';
 | 
			
		||||
				if (prompt)
 | 
			
		||||
					putstr(prompt);
 | 
			
		||||
				putstr(buf);
 | 
			
		||||
				wrt ' ';
 | 
			
		||||
				wrt 0x1b;
 | 
			
		||||
				wrt 0x5b;
 | 
			
		||||
				wrt 0x44;
 | 
			
		||||
				esccode('D');
 | 
			
		||||
				a = size - i;
 | 
			
		||||
				loop {
 | 
			
		||||
					if (a == 0)
 | 
			
		||||
						break;
 | 
			
		||||
					a = a - 1;
 | 
			
		||||
					esccode('D');
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		} else if (c == '\n') {
 | 
			
		||||
			wrt '\n';
 | 
			
		||||
			return buf;
 | 
			
		||||
		} else {
 | 
			
		||||
			size = size + 1;
 | 
			
		||||
			if (size > capacity) {
 | 
			
		||||
			if (size >= capacity) {
 | 
			
		||||
				buf = realloc(buf, capacity * 2);
 | 
			
		||||
				if (buf == NULL)
 | 
			
		||||
					return NULL;
 | 
			
		||||
				capacity = capacity * 2;
 | 
			
		||||
			}
 | 
			
		||||
			a = size - i - 1;
 | 
			
		||||
			loop {
 | 
			
		||||
				if ((a == 0xffff) | (a == 0))
 | 
			
		||||
					break;
 | 
			
		||||
				[buf + i + a] = [buf + i + a - 1];
 | 
			
		||||
				a = a - 1;
 | 
			
		||||
			}
 | 
			
		||||
			[buf + i] = c;
 | 
			
		||||
			[buf + size] = 0;
 | 
			
		||||
			putstr(buf + i);
 | 
			
		||||
			a = strlen(buf + i) - 1;
 | 
			
		||||
			loop {
 | 
			
		||||
				if ((a == 0xffff) | (a == 0))
 | 
			
		||||
					break;
 | 
			
		||||
				a = a - 1;
 | 
			
		||||
				esccode('D');
 | 
			
		||||
			}
 | 
			
		||||
			i = i + 1;
 | 
			
		||||
			[buf + i] = 0;
 | 
			
		||||
			wrt c;
 | 
			
		||||
			if (c == '\n')
 | 
			
		||||
				return buf;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
geadline(prompt) => geadline2(prompt, NULL);
 | 
			
		||||
 | 
			
		||||
esccode(c)
 | 
			
		||||
{
 | 
			
		||||
	wrt 0x1b;
 | 
			
		||||
	wrt '[';
 | 
			
		||||
	wrt c;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								src/getchar.🗿
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/getchar.🗿
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
getchar()
 | 
			
		||||
{
 | 
			
		||||
	local c;
 | 
			
		||||
	red &c;
 | 
			
		||||
	return c;
 | 
			
		||||
}
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
isalpha(c) return (c >= 'a' & c <= 'z') | (c >= 'A' & c <= 'Z');
 | 
			
		||||
isalpha(c) => (c >= 'a' & c <= 'z') | (c >= 'A' & c <= 'Z');
 | 
			
		||||
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
isascii(c) return c < 128;
 | 
			
		||||
isascii(c) => c < 128;
 | 
			
		||||
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
isdigit(c) return c >= '0' & c <= '9';
 | 
			
		||||
isdigit(c) => c >= '0' & c <= '9';
 | 
			
		||||
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
isalnum(c) return isalpha(c) | isdigit(c);
 | 
			
		||||
isalnum(c) => isalpha(c) | isdigit(c);
 | 
			
		||||
 | 
			
		||||
@ -1 +1 @@
 | 
			
		||||
isprint(c) return c >= ' ' & c <= '~';
 | 
			
		||||
isprint(c) => c >= ' ' & c <= '~';
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ memset(tab, size, value)
 | 
			
		||||
	loop {
 | 
			
		||||
		if (i == size)
 | 
			
		||||
			return (tab);
 | 
			
		||||
		[tab + i++] = value;
 | 
			
		||||
		[tab + i] = value;
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,7 @@ ntoa_get_size(number)
 | 
			
		||||
	local size = 0;
 | 
			
		||||
	
 | 
			
		||||
	if (number == 0)
 | 
			
		||||
		size++;
 | 
			
		||||
		return 1;
 | 
			
		||||
	loop 
 | 
			
		||||
	{
 | 
			
		||||
		if (number == 0)
 | 
			
		||||
@ -29,8 +29,8 @@ ntoa(number)
 | 
			
		||||
	{
 | 
			
		||||
		if (number == 0)
 | 
			
		||||
			return (str);
 | 
			
		||||
		[str + size - 1] = number % 10 + '0';
 | 
			
		||||
		number = number / 10;
 | 
			
		||||
		size--;
 | 
			
		||||
		[str + size] = number % 10 + '0';
 | 
			
		||||
		number = number / 10;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								src/ntoa_s.🗿
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/ntoa_s.🗿
									
									
									
									
									
								
							@ -1,18 +1,3 @@
 | 
			
		||||
ntoa_get_size(number)
 | 
			
		||||
{
 | 
			
		||||
	local size = 0;
 | 
			
		||||
	
 | 
			
		||||
	if (number == 0)
 | 
			
		||||
		size++;
 | 
			
		||||
	loop 
 | 
			
		||||
	{
 | 
			
		||||
		if (number == 0)
 | 
			
		||||
			return (size);
 | 
			
		||||
		number = number / 10;
 | 
			
		||||
		size++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ntoa_s(number)
 | 
			
		||||
{
 | 
			
		||||
	local str, sign, size;
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
print_raw_bit(number)
 | 
			
		||||
{
 | 
			
		||||
	local tab = get_raw_bit(number), i = 0;
 | 
			
		||||
	local tab = get_raw_bit(number);
 | 
			
		||||
	puttab_num(tab, 16);
 | 
			
		||||
	free(tab);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1 +1,5 @@
 | 
			
		||||
putchar(c) wrt c;
 | 
			
		||||
putchar(c)
 | 
			
		||||
{
 | 
			
		||||
	wrt c;
 | 
			
		||||
	return c;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,6 @@
 | 
			
		||||
putnum(number)
 | 
			
		||||
{
 | 
			
		||||
	local str;
 | 
			
		||||
	str = ntoa(number);
 | 
			
		||||
	if (str == 0)
 | 
			
		||||
		return;
 | 
			
		||||
	local str = ntoa(number);
 | 
			
		||||
	putstr(str);
 | 
			
		||||
	free(str);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								src/putstr.🗿
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/putstr.🗿
									
									
									
									
									
								
							@ -1,10 +1,14 @@
 | 
			
		||||
putstr(str)
 | 
			
		||||
{
 | 
			
		||||
	local i = 0;
 | 
			
		||||
	local tmp = str;
 | 
			
		||||
	if (str == NULL) {
 | 
			
		||||
		putstr("(null)");
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	loop {
 | 
			
		||||
		if ([str + i] == 0)
 | 
			
		||||
			return;
 | 
			
		||||
		putchar([str + i]);
 | 
			
		||||
		i++;
 | 
			
		||||
		if ([tmp] == 0)
 | 
			
		||||
			return str;
 | 
			
		||||
		putchar([tmp]);
 | 
			
		||||
		tmp++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										28
									
								
								src/puttab.🗿
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								src/puttab.🗿
									
									
									
									
									
								
							@ -1,20 +1,19 @@
 | 
			
		||||
puttab_str(tab)
 | 
			
		||||
{
 | 
			
		||||
	local tmp = tab;
 | 
			
		||||
 | 
			
		||||
	putchar('[');
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		if ([tmp] == 0)
 | 
			
		||||
			break;
 | 
			
		||||
		putchar('"');
 | 
			
		||||
		putstr([tmp]);
 | 
			
		||||
		putchar('"');
 | 
			
		||||
		if ([tmp + 1] != 0)
 | 
			
		||||
			putstr(", ");
 | 
			
		||||
		tmp++;
 | 
			
		||||
	}
 | 
			
		||||
		if ([tab] == 0) {
 | 
			
		||||
			putchar(']');
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		putchar('"');
 | 
			
		||||
		putstr([tab]);
 | 
			
		||||
		putchar('"');
 | 
			
		||||
		tab++;
 | 
			
		||||
		if ([tab] != 0)
 | 
			
		||||
			putstr(", ");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
puttab_num(tab, size)
 | 
			
		||||
@ -24,12 +23,13 @@ puttab_num(tab, size)
 | 
			
		||||
	putchar('[');
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		if (i == size)
 | 
			
		||||
			break;
 | 
			
		||||
		if (i == size) {
 | 
			
		||||
			putchar(']');
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		putnum([tab + i]);
 | 
			
		||||
		i++;
 | 
			
		||||
		if (i != size)
 | 
			
		||||
			putstr(", ");
 | 
			
		||||
	}
 | 
			
		||||
	putchar(']');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
replace(str, fill, start, stop)
 | 
			
		||||
replace_index(str, fill, start, stop)
 | 
			
		||||
{
 | 
			
		||||
	local out;
 | 
			
		||||
	local sum;
 | 
			
		||||
@ -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++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								test.sh
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								test.sh
									
									
									
									
									
								
							@ -6,13 +6,18 @@ tester()
 | 
			
		||||
		cat src/*.🗿 tests/$val.🗿 tests/test.🗿 >tmp.🗿
 | 
			
		||||
		golemc tmp.🗿 > tmp.asm
 | 
			
		||||
		orgaasm tmp.asm tmp.rom
 | 
			
		||||
		if [ -f tests/$val.input ]
 | 
			
		||||
		then
 | 
			
		||||
			orgaemu tmp.rom < tests/$val.input
 | 
			
		||||
		else
 | 
			
		||||
			orgaemu tmp.rom
 | 
			
		||||
		fi
 | 
			
		||||
		echo
 | 
			
		||||
	done
 | 
			
		||||
}
 | 
			
		||||
if [ $# -eq 0 ]
 | 
			
		||||
then
 | 
			
		||||
	tester $(ls tests/ | grep -v 'test.🗿' | sed 's/^tests\///; s/\.🗿$//' | tr '\n' ' ' );
 | 
			
		||||
	tester $(ls tests/*.🗿 | grep -v 'test.🗿' | sed 's/^tests\///; s/\.🗿$//' | tr '\n' ' ' );
 | 
			
		||||
else
 | 
			
		||||
	tester $@;
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								tests/geadline.input
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/geadline.input
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
yo
 | 
			
		||||
bozo
 | 
			
		||||
z[Dbo[C[C[Co
 | 
			
		||||
							
								
								
									
										18
									
								
								tests/geadline.🗿
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								tests/geadline.🗿
									
									
									
									
									
										Normal 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, "");
 | 
			
		||||
}
 | 
			
		||||
@ -1,11 +0,0 @@
 | 
			
		||||
main()
 | 
			
		||||
{
 | 
			
		||||
	local tmp;
 | 
			
		||||
	name = "reallocarray";
 | 
			
		||||
 | 
			
		||||
	tmp = strdup("yo");
 | 
			
		||||
	if (tmp == NULL)
 | 
			
		||||
		return 1;
 | 
			
		||||
	tmp = reallocarray(tmp, strlen(tmp), 5);
 | 
			
		||||
	test_str(tmp, "yo", "");
 | 
			
		||||
}
 | 
			
		||||
@ -1,9 +0,0 @@
 | 
			
		||||
main()
 | 
			
		||||
{
 | 
			
		||||
	name = "replace";
 | 
			
		||||
 | 
			
		||||
	test_str(replace("yo ca va ?", "t", 2, 3), "yotca va ?", "");
 | 
			
		||||
	test_str(replace("yo ca va ?", "", 2, 3), "yoca va ?", "empty fill");
 | 
			
		||||
	test_str(replace("yo ca va ?", "aaaaa", 2, 3), "yoaaaaaca va ?", "");
 | 
			
		||||
	test_str(replace("", "aaaaa", 0, 0), "aaaaa", "");
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								tests/replace_index.🗿
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								tests/replace_index.🗿
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
main()
 | 
			
		||||
{
 | 
			
		||||
	name = "replace_index";
 | 
			
		||||
 | 
			
		||||
	test_str(replace_index("yo ca va ?", "t", 2, 3), "yotca va ?", "");
 | 
			
		||||
	test_str(replace_index("yo ca va ?", "", 2, 3), "yoca va ?", "empty fill");
 | 
			
		||||
	test_str(replace_index("yo ca va ?", "aaaaa", 2, 3), "yoaaaaaca va ?", "");
 | 
			
		||||
	test_str(replace_index("", "aaaaa", 0, 0), "aaaaa", "");
 | 
			
		||||
}
 | 
			
		||||
@ -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
									
								
							
							
						
						
									
										14
									
								
								wiki/strcat.md
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										14
									
								
								wiki/strcpy.md
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										16
									
								
								wiki/strlen.md
									
									
									
									
									
										Normal 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
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										17
									
								
								wiki/strncpy.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								wiki/strncpy.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
# STRNCPY
 | 
			
		||||
Strncpy is a function that takes two chars lists and a number as a parameter and write the second in the first but only the n - 1 first char (like strncpy in C)
 | 
			
		||||
 | 
			
		||||
## params
 | 
			
		||||
1. chars list
 | 
			
		||||
2. chars list
 | 
			
		||||
3. number
 | 
			
		||||
 | 
			
		||||
## example
 | 
			
		||||
```
 | 
			
		||||
strncpy("y", "o", 2) "y" => "o"
 | 
			
		||||
strncpy("y", "", 1) "y" => ""
 | 
			
		||||
strncpy("", "o", 2) "" => "o"
 | 
			
		||||
strncpy("hello ", "world!", 7) => "world!"
 | 
			
		||||
strncpy("hello ", "world!", 14) => "world!"
 | 
			
		||||
strncpy("hello ", "world!", 0) => "hello "
 | 
			
		||||
```
 | 
			
		||||
		Reference in New Issue
	
	Block a user