1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #1484 from ailin-nemui/realposix

change realpath to use syntax based on _POSIX_VERSION
This commit is contained in:
ailin-nemui 2023-08-09 18:52:16 +00:00 committed by GitHub
commit f9c9485d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,6 +305,9 @@ int config_write(CONFIG_REC *rec, const char *fname, int create_mode)
const char *base_name;
char *tmp_name = NULL;
char *dest_name = NULL;
#if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L
char resolved_path[PATH_MAX] = { 0 };
#endif
g_return_val_if_fail(rec != NULL, -1);
g_return_val_if_fail(fname != NULL || rec->fname != NULL, -1);
@ -313,16 +316,15 @@ int config_write(CONFIG_REC *rec, const char *fname, int create_mode)
base_name = fname != NULL ? fname : rec->fname;
/* expand all symlinks; else we may replace a symlink with a regular file */
dest_name = realpath(base_name, NULL);
if (errno == EINVAL) {
/* variable path length not supported by glibc < 2.3, Solaris < 11 */
char resolved_path[PATH_MAX] = { 0 };
errno = 0;
if ((dest_name = realpath(base_name, resolved_path)) != NULL) {
dest_name = g_strdup(dest_name);
}
#if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L
/* variable path length not supported by glibc < 2.3, Solaris < 11 */
errno = 0;
if ((dest_name = realpath(base_name, resolved_path)) != NULL) {
dest_name = g_strdup(dest_name);
}
#else
dest_name = realpath(base_name, NULL);
#endif
if (dest_name == NULL) {
if (errno == ENOENT) {