about summary refs log tree commit diff
path: root/cmd
diff options
context:
space:
mode:
authorAlexey Yerin <yyp@disroot.org>2024-04-01 21:34:51 +0300
committerAlexey Yerin <yyp@disroot.org>2024-04-01 21:35:25 +0300
commit5b7571b7d91deef34ef92c8d9cf897320d3c8fab (patch)
tree4084b9717a2c79fd4ae98e9474e412e0fd43ba2b /cmd
parent49ae43171514e882c795166014edf94da0125033 (diff)
Update per for-each changes
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hare-gi/ident.ha30
1 files changed, 10 insertions, 20 deletions
diff --git a/cmd/hare-gi/ident.ha b/cmd/hare-gi/ident.ha
index 7dae645..65571f4 100644
--- a/cmd/hare-gi/ident.ha
+++ b/cmd/hare-gi/ident.ha
@@ -6,10 +6,10 @@ use strings;
 
 const keywords: [_]str = [
 	"abort", "align", "alloc", "append", "as", "assert", "bool", "break",
-	"case", "const", "continue", "defer", "def", "delete", "else", "enum",
-	"export", "f32", "f64", "false", "fn", "for", "free", "i16", "i32",
-	"i64", "i8", "if", "insert", "int", "is", "len", "let", "match", "null",
-	"nullable", "offset", "return", "rune", "size", "static", "str",
+	"case", "const", "continue", "def", "defer", "delete", "done", "else",
+	"enum", "export", "f32", "f64", "false", "fn", "for", "free", "i16",
+	"i32", "i64", "i8", "if", "insert", "int", "is", "len", "let", "match",
+	"null", "nullable", "offset", "return", "rune", "size", "static", "str",
 	"struct", "switch", "true", "type", "u16", "u32", "u64", "u8", "uint",
 	"uintptr", "union", "use", "vaarg", "vaend", "valist", "vastart",
 	"void", "yield",
@@ -27,8 +27,8 @@ fn fix_identifier(s: str) str = {
 		return fmt::bsprintf(buf, "_{}", s);
 	};
 
-	for (let i = 0z; i < len(keywords); i += 1) {
-		if (keywords[i] == s) {
+	for (let keyword .. keywords) {
+		if (s == keyword) {
 			return fmt::bsprintf(buf, "{}_", s);
 		};
 	};
@@ -42,11 +42,8 @@ fn normalize_signal(in: str) str = {
 	let buf = memio::fixed(buf);
 
 	let iter = strings::iter(in);
-	for (true) match (strings::next(&iter)) {
-	case let r: rune =>
+	for (let r => strings::next(&iter)) {
 		memio::appendrune(&buf, if (r == '-') '_' else r)!;
-	case =>
-		break;
 	};
 	return memio::string(&buf)!;
 };
@@ -57,11 +54,8 @@ fn to_uppercase(in: str) str = {
 	let buf = memio::fixed(buf);
 
 	let iter = strings::iter(in);
-	for (true) match (strings::next(&iter)) {
-	case let r: rune =>
+	for (let r => strings::next(&iter)) {
 		memio::appendrune(&buf, ascii::toupper(r))!;
-	case =>
-		break;
 	};
 	return memio::string(&buf)!;
 };
@@ -76,8 +70,7 @@ fn swap_case(in: str) str = {
 
 	let iter = strings::iter(in);
 	let prev = '!';
-	for (true) match (strings::next(&iter)) {
-	case let r: rune =>
+	for (let r => strings::next(&iter)) {
 		if (ascii::isupper(r) && !ascii::isupper(prev)) {
 			if (len(memio::string(&buf)!) > 0) {
 				append(parts,
@@ -87,8 +80,6 @@ fn swap_case(in: str) str = {
 		};
 		memio::appendrune(&buf, ascii::tolower(r))!;
 		prev = r;
-	case void =>
-		break;
 	};
 
 	if (len(memio::string(&buf)!) > 0) {
@@ -106,8 +97,7 @@ fn swap_case(in: str) str = {
 		("DBus", "dbus"),
 		("cairo_t", "cairo_t"),
 	];
-	for (let i = 0z; i < len(tests); i += 1) {
-		const (in, expected) = tests[i];
+	for (let (in, expected) .. tests) {
 		const out = swap_case(in);
 		if (out != expected) {
 			fmt::fatalf("Fail '{}': expected '{}', got '{}'",