summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--legacy/evil/AUTHORS1
-rw-r--r--legacy/evil/ChangeLog7
-rw-r--r--legacy/evil/src/lib/evil_stdlib.c64
-rw-r--r--legacy/evil/src/lib/evil_stdlib.h8
4 files changed, 79 insertions, 1 deletions
diff --git a/legacy/evil/AUTHORS b/legacy/evil/AUTHORS
index cee8fc9f11..54911d18d2 100644
--- a/legacy/evil/AUTHORS
+++ b/legacy/evil/AUTHORS
@@ -6,3 +6,4 @@ Main Authors:
6 Paul Vixie (ISC) (inet_pton and inet_ntop functions) 6 Paul Vixie (ISC) (inet_pton and inet_ntop functions)
7 Daniel Stenberg (inet_pton and inet_ntop functions) 7 Daniel Stenberg (inet_pton and inet_ntop functions)
8 The MinGW and MinGW-w64 teams (POSIX printf family functions) 8 The MinGW and MinGW-w64 teams (POSIX printf family functions)
9 Keith Marshall (realpath on Windows XP). See http://sourceforge.net/tracker/?func=detail&atid=302435&aid=1294010&group_id=2435
diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog
index d7f5e7bd13..9beb471d40 100644
--- a/legacy/evil/ChangeLog
+++ b/legacy/evil/ChangeLog
@@ -1,3 +1,10 @@
12012-07-03 Vincent Torri <doursse at users dot sf dot net>
2
3 * AUTHORS:
4 * src/lib/evil_stdlib.c:
5 * src/lib/evil_stdlib.h:
6 Update realpath() code, based on Keith Marshall's implementation.
7
12012-04-26 Vincent Torri <doursse at users dot sf dot net> 82012-04-26 Vincent Torri <doursse at users dot sf dot net>
2 9
3 * NEWS: 10 * NEWS:
diff --git a/legacy/evil/src/lib/evil_stdlib.c b/legacy/evil/src/lib/evil_stdlib.c
index 11a33103f7..d22a7dc71e 100644
--- a/legacy/evil/src/lib/evil_stdlib.c
+++ b/legacy/evil/src/lib/evil_stdlib.c
@@ -362,7 +362,69 @@ char *
362realpath(const char *file_name, char *resolved_name) 362realpath(const char *file_name, char *resolved_name)
363{ 363{
364#ifndef __MINGW32CE__ 364#ifndef __MINGW32CE__
365 return _fullpath(resolved_name, file_name, PATH_MAX); 365 char *retname = NULL; /* we will return this, if we fail */
366
367 /* SUSv3 says we must set `errno = EINVAL', and return NULL,
368 * if `name' is passed as a NULL pointer.
369 */
370
371 if (file_name == NULL)
372 errno = EINVAL;
373
374 /* Otherwise, `name' must refer to a readable filesystem object,
375 * if we are going to resolve its absolute path name.
376 */
377
378 else if (access(file_name, 4) == 0)
379 {
380 /* If `name' didn't point to an existing entity,
381 * then we don't get to here; we simply fall past this block,
382 * returning NULL, with `errno' appropriately set by `access'.
383 *
384 * When we _do_ get to here, then we can use `_fullpath' to
385 * resolve the full path for `name' into `resolved', but first,
386 * check that we have a suitable buffer, in which to return it.
387 */
388
389 if ((retname = resolved_name) == NULL)
390 {
391 /* Caller didn't give us a buffer, so we'll exercise the
392 * option granted by SUSv3, and allocate one.
393 *
394 * `_fullpath' would do this for us, but it uses `malloc', and
395 * Microsoft's implementation doesn't set `errno' on failure.
396 * If we don't do this explicitly ourselves, then we will not
397 * know if `_fullpath' fails on `malloc' failure, or for some
398 * other reason, and we want to set `errno = ENOMEM' for the
399 * `malloc' failure case.
400 */
401
402 retname = malloc(_MAX_PATH);
403 }
404
405 /* By now, we should have a valid buffer.
406 * If we don't, then we know that `malloc' failed,
407 * so we can set `errno = ENOMEM' appropriately.
408 */
409
410 if (retname == NULL)
411 errno = ENOMEM;
412
413 /* Otherwise, when we do have a valid buffer,
414 * `_fullpath' should only fail if the path name is too long.
415 */
416
417 else if ((retname = _fullpath(retname, file_name, _MAX_PATH)) == NULL)
418 errno = ENAMETOOLONG;
419 }
420
421 /* By the time we get to here,
422 * `retname' either points to the required resolved path name,
423 * or it is NULL, with `errno' set appropriately, either of which
424 * is our required return condition.
425 */
426
427 return retname;
366#else 428#else
367 char cwd[PATH_MAX]; 429 char cwd[PATH_MAX];
368 size_t l1; 430 size_t l1;
diff --git a/legacy/evil/src/lib/evil_stdlib.h b/legacy/evil/src/lib/evil_stdlib.h
index 96a0ae9fe6..81d564f86f 100644
--- a/legacy/evil/src/lib/evil_stdlib.h
+++ b/legacy/evil/src/lib/evil_stdlib.h
@@ -175,6 +175,14 @@ EAPI int mkstemp(char *__template);
175 * That function can be used to obtain the absolute path name for 175 * That function can be used to obtain the absolute path name for
176 * relative paths (relPath) that include "./" or "../" in their names. 176 * relative paths (relPath) that include "./" or "../" in their names.
177 * 177 *
178 * On Windows XP, errno is set in the following cases:
179 *
180 * @li EACCESS: if @p file_name can not be accessed.
181 * @li EINVAL: if @p file_name is @c NULL.
182 * @li ENAMETOOLONG: if the path name is too long.
183 * @li ENOENT: @p file_name does not exist
184 * @li ENOMEM: if memory allocation fails.
185 *
178 * Conformity: None. 186 * Conformity: None.
179 * 187 *
180 * Supported OS: Windows XP, Windows CE. 188 * Supported OS: Windows XP, Windows CE.