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

324 Commits

Author SHA1 Message Date
Delyan Angelov
b7c01db1f9
builtin: add .vstring_literal and .vstring_literal_with_len for converting read only strings like os.args 2021-03-23 22:10:28 +02:00
Delyan Angelov
026f8424c2
builtin: fix a leak in string.index_kmp 2021-03-23 21:48:08 +02:00
Delyan Angelov
d098a3caca
builtin: make string.add() public temporarily till -autofree improves 2021-03-23 20:20:53 +02:00
Delyan Angelov
419ee8ae2a
builtin: fix a bug in []string.join() 2021-03-23 20:14:46 +02:00
Alexander Medvednikov
0c055a1ce9 all: s.contains(s2) instead of in 2021-03-23 11:38:56 +03:00
Delyan Angelov
c76c69ec35
all: simplify return if ... constructs to make more code compatible with -autofree 2021-03-22 16:45:29 +02:00
yuyi
320cd00203
string: fix replace_each() (#9415) 2021-03-22 09:46:45 +01:00
Delyan Angelov
8fa7e67000
builtin: use return s.clone() instead of return s consistently, to make manual free easier 2021-03-18 22:23:36 +02:00
Delyan Angelov
d4e16b6ddd
builtin: reduce memory allocations for s.trim, s.trim_left and s.trim_right 2021-03-18 19:52:33 +02:00
shadowninja55
b4f7a975e8
builtin.string: optimize string.count where substr.len == 1 (#9337) 2021-03-17 00:19:48 +02:00
shadowninja55
d92f9e77b0
builtin.string: optimize string.split_nth() for len == 1 delim (#9325) 2021-03-16 20:30:27 +02:00
JalonSolov
6f550ebbdc
string: fix fields method when no whitespace (#9326) 2021-03-16 19:45:27 +02:00
Alexander Medvednikov
93df560cf9 builtin: deprecate string.split_by_whitespace in favor of fields() 2021-03-16 08:29:14 +03:00
Alexander Medvednikov
667a26335f builtin: fix substr() 2021-03-15 21:16:23 +01:00
Alexander Medvednikov
77d5fcca59 urllib: a temporary autofree fix 2021-03-15 21:12:11 +01:00
Delyan Angelov
d65ad68e77
builtin: add 0 terminators for strings returned by .to_lower, .to_upper, utf32_to_str_no_malloc/2 2021-03-14 18:21:45 +02:00
Stanislav Ershov
c190b6a131
vlib: remove older deprecated functions (#8864) 2021-02-20 20:42:55 +02:00
Nick Treleaven
4a0367a63c
vlib: add [unsafe] tag to more functions: tos, string_from_wide, strings.Builder: write_bytes, free (#8766) 2021-02-15 17:15:52 +02:00
Nick Treleaven
ea803113c3
checker: check unsafe V function calls (#8752) 2021-02-14 19:31:42 +01:00
Lukas Neubert
473cd1d416
fmt: single line ternary return (#8605) 2021-02-08 00:28:46 +01:00
Alexander Medvednikov
a81ee0e94e tools/fast: measure v.c size and parse/check/cgen steps 2021-02-07 04:48:54 +01:00
Alexander Medvednikov
216fea1eb3 string: remove left/right (one way!) 2021-01-22 10:26:07 +01:00
Alexander Medvednikov
5815d96418 Revert "builtin: make string.(left|right) pub (#8245)"
This reverts commit 820e684313.
2021-01-22 10:09:31 +01:00
zakuro
820e684313
builtin: make string.(left|right) pub (#8245) 2021-01-22 09:35:32 +02:00
Lukas Neubert
ac2c3847af
all: update copyright to 2019-2021 (#8029) 2021-01-18 13:20:06 +01:00
yuyi
aeddd5b559
string: minor optimization (fix #8100) (#8106) 2021-01-15 02:26:06 +01:00
Alexander Medvednikov
3e04dfc79f builtin: fix byte.str() (part 1) 2021-01-05 18:59:51 +01:00
Delyan Angelov
84fc9cec4b
builtin: add string.split_by_whitespace() 2020-12-29 08:46:46 +02:00
yuyi
b47daad40d
all: remove redundant array.contains definitions (#7464) 2020-12-22 08:32:32 +01:00
Larpon
1ff6230062
builtin: document all functions in string.v (#7273) 2020-12-12 12:10:29 +02:00
Alexander Medvednikov
d319fe14f0 string: fix a one byte leak in .substr() 2020-12-11 05:12:18 +01:00
Alexander Medvednikov
a297cf8676 string: fix one byte leak in clone() 2020-12-11 05:03:37 +01:00
Seven Du
4a35a75b64
json: fix raw json string decoding crash when expected key is missing (#7206) 2020-12-09 20:10:41 +01:00
Andréas Livet
a2ec52b8c4
builtin: rewrite string.split_nth and fix some bugs (#7189) 2020-12-08 10:51:47 +02:00
yuyi
215a76a715
string: make tos_lit deprecated (#7129) 2020-12-04 20:34:58 +02:00
yuyi
06eaded6ea
string: change tos_lit to _SLIT (#7079) 2020-12-03 16:02:48 +01:00
Alexander Medvednikov
86b5f7ef5d string: fix ustring.free() 2020-11-28 03:41:43 +01:00
Daniel Däschle
52b627feb3
checker: check filter, map and sort left type (#6952) 2020-11-26 11:28:54 +01:00
Swastik Baranwal
00464ad988
builtin: add charptr.vstring() and charptr.vstring_with_len() (#6830) 2020-11-14 19:43:42 +02:00
Alexander Medvednikov
6d11caf784 autofree: string.replace() test 2020-10-21 19:44:31 +02:00
Alexander Medvednikov
7da1afa140 all: switch to the new fn arg syntax everywhere; add lots of vfmt -verify tests 2020-10-15 12:32:28 +02:00
Delyan Angelov
ce302c29e4 builtin: support also [abc,def].sort(b>a) 2020-10-06 21:33:15 +03:00
Henrixounez
c324169af0
all: remove intermediate handling for both global definition syntaxes (#6546) 2020-10-03 15:41:45 +02:00
Delyan Angelov
d2badcdedf vlib: fix more C warns on windows 2020-09-18 13:40:47 +03:00
Oghogho Odemwingie
332f3a924c
builtin: consume matched string length in string.replace_each (#6349) 2020-09-12 02:31:06 +02:00
Alexander Medvednikov
4bc0dde413 all: new .sort(a < b) syntax 2020-08-12 05:54:51 +02:00
Delyan Angelov
36eae1c175
builtin: x.vstring() instead of string(x) (#6102) 2020-08-10 18:05:26 +02:00
Nick Treleaven
2dd90de993
parser: error on [unsafe_fn] (#6090) 2020-08-09 12:22:11 +03:00
Alexander Medvednikov
c65dbe51d6 parser: c2v fixes 2020-08-09 03:58:14 +02:00
Lukas Neubert
f2c639c869
builtin: add string.contains_any() (#5963) 2020-07-29 21:48:50 +02:00
Nick Treleaven
ee349691f9
v/checker: Warn about pointer indexing outside unsafe {} (#5918) 2020-07-22 20:28:53 +03:00
Nick Treleaven
a74cbf55c7
checker: warn if C.m* or C.s* functions are called outside unsafe blocks (#5869) 2020-07-20 20:06:41 +03:00
Nick Treleaven
fb76e02c59
builtin: speed up string.clone() by using C.memcpy (#5837) 2020-07-20 17:44:35 +03:00
Nick Treleaven
105a0e015e
checker: warn if unsafe method called outside unsafe block (#5863) 2020-07-17 19:14:12 +02:00
Nick Treleaven
f5e6a83a05
builtin: unsafe vlib pointer indexing (#5836) 2020-07-15 21:56:50 +02:00
ka-weihe
df45488e09
cgen: fix warnings (#5820) 2020-07-14 00:16:31 +02:00
Swastik Baranwal
b5b5176f9b
string: add filter method (#5812) 2020-07-12 21:07:28 +03:00
Alexander Medvednikov
ab3c1f2a08 prealloc: skip frees for now 2020-07-11 13:22:18 +02:00
Uwe Krüger
646df49c74
builtin: fix string.hash method for gcc -O2 (#5794) 2020-07-11 01:18:52 +03:00
Delyan Angelov
7248d8422e vfmt: keep vproto.Name, when current module is proto 2020-07-11 00:59:19 +03:00
Delyan Angelov
78e1127d99
cgen: treat the main module like any other v module 2020-07-01 00:53:53 +02:00
Delyan Angelov
2fd960f12c builtin: implement a double free detection for v strings 2020-06-30 18:32:04 +03:00
nyaascii
f10d2bb75f
string: fix trim_prefix and trim_suffix methods (#5572) 2020-06-30 15:44:53 +02:00
Emily Hudson
c84bafbdae
vlib,cgen: cleanup array inits using `.repeat() instead of new init syntax 2020-06-27 21:46:04 +02:00
yuyi
7efb3ecb34
checker: check deprecated functions 2020-06-23 16:25:24 +02:00
Swastik Baranwal
0052ab71e9
string: add map method 2020-06-17 12:26:55 +02:00
yuyi
2ef0f15b34
string: fix contains behaviour (closes #5371) 2020-06-14 19:24:15 +10:00
Alexander Medvednikov
af27963938 string: do not free empty strings 2020-06-12 17:20:51 +00:00
Alexander Medvednikov
5dcd2303c9 builtin: fix string.fields() 2020-06-09 10:15:20 +02:00
Alexander Medvednikov
dabfc4ebd0 checker: do not display errors for incorrectly initialized vars 2020-06-08 13:10:47 +02:00
Uwe Krüger
076089d3c5
checker: apply stricter type checks to function args and return types 2020-06-01 21:15:59 +02:00
Delyan Angelov
97b9ce04a4 crypto.rand: cleanup test, make it less likely to fail in CI 2020-06-01 07:49:52 +03:00
Delyan Angelov
481f103dc9 checker: make an error using non pub fns from other modules 2020-05-27 12:00:19 +03:00
Uwe Krüger
013fdb8a4b
checker: restrict numeric promotions to cases where no data is lost 2020-05-27 05:42:48 +02:00
Alexander Medvednikov
f41e2c0a4b string: make replace() clone for now; parser: comptime method 2020-05-25 08:17:36 +02:00
Delyan Angelov
ac396ea02f http: cleanup backend_nix.c.v, fixes vpm too 2020-05-20 12:04:28 +03:00
Uwe Krüger
2635be511f
all: re-apply C++ support 2020-05-18 21:38:06 +02:00
Alexander Medvednikov
07a78b2843 Revert "all: C++ compiler support"
This reverts commit 9a237c3e82.
2020-05-18 17:05:48 +02:00
Uwe Krüger
9a237c3e82
all: C++ compiler support 2020-05-18 15:51:36 +02:00
Alexander Medvednikov
4f307c1a78 checker: requre & in struct init; http: chunked encoding 2020-05-18 05:11:00 +02:00
yuyi
7f4cf08516
parser: check (mut f Foo) syntax 2020-05-17 13:51:18 +02:00
Swastik Baranwal
04744a5390
string: add trim_prefix and trim_suffix 2020-05-15 19:37:14 +02:00
Delyan Angelov
673acdbd00 tcc: fix selfcompilation with tcc. Temporarily disable crashing interface test 2020-05-07 20:59:45 +03:00
Alexander Medvednikov
8cfb2ad6c9 string: is_lit 2020-05-07 18:05:57 +02:00
Delyan Angelov
f638caef39 compiler: v -autofree can now compile itself 2020-05-06 19:03:51 +03:00
yuyi
1fabb7d5a6
checker: fix string.str() error 2020-04-29 13:51:42 +02:00
Enzo Baldisserri
682838a0cf
checker: check array and fields mutability 2020-04-27 22:53:26 +02:00
joe-conigliaro
9f76a7b250
parser: simplify unused vars & add loop/if vars etc 2020-04-27 23:16:31 +10:00
Alexander Medvednikov
ef26f27753 builtin: replace isnil calls for perfomance 2020-04-27 07:13:36 +02:00
Larpon
7b39ab6d06
string: fix replace_each edge case error message 2020-04-26 12:40:39 +02:00
Alexander Medvednikov
3ab8dc0092 parser: array init: []string => []string{} 2020-04-26 09:17:17 +02:00
ka-weihe
d72e401378
string: optimize eq 2020-04-25 20:19:53 +02:00
Alexander Medvednikov
48857090fc runtime as type check: part 2 2020-04-25 08:42:23 +02:00
Kris Cherven
155891a4e0
parser: add unused variable warning 2020-04-22 01:52:56 +02:00
yuyi
0ced7116b6
string: add is_upper/is_lower and fix parser.match_expr error
* string: add is_upper/is_lower and fix parser.match_expr error

* to_capital => capitalize, to_title => title

* is_titled => is_title, is_capitalized => is_capital
2020-04-12 13:09:05 +03:00
Delyan Angelov
6433c23a34 string: add s.strip_margin_custom/1, instead of passing varargs to s.strip_margin()
The reason for adding s.strip_margin_custom/1 is that
passing varargs interfere with the current implementation of the
builtin module caching.
2020-04-11 11:06:12 +03:00
Alexander Medvednikov
6bbd1943dd cgen: fix &string cast; vfmt fixes 2020-04-07 18:51:44 +02:00
Major Taylor
f099f90f50
string: fix trim_right, add tests 2020-04-06 14:30:25 +02:00
Delyan Angelov
abf15e863c
v2: compile vrepl, 'fn main(){println(2+2)}' runs now
It works if you give it complete V programs like
fn main(){println(2+2)}
but not for single expressions like 2+2 or statements like a:='abc'
2020-04-02 19:21:12 +03:00
Alexander Medvednikov
473d9fef55 checker: do not allow extra () in if conditions 2020-03-27 14:57:19 +01:00
Alexander Medvednikov
ed3e0c43bc cgen: for c in string; short struct init syntax fixes; 2020-03-26 17:03:14 +01:00
Alexander Medvednikov
f101e9b9e2 v2: string fixes, is_dir fix 2020-03-24 11:14:11 +01:00
Alexander Medvednikov
fe6707b26d cgen: minor fixes 2020-03-18 16:47:37 +01:00
yuyi
456c0250b0
string: fix strip_margin 2020-03-16 15:46:09 +01:00
Major Taylor
8d19ba9195
string: strip_margin: fix the error message for multiple args 2020-03-15 07:49:37 +01:00
Major Taylor
2d5c7c8e93
string: add strip_margin 2020-03-15 05:46:12 +01:00
Alexander Medvednikov
a182b5c531 cgen: more errors fixed 2020-03-11 23:22:40 +01:00
Alexander Medvednikov
e0c85f87ae cgen: args fixes 2020-03-11 21:11:27 +01:00
Alexander Medvednikov
63032c4bb7 cgen: minor fixes 2020-03-07 16:23:10 +01:00
Alexey
632a538eb3
string: update string.repeat behavior
Panic if a repeat count is negative.
Return an empty string if a repeat count is zero.
2020-02-29 15:25:31 +01:00
spaceface777
ef8c1203b4
cleanup: replace C for loops with range 2020-02-24 17:55:16 +01:00
Alexey
c85ccad0a6
string: update check if a char is a space 2020-02-20 20:14:54 +01:00
Alexey
e4de1e1e89
string: add more test cases 2020-02-20 20:14:21 +01:00
yuyi
8be07194c7
string: fix capitalize 2020-02-20 11:33:38 +01:00
yuyi
391da0ba07
string: optimize starts_with and ends_with 2020-02-19 15:18:09 +01:00
Alexander Medvednikov
31c1483b9d vfmt2: fn args, comments 2020-02-18 20:20:15 +01:00
Delyan Angelov
195f3f465b
option to disable bounds checking; examples/path_tracing.v: optimizations 2020-02-16 16:13:45 +01:00
Alexey
1eeee40278
string: split into lines correctly 2020-02-09 09:23:57 +01:00
Alexander Medvednikov
06b5f43e48 builtin: remove unneeded casts 2020-02-05 11:22:24 +01:00
Alexander Medvednikov
2b433cdf64 v2: match, <<=, >>=, |=, ~, unsafe, map init 2020-02-05 10:00:14 +01:00
Alexander Medvednikov
80daaff874 v2: scopes, or, in, hex 2020-02-04 17:44:39 +01:00
Delyan Angelov
219239eadc string.split_nth - return the rest of the string as the last value in the result array 2020-01-24 20:12:36 +01:00
Shun Sakai
c8c43a2475 update copyright year 2020-01-23 21:04:46 +01:00
penguindark
da9b6394e8 0bxxxx binary literal support; _ in literals (1_000_000) 2020-01-23 03:28:25 +01:00
Alexander Medvednikov
e1132156f5 make sqlite.DB public; make string.left/right private 2020-01-16 18:41:38 +01:00
Alexander Medvednikov
de3ad2b04f fix vweb tutorial project; clean up gg functions a bit 2020-01-15 22:17:45 +01:00
Swastik Baranwal
2741c0b211 string: new type conversion functions 2020-01-14 18:05:38 +01:00
Alexander Medvednikov
4c7df98ac9 make private struct warning an error 2020-01-12 19:59:57 +01:00
BigBlack
98b81252b7 fix #3217 (string.replace) 2019-12-27 07:20:06 +03:00
Alexander Medvednikov
d082b3f4b9 run vfmt on vlib/builtin 2019-12-20 00:12:29 +03:00
penguindark
3dbf7a4039 atof implementation in V 2019-12-17 01:07:13 +03:00
Alexander Medvednikov
e7856a1afc do not allow malloc(0) 2019-12-16 21:29:32 +03:00
Alexander Medvednikov
b8f728590b string: last_index ?int 2019-12-12 21:54:48 +03:00
Alexander Medvednikov
cdfbb2978d strings: replace_each([]); orm: update 2019-12-10 23:57:49 +03:00
Alexander Medvednikov
9726e18c0a string: optimize replace() 2019-12-10 18:50:21 +03:00
Alexander Medvednikov
6f49d4c1d2 orm: bool support; vweb fixes 2019-12-09 23:20:29 +03:00
Don Alfons Nisnoni
254afcb2d0 *C.char => charptr 2019-12-02 11:37:35 +03:00
radare
5ff387bbe4 strings: split_nth and add tests 2019-12-01 16:10:13 +03:00
Alexander Medvednikov
3fea8f3de5 *char => charptr everywhere 2019-12-01 10:33:26 +03:00
Alexander Medvednikov
81d4f66fbb string: make index() return ?int instead of int/-1 2019-11-30 13:21:21 +03:00
Alexander Medvednikov
cc2bd0bb68 string: make substr private 2019-11-30 12:50:57 +03:00
Alexander Medvednikov
b38283dcf1 string: make left/right private 2019-11-30 12:06:17 +03:00
Delyan Angelov
7545ea709a enable alpine/musl CI tests 2019-11-28 11:46:52 +03:00
bogen85
f6ec1b29f9 strconv: make string.int() stop parsing on invalid digit 2019-11-28 09:46:10 +03:00
bogen85
5c217b9e61 fix hexadecimal constants + freestanding fixes 2019-11-26 06:12:37 +03:00
Alexander Medvednikov
e9e931fe4a force C function definitions 2019-11-24 12:14:22 +03:00
Alexander Medvednikov
4a833d8151 parser: clean up all [] 2019-11-14 09:21:20 +03:00
BigBlack
0ab09a57f7 parser: multi-level pointers 2019-11-11 18:43:22 +03:00
Don Alfons Nisnoni
b9728c7af0 string: update split() method 2019-11-10 19:37:36 +03:00
Alexander Medvednikov
987f5fd2a1 string: bring back strconv 2019-11-01 00:28:52 +03:00