1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

make function arguments immutable

This commit is contained in:
Alexander Medvednikov
2019-07-05 00:20:59 +02:00
parent 74dbb1bce3
commit 0f0ed8d716
8 changed files with 42 additions and 33 deletions

View File

@@ -642,14 +642,14 @@ pub fn (s string) ustring_tmp() ustring {
}
fn (u ustring) substr(start, end int) string {
start = u.runes[start]
if end >= u.runes.len {
end = u.s.len
_start := u.runes[start]
_end := if end >= u.runes.len {
u.s.len
}
else {
end = u.runes[end]
u.runes[end]
}
return u.s.substr(start, end)
return u.s.substr(_start, _end)
}
fn (u ustring) left(pos int) string {

View File

@@ -262,8 +262,8 @@ fn popen(path string) *FILE {
}
// exec starts the specified command, waits for it to complete, and returns its output.
pub fn exec(cmd string) string {
cmd = '$cmd 2>&1'
pub fn exec(_cmd string) string {
cmd := '$_cmd 2>&1'
f := popen(cmd)
if isnil(f) {
// TODO optional or error code
@@ -331,8 +331,8 @@ pub fn dir_exists(path string) bool {
// mkdir creates a new directory with the specified path.
pub fn mkdir(path string) {
$if windows {
path = path.replace('/', '\\')
C.CreateDirectory(path.cstr(), 0)
_path := path.replace('/', '\\')
C.CreateDirectory(_path.cstr(), 0)
}
$else {
C.mkdir(path.cstr(), 511)// S_IRWXU | S_IRWXG | S_IRWXO

View File

@@ -33,7 +33,7 @@ pub fn (b Builder) str() string {
return tos(b.buf.data, b.len)
}
pub fn (b Builder) cut(n int) {
pub fn (b mut Builder) cut(n int) {
b.len -= n
}