mirror of
https://github.com/vlang/v.git
synced 2025-08-04 02:07:28 -04:00
all: fix typos (#24470)
This commit is contained in:
parent
0a37c22e4f
commit
1957162c2a
@ -284,7 +284,7 @@
|
|||||||
- Fix msvc build filename, remove temp files (#23890)
|
- Fix msvc build filename, remove temp files (#23890)
|
||||||
- Improve the stability of generated code for auto string methods
|
- Improve the stability of generated code for auto string methods
|
||||||
- Fix codegen for array of anon struct (fix #23896) (#23907)
|
- Fix codegen for array of anon struct (fix #23896) (#23907)
|
||||||
- Make sure to call the overriden `pub fn (mut a []string) free() {` method, NOT the generic `fn (a &array) free() {` one. (#23911)
|
- Make sure to call the overridden `pub fn (mut a []string) free() {` method, NOT the generic `fn (a &array) free() {` one. (#23911)
|
||||||
- Fix generic container init (fix #23910) (#23912)
|
- Fix generic container init (fix #23910) (#23912)
|
||||||
- Fix codegen for generic structinit and generic array return (fix #23916) (#23943)
|
- Fix codegen for generic structinit and generic array return (fix #23916) (#23943)
|
||||||
- Implement alias operator overloading for generic struct parent type (fix #23965) (#23967)
|
- Implement alias operator overloading for generic struct parent type (fix #23965) (#23967)
|
||||||
@ -1188,7 +1188,7 @@
|
|||||||
- net.http: implement http.download_file_with_progress/2, saving each chunk, as it is received, without growing the memory usage (#21633)
|
- net.http: implement http.download_file_with_progress/2, saving each chunk, as it is received, without growing the memory usage (#21633)
|
||||||
- veb: update import name in docs (#21668)
|
- veb: update import name in docs (#21668)
|
||||||
- Add `m3u8` MIME type `application/vnd.apple.mpegurl` for multimedia playlists (#21688)
|
- Add `m3u8` MIME type `application/vnd.apple.mpegurl` for multimedia playlists (#21688)
|
||||||
- veb.auth: use constant time comparision in compare_password_with_hash (#21693)
|
- veb.auth: use constant time comparison in compare_password_with_hash (#21693)
|
||||||
- net.http: correct `Response.status()` method comment, to indicate returning of a `Status` enum field, instead of struct (#21735)
|
- net.http: correct `Response.status()` method comment, to indicate returning of a `Status` enum field, instead of struct (#21735)
|
||||||
- net: fix TcpConn.peer_ip/0 to only return the ip address, without the port number (#21831)
|
- net: fix TcpConn.peer_ip/0 to only return the ip address, without the port number (#21831)
|
||||||
- Add mime type `text/x-vlang`, for `.v` and `.vsh` file extensions (#21851)
|
- Add mime type `text/x-vlang`, for `.v` and `.vsh` file extensions (#21851)
|
||||||
|
@ -11,37 +11,37 @@ fn a3()
|
|||||||
fn a4()
|
fn a4()
|
||||||
This should be merged into one paragraph.
|
This should be merged into one paragraph.
|
||||||
|
|
||||||
Note: this should be it's own paragraph.
|
Note: this should be its own paragraph.
|
||||||
fn a5()
|
fn a5()
|
||||||
This should be its own paragraph.
|
This should be its own paragraph.
|
||||||
|
|
||||||
Note: this should also be it own paragraph
|
Note: this should also be it own paragraph
|
||||||
|
|
||||||
Note: this should be it's own paragraph.
|
Note: this should be its own paragraph.
|
||||||
fn a6()
|
fn a6()
|
||||||
A comment
|
A comment
|
||||||
|
|
||||||
Fixme: this should be it's own paragraph.
|
Fixme: this should be its own paragraph.
|
||||||
|
|
||||||
Fixme: this should be it's own paragraph.
|
Fixme: this should be its own paragraph.
|
||||||
|
|
||||||
Fixme: this should be it's own paragraph.
|
Fixme: this should be its own paragraph.
|
||||||
fn a7()
|
fn a7()
|
||||||
A comment
|
A comment
|
||||||
|
|
||||||
Todo: this should be it's own paragraph.
|
Todo: this should be its own paragraph.
|
||||||
|
|
||||||
Todo: this should be it's own paragraph.
|
Todo: this should be its own paragraph.
|
||||||
|
|
||||||
Todo: this should be it's own paragraph.
|
Todo: this should be its own paragraph.
|
||||||
fn a8()
|
fn a8()
|
||||||
A comment
|
A comment
|
||||||
|
|
||||||
Todo: this should be it's own paragraph.
|
Todo: this should be its own paragraph.
|
||||||
|
|
||||||
Note: this should be it's own paragraph.
|
Note: this should be its own paragraph.
|
||||||
|
|
||||||
Fixme: this should be it's own paragraph.
|
Fixme: this should be its own paragraph.
|
||||||
fn a9()
|
fn a9()
|
||||||
normal comment
|
normal comment
|
||||||
fn foo()
|
fn foo()
|
||||||
|
22
cmd/tools/vdoc/testdata/multiline/main.v
vendored
22
cmd/tools/vdoc/testdata/multiline/main.v
vendored
@ -18,38 +18,38 @@ pub fn a3() {
|
|||||||
|
|
||||||
// This should be merged
|
// This should be merged
|
||||||
// into one paragraph.
|
// into one paragraph.
|
||||||
// Note: this should be it's own paragraph.
|
// Note: this should be its own paragraph.
|
||||||
pub fn a4() {
|
pub fn a4() {
|
||||||
println('hi')
|
println('hi')
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should be its own paragraph.
|
// This should be its own paragraph.
|
||||||
// NOTE: this should also be it own paragraph
|
// NOTE: this should also be it own paragraph
|
||||||
// note: this should be it's own paragraph.
|
// note: this should be its own paragraph.
|
||||||
pub fn a5() {
|
pub fn a5() {
|
||||||
println('hi')
|
println('hi')
|
||||||
}
|
}
|
||||||
|
|
||||||
// A comment
|
// A comment
|
||||||
// Fixme: this should be it's own paragraph.
|
// Fixme: this should be its own paragraph.
|
||||||
// fixme: this should be it's own paragraph.
|
// fixme: this should be its own paragraph.
|
||||||
// FIXME: this should be it's own paragraph.
|
// FIXME: this should be its own paragraph.
|
||||||
pub fn a6() {
|
pub fn a6() {
|
||||||
println('hi')
|
println('hi')
|
||||||
}
|
}
|
||||||
|
|
||||||
// A comment
|
// A comment
|
||||||
// TODO: this should be it's own paragraph.
|
// TODO: this should be its own paragraph.
|
||||||
// todo: this should be it's own paragraph.
|
// todo: this should be its own paragraph.
|
||||||
// Todo: this should be it's own paragraph.
|
// Todo: this should be its own paragraph.
|
||||||
pub fn a7() {
|
pub fn a7() {
|
||||||
println('hi')
|
println('hi')
|
||||||
}
|
}
|
||||||
|
|
||||||
// A comment
|
// A comment
|
||||||
// TODO: this should be it's own paragraph.
|
// TODO: this should be its own paragraph.
|
||||||
// NOTE: this should be it's own paragraph.
|
// NOTE: this should be its own paragraph.
|
||||||
// FIXME: this should be it's own paragraph.
|
// FIXME: this should be its own paragraph.
|
||||||
pub fn a8() {
|
pub fn a8() {
|
||||||
println('hi')
|
println('hi')
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ fn (upd VlsUpdater) download_prebuilt() ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if has_last_updated_at && !upd.is_force && asset_last_updated_at <= last_updated_at {
|
if has_last_updated_at && !upd.is_force && asset_last_updated_at <= last_updated_at {
|
||||||
upd.log("VLS was already updated to it's latest version.")
|
upd.log('VLS was already updated to its latest version.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ fn (upd VlsUpdater) compile_from_source() ! {
|
|||||||
upd.log('Updating VLS repo...')
|
upd.log('Updating VLS repo...')
|
||||||
pull_result := os.execute('${os.quoted_path(vexe)} retry -- ${git} -C ${vls_src_folder} pull')
|
pull_result := os.execute('${os.quoted_path(vexe)} retry -- ${git} -C ${vls_src_folder} pull')
|
||||||
if !upd.is_force && pull_result.output.trim_space() == 'Already up to date.' {
|
if !upd.is_force && pull_result.output.trim_space() == 'Already up to date.' {
|
||||||
upd.log("VLS was already updated to it's latest version.")
|
upd.log('VLS was already updated to its latest version.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ fn reduce_scope(content string, error_msg string, command string, do_fmt bool, f
|
|||||||
outer_modified_smth = true
|
outer_modified_smth = true
|
||||||
println('')
|
println('')
|
||||||
show_code_stats(code)
|
show_code_stats(code)
|
||||||
} else { // if can remove it, no need to go though it's children
|
} else { // if can remove it, no need to go through its children
|
||||||
for i in 0 .. item.children.len {
|
for i in 0 .. item.children.len {
|
||||||
stack.insert(0, &item.children[i]) // breadth first search
|
stack.insert(0, &item.children[i]) // breadth first search
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ fn reduce_scope(content string, error_msg string, command string, do_fmt bool, f
|
|||||||
outer_modified_smth = true
|
outer_modified_smth = true
|
||||||
println('')
|
println('')
|
||||||
show_code_stats(code)
|
show_code_stats(code)
|
||||||
} else { // if can remove it, can remove it's children
|
} else { // if can remove it, can remove its children
|
||||||
for i in 0 .. item.children.len {
|
for i in 0 .. item.children.len {
|
||||||
stack << &item.children[i]
|
stack << &item.children[i]
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// vshader aids in generating special shader code C headers via sokol-shdc's 'annotated GLSL' format to any
|
// vshader aids in generating special shader code C headers via sokol-shdc's 'annotated GLSL' format to any
|
||||||
// supported target formats that sokol_gfx supports internally.
|
// supported target formats that sokol_gfx supports internally.
|
||||||
//
|
//
|
||||||
// vshader bootstraps itself by downloading it's own dependencies to a system cache directory on first run.
|
// vshader bootstraps itself by downloading its own dependencies to a system cache directory on first run.
|
||||||
//
|
//
|
||||||
// Please see https://github.com/floooh/sokol-tools/blob/master/docs/sokol-shdc.md#feature-overview
|
// Please see https://github.com/floooh/sokol-tools/blob/master/docs/sokol-shdc.md#feature-overview
|
||||||
// for a more in-depth overview of the specific tool in use.
|
// for a more in-depth overview of the specific tool in use.
|
||||||
|
@ -62,7 +62,7 @@ fn main() {
|
|||||||
exit(0)
|
exit(0)
|
||||||
} else {
|
} else {
|
||||||
// The process supervisor should NOT crash/panic, unlike the workers.
|
// The process supervisor should NOT crash/panic, unlike the workers.
|
||||||
// It's job, is to:
|
// Its job, is to:
|
||||||
// 1) start workers
|
// 1) start workers
|
||||||
// 2) accumulate results
|
// 2) accumulate results
|
||||||
// 3) produce a summary at the end
|
// 3) produce a summary at the end
|
||||||
|
@ -6072,7 +6072,7 @@ that are substituted at compile time:
|
|||||||
- `@BUILD_TIME` => replaced with the build time, for example '12:32:07' .
|
- `@BUILD_TIME` => replaced with the build time, for example '12:32:07' .
|
||||||
- `@BUILD_TIMESTAMP` => replaced with the build timestamp, for example '1726219885' .
|
- `@BUILD_TIMESTAMP` => replaced with the build timestamp, for example '1726219885' .
|
||||||
Note: `@BUILD_DATE`, `@BUILD_TIME`, `@BUILD_TIMESTAMP` represent times in the UTC timezone.
|
Note: `@BUILD_DATE`, `@BUILD_TIME`, `@BUILD_TIMESTAMP` represent times in the UTC timezone.
|
||||||
By default, they are based on the current time of the compilation/build. They can be overriden
|
By default, they are based on the current time of the compilation/build. They can be overridden
|
||||||
by setting the environment variable `SOURCE_DATE_EPOCH`. That is also useful while making
|
by setting the environment variable `SOURCE_DATE_EPOCH`. That is also useful while making
|
||||||
releases, since you can use the equivalent of this in your build system/script:
|
releases, since you can use the equivalent of this in your build system/script:
|
||||||
`export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) ;` , and then use `@BUILD_DATE` etc.,
|
`export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) ;` , and then use `@BUILD_DATE` etc.,
|
||||||
|
@ -7,7 +7,7 @@ import hash
|
|||||||
|
|
||||||
// NID constants
|
// NID constants
|
||||||
//
|
//
|
||||||
// NIST P-256 is refered to as secp256r1 and prime256v1, defined as #define NID_X9_62_prime256v1 415
|
// NIST P-256 is referred to as secp256r1 and prime256v1, defined as #define NID_X9_62_prime256v1 415
|
||||||
// Different names, but they are all the same.
|
// Different names, but they are all the same.
|
||||||
// https://www.rfc-editor.org/rfc/rfc4492.html#appendix-A
|
// https://www.rfc-editor.org/rfc/rfc4492.html#appendix-A
|
||||||
const nid_prime256v1 = C.NID_X9_62_prime256v1
|
const nid_prime256v1 = C.NID_X9_62_prime256v1
|
||||||
|
@ -62,7 +62,7 @@ fn test_raw_indexing() {
|
|||||||
assert utf8.raw_index(a, 7) == 'g'
|
assert utf8.raw_index(a, 7) == 'g'
|
||||||
assert utf8.raw_index(a, 8) == '!'
|
assert utf8.raw_index(a, 8) == '!'
|
||||||
|
|
||||||
// test differnt utf8 byte lenghts
|
// test differnt utf8 byte lengths
|
||||||
c := 'a©★🚀'
|
c := 'a©★🚀'
|
||||||
assert utf8.raw_index(c, 0) == 'a' // 1 byte
|
assert utf8.raw_index(c, 0) == 'a' // 1 byte
|
||||||
assert utf8.raw_index(c, 1) == '©' // 2 bytes
|
assert utf8.raw_index(c, 1) == '©' // 2 bytes
|
||||||
|
@ -108,7 +108,7 @@ fn do_work() {
|
|||||||
|
|
||||||
### Notes:
|
### Notes:
|
||||||
|
|
||||||
1. Each `EventBus` instance has it's own registry (i.e. there is no global event registry
|
1. Each `EventBus` instance has its own registry (i.e. there is no global event registry
|
||||||
so you can't just subscribe to an event wherever you are.
|
so you can't just subscribe to an event wherever you are.
|
||||||
2. Each `EventBus` has a `Subscriber` instance which will need to be either exposed or you can make
|
2. Each `EventBus` has a `Subscriber` instance which will need to be either exposed or you can make
|
||||||
small public helper functions specific to your module like (`onPress`, `onError`) and etc.
|
small public helper functions specific to your module like (`onPress`, `onError`) and etc.
|
||||||
|
@ -22,7 +22,7 @@ pub fn debugger_present() bool {
|
|||||||
// no external debugger
|
// no external debugger
|
||||||
exit(0)
|
exit(0)
|
||||||
} else {
|
} else {
|
||||||
// an error occured, a external debugger must be present
|
// an error occurred, a external debugger must be present
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,7 @@ pub fn debugger_present() bool {
|
|||||||
// no external debugger
|
// no external debugger
|
||||||
exit(0)
|
exit(0)
|
||||||
} else {
|
} else {
|
||||||
// an error occured, a external debugger must be present
|
// an error occurred, a external debugger must be present
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,7 @@ pub fn debugger_present() bool {
|
|||||||
// no external debugger
|
// no external debugger
|
||||||
exit(0)
|
exit(0)
|
||||||
} else {
|
} else {
|
||||||
// an error occured, a external debugger must be present
|
// an error occurred, a external debugger must be present
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -211,7 +211,7 @@ mut:
|
|||||||
b int // private mutable
|
b int // private mutable
|
||||||
c int // (you can list multiple fields with the same access modifier)
|
c int // (you can list multiple fields with the same access modifier)
|
||||||
pub:
|
pub:
|
||||||
d int // public immmutable (readonly)
|
d int // public immutable (readonly)
|
||||||
pub mut:
|
pub mut:
|
||||||
e int // public, but mutable only in parent module
|
e int // public, but mutable only in parent module
|
||||||
f int // public and mutable both inside and outside parent module
|
f int // public and mutable both inside and outside parent module
|
||||||
|
@ -148,7 +148,7 @@ pub fn (t &ResolverInfo) get_ct_type_var(node ast.Expr) ast.ComptimeVarKind {
|
|||||||
return .no_comptime
|
return .no_comptime
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_type_from_comptime_var retrives the comptime type related to $for variable
|
// get_type_from_comptime_var retrieves the comptime type related to $for variable
|
||||||
@[inline]
|
@[inline]
|
||||||
pub fn (t &TypeResolver) get_type_from_comptime_var(var ast.Ident) ast.Type {
|
pub fn (t &TypeResolver) get_type_from_comptime_var(var ast.Ident) ast.Type {
|
||||||
match var.name {
|
match var.name {
|
||||||
|
@ -3,7 +3,7 @@ import os
|
|||||||
|
|
||||||
fn test_githash() {
|
fn test_githash() {
|
||||||
if os.getenv('GITHUB_JOB') == '' {
|
if os.getenv('GITHUB_JOB') == '' {
|
||||||
eprintln('> skipping test, since it needs GITHUB_JOB to be defined (it is flaky on development machines, with changing repos and v compiled with `./v self` from uncommited changes).')
|
eprintln('> skipping test, since it needs GITHUB_JOB to be defined (it is flaky on development machines, with changing repos and v compiled with `./v self` from uncommitted changes).')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !os.exists(os.join_path(@VMODROOT, '.git')) {
|
if !os.exists(os.join_path(@VMODROOT, '.git')) {
|
||||||
|
@ -6,7 +6,7 @@ module util
|
|||||||
import os
|
import os
|
||||||
import v.vmod
|
import v.vmod
|
||||||
|
|
||||||
// resolve_vmodroot replaces all occurences of `@VMODROOT` in `str`, with an absolute path,
|
// resolve_vmodroot replaces all occurrences of `@VMODROOT` in `str`, with an absolute path,
|
||||||
// formed by resolving, where the nearest `v.mod` is, given the folder `dir`.
|
// formed by resolving, where the nearest `v.mod` is, given the folder `dir`.
|
||||||
pub fn resolve_vmodroot(str string, dir string) !string {
|
pub fn resolve_vmodroot(str string, dir string) !string {
|
||||||
mut mcache := vmod.get_cache()
|
mut mcache := vmod.get_cache()
|
||||||
|
@ -124,7 +124,7 @@ pub fn (mut s Scanner) scan() token.Token {
|
|||||||
s.offset++
|
s.offset++
|
||||||
// NOTE: I have made `@[` a token instead of using `@` and `[` because `@`
|
// NOTE: I have made `@[` a token instead of using `@` and `[` because `@`
|
||||||
// is not currently used as a token, and it is also easier to parse this way.
|
// is not currently used as a token, and it is also easier to parse this way.
|
||||||
// if/when `@` becomes used as a token of it's own, then I may change this.
|
// if/when `@` becomes used as a token of its own, then I may change this.
|
||||||
if c == `@` && s.src[s.offset] == `[` {
|
if c == `@` && s.src[s.offset] == `[` {
|
||||||
s.offset++
|
s.offset++
|
||||||
return .attribute
|
return .attribute
|
||||||
|
@ -411,7 +411,7 @@ fn handle_read[A, X](mut pv picoev.Picoev, mut params RequestParams, fd int) {
|
|||||||
eprintln('[veb] error reading request body: ${err}')
|
eprintln('[veb] error reading request body: ${err}')
|
||||||
|
|
||||||
if err is io.Eof {
|
if err is io.Eof {
|
||||||
// we expect more data to be send, but an Eof error occured, meaning
|
// we expect more data to be send, but an Eof error occurred, meaning
|
||||||
// that there is no more data to be read from the socket.
|
// that there is no more data to be read from the socket.
|
||||||
// And at this point we expect that there is data to be read for the body.
|
// And at this point we expect that there is data to be read for the body.
|
||||||
fast_send_resp(mut conn, http.new_response(
|
fast_send_resp(mut conn, http.new_response(
|
||||||
|
@ -437,7 +437,7 @@ pub fn (mut c Cipher) set_counter(ctr u64) {
|
|||||||
// rekey resets internal Cipher's state and reinitializes state with the provided key and nonce
|
// rekey resets internal Cipher's state and reinitializes state with the provided key and nonce
|
||||||
pub fn (mut c Cipher) rekey(key []u8, nonce []u8) ! {
|
pub fn (mut c Cipher) rekey(key []u8, nonce []u8) ! {
|
||||||
unsafe { c.reset() }
|
unsafe { c.reset() }
|
||||||
// this routine was publicly accesible to user, so we add a check here
|
// this routine was publicly accessible to user, so we add a check here
|
||||||
// to ensure the supplied key and nonce has the correct size.
|
// to ensure the supplied key and nonce has the correct size.
|
||||||
if key.len != key_size {
|
if key.len != key_size {
|
||||||
return error('Bad key size provided for rekey')
|
return error('Bad key size provided for rekey')
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
This `slhdsa` module requires latest OpenSSL library and development headers.
|
This `slhdsa` module requires latest OpenSSL library and development headers.
|
||||||
It required minimum of OpenSLL 3.5 version.
|
It required minimum of OpenSLL 3.5 version.
|
||||||
Likely most of the linux (unix) distros does not ships with this version on this time
|
Likely most of the linux (unix) distros do not ship with this version on this time
|
||||||
of writing, at March, 2025.
|
of writing, at March, 2025.
|
||||||
|
|
||||||
You can manually download and install OpenSSL library by your self. This documents acts as a simple
|
You can manually download and install OpenSSL library by your self. This documents acts as a simple
|
||||||
@ -23,7 +23,7 @@ $ ./Configure --prefix=/opt/ssl --openssldir=/opt/ssl
|
|||||||
$ make
|
$ make
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
```
|
```
|
||||||
By succesfully this step, the latest OpenSSL has been built and installed onto
|
By successfully completing this step, the latest OpenSSL has been built and installed onto
|
||||||
configured path. You need to tell the system to add this path. <br>
|
configured path. You need to tell the system to add this path. <br>
|
||||||
|
|
||||||
4. Add `/opt/ssl/lib64` entry onto `/etc/ld.so.conf.d/libcrypto.conf`
|
4. Add `/opt/ssl/lib64` entry onto `/etc/ld.so.conf.d/libcrypto.conf`
|
||||||
|
@ -100,7 +100,7 @@ pub fn (pv PrivateKey) dump_key() !string {
|
|||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
// public_key gets the the public part of this private key as a PublicKey.
|
// public_key gets the public part of this private key as a PublicKey.
|
||||||
pub fn (pv PrivateKey) public_key() !PublicKey {
|
pub fn (pv PrivateKey) public_key() !PublicKey {
|
||||||
pbkey := C.EVP_PKEY_dup(pv.key)
|
pbkey := C.EVP_PKEY_dup(pv.key)
|
||||||
// we clears out the private bits from the key
|
// we clears out the private bits from the key
|
||||||
|
@ -197,7 +197,7 @@ pub fn (v Integer) payload() ![]u8 {
|
|||||||
// - The integer value contains the encoded integer if it is positive, or its two's complement if it is negative.
|
// - The integer value contains the encoded integer if it is positive, or its two's complement if it is negative.
|
||||||
// - If the integer is positive but the high order bit is set to 1, a leading 0x00 is added to the content
|
// - If the integer is positive but the high order bit is set to 1, a leading 0x00 is added to the content
|
||||||
// to indicate that the number is not negative.
|
// to indicate that the number is not negative.
|
||||||
// - If the number is negative after applying two's-complement rules, and the the most-significant-bit of the
|
// - If the number is negative after applying two's-complement rules, and the most-significant-bit of the
|
||||||
// the high order bit of the bytes results isn't set, pad it with 0xff in order to keep the number negative.
|
// the high order bit of the bytes results isn't set, pad it with 0xff in order to keep the number negative.
|
||||||
fn (v Integer) pack_into_twoscomplement_form() !([]u8, int) {
|
fn (v Integer) pack_into_twoscomplement_form() !([]u8, int) {
|
||||||
match v.value {
|
match v.value {
|
||||||
@ -226,7 +226,7 @@ fn (v Integer) pack_into_twoscomplement_form() !([]u8, int) {
|
|||||||
}
|
}
|
||||||
-1 {
|
-1 {
|
||||||
// A negative number has to be converted to two's-complement form.
|
// A negative number has to be converted to two's-complement form.
|
||||||
// by invert the number and and then subtract it with big(1), or with other mean
|
// by invert the number and then subtract it with big(1), or with other mean
|
||||||
// Flip all of the bits in the value and then add one to the resulting value.
|
// Flip all of the bits in the value and then add one to the resulting value.
|
||||||
// If the most-significant-bit isn't set then we'll need to pad the
|
// If the most-significant-bit isn't set then we'll need to pad the
|
||||||
// beginning with 0xff in order to keep the number negative.
|
// beginning with 0xff in order to keep the number negative.
|
||||||
|
@ -553,15 +553,15 @@ fn (mut decoder Decoder) decode_value[T](mut val T) ! {
|
|||||||
string_info := decoder.current_node.value
|
string_info := decoder.current_node.value
|
||||||
|
|
||||||
if string_info.value_kind == .string_ {
|
if string_info.value_kind == .string_ {
|
||||||
buffer_lenght, escape_positions := decoder.calculate_string_space_and_escapes()!
|
buffer_length, escape_positions := decoder.calculate_string_space_and_escapes()!
|
||||||
|
|
||||||
string_buffer := []u8{cap: buffer_lenght}
|
string_buffer := []u8{cap: buffer_length}
|
||||||
|
|
||||||
if escape_positions.len == 0 {
|
if escape_positions.len == 0 {
|
||||||
if string_info.length != 0 {
|
if string_info.length != 0 {
|
||||||
unsafe {
|
unsafe {
|
||||||
string_buffer.push_many(decoder.json.str + string_info.position + 1,
|
string_buffer.push_many(decoder.json.str + string_info.position + 1,
|
||||||
buffer_lenght)
|
buffer_length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user