REPL: `exit` to exit

pull/816/head
Alexander Medvednikov 2019-06-29 22:56:21 +02:00
parent f4f1622528
commit a2b80d5b3d
2 changed files with 2 additions and 11 deletions

View File

@ -851,7 +851,7 @@ fn run_repl() []string {
exit(1)
}
println('V $Version')
println('Use Ctrl-D to exit')
println('Use Ctrl-D or `exit` to exit')
println('For now you have to use println() to print values, this will be fixed soon\n')
file := TmpPath + '/vrepl.v'
mut lines := []string
@ -862,7 +862,7 @@ fn run_repl() []string {
continue
}
line = line.trim_space()
if line == '' {
if line == '' || line == 'exit' {
break
}
// Save the source only if the user is printing something,

View File

@ -622,8 +622,6 @@ pub fn (s string) ustring() ustring {
}
for i := 0; i < s.len; i++ {
char_len := utf8_char_len(s.str[i])
//# char_len =UTF8_CHAR_LEN(s.str[i]);
// println('cl=$char_len')
res.runes << i
i += char_len - 1
res.len++
@ -644,8 +642,6 @@ pub fn (s string) ustring_tmp() ustring {
res.runes.len = s.len
mut j := 0
for i := 0; i < s.len; i++ {
//char_len := 0
//# char_len =UTF8_CHAR_LEN(s.str[i]);
char_len := utf8_char_len(s.str[i])
res.runes[j] = i
j++
@ -656,18 +652,13 @@ pub fn (s string) ustring_tmp() ustring {
}
fn (u ustring) substr(start, end int) string {
// println('substr($start, $end)')
// println('runes=')
// println(u.runes)
start = u.runes[start]
// handle last char
if end >= u.runes.len {
end = u.s.len
}
else {
end = u.runes[end]
}
// println('fast $start, $end')
return u.s.substr(start, end)
}