aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-04-19posix_spawn_file_actions_addfchdir_np: return EBADF on negative fdCorinna Vinschen1-1/+6
FreeBSD and Musl implement posix_spawn_file_actions_addfchdir_np so that it checks the incoming descriptor for being negative, and, if so, return with EBADF. The POSIX proposal defining posix_spawn_file_actions_addfchdir follows this behaviour, see https://www.austingroupbugs.net/view.php?id=1208 Fixes: 7e03fc35f528 ("Add posix_spawn_file_actions_add{f}chdir_np") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-19Cygwin: mbrtowi: fix segfault when pwi is NULLDavid McFarland1-2/+4
mbrtowi was missing null-checks on pwi, but NULL is passed from regex/engine.c:173. In a git repo with sendemail.smtpserver set, this results in a segfault when using git-send-email, which calls: git config --get-regexp '^sende?mail[.]' Fixes: 60c25da90d01 ("Cygwin: mbrtowi: define replacement for mbrtowc, returning UTF-32 value") Signed-off-by: David McFarland <corngood@gmail.com>
2023-04-19Cygwin: Export posix_spawn_file_actions_add{f}chdir_npCorinna Vinschen3-0/+10
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18Add posix_spawn_file_actions_add{f}chdir_npCorinna Vinschen3-3/+95
These are defined as _np functions and available in glibc, musl, macOS, FreeBSD, Solaris ≥ 11.3 They are likely to be standardized without the _np suffix as a result of Austin Group issue 1208. if so, both names will be kept as aliases. Introduce HAVE_CHDIR and HAVE_FCHDIR to allow building on systems not providing these calls. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18Cygwin: align renameat2 to Linux behaviourCorinna Vinschen2-5/+17
In contrast to rename default behaviour, Linux' renameat2 returns -1 with errno set to EEXIST, if oldfile and newfile refer to the same file, and the RENAME_NOREPLACE flag is set. Follow suit, given this is a Linux-only function anyway. Fixes: f665b1cef30f ("cygwin: Implement renameat2") Reported-by: Bruno Haible <bruno@clisp.org> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18Cygwin: fix errno values set by readlinkatCorinna Vinschen2-20/+25
readlinkat(fd, "", ...) is supposed to return ENOENT per POSIX, but Cygwin returns EBADF. At the same time, we have to maintain the special feature of glibc that readlinkat(fd, "", ...) operates on fd, if fd is pointing at a symlink opened with O_PATH|O_NOFOLLOW. And, while fixing that, readlinkat(fd, path, ...) *still* has to set errno to EBADF, if fd is an invalid descriptor *and* path is a relative path. This required to change the evaluation order in the helper function gen_full_path_at. Last but not least, in case of the aforementioned glibc-like special handling for symlink descriptors, we have to make sure that errors from gen_full_path_at are not spilled into that special handling. Fixes: 6cc05784e16a ("Cygwin: readlinkat: allow pathname to be empty") Reported-by: Bruno Haible <bruno@clisp.org> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18Cygwin: fix return value of ilogbl(NaN)Corinna Vinschen2-0/+7
Fixes: 792e51b72149 ("Add missing long double functions to Cygwin") Reported-by: Bruno Haible <bruno@clisp.org> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18Cygwin: add release text for previous commitCorinna Vinschen1-0/+3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18Cygwin: cygheap: fix fork error after heap has grownDavid McFarland1-1/+2
2f9b8ff0 introduced a problem where forks would sometimes fail with: child_copy: cygheap read copy failed, 0x0..0x80044C750, done 0, windows pid 14032, Win32 error 299 When cygheap_max was > CYGHEAP_STORAGE_INITIAL, commit_size would be set to allocsize(cygheap_max), which is an address, not a size. VirtualAlloc would be called to commit commit_size bytes, which would fail, and then child_copy would be called with zero as the base address. Fixes: 2f9b8ff00cce ("Cygwin: decouple cygheap from Cygwin DLL") Signed-off-by: David McFarland <corngood@gmail.com>
2023-04-14Cygwin: pty: Fix reading CONIN$ when stdin is not a pty.Takashi Yano2-0/+9
Previously, the pty master sends inputs to the pipe for cygwin app even when pseudo console is activated if stdin is not the pty. This causes the problem that key input is not sent to non cygwin app even if the app opens CONIN$. This patch sets switch_to_nat_pipe to true regardless whether stdin is the pty or not to allow that case. https://cygwin.com/pipermail/cygwin/2023-April/253424.html Reported-by: Wladislav Artsimovich <cygwin@frost.kiwi> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-04-13Replace always true if with elseAndoni Arregi1-2/+5
2023-04-13Compare j as unsignedAndoni Arregi1-1/+1
j is int32_t and thus j<<31 is undefined if j==1. Taken from FreeBSD commit bdd8abc6d6a93ce3ab8ad5db716222ee3110c4a3
2023-04-13Fix x close to 1, y between 2^31 and 2^64Andoni Arregi1-2/+2
E.g. known errors: x = 0x1.000002c5e2e99p+0, y = 0x1.c9eee35374af6p+31 had an error of 639 ULP and is now correctly rounded. x = 0x1.fffffd2e3e669p-1, y = 0x1.344c9823eb66cp+32 had an error of 428 ULP and is now correctly rounded.
2023-04-13Fix missing sign for overflow/underflow where x is negative and y is large ↵Andoni Arregi1-19/+18
odd integer
2023-04-03Cygwin: chattr: fix description of requirements for casesensitive directoriesCorinna Vinschen2-7/+20
Preconditions of WSL or empty directories dependent on Windows versions was totally screwed up. Drop the description from --help, describe the preconditions for case-sensitive dirs in the man page instead. Fixes: fc6e89c937c1 ("Cygwin: chattr: clarify requirements for casesensitive directories") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-03Respect `db_home` setting even for SYSTEM/Microsoft accountsJohannes Schindelin1-1/+5
We should not blindly set the home directory of the SYSTEM account (or of Microsoft accounts) to `/home/<name>`, especially `/etc/nsswitch.conf` defines `db_home: env`, in which case we want to respect the `HOME` variable. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-03-30Bump newlib version in the manual to 4.3.0Tobias Burnus2-4/+4
While commit 9e09d6ed8 (tag: newlib-4.3.0) bumped the newlib version to 4.3.0, this commit updates the version/date in the libc/libm manuals to match.
2023-03-29Cygwin: doc: fix description of new "env" schema for /etc/nsswitch.confCorinna Vinschen1-10/+6
Fixes: 27376c60a9b8 ("Allow deriving the current user's home directory via the HOME variable") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-29Cygwin: dirname: fix handling of leading slashesCorinna Vinschen2-1/+4
Per https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/xbd_chap04.html: "A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash." So more than 2 leading slashes are supposed to be folded into one, which our dirname neglected. Fix that. Fixes: 24e8fc6872a3b ("* cygwin.din (basename): Export.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-28Allow deriving the current user's home directory via the HOME variableJohannes Schindelin3-1/+75
This patch hails from Git for Windows (where the Cygwin runtime is used in the form of a slightly modified MSYS2 runtime), where it is a well-established technique to let the `$HOME` variable define where the current user's home directory is, falling back to `$HOMEDRIVE$HOMEPATH` and `$USERPROFILE`. The idea is that we want to share user-specific settings between programs, whether they be Cygwin, MSYS2 or not. Unfortunately, we cannot blindly activate the "db_home: windows" setting because in some setups, the user's home directory is set to a hidden directory via an UNC path (\\share\some\hidden\folder$) -- something many programs cannot handle correctly, e.g. `cmd.exe` and other native Windows applications that users want to employ as Git helpers. The established technique is to allow setting the user's home directory via the environment variables mentioned above: `$HOMEDRIVE$HOMEPATH` or `$USERPROFILE`. This has the additional advantage that it is much faster than querying the Windows user database. Of course this scheme needs to be opt-in. For that reason, it needs to be activated explicitly via `db_home: env` in `/etc/nsswitch.conf`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-03-27Cygwin: chattr: clarify requirements for casesensitive directoriesCorinna Vinschen2-4/+6
- Windows 10 requires WSL - Windows 11 only allows enabling casesensitivity if dir is empty Fixes: 0d4b39d37b966 ("Cygwin: Add lsattr and chattr tools") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26Cygwin: /proc/locales: filter out useless explicit utf8 localesCorinna Vinschen1-4/+6
Fixes: c42b98bdc665f ("Cygwin: introduce /proc/codesets and /proc/locales") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26Cygwin: locales: fix behaviour for @euro localesCorinna Vinschen1-1/+9
Latest Windows supports more EU locales than GLibc, so some of the @euro locales are not covered by checking the GLibc locale defaults. Those locales have no long history, they are all UTF-8. So just check for @euro in the UTF-8 case and set them to ISO-8859-15. Fixes: 2483e54be852e ("Cygwin: locale: Set default charset from Linux locale -> codeset mapping") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26Cygwin: locales: fix behaviour for @cjk* and @euro localesCorinna Vinschen1-1/+7
@cjknarrow and @cjkwide modifiers are newlib only, so they need some tweaking in __set_charset_from_locale. Fixes: 2483e54be852e ("Cygwin: locale: Set default charset from Linux locale -> codeset mapping") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26Cygwin: /proc/locales: use ENCODING_LEN to define array sizesCorinna Vinschen1-12/+12
Fixes: c42b98bdc665f ("Cygwin: introduce /proc/codesets and /proc/locales") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26Cygwin: /proc/locales: use modifier when checking default codesetCorinna Vinschen1-5/+6
Drop usage of newlocale/nl_langinfo_l/freelocale. Call __set_charset_from_locale instead, and make sure to call it with modifier, if any, otherwise suffer wrong results. Fixes: c42b98bdc665f ("Cygwin: introduce /proc/codesets and /proc/locales") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-25Cygwin: locales: fix return value check of ResolveLocaleNameCorinna Vinschen1-1/+1
ResolveLocaleName does not simply return an error value if it can't resolve a locale. Rather, it returns an empty string and the length of this string: 1. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-25Revert "Cygwin: locales: drop supporting iso639 strings as valid locales"Corinna Vinschen1-2/+11
This reverts commit 15898b95881b1fa504e671e0bcfd653b242effa8. The idea behind this patch was wrong. Systems are supposed to support iso639-only strings as settings for the locale environment variables, and they are not necessarily available in the /usr/share/locale/locale.alias file. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24Cygwin: locales: implement own method to check locale validityCorinna Vinschen1-1/+61
The Windows function ResolveLocaleName is next to useless to convert a partial locale identifier into a full, supported locale identifier. It converts anything which vaguely resembles a locale into some other locale it supports. Bad examples are: "en-XY" gets converted to "en-US", and worse, "ff-BF" gets converted to "ff-Latn-SN", even though "ff-Adlm-BF" exists! To check if a locale is supported, we have to enumerate all valid Windows locales, and return the match, even if the locale in Windows requires a script. Implement resolve_locale_name() as replacement function for ResolveLocaleName. Fixes: e95a7a795522 ("Cygwin: convert Windows locale handling from LCID to ISO5646 strings") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24Cygwin: locales: drop supporting iso639 strings as valid localesCorinna Vinschen1-11/+2
This was incorrect behaviour. The only valid way to support those is by adding them to /usr/share/locale/locale.alias. Fixes: e95a7a795522 ("Cygwin: convert Windows locale handling from LCID to ISO5646 strings") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24Cygwin: locales: set errno to ENOENT if locale is invalidCorinna Vinschen1-2/+8
This allows newlocale to return with a valid errno if the locale is invalid. Fixes: e95a7a795522 ("Cygwin: convert Windows locale handling from LCID to ISO5646 strings") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24Cygwin: /proc/locales: fix "sr" localesCorinna Vinschen1-2/+6
The sr_XY locales are supposed to default to cyrillic, but the code always attached a @cyrillic, same reason as in the previous commit. Special case "sr" further to workaround that issue. Fixes: c42b98bdc665 ("Cygwin: introduce /proc/codesets and /proc/locales") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24Cygwin: /proc/locales: fix sd_IN localeCorinna Vinschen1-1/+8
Due to the way locales are evaluated in Windows, we can't ask for the script of the "sd-IN" locale, because Windows only knows the "sd-Deva-IN" locale. So asking for the script of the "sd" locale returns "Arab;", because "sd" is converted to "sd-Arab-PK". Special case "sd-IN" to workaround that issue. Fixes: c42b98bdc665 ("Cygwin: introduce /proc/codesets and /proc/locales") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24newlocale: set errno to ENOENT if __loadlocale failsCorinna Vinschen1-1/+4
__loadlocale never sets errno, but newlocale is supposed to return ENOENT if the locale isn't valid. Fixes: aefd8b5b518b ("Implement newlocale, freelocale, duplocale, uselocale") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-21Cygwin: log disabling posix semanticsYoshinao Muramatsu1-1/+7
Add log when workaround occurs Signed-off-by: Yoshinao Muramatsu <ysno@ac.auone-net.jp>
2023-03-21Cygwin: fix rename in containerYoshinao Muramatsu1-0/+10
Renaming files returns STATUS_INVALID_PARAMETE on a bind mounted file system in hyper-v container with FILE_RENAME_POSIX_SEMANTICS. Disable the use_posix_semantics flag and retry. Signed-off-by: Yoshinao Muramatsu <ysno@ac.auone-net.jp>
2023-03-21Cygwin: fix unlink in containerYoshinao Muramatsu1-1/+4
Deleting files returns STATUS_INVALID_PARAMETE on a bind mounted file system in hyper-v container with FILE_DISPOSITION_POSIX_SEMANTICS. Therefore fall back to default method. This code is suggested by Johannes Schindelin on github and I change it more simple. Signed-off-by: Yoshinao Muramatsu <ysno@ac.auone-net.jp>
2023-03-21Cygwin: don't use unlink/rename POSIX semantics on certain NTFSCorinna Vinschen1-5/+9
If a host NTFS is mapped into a Hyper-V isolated container, the OPEN_BY_FILE_ID filesystem flag is missing, just as if that NTFS is a remote drive. However, NtQueryVolumeInformationFile claims the drive is a local drive. We can use this fact to learn that the process is running under Hyper-V, and that the Hyper-V isolated process can't use rename/unlink with POSIX semantics. Strange enough, the POSIX_UNLINK_RENAME filesystem flag is still set... Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-21Cygwin: fs_info::update: fix NTFS filesystem flagsCorinna Vinschen1-7/+5
These flags are used to check a remote filesystem. Not all flags supported by a local NTFS are available when checking a remote NTFS. Fix the flag set accordingly, otherwise the remote NTFS will ba handled as CIFS. Fixes: fcccdc4021ff ("Cygwin: fs_info: update filesystem flags and check Windows 7 flags") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20Cygwin: regex: fix faulty check for valid range expressionCorinna Vinschen1-3/+1
Except for the "C" or "POSIX" locale, checking for start <= finish is always wrong. Range start must be <= range finish in terms of the locale's collating order. So make sure to call always wcscoll(), even in the "C"/"POSIX" locale, which makes wcscoll equivalent to wcscmp anyway. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20Cygwin: regex: fix freeing g->charjump in low memory conditionCorinna Vinschen1-1/+1
computejumps() moves g->charjump to a position relativ to the value of CHAR_MIN. As such, g->charjump doesn't necessarily point to the address actually allocated. While regfree() takes that into account, the low memory handling in regcomp_internal() doesn't. Fix that by free'ing the actually allocated address, as in regfree(). Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20Cygwin: unlink: drop unlink_nt/unlink_nt_shareable wrappersCorinna Vinschen3-22/+10
Useless indirection. Rename _unlink_nt back to unlink_nt and call the function directly with `sharable' flag as needed. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20Cygwin: fs_info: update filesystem flags and check Windows 7 flagsCorinna Vinschen2-9/+74
Update the list of filesystem flags to the flags supported since Windows 7. Make sure to use the new flags only with Windows filesystems, not with 3rd party filesystems. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16Cygwin: add support for GB18030 codesetCorinna Vinschen7-7/+37
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16Cygwin: regex: NONCHAR: re-add cast to intCorinna Vinschen1-1/+1
wint_t is unsigned int and the test checks for a negative value. Thus, it's optimized out by gcc. Add the cast from commit 44caccfca2433 to avoid this. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16Cygwin: regex: wgetnext: Re-add kludge to be more glibc compatibleCorinna Vinschen1-0/+12
Add comment to explain. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16Cygwin: regex: convert wchar_t to wint_t throughoutCorinna Vinschen3-15/+21
...and use __wcollate_range_cmp. This will have to be tweaked further when supporting collation symbols... Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16Cygwin: regex: fix build errorsCorinna Vinschen1-5/+6
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16Cygwin: replace regex with latest verbatim FreeBSD versionCorinna Vinschen12-660/+1093
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-15Cygwin: kill(1): Add -L to documentationCorinna Vinschen1-2/+8
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>