~sircmpwn/hare

hare/rt/strcmp.ha -rw-r--r-- 326 bytes
ea90e6dfEyal Sawady unix::umask: don't return an error 10 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
type string = struct {
	data: *[*]u8,
	length: size,
	capacity: size,
};

export fn strcmp(_a: str, _b: str) bool = {
	if (len(_a) != len(_b)) {
		return false;
	};
	let a = (&_a: *string).data, b = (&_b: *string).data;
	for (let i = 0z; i < len(_a); i += 1) {
		if (a[i] != b[i]) {
			return false;
		};
	};
	return true;
};