mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: replace "NB:" with "Note:" (docs/comments)
This commit is contained in:
@@ -36,7 +36,7 @@ pub fn getenv_opt(key string) ?string {
|
||||
if s == voidptr(0) {
|
||||
return none
|
||||
}
|
||||
// NB: C.getenv *requires* that the result be copied.
|
||||
// Note: C.getenv *requires* that the result be copied.
|
||||
return cstring_to_vstring(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ pub fn open(path string) ?File {
|
||||
// create creates or opens a file at a specified location and returns a write-only `File` object.
|
||||
pub fn create(path string) ?File {
|
||||
/*
|
||||
// NB: android/termux/bionic is also a kind of linux,
|
||||
// Note: android/termux/bionic is also a kind of linux,
|
||||
// but linux syscalls there sometimes fail,
|
||||
// while the libc version should work.
|
||||
$if linux {
|
||||
@@ -264,7 +264,7 @@ pub fn (mut f File) write_to(pos u64, buf []byte) ?int {
|
||||
}
|
||||
|
||||
// write_ptr writes `size` bytes to the file, starting from the address in `data`.
|
||||
// NB: write_ptr is unsafe and should be used carefully, since if you pass invalid
|
||||
// Note: write_ptr is unsafe and should be used carefully, since if you pass invalid
|
||||
// pointers to it, it will cause your programs to segfault.
|
||||
[unsafe]
|
||||
pub fn (mut f File) write_ptr(data voidptr, size int) int {
|
||||
@@ -297,7 +297,7 @@ pub fn (mut f File) write_full_buffer(buffer voidptr, buffer_len usize) ? {
|
||||
|
||||
// write_ptr_at writes `size` bytes to the file, starting from the address in `data`,
|
||||
// at byte offset `pos`, counting from the start of the file (pos 0).
|
||||
// NB: write_ptr_at is unsafe and should be used carefully, since if you pass invalid
|
||||
// Note: write_ptr_at is unsafe and should be used carefully, since if you pass invalid
|
||||
// pointers to it, it will cause your programs to segfault.
|
||||
[unsafe]
|
||||
pub fn (mut f File) write_ptr_at(data voidptr, size int, pos u64) int {
|
||||
|
||||
@@ -258,7 +258,7 @@ pub fn cp(src string, dst string) ? {
|
||||
}
|
||||
|
||||
// vfopen returns an opened C file, given its path and open mode.
|
||||
// NB: os.vfopen is useful for compatibility with C libraries, that expect `FILE *`.
|
||||
// Note: os.vfopen is useful for compatibility with C libraries, that expect `FILE *`.
|
||||
// If you write pure V code, os.create or os.open are more convenient.
|
||||
pub fn vfopen(path string, mode string) ?&C.FILE {
|
||||
if path.len == 0 {
|
||||
@@ -397,7 +397,7 @@ pub fn exists(path string) bool {
|
||||
// is_executable returns `true` if `path` is executable.
|
||||
pub fn is_executable(path string) bool {
|
||||
$if windows {
|
||||
// NB: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
|
||||
// Note: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
|
||||
// i.e. there is no X bit there, the modes can be:
|
||||
// 00 Existence only
|
||||
// 02 Write-only
|
||||
@@ -781,7 +781,7 @@ pub fn getwd() string {
|
||||
// See http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
|
||||
// Also https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
|
||||
// and https://insanecoding.blogspot.com/2007/11/implementing-realpath-in-c.html
|
||||
// NB: this particular rabbit hole is *deep* ...
|
||||
// Note: this particular rabbit hole is *deep* ...
|
||||
[manualfree]
|
||||
pub fn real_path(fpath string) string {
|
||||
size := max_path_bufffer_size()
|
||||
@@ -833,7 +833,7 @@ pub fn real_path(fpath string) string {
|
||||
unsafe { res.free() }
|
||||
return fpath.clone()
|
||||
}
|
||||
// NB: fullpath is much larger (usually ~4KB), than what C.realpath will
|
||||
// Note: fullpath is much larger (usually ~4KB), than what C.realpath will
|
||||
// actually fill in the vast majority of the cases => it pays to copy the
|
||||
// resulting string from that buffer, to a shorter one, and then free the
|
||||
// 4KB fullpath buffer.
|
||||
@@ -946,7 +946,7 @@ pub fn open_append(path string) ?File {
|
||||
// execvp - loads and executes a new child process, *in place* of the current process.
|
||||
// The child process executable is located in `cmdpath`.
|
||||
// The arguments, that will be passed to it are in `args`.
|
||||
// NB: this function will NOT return when successfull, since
|
||||
// Note: this function will NOT return when successfull, since
|
||||
// the child process will take control over execution.
|
||||
pub fn execvp(cmdpath string, cmdargs []string) ? {
|
||||
mut cargs := []&char{}
|
||||
@@ -972,7 +972,7 @@ pub fn execvp(cmdpath string, cmdargs []string) ? {
|
||||
// The child process executable is located in `cmdpath`.
|
||||
// The arguments, that will be passed to it are in `args`.
|
||||
// You can pass environment variables to through `envs`.
|
||||
// NB: this function will NOT return when successfull, since
|
||||
// Note: this function will NOT return when successfull, since
|
||||
// the child process will take control over execution.
|
||||
pub fn execve(cmdpath string, cmdargs []string, envs []string) ? {
|
||||
mut cargv := []&char{}
|
||||
@@ -992,7 +992,7 @@ pub fn execve(cmdpath string, cmdargs []string, envs []string) ? {
|
||||
} $else {
|
||||
res = C.execve(&char(cmdpath.str), cargv.data, cenvs.data)
|
||||
}
|
||||
// NB: normally execve does not return at all.
|
||||
// Note: normally execve does not return at all.
|
||||
// If it returns, then something went wrong...
|
||||
if res == -1 {
|
||||
return error_with_code(posix_get_error_msg(C.errno), C.errno)
|
||||
|
||||
@@ -38,7 +38,7 @@ fn init() {
|
||||
// See http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html
|
||||
// Also https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html
|
||||
// and https://insanecoding.blogspot.com/2007/11/implementing-realpath-in-c.html
|
||||
// NB: this particular rabbit hole is *deep* ...
|
||||
// Note: this particular rabbit hole is *deep* ...
|
||||
pub fn real_path(fpath string) string {
|
||||
$if js_node {
|
||||
mut res := ''
|
||||
|
||||
@@ -283,7 +283,7 @@ pub fn get_lines_joined() string {
|
||||
}
|
||||
|
||||
// get_raw_lines_joined reads *all* input lines from stdin.
|
||||
// It returns them as one large string. NB: unlike os.get_lines_joined,
|
||||
// It returns them as one large string. Note: unlike os.get_lines_joined,
|
||||
// empty lines (that contain only `\r\n` or `\n`), will be present in
|
||||
// the output.
|
||||
// Reading is stopped, only on EOF of stdin.
|
||||
|
||||
@@ -53,7 +53,7 @@ fn C.link(&char, &char) int
|
||||
|
||||
fn C.gethostname(&char, int) int
|
||||
|
||||
// NB: not available on Android fn C.getlogin_r(&char, int) int
|
||||
// Note: not available on Android fn C.getlogin_r(&char, int) int
|
||||
fn C.getlogin() &char
|
||||
|
||||
fn C.getppid() int
|
||||
|
||||
@@ -357,7 +357,7 @@ fn test_mv() {
|
||||
|
||||
fn test_cp_all() {
|
||||
// fileX -> dir/fileX
|
||||
// NB: clean up of the files happens inside the cleanup_leftovers function
|
||||
// Note: clean up of the files happens inside the cleanup_leftovers function
|
||||
os.write_file('ex1.txt', 'wow!') or { panic(err) }
|
||||
os.mkdir('ex') or { panic(err) }
|
||||
os.cp_all('ex1.txt', 'ex', false) or { panic(err) }
|
||||
@@ -749,7 +749,7 @@ fn test_posix_set_bit() ? {
|
||||
}
|
||||
mode = u32(s.st_mode) & 0o0777
|
||||
assert mode == 0o0777
|
||||
// NB: setting the sticky bit is platform dependend
|
||||
// Note: setting the sticky bit is platform dependend
|
||||
// `chmod -s -g -t`
|
||||
os.posix_set_permission_bit(fpath, os.s_isuid, false)
|
||||
os.posix_set_permission_bit(fpath, os.s_isgid, false)
|
||||
|
||||
@@ -40,10 +40,10 @@ pub fn (mut p Process) signal_continue() {
|
||||
}
|
||||
|
||||
// wait - wait for a process to finish.
|
||||
// NB: You have to call p.wait(), otherwise a finished process
|
||||
// Note: You have to call p.wait(), otherwise a finished process
|
||||
// would get to a zombie state, and its resources will not get
|
||||
// released fully, until its parent process exits.
|
||||
// NB: This call will block the calling process until the child
|
||||
// Note: This call will block the calling process until the child
|
||||
// process is finished.
|
||||
pub fn (mut p Process) wait() {
|
||||
if p.status == .not_started {
|
||||
|
||||
@@ -5,7 +5,7 @@ $if js_node {
|
||||
}
|
||||
|
||||
// new_process - create a new process descriptor
|
||||
// NB: new does NOT start the new process.
|
||||
// Note: new does NOT start the new process.
|
||||
// That is done because you may want to customize it first,
|
||||
// by calling different set_ methods on it.
|
||||
// In order to start it, call p.run() or p.wait()
|
||||
|
||||
@@ -36,7 +36,7 @@ pub mut:
|
||||
}
|
||||
|
||||
// new_process - create a new process descriptor
|
||||
// NB: new does NOT start the new process.
|
||||
// Note: new does NOT start the new process.
|
||||
// That is done because you may want to customize it first,
|
||||
// by calling different set_ methods on it.
|
||||
// In order to start it, call p.run() or p.wait()
|
||||
|
||||
@@ -13,7 +13,7 @@ fn (mut p Process) unix_spawn_process() int {
|
||||
pid := fork()
|
||||
if pid != 0 {
|
||||
// This is the parent process after the fork.
|
||||
// NB: pid contains the process ID of the child process
|
||||
// Note: pid contains the process ID of the child process
|
||||
if p.use_stdio_ctl {
|
||||
p.stdio_fd[0] = pipeset[1] // store the write end of child's in
|
||||
p.stdio_fd[1] = pipeset[2] // store the read end of child's out
|
||||
|
||||
@@ -2,7 +2,7 @@ module os
|
||||
|
||||
// os.Signal - enumerate possible POSIX signals and
|
||||
// their integer codes.
|
||||
// NB: the integer codes are given here explicitly,
|
||||
// Note: the integer codes are given here explicitly,
|
||||
// to make it easier to lookup, without needing to
|
||||
// consult man pages / signal.h .
|
||||
|
||||
|
||||
Reference in New Issue
Block a user