Fixes to examples and MSVC compilation.

This commit is contained in:
Christoffer Lerno
2025-02-27 15:42:38 +01:00
committed by Christoffer Lerno
parent cc5f9c6aab
commit 8bb99c6f81
9 changed files with 14 additions and 16 deletions

View File

@@ -47,7 +47,7 @@ fn Resource! prep_out(String out_name, String[] prep_names)
fn void main()
{
Resource writer = prep_out("out", String[] { "a", "b"})!!;
Resource writer = prep_out("out", (String[]) { "a", "b"})!!;
defer writer.deinit();
io::printn("use out");
}

View File

@@ -27,6 +27,6 @@ fn void main()
{
long val1 = perform("something");
long val2 = @with_mode("faster", perform, "reliable");
long val3 = perform(String[] {"something"});
long val3 = perform((String[]){"something"});
io::printfn("%d %d %d", val1, val2, val3);
}

View File

@@ -22,7 +22,7 @@ int err_count = 0;
fn int! ask_guess(int high)
{
io::printf("Guess a number between 1 and %d: ", high);
String text = io::readline() ?? InputResult.FAILED_TO_READ?!;
String text = io::treadline() ?? InputResult.FAILED_TO_READ?!;
return text.to_int() ?? InputResult.NOT_AN_INT?;
}

View File

@@ -2,8 +2,8 @@ import std::io;
fn void main()
{
Path path = path::new_cwd()!!;
foreach (i, p : path::new_ls(path)!!)
Path path = path::cwd(mem)!!;
foreach (i, p : path::ls(mem, path)!!)
{
io::printfn("%02d %s", i, p.str_view());
}

View File

@@ -5,7 +5,7 @@ fn void main()
{
printn("Enter a story template, terminated by an empty line:");
String story = "";
while (try String line = stdin().readline().strip())
while (try String line = stdin().readline(mem).strip())
{
story = story.append(line);
@@ -21,7 +21,7 @@ fn void main()
{
VarString s = match.string;
printf("Enter a value for '%s': ", s[1..^2]);
String word = stdin().readline().strip()!;
String word = stdin().readline(mem).strip()!;
story = story.replace(s, word);
}

View File

@@ -13,9 +13,9 @@ fault TokenResult
fn void main(String[] args)
{
// Grab a string from stdin
String s = io::readline()!!;
String s = io::readline(mem)!!;
// Delete it at scope end [defer]
defer s.free();
defer free(s);
// Copy the slice, which doesn't change the underlying data.
String numbers = s;