mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
string: make left/right private
This commit is contained in:
parent
b92a3544f5
commit
b38283dcf1
@ -384,14 +384,14 @@ pub fn (s string) split_into_lines() []string {
|
||||
}
|
||||
|
||||
// 'hello'.left(2) => 'he'
|
||||
pub fn (s string) left(n int) string {
|
||||
fn (s string) left(n int) string {
|
||||
if n >= s.len {
|
||||
return s
|
||||
}
|
||||
return s.substr(0, n)
|
||||
}
|
||||
// 'hello'.right(2) => 'llo'
|
||||
pub fn (s string) right(n int) string {
|
||||
fn (s string) right(n int) string {
|
||||
if n >= s.len {
|
||||
return ''
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ fn (p mut Parser) fn_decl() {
|
||||
is_public: is_pub || p.is_vh // functions defined in .vh are always public
|
||||
is_unsafe: p.attr == 'unsafe_fn'
|
||||
is_deprecated: p.attr == 'deprecated'
|
||||
comptime_define: if p.attr.starts_with('if ') { p.attr.right(3) } else { '' }
|
||||
comptime_define: if p.attr.starts_with('if ') { p.attr[3..] } else { '' }
|
||||
}
|
||||
is_live := p.attr == 'live' && !p.pref.is_so && p.pref.is_live
|
||||
if p.attr == 'live' && p.first_pass() && !p.pref.is_live && !p.pref.is_so {
|
||||
|
@ -983,11 +983,11 @@ fn (p mut Parser) get_type() string {
|
||||
p.check(.amp)
|
||||
}
|
||||
// generic type check
|
||||
ti := p.cur_fn.dispatch_of.inst
|
||||
if p.lit in ti.keys() {
|
||||
ti := p.cur_fn.dispatch_of.inst
|
||||
if p.lit in ti.keys() {
|
||||
typ += ti[p.lit]
|
||||
} else {
|
||||
typ += p.lit
|
||||
} else {
|
||||
typ += p.lit
|
||||
}
|
||||
// C.Struct import
|
||||
if p.lit == 'C' && p.peek() == .dot {
|
||||
@ -2093,7 +2093,7 @@ fn (p mut Parser) index_expr(typ_ string, fn_ph int) string {
|
||||
// }
|
||||
if is_indexer {
|
||||
l := p.cgen.cur_line.trim_space()
|
||||
index_val := l.right(l.last_index(' ')).trim_space()
|
||||
index_val := l[l.last_index(' ')..].trim_space()
|
||||
p.cgen.resetln(l[..fn_ph])
|
||||
p.table.varg_access << VargAccess{
|
||||
fn_name: p.cur_fn.name,
|
||||
|
@ -421,7 +421,7 @@ pub fn (t Time) weekday_str() string {
|
||||
}
|
||||
|
||||
pub struct C.timeval {
|
||||
tv_sec u64
|
||||
tv_sec u64
|
||||
tv_usec u64
|
||||
}
|
||||
|
||||
@ -527,7 +527,7 @@ pub fn (t Time) get_fmt_date_str(fmt_dlmtr FormatDelimiter, fmt_date FormatDate)
|
||||
}
|
||||
|
||||
month := '${t.smonth()}'
|
||||
year := t.year.str().right(2)
|
||||
year := t.year.str()[2..]
|
||||
|
||||
return match fmt_date {
|
||||
.ddmmyy { '${t.day:02d}|${t.month:02d}|$year' }
|
||||
|
Loading…
Reference in New Issue
Block a user