Commit Graph

72 Commits

Author SHA1 Message Date
Gianmarco
f44c49c5bd Change unicode lookup tables to have int32 elements to support platforms where sizeof(int) < 4 (#23433)
Fixes an issue that comes up when using strutils.`%` or any other
strutils/strformat feature that uses the unicode lookup tables behind
the scenes, on systems where ints are than 32-bit wide.

Tested with:

```bash
./koch test cat lib
```

Refer to the discussion in #23125.

(cherry picked from commit 4c38569229)
2024-04-22 16:18:24 +02:00
ringabout
b07526b2c7 refactor envvars, oserrors; register vmops (#20592)
* refactor envvars, oserrors; register vmops

* remove type definitions
2022-10-18 19:44:26 +02:00
ringabout
c0824b9b80 [std/os clean up] import and export osseps (#20580)
import and export osseps
2022-10-17 20:29:00 +02:00
metagn
0b1650576c move widestrs out of system (#20462)
* move widestrs out of system

* fix osproc
2022-10-01 22:35:09 +02:00
metagn
f4af9e955b remove some deprecated pre-1.0 stdlib modules (#20202)
* remove pre-1.0 stdlib deprecations

notable exceptions:
* ze, toU8 etc in system/arithmetics
* potentially callsite

* undo macros, ospaths, securehash, oswalkdir

* add sets back

* add back future, document deprecated versions

* add to changelog [skip ci]
2022-08-23 20:18:40 +02:00
havardjohn
f4bbf3bf0b Add use of Windows Wide CRT API for env. vars (#20084)
* 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 4d4fe8bd3e.

* 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>
2022-08-20 04:30:11 -04:00
rockcavera
c7d5b8c83d Fix #19038 - making the Nim compiler work again on Windows XP (#19331)
* 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>
2022-01-07 08:26:55 +01:00
Andrey Makarov
b21eb1ed36 change os.nim doc links to new style (#19102) 2021-11-08 13:10:01 +01:00
Timothee Cour
f061971a9b envPairs works in vm, nims (#18615)
* envPairs works in vm, nims

* fixup
2021-09-29 09:32:39 +02:00
Timothee Cour
6b3c77e7f4 Remove tracking of environment from osenv.nim v2 (#18575)
* 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>
2021-07-29 23:05:26 +02:00
Caden Haustein
f62f4159f8 Replace calls to putenv with setenv (#18530)
* Replace calls to C `putenv` with C `setenv` to remove possible memory leaks

* Add test of correct behaviour on invalid input

* Fix style in tests/stdlib/tos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update tests/stdlib/tos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update tests/stdlib/tos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Add comment with bug number to tests/stdlib/tos.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Fix possible msvc arch issues

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2021-07-23 10:04:29 +02:00
Timothee Cour
ffce6de84c improve rendering of newOSError.additionalInfo (#18443)
* improve rendering of newOSError.additionalInfo

* fixup
2021-07-07 09:43:16 +02:00
konsumlamm
9819fb21d8 Use .. warning:: (#17320) 2021-03-10 10:39:23 -08:00
flywind
0e3ea16554 use lowercase --define switches (#17283) 2021-03-07 12:08:41 +01:00
Juan Carlos
4982d1c662 https://github.com/nim-lang/Nim/pull/15826/files#r585368355 (#17233) 2021-03-03 11:58:05 +01:00
flywind
4556901572 use single backtick (#17141) 2021-02-21 19:53:28 -08:00
Rummskartoffel
2a60974ede Correct typo in osseps.nim (#16939) 2021-02-04 15:36:28 -08:00
Juan Carlos
78a99587a4 Deprecate TaintedString (#15423)
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
2021-01-15 18:56:38 -08:00
Andreas Rumpf
b87bcb6d92 fixes #16359 [backport] (#16377) 2020-12-17 13:35:02 +01:00
flywind
139075e965 move decode_helpers to std/private (#16209) 2020-12-02 10:30:55 -08:00
Timothee Cour
cc882917fe js -d:nodejs now supports osenv: getEnv, putEnv, envPairs, delEnv, existsEnv (v2) (#15826)
* js -d:nodejs now supports osenv: `getEnv`, `putEnv`, `envPairs`, `delEnv`, `existsEnv`

* refactor to osenv

* fix for js (without -d:nodejs) + VM

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
2020-11-12 14:36:57 +01:00
Miran
c62513049c fix #14082, don't crash on incorrectly formatted input (#14977) [backport]
* fix #14082, don't crash on incorrectly formatted input

* address code review

* remove duplication
2020-07-17 10:59:53 +02:00
Arne Döring
4005f0d0e4 forward type alignment information to seqs (#12430) 2020-04-19 07:52:01 +02:00
alaviss
0eaacbc2c4 More fixes for Haiku (#13774)
* osproc: move fork-based code path under the when conditional

* osproc: avoid using the environ global on Haiku

* osenv: import environ from stdlib.h on Haiku

Haiku's environ is declared in `<stdlib.h>` by default, differing from
POSIX and/or Linux. Import it from there to avoid collision with anyone
importing `<stdlib.h>` from Nim.
2020-03-27 09:08:13 +01:00
Timothee Cour
bf22b44b1f miscellaneous bug fixes (#13291)
* fix for emscripten etc

* add testcase for #13290

* replace deprecated isNilOrWhitespace
2020-01-30 10:54:50 +01:00
Teashrock
27fee4d8b4 Deleted misplaced separator (#13085) [backport]
Misplaced separator, which was constantly breaking compilation on Haiku OS, was deleted.
2020-01-09 11:48:13 +01:00
narimiran
cc3e9ca164 remove unused imports 2019-11-06 12:01:00 +01:00
Andreas Rumpf
c0d240b8cd fixes #11807 (#11900)
* fixes #11807
* make tests green again
2019-08-07 22:40:58 +02:00
genotrance
44aadd50cf Fix #10630 - fix broken separators in nim doc (#11814) 2019-07-24 14:45:05 +02:00
alaviss
a59fb5b352 os: confine osErrorMsg example to Linux (#11725)
POSIX does **not** define the exact number for each errors. This caused
a failure in docs building on Haiku.
2019-07-13 16:16:09 +02:00
Kaushal Modi
7182922622 [feature] Added os.delEnv; add delEnv support to nimscript too (#11466)
[feature] Fixes https://github.com/nim-lang/Nim/issues/11452.
2019-06-15 11:32:26 +02:00
Dominik Picheta
73c44c6e9b [bugfix] Fixes async IO operations stalling even after socket is closed. (#11232) 2019-06-12 17:07:05 +02:00
genotrance
c94ab46923 Fix ospaths import error (#11150) 2019-05-01 08:54:02 +02:00
Araq
c3067e36bb newruntime: progress 2019-04-01 16:51:18 +02:00
Miran
aeb30a72c0 update unicode.nim (#10921)
* update unicode.nim

* create a script to create the needed unicode data
* make unicode.nim compatible with Unicode v12.0.0
* slightly improve unicode.nim documentation (fixes #4795)

* more documentation
2019-03-31 08:36:04 +02:00
Miran
0c2c2dca2a better docs: os (#10492)
* better docs: os
* remove broken test on osx
2019-01-30 17:35:09 +01:00
Kobi
28b3c8d74d prevent index out of bounds error in oserr.nim 2019-01-19 10:56:36 -08:00
Federico Ceratto
095eaacf21 Fix spelling errors (#10379) 2019-01-19 16:01:27 +01:00
narimiran
29e0a792ff [backport] fix documentation leak to os.nim[ci skip] 2019-01-14 09:24:12 +01:00
Araq
9cc4a57768 os.nim: big refactoring, use the new pathnorm that was extracted by compiler/pathutils.nim; added os.relativePath 2018-12-13 12:05:50 +01:00
Andreas Rumpf
3177aee75f Merge pull request #9910 from nc-x/fix-semicolon
Fixes #9907
2018-12-11 12:26:23 +01:00
Neelesh Chandola
5aba5875da Address Comments 2018-12-11 10:44:43 +05:30
Neelesh Chandola
abdfbd07a5 Fixes #9907 2018-12-09 10:35:30 +05:30
Dominik Picheta
775bfb3e8d Merge async common into asyncdispatch. 2018-12-07 22:47:10 +00:00
pgkos
4efbde84ee Make getEnv case insensitive on Windows (#9722) 2018-11-16 08:45:50 +01:00
Andreas Rumpf
8d850f7a69 deprecated ospaths (#9665) 2018-11-09 16:36:49 +01:00
LemonBoy
a27429304e Convert *_family fields to cushort
Fixes #9008
2018-09-19 12:33:11 +02:00
Timothee Cour
67aa8eab0b add data.sysCommand when startProcessAuxSpawn raises 2018-09-06 03:12:10 -07:00
Timothee Cour
9249276db0 addresses issue #8391 show runtime context on some failed operations (#8393) 2018-07-23 22:58:03 +02:00
Dominik Picheta
f805018461 Fixes #5880. (#7229) 2018-07-10 00:33:31 +02:00