summary refs log tree commit diff stats
path: root/lib/std/syncio.nim
Commit message (Collapse)AuthorAgeFilesLines
* fix noreturn/implicit discard check logic (#23681)metagn2024-06-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | fixes #10440, fixes #13871, fixes #14665, fixes #19672, fixes #23677 The false positive in #23677 was caused by behavior in `implicitlyDiscardable` where only the last node of `if`/`case`/`try` etc expressions were considered, as in the final node of the final branch (in this case `else`). To fix this we use the same iteration in `implicitlyDiscardable` that we use in `endsInNoReturn`, with the difference that for an `if`/`case`/`try` statement to be implicitly discardable, all of its branches must be implicitly discardable. `noreturn` calls are also considered implicitly discardable for this reason, otherwise stuff like `if true: discardableCall() else: error()` doesn't compile. However `endsInNoReturn` also had bugs, one where `finally` was considered in noreturn checking when it shouldn't, another where only `nkIfStmt` was checked and not `nkIfExpr`, and the node given for the error message was bad. So `endsInNoReturn` now skips over `skipForDiscardable` which no longer contains `nkIfStmt`/`nkCaseStmt`/`nkTryStmt`, stores the first encountered returning node in a var parameter for the error message, and handles `finally` and `nkIfExpr`. Fixing #23677 already broke a line in `syncio` so some package code might be affected.
* Update syncio.nim, fixes "open by FileHandle" doesn't work on Windows (#23456)lit2024-04-031-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Reprodution if on Windows: ```Nim when defined(windows): var file: File let succ = file.open(<aFileHandle>) ``` then `succ` will be false. If tested, it can be found to fail with errno `22` and message: `Invalid argument` ## Problem After some investigations and tests, I found it's due to the `mode` argument for `fdopen`. Currently `NoInheritFlag`(`'N'` in Windows) is added to `mode` arg passed to `_fdopen`, but if referring to [Windows `_fdopen` doc](https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fdopen-wfdopen?view=msvc-170), you'll find there is no `'N'` describled. That's `'N'` is not accepted by `_fdopen`. Therefore, the demo above will fail. ## In Addition To begin with, technologically speaking, when opening with a `fileHandle`(or called `fd`), there is no concept of fd-inheritable as `fd` is opened already. In POSIX, `NoInheritFlag` is defined as `e`. It's pointed out in [POSIX `open` man-doc](https://www.man7.org/linux/man-pages/man3/fopen.3.html) that `e` in mode is ignored for fdopen(), which means `e` for `fdopen()` is not wanted, just allowed. Therefore, better to also not pass `e` to `fdopen` --- In all, that's this PR.
* fixes #22166; adds sideeffects for `close` and `setFilePos` (#23380)ringabout2024-03-091-2/+2
| | | fixes #22166
* follow up #22380; fixes incorrect usages of `newWideCString` (#23278)ringabout2024-02-051-1/+1
| | | follow up #22380
* reserve `sysFatal` for `Defect` (#22158)Jacek Sieka2023-11-061-9/+6
| | | | | | | | Per manual, `panics:on` affects _only_ `Defect`:s - thus `sysFatal` should not redirect any other exceptions. Also, when `sysFatal` is used in `nimPanics` mode, it should use regular exception handling pipeline to ensure exception hooks are called consistently for all raised defects.
* fixes incorrect cint overflow in system (#22718)ringabout2023-09-181-1/+1
| | | fixes #22700
* fixes syncio document (#22498)Nan Xiao2023-08-171-2/+2
|
* fixes syncio document (#22467)Nan Xiao2023-08-141-2/+2
|
* remove decades-deprecated Win32 API *A function support (#21315)tersec2023-03-021-2/+2
|
* fixes #21273; fixes an io.readLine off by one bug [backport 1.0] (#21276)ringabout2023-01-251-3/+4
| | | fixes #21273; io.readLine off by one
* fix #12122 (#21096)Bung2022-12-161-1/+1
|
* tyInt tyUint fit target int bit width (#20829)Bung2022-12-011-3/+3
|
* fix #20835 (#20872)rockcavera2022-11-181-2/+21
| | | Update syncio.nim
* fixes ptr to cstring warnings[backport] (#20848)ringabout2022-11-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix =#13790 ptr char (+friends) should not implicitly convert to cstring * Apply suggestions from code review * first round; compiles on windows * nimPreviewSlimSystem * conversion is unsafe, cast needed * fixes more tests * fixes asyncnet * another try another error * last one * true * one more * why bugs didn't show at once * add `nimPreviewCstringConversion` switch * typo * fixes ptr to cstring warnings[backport] * add fixes Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* fix fwrite prototype (#20644)Jacek Sieka2022-10-241-1/+1
| | | | | | | | | * fix fwrite prototype * Update lib/std/syncio.nim Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* move widestrs out of system (#20462)metagn2022-10-011-0/+2
| | | | | * move widestrs out of system * fix osproc
* moderate system cleanup & refactor (#20355)metagn2022-09-281-53/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * system refactor, move out 600 lines * compilation, slice, backwardsindex, misc_num moved out of system * some procs/types moved into arithmetics, basic_types * system no longer depends on syncio * some procs moved around to fit with their surroundings * make exceptions an import, old ops to misc_num * move instantiationInfo back * move back nim version, fix windows echo * include compilation * better docs for imported modules, fix unsigned ops also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem * fix terminal * workaround IC test & weird csize bug, changelog * move NimMajor etc back to compilation, rebase for CI * try ic fix * form single `indices`, slim out TaintedString, try fix IC * fix CI, update changelog, addQuitProc * fix CI * try fix CI * actually fix CI finally hopefully * Update lib/system/compilation.nim Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * update kochdocs * hopefully fix csize uses for slimsystem * fix tquit Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Revert "fix #19600 No error checking on fclose (#19836)" (#20297)ringabout2022-09-021-4/+2
| | | This reverts commit 04e4a5ec0e35fc7e1c346c2d002e8487b4b48cb5.
* fix #19600 No error checking on fclose (#19836)Bung2022-08-291-2/+4
| | | | | * fix #19600 No error checking on fclose * add IOError to open
* move formatfloat out of system (#20195)ringabout2022-08-241-1/+1
| | | | | | | | | | | | | | | * move formatfloat out of system * fixes doc * Update changelog.md * careless * fixes * deprecate system/formatfloat * better handling
* move io out of system (#19442)flywind2022-02-021-0/+962
* move io out of system * fix tests * fix tests * next step * rename to syncio * rename * fix nimscript * comma * fix * fix parts of errors * good for now * fix test