ecl_namestring() takes now a second argument which is a flag and includes the possibility of enforcing that the output be a base string. This is used by chdir, which formerly failed to work because of getting an extended string from namestring.

This commit is contained in:
Juan Jose Garcia Ripoll 2009-08-03 21:14:40 +02:00
parent 185cc872f1
commit 54c3c99f3a
4 changed files with 38 additions and 19 deletions

View file

@ -1,6 +1,13 @@
ECL 9.8.1:
==========
* Important notes:
- The GMP library had to be patched to build with latest versions of GCC.
Since our patch only covers the main header and there might be some corners
left, it is recommended to build ECL against a better maintained version of
the library, such as MPIR or the versions supplied by your operating system.
* Ports:
- The MSVC port now boots also when built without support for Unicode.
@ -11,7 +18,7 @@ ECL 9.8.1:
- The NetBSD port builds with default values using the garbage collector
in the pkgsrc distribution.
- Solaris/Sparc now builds with the given libraries (GMP and Boehm).
- Solaris now builds with the given libraries (GMP and Boehm).
* Compiler:
@ -60,6 +67,8 @@ ECL 9.8.1:
- --enable-slow-config works again.
- EXT:CHDIR got broken when using Unicode.
;;; Local Variables: ***
;;; mode:text ***
;;; fill-column:79 ***

View file

@ -795,7 +795,9 @@ si_coerce_to_filename(cl_object pathname_orig)
pathname = coerce_to_file_pathname(pathname_orig);
if (cl_wild_pathname_p(1,pathname) != Cnil)
cl_error(3, @'file-error', @':pathname', pathname_orig);
namestring = cl_namestring(pathname);
namestring = ecl_namestring(pathname,
ECL_NAMESTRING_TRUNCATE_IF_ERROR |
ECL_NAMESTRING_FORCE_BASE_STRING);
if (namestring == Cnil) {
FEerror("Pathname ~A does not have a physical namestring",
1, pathname_orig);
@ -803,14 +805,6 @@ si_coerce_to_filename(cl_object pathname_orig)
if (cl_core.path_max != -1 &&
ecl_length(namestring) >= cl_core.path_max - 16)
FEerror("Too long filename: ~S.", 1, namestring);
#ifdef ECL_UNICODE
if (type_of(namestring) == t_string) {
if (!ecl_fits_in_base_string(namestring))
FEerror("The filesystem does not accept filenames with extended characters: ~S",
1, namestring);
namestring = si_copy_to_simple_base_string(namestring);
}
#endif
return namestring;
}
@ -869,11 +863,12 @@ ecl_merge_pathnames(cl_object path, cl_object defaults, cl_object default_versio
produce a readable representation of the pathname, NIL is returned.
*/
cl_object
ecl_namestring(cl_object x, int truncate_if_unreadable)
ecl_namestring(cl_object x, int flags)
{
bool logical;
cl_object l, y;
cl_object buffer, host;
bool truncate_if_unreadable = flags & ECL_NAMESTRING_TRUNCATE_IF_ERROR;
x = cl_pathname(x);
@ -995,13 +990,24 @@ NO_DIRECTORY:
return Cnil;
}
}
return cl_get_output_stream_string(buffer);
buffer = cl_get_output_stream_string(buffer);
#ifdef ECL_UNICODE
if (type_of(buffer) == t_string &&
(flags & ECL_NAMESTRING_FORCE_BASE_STRING)) {
if (!ecl_fits_in_base_string(buffer))
FEerror("The filesystem does not accept filenames "
"with extended characters: ~S",
1, buffer);
buffer = si_copy_to_simple_base_string(buffer);
}
#endif
return buffer;
}
cl_object
cl_namestring(cl_object x)
{
@(return ecl_namestring(x, 1))
@(return ecl_namestring(x, ECL_NAMESTRING_TRUNCATE_IF_ERROR))
}
@(defun parse_namestring (thing
@ -1138,7 +1144,7 @@ cl_file_namestring(cl_object pname)
pname->pathname.name,
pname->pathname.type,
pname->pathname.version),
1))
ECL_NAMESTRING_TRUNCATE_IF_ERROR))
}
cl_object
@ -1148,7 +1154,7 @@ cl_directory_namestring(cl_object pname)
@(return ecl_namestring(ecl_make_pathname(Cnil, Cnil,
pname->pathname.directory,
Cnil, Cnil, Cnil),
1))
ECL_NAMESTRING_TRUNCATE_IF_ERROR))
}
cl_object
@ -1200,7 +1206,7 @@ cl_host_namestring(cl_object pname)
EN_MATCH(path, defaults, type),
EN_MATCH(path, defaults, version));
newpath->pathname.logical = path->pathname.logical;
@(return ecl_namestring(newpath, 1))
@(return ecl_namestring(newpath, ECL_NAMESTRING_TRUNCATE_IF_ERROR))
@)
#undef EN_MATCH

View file

@ -937,7 +937,7 @@ si_get_library_pathname(void)
s = cl_make_pathname(8, @':name', Cnil, @':type', Cnil,
@':version', Cnil,
@':defaults', s);
s = ecl_namestring(s, 0);
s = ecl_namestring(s, ECL_NAMESTRING_FORCE_BASE_STRING);
}
#else
s = make_constant_base_string(ECLDIR "/");
@ -949,7 +949,7 @@ si_get_library_pathname(void)
ecl_internal_error("Cannot find ECL's directory");
}
/* Produce a string */
s = ecl_namestring(s, 0);
s = ecl_namestring(s, ECL_NAMESTRING_FORCE_BASE_STRING);
}
cl_core.library_pathname = s;
OUTPUT_UNCHANGED:
@ -965,7 +965,9 @@ si_get_library_pathname(void)
if (directory->pathname.name != Cnil ||
directory->pathname.type != Cnil)
FEerror("~A is not a directory pathname.", 1, directory);
namestring = cl_namestring(directory);
namestring = ecl_namestring(directory,
ECL_NAMESTRING_TRUNCATE_IF_ERROR |
ECL_NAMESTRING_FORCE_BASE_STRING);
if (safe_chdir((char*)namestring->base_string.self) <0)
FElibc_error("Can't change the current directory to ~A",
1, namestring);

View file

@ -1291,6 +1291,8 @@ extern ECL_API cl_object ecl_make_pathname(cl_object host, cl_object device, cl_
extern ECL_API cl_object ecl_parse_namestring(cl_object s, cl_index start, cl_index end, cl_index *ep, cl_object default_host);
extern ECL_API cl_object coerce_to_physical_pathname(cl_object x);
extern ECL_API cl_object coerce_to_file_pathname(cl_object pathname);
#define ECL_NAMESTRING_TRUNCATE_IF_ERROR 1
#define ECL_NAMESTRING_FORCE_BASE_STRING 2
extern ECL_API cl_object ecl_namestring(cl_object pname, int truncate_if_impossible);
extern ECL_API cl_object si_coerce_to_filename(cl_object pathname);
extern ECL_API cl_object ecl_merge_pathnames(cl_object path, cl_object defaults, cl_object default_version);