summary refs log tree commit diff stats
path: root/lib/std/private
Commit message (Collapse)AuthorAgeFilesLines
* remove decades-deprecated Win32 API *A function support (#21315)tersec2023-03-025-123/+51
|
* Fix: nintendoswitch compilation (#21368)Dmitry Arkhipenko2023-02-251-1/+1
| | | | | * Fix: make nintendoswitch someGcc, remove symlink support for nintendoswitch, add getAppFilename for nintendoswitch * Fix: use getApplHeuristic on nintendoswitch
* fixes #21393 and misc style changes (#21419)Andreas Rumpf2023-02-242-4/+2
| | | | | | | | | * fixes #21393 and misc style changes * progress --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
* Add `getDataDir` proc (#21408)Ecorous2023-02-211-0/+27
| | | | | | | | | * Add getDataDir() * Update lib/std/private/osappdirs.nim --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* docgen: implement cross-document links (#20990)Andrey Makarov2023-01-047-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * docgen: implement cross-document links Fully implements https://github.com/nim-lang/RFCs/issues/125 Follow-up of: https://github.com/nim-lang/Nim/pull/18642 (for internal links) and https://github.com/nim-lang/Nim/issues/20127. Overview -------- Explicit import-like directive is required, called `.. importdoc::`. (the syntax is % RST, Markdown will use it for a while). Then one can reference any symbols/headings/anchors, as if they were in the local file (but they will be prefixed with a module name or markup document in link text). It's possible to reference anything from anywhere (any direction in `.nim`/`.md`/`.rst` files). See `doc/docgen.md` for full description. Working is based on `.idx` files, hence one needs to generate all `.idx` beforehand. A dedicated option `--index:only` is introduced (and a separate stage for `--index:only` is added to `kochdocs.nim`). Performance note ---------------- Full run for `./koch docs` now takes 185% of the time before this PR. (After: 315 s, before: 170 s on my PC). All the time seems to be spent on `--index:only` run, which takes almost as much (85%) of normal doc run -- it seems that most time is spent on file parsing, turning off HTML generation phase has not helped much. (One could avoid it by specifying list of files that can be referenced and pre-processing only them. But it can become error-prone and I assume that these linke will be **everywhere** in the repository anyway, especially considering https://github.com/nim-lang/RFCs/issues/478. So every `.nim`/`.md` file is processed for `.idx` first). But that's all without significant part of repository converted to cross-module auto links. To estimate impact I checked the time for `doc`ing a few files (after all indexes have been generated), and everywhere difference was **negligible**. E.g. for `lib/std/private/osfiles.nim` that `importdoc`s large `os.idx` and hence should have been a case with relatively large performance impact, but: * After: 0.59 s. * Before: 0.59 s. So Nim compiler works so slow that doc part basically does not matter :-) Testing ------- 1) added `extlinks` test to `nimdoc/` 2) checked that `theindex.html` is still correct 2) fixed broken auto-links for modules that were derived from `os.nim` by adding appropriate ``importdoc`` Implementation note ------------------- Parsing and formating of `.idx` entries is moved into a dedicated `rstidx.nim` module from `rstgen.nim`. `.idx` file format changed: * fields are not escaped in most cases because we need original strings for referencing, not HTML ones (the exception is linkTitle for titles and headings). Escaping happens later -- on the stage of `rstgen` buildIndex, etc. * all lines have fixed number of columns 6 * added discriminator tag as a first column, it always allows distinguish Nim/markup entries, titles/headings, etc. `rstgen` does not rely any more (in most cases) on ad-hoc logic to determine what type each entry is. * there is now always a title entry added at the first line. * add a line number as 6th column * linkTitle (4th) column has a different format: before it was like `module: funcName()`, now it's `proc funcName()`. (This format is also propagated to `theindex.html` and search results, I kept it that way since I like it more though it's discussible.) This column is what used for Nim symbols resolution. * also changed details on column format for headings and titles: "keyword" is original, "linkTitle" is HTML one * fix paths on Windows + more clear code * Update compiler/docgen.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de> * Handle .md and .nim paths uniformly in findRefFile * handle titles better + more comments * don't allow markup overwrite index title for .nim files Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* remove legacy code (#21134)ringabout2022-12-261-15/+1
| | | | | * remove legacy code * fixes
* fixes #19292; fixes #21122; fixes putEnv and setEnv with vcc (#21143)ringabout2022-12-201-13/+13
| | | | | * fixes #19292; fixes 21122; fixes putEnv and setEnv with vcc * add a test
* fix #12122 (#21096)Bung2022-12-161-2/+2
|
* build the documentation of official packages (#20986)ringabout2022-12-061-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * remove db stuffs * remove punycode * remove * fixes script * add cloner * patches * disable * patch * fixes external packages * disable two packages * preview documentation build * try again * fixes URL * fixes a bug * simplify * fixes documentaion * fixes * Apply suggestions from code review
* tyInt tyUint fit target int bit width (#20829)Bung2022-12-013-30/+30
|
* Move command line parameter code (#20946)IgorDeepakM2022-11-301-2/+0
| | | | | Command line paramater code moved from os.nim to cmdparam.nim Co-authored-by: IgorDeepakM <IgorDeepak@noreply.com>
* correct Ptr field name for RTL_CONDITION_VARIABLE? (#20896)metagn2022-11-221-1/+1
| | | | | correct field name for RTL_CONDITION_VARIABLE? ref #20895
* fixes ptr to cstring warnings[backport] (#20848)ringabout2022-11-164-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* fixes #20526; use `nimPreviewSlimSystem` for documentation build (#20714)ringabout2022-11-011-1/+1
| | | | | | | * fixes #20526; use `nimPreviewSlimSystem` for `koch docs` * fixes documentation errors * fixes remaning issues
* move threads out of system (#20674)ringabout2022-10-292-0/+410
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * move syslocks first * progress * clean up * go on * clean up * clean up * add imports syslocks * remove documentation * public deallocOsPages * fixes genode * fixes more * fixes boehmGC * cover more cases * fixes cyclic deps * fixes genode * cleanup * unpublic fields * cleanup * clean up
* Fix #20628 for Windows (#20667)Andrey Makarov2022-10-282-14/+14
| | | | | | | * Fix #20628 for Windows * Move isRegular - !isSpecial and onlyRegular - skipSpecial * Forgot to change it in 1 more place
* clean up `std/os` related modules (#20651)ringabout2022-10-253-27/+95
| | | | | | | | | * clean up `std/os` related modules * use `cmpPaths` * reset * cleanup
* Implement Unix file regularity check (#20448) (#20628)Andrey Makarov2022-10-252-23/+36
| | | | | * Implement Unix file regularity check * update std/dirs also
* move procs in os to `appdirs` (#20605)ringabout2022-10-201-0/+147
| | | | | * move procs in os to `appdirs` * Update lib/std/private/osappdirs.nim
* [std/os] split and re-export (#20593)ringabout2022-10-205-0/+2228
| | | | | | | * [std/os] split and export * move to private modules * fixes docs and tests Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* [`std/os` clean up] import and export `osseps` (#20580)ringabout2022-10-171-0/+111
| | | import and export osseps
* move widestrs out of system (#20462)metagn2022-10-011-0/+3
| | | | | * move widestrs out of system * fix osproc
* make koch and tools work with `nimPreviewSlimSystem` (#20459)ringabout2022-09-301-0/+3
|
* fix #19500; remove find optimization [backport: 1.6] (#19714)ringabout2022-09-281-0/+37
| | | | | | | | | | | | | | | | * remove find optimization close #19500 * save find to std * add simple tests * Apply suggestions from code review Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: sandytypical <43030857+xflywind@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* Implement Markdown definition lists (+ migration) (#20333)Andrey Makarov2022-09-111-0/+4
| | | | | | | | | | | | | | | Implements definition lists Markdown extension adopted in a few implementations including: * [Pandoc]( https://pandoc.org/MANUAL.html#definition-lists) * [kramdown]( https://kramdown.gettalong.org/quickref.html#definition-lists) * [PHP extra Markdown]( https://michelf.ca/projects/php-markdown/extra/#def-list) Also affected files have been migrated. RST definition lists are turned off for Markdown: this solves the problem of broken formatting mentioned in https://github.com/nim-lang/Nim/pull/20292.
* Implement Pandoc Markdown concise link extension (#20304)Andrey Makarov2022-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement Pandoc Markdown concise link extension This implements https://github.com/nim-lang/Nim/issues/20127. Besides reference to headings we also support doing references to Nim symbols inside Nim modules. Markdown: ``` Some heading ------------ Ref. [Some heading]. ``` Nim: ``` proc someFunction*() ... ... ## Ref. [someFunction] ``` This is substitution for RST syntax like `` `target`_ ``. All 3 syntax variants of extension from Pandoc Markdown are supported: `[target]`, `[target][]`, `[description][target]`. This PR also fixes clashes in existing files, particularly conflicts with RST footnote feature, which does not work with this PR (but there is a plan to adopt a popular [Markdown footnote extension](https://pandoc.org/MANUAL.html#footnotes) to make footnotes work). Also the PR fixes a bug that Markdown links did not work when `[...]` section had a line break. The implementation is straightforward since link resolution did not change w.r.t. RST implementation, it's almost only about new syntax addition. The only essential difference is a possibility to add a custom link description: form `[description][target]` which does not have an RST equivalent. * fix nim 1.0 gotcha
* Add improved Windows UNC path support in std/os (#20281)havardjohn2022-09-031-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add improved Windows UNC path support in std/os Original issue: `std/os.createDir` tries to create every component of the given path as a directory. The problem is that `createDir` interprets every backslash/slash as a path separator. For a UNC path this is incorrect. E.g. one UNC form is `\\Server\Volume\Path`. It's an error to create the `\\Server` directory, as well as creating `\\Server\Volume`. Add `ntpath.nim` module with `splitDrive` proc. This implements UNC path parsing as implemented in the Python `ntpath.py` module. The following UNC forms are supported: * `\\Server\Volume\Path` * `\\?\Volume\Path` * `\\?\UNC\Server\Volume\Path` Improves support for UNC paths in various procs in `std/os`: --- * pathnorm.addNormalizePath * Issue: This had incomplete support for UNC paths * The UNC prefix (first 2 characters of a UNC path) was assumed to be exactly `\\`, but it can be `//` and `\/`, etc. as well * Also, the UNC prefix must be normalized to the `dirSep` argument of `addNormalizePath` * Resolution: Changed to account for different UNC prefixes, and normalizing the prefixes according to `dirSep` * Affected procs that get tests: `relativePath`, `joinPath` * Issue: The server/volume part of UNC paths can be stripped when normalizing `..` path components * This error should be negligable, so ignoring this * splitPath * Now make sure the UNC drive is not split; return the UNC drive as `head` if the UNC drive is the only component of the path * Consequently fixes `extractFilename`, `lastPathPart` * parentDir / `/../` * Strip away drive before working on the path, prepending the drive after all work is done - prevents stripping UNC components * Return empty string if drive component is the only component; this is the behavior for POSIX paths as well * Alternative implementation: Just call something like `pathnorm.normalizePath(path & "/..")` for the whole proc - maybe too big of a change * tailDir * If drive is present in path, just split that from path and return path * parentDirs iterator * Uses `parentDir` for going backwards * When going forwards, first `splitDrive`, yield the drive field, and then iterate over path field as normal * splitFile * Make sure path parsing stops at end of drive component * createDir * Fixed by skipping drive part before creating directories * Alternative implementation: use `parentDirs` iterator instead of iterating over characters * Consequence is that it will try to create the root directory * isRootDir * Changed to treat UNC drive alone as root (e.g. "//?/c:" is root) * This change prevents the empty string being yielded by the `parentDirs` iterator with `fromRoot = false` * Internal `sameRoot` * The "root" refers to the drive, so `splitDrive` can be used here This adds UNC path support to all procs that could use it in std/os. I don't think any more work has to be done to support UNC paths. For the future, I believe the path handling code can be refactored due to duplicate code. There are multiple ways of manipulating paths, such as manually searching string for path separator and also having a path normalizer (pathnorm.nim). If all path manipulation used `pathnorm.nim`, and path component splitting used `parentDirs` iterator, then a lot of code could be removed. Tests --- Added test file for `pathnorm.nim` and `ntpath.nim`. `pathnorm.normalizePath` has no tests, so I'm adding a few unit tests. `ntpath.nim` contains tests copied from Python's test suite. Added integration tests to `tos.nim` that tests UNC paths. Removed incorrect `relativePath` runnableExamples from being tested on Windows: --- `relativePath("/Users///me/bar//z.nim", "//Users/", '/') == "me/bar/z.nim"` This is incorrect on Windows because the `/` and `//` are not the same root. `/` (or `\`) is expanded to the drive in the current working directory (e.g. `C:\`). `//` (or `\\`), however, are the first two characters of a UNC path. The following holds true for normal Windows installations: * `dirExists("/Users") != dirExists("//Users")` * `dirExists("\\Users") != dirExists("\\\\Users")` Fixes #19103 Questions: --- * Should the `splitDrive` proc be in `os.nim` instead with copyright notice above the proc? * Is it fine to put most of the new tests into the `runnableExamples` section of the procs in std/os? * [skipci] Apply suggestions from code review Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * [skip ci] Update lib/pure/os.nim Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Move runnableExamples tests in os.nim to tos.nim * tests/topt_no_cursor: Change from using splitFile to splitDrive `splitFile` can no longer be used in the test, because it generates different ARC code on Windows and Linux. This replaces `splitFile` with `splitDrive`, because it generates same ARC code on Windows and Linux, and returns a tuple. I assume the test wants a proc that returns a tuple. * Drop copyright attribute to Python Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* move formatfloat out of system (#20195)ringabout2022-08-242-0/+1757
| | | | | | | | | | | | | | | * move formatfloat out of system * fixes doc * Update changelog.md * careless * fixes * deprecate system/formatfloat * better handling
* test removing dollar for objects out of system (#20242)metagn2022-08-241-0/+39
| | | | | | | | | | | * test removing dollar for objects out of system * test & fixes * fix bootstrap * use nimPreviewSlimSystem, test stdlib category * fix test
* Add use of Windows Wide CRT API for env. vars (#20084)havardjohn2022-08-201-29/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add use of Windows Wide CRT API for env. vars Replaces use of CRT API `getenv` and `putenv` with respectively `_wgetenv` and `_wputenv`. Motivation is to reliably convert environment variables to UTF-8, and the wide API is best there, because it's reliably UTF-16. Changed the hack in `lib/std/private/win_setenv.nim` by switching the order of the Unicode and MBCS environment update; Unicode first, MBCS second. Because `_wgetenv`/`_wputenv` is now used, the Unicode environment will be initialized, so it should always be updated. Stop updating MBCS environment with the name of `getEnv`. It's not necessarily true that MBCS encoding and the `string` encoding is the same. Instead convert UTF-16 to current Windows code page with `wcstombs`, and use that string to update MBCS. Fixes regression in `6b3c77e` that caused `std/envvars.getEnv` or `std/os.getEnv` on Windows to return non-UTF-8 encoded strings. Add tests that test environment variables with Unicode characters in their name or value. * Fix test issues Fixes * `nim cpp` didn't compile the tests * Nimscript import of `tosenv.nim` from `test_nimscript.nims` failed with "cannot importc" * Fix missing error check on `wcstombs` * Fix ANSI testing errors * Separate ANSI-related testing to their own tests, and only executing them if running process has a specific code page * Setting locale with `setlocale` was not reliable and didn't work on certain machines * Add handling of a "no character representation" error in second `wcstombs` call * tests/newruntime_misc: Increment allocCount Increments overall allocations in `tnewruntime_misc` test. This is because `getEnv` now does an additional allocation: allocation of the UTF-16 string used as parameter to `c_wgetenv`. * Revert "tests/newruntime_misc: Increment allocCount" This reverts commit 4d4fe8bd3edb1bfc6d600f247af797c7552f5477. * tests/newruntime_misc: Increment allocCount on Windows Increments overall allocations in `tnewruntime_misc` test for Windows. This is because `getEnv` on Windows now does an additional allocation: allocation of the UTF-16 string used as parameter to `c_wgetenv`. * Refactor, adding suggestions from code review Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> * Document, adding suggestions Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com> Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* typetraits: add toSigned, toUnsigned (#18445)Timothee Cour2022-04-071-5/+10
| | | | | | | | * typetraits: add toSigned, toUnsigned * improve and add tests Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: flywind <xzsflywind@gmail.com>
* move assertions out of system (#19599)flywind2022-03-231-0/+4
|
* Fix #19038 - making the Nim compiler work again on Windows XP (#19331)rockcavera2022-01-071-20/+21
| | | | | | | | | | | | | * Update osenv.nim * Update win_setenv.nim * Update lib/pure/includes/osenv.nim * Update lib/pure/includes/osenv.nim * fixing cstring Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* add std/private/win_getsysteminfo; refactor the usage of `GetSystemInfo` ↵flywind2022-01-041-0/+15
| | | | | | | | | | | (#19310) * add std/private/win_getsysteminfo * import at the top level * wrappers follow nep1 too * follow review comment
* fix 19292 (#19293)rockcavera2021-12-291-6/+9
|
* fixes #19078 [backport] (#19090)Andreas Rumpf2021-11-021-3/+6
|
* fix a potential bug (#18900)flywind2021-10-141-1/+1
|
* strict effects (#18777)Andreas Rumpf2021-09-021-1/+6
| | | | | | | | | | | | | | | | | * fixes #17369 * megatest is green for --cpu:arm64 * docgen output includes more tags/raises * implemented 'effectsOf' * algorithm.nim: uses new effectsOf annotation * closes #18376 * closes #17475 * closes #13905 * allow effectsOf: [a, b] * added a test case * parameters that are not ours cannot be declared as .effectsOf * documentation * manual: added the 'sort' example * bootstrap with the new better options
* improvements to `addInt` and `$` for integer types (#18592)Timothee Cour2021-08-192-20/+57
| | | | | | | | * improvements to $(SomeInteger) and addInt * remove mIntToStr, mInt64ToStr * improvements * fix tests/pragmas/tinjectstmt.nim; the diff is harmless, cgen code is identical with -d:danger or debug mode * rm tests/system/tstrmantle.nim * revert compiler/jsgen.nim for -d:nimVersion140
* fix a sqlite bug (#18669)flywind2021-08-121-0/+15
|
* renamed: lib/std/private/vmutils.nim -> lib/std/private/bitops_utils.nim ↵Timothee Cour2021-08-081-0/+0
| | | | to avoid confusion with unrelated std/vmutils (#18660)
* Remove tracking of environment from osenv.nim v2 (#18575)Timothee Cour2021-07-291-0/+92
| | | | | | | | | | | | | * Remove unnecessary environment tracking * try to fix windows * fix delEnv * make putEnv work on windows even with empty values; improve tests: add tests, add js, vm testing * [skip ci] fix changelog Co-authored-by: Caden Haustein <code@brightlysalty.33mail.com>
* fix nativeToUnixPath (#18501)Timothee Cour2021-07-171-3/+8
|
* Simplify addInt, remove digits10 (#18356)Clyybber2021-06-281-35/+23
| | | | | | | | | | | | | * Simplify addInt, remove digits10 Co-authored-by: Charles Blake <charlechaud@gmail.com> * Fix bootstrapping * Add noInit to tmp array * noInit -> noinit Co-authored-by: Charles Blake <charlechaud@gmail.com>
* merge similar procs regarding digits (#18318)flywind2021-06-221-0/+88
|
* gitutils: add diffStrings, diffFiles, and use it in testament to compare ↵Timothee Cour2021-04-301-1/+39
| | | | | | | | | | | | | expected vs gotten (#17892) * gitutils: add diffStrings, diffFiles, and use it in testament to compare expected vs gotten * refactor with createTempDir * cleanup * refacotr * PRTEMP fake test spec changes to show effect of diffStrings * add runnableExamples for experimental/diff + cross-reference with gitutils * Revert "PRTEMP fake test spec changes to show effect of diffStrings" This reverts commit 57dc8d642dce6c1127c98b7cbc9edbfe747d4047.
* refactor all code that builds csources (#17815)Timothee Cour2021-04-231-1/+1
| | | | | | | | | | | | | | | * refactor all code that builds csources * fixup * nim_csourcesDir_v0 + nim_csourcesDir * remove deprecated, unused scripts from ci/ * reuse nimCsourcesHash in ci * simplify CI pipelines by reusing nimBuildCsourcesIfNeeded * simplify ci_docs.yml by reusing nimBuildCsourcesIfNeeded * cleanup * use csources_v1 as destination dir * fixup * remove pushCsources * address comment: remove build.sh support for now * fixup
* CIs: attempt to use csources_v1 (#16282)Andreas Rumpf2021-04-211-1/+1
| | | | | | | | * CIs: attempt to use csources_v1 * also updated the BSDs * also updated azure pipelines * std modules should not itself use the 'std/' import dir... * compiler has to be careful with std/ for v1 booting
* nnkArglist => nnkArgList + special case stylecheck:error (#17529)Timothee Cour2021-03-271-1/+1
| | | | | * nnkArglist => nnkArgList * special case stylecheck:error
* close #11330 sets uses optimized countSetBits (#17334)flywind2021-03-221-0/+17
| | | | | | | * Update lib/pure/bitops.nim * Update lib/system/sets.nim * Apply suggestions from code review Co-authored-by: Andreas Rumpf <rumpf_a@web.de>