From a2b80d5b3d022ea8293ee0297ecce5ceeb2feec4 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 29 Jun 2019 22:56:21 +0200 Subject: [PATCH] REPL: `exit` to exit --- compiler/main.v | 4 ++-- vlib/builtin/string.v | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index d3d6d397ad..5e63153b2b 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -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, diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 27b0bdbd32..9aaeeea287 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -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) }