ASSERT (close (fd) == 0);
}
+ /* Check // handling (the easy cases, without symlinks).
+ This // handling is not mandated by POSIX. However, many applications
+ expect that canonicalize_file_name "canonicalizes" the file name,
+ that is, that different results of canonicalize_file_name correspond
+ to different files (except for hard links). */
+ {
+ char *result0 = canonicalize_file_name ("/etc/passwd");
+ if (result0 != NULL) /* This file does not exist on native Windows. */
+ {
+ char *result;
+
+ result = canonicalize_file_name ("/etc//passwd");
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_file_name ("/etc///passwd");
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ /* On Windows, the syntax //host/share/filename denotes a file
+ in a directory named 'share', exported from host 'host'.
+ See also m4/double-slash-root.m4. */
+#if !(defined _WIN32 || defined __CYGWIN__)
+ result = canonicalize_file_name ("//etc/passwd");
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_file_name ("//etc//passwd");
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_file_name ("//etc///passwd");
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+#endif
+
+ result = canonicalize_file_name ("///etc/passwd");
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_file_name ("///etc//passwd");
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_file_name ("///etc///passwd");
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+ }
+ }
+
/* Check for ., .., intermediate // handling, and for error cases. */
{
char *result = canonicalize_file_name (BASE "//./..//" BASE "/tra");
ASSERT (errno == ELOOP);
}
- /* Check that leading // is honored correctly. */
+ /* Check that leading // within symlinks is honored correctly. */
{
struct stat st1;
struct stat st2;
ASSERT (close (fd) == 0);
}
+ /* Check // handling (the easy cases, without symlinks).
+ This // handling is not mandated by POSIX. However, many applications
+ expect that canonicalize_filename_mode "canonicalizes" the file name,
+ that is, that different results of canonicalize_filename_mode correspond
+ to different files (except for hard links). */
+ {
+ char *result0 = canonicalize_file_name ("/etc/passwd");
+ if (result0 != NULL) /* This file does not exist on native Windows. */
+ {
+ char *result;
+
+ result = canonicalize_filename_mode ("/etc/passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_filename_mode ("/etc//passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_filename_mode ("/etc///passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ /* On Windows, the syntax //host/share/filename denotes a file
+ in a directory named 'share', exported from host 'host'.
+ See also m4/double-slash-root.m4. */
+#if !(defined _WIN32 || defined __CYGWIN__)
+ result = canonicalize_filename_mode ("//etc/passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_filename_mode ("//etc//passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_filename_mode ("//etc///passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+#endif
+
+ result = canonicalize_filename_mode ("///etc/passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_filename_mode ("///etc//passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+
+ result = canonicalize_filename_mode ("///etc///passwd", CAN_MISSING);
+ ASSERT (result != NULL && strcmp (result, result0) == 0);
+ }
+ }
+
/* Check for ., .., intermediate // handling, and for error cases. */
{
char *result1 = canonicalize_file_name (BASE "//./..//" BASE "/tra");
free (result2);
}
- /* Check that leading // is honored correctly. */
+ /* Check that leading // within symlinks is honored correctly. */
{
struct stat st1;
struct stat st2;