This commit is contained in:
parent
64b4430b85
commit
5c5572897d
|
|
@ -270,6 +270,15 @@ namespace PascalABCCompiler
|
|||
}
|
||||
}
|
||||
|
||||
public class InvalidPathError : CompilerCompilationError
|
||||
{
|
||||
public InvalidPathError(SyntaxTree.SourceContext sc)
|
||||
: base(string.Format(StringResources.Get("COMPILATIONERROR_INVALID_PATH")))
|
||||
{
|
||||
this.source_context = sc;
|
||||
}
|
||||
}
|
||||
|
||||
public class ResourceFileNotFound : CompilerCompilationError
|
||||
{
|
||||
public ResourceFileNotFound(string ResFileName, TreeRealization.location sl)
|
||||
|
|
@ -1812,7 +1821,19 @@ namespace PascalABCCompiler
|
|||
CompilerOptions.OutputDirectory = project.output_directory;
|
||||
}
|
||||
|
||||
public string Compile()
|
||||
private static string CombinePathWithCheck(string path1, string path2, location loc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Path.Combine(path1, path2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidPathError(loc);
|
||||
}
|
||||
}
|
||||
|
||||
public string Compile()
|
||||
{
|
||||
|
||||
try
|
||||
|
|
@ -2007,7 +2028,7 @@ namespace PascalABCCompiler
|
|||
{
|
||||
ErrorsList.Add(new MainResourceNotAllowed(cds[0].location));
|
||||
}
|
||||
cdo.MainResourceFileName = Path.Combine(Path.GetDirectoryName(cds[0].source_file), cds[0].directive);
|
||||
cdo.MainResourceFileName = CombinePathWithCheck(Path.GetDirectoryName(cds[0].source_file), cds[0].directive, cds[0].location);
|
||||
if (!File.Exists(cdo.MainResourceFileName))
|
||||
{
|
||||
ErrorsList.Add(new ResourceFileNotFound(cds[0].directive, cds[0].location));
|
||||
|
|
@ -2021,7 +2042,7 @@ namespace PascalABCCompiler
|
|||
List<TreeRealization.compiler_directive> ResourceDirectives = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_resource];
|
||||
foreach (TreeRealization.compiler_directive cd in ResourceDirectives)
|
||||
{
|
||||
var resource_fname = Path.Combine(Path.GetDirectoryName(cd.source_file), cd.directive);
|
||||
var resource_fname = CombinePathWithCheck(Path.GetDirectoryName(cd.source_file), cd.directive, cd.location);
|
||||
|
||||
if (File.Exists(resource_fname))
|
||||
ResourceFiles.Add(resource_fname);
|
||||
|
|
@ -2275,6 +2296,7 @@ namespace PascalABCCompiler
|
|||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
|
||||
string fn = "Compiler";
|
||||
if (CurrentCompilationUnit != null && this.CurrentCompilationUnit.SyntaxTree != null) fn = Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name);
|
||||
Errors.CompilerInternalError comp_err = new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", fn), err);
|
||||
|
|
@ -2635,7 +2657,7 @@ namespace PascalABCCompiler
|
|||
// Вначале - кешированные стандартные dll
|
||||
if (standart_assembly_dict.ContainsKey(FileName))
|
||||
return standart_assembly_dict[FileName];
|
||||
if (curr_path != null && System.IO.File.Exists(Path.Combine(curr_path, FileName)))
|
||||
if (curr_path != null && System.IO.File.Exists(Path.Combine(curr_path, FileName, null)))
|
||||
return Path.Combine(curr_path, FileName);
|
||||
if (System.IO.File.Exists(FileName))
|
||||
{
|
||||
|
|
@ -2664,7 +2686,7 @@ namespace PascalABCCompiler
|
|||
}
|
||||
//\MikhailoMMX
|
||||
|
||||
var FullFileName = Path.Combine(curr_path, FileName);
|
||||
var FullFileName = CombinePathWithCheck(curr_path, FileName, new location(sc.begin_position.line_num, sc.begin_position.column_num, sc.end_position.line_num, sc.end_position.column_num, new document(sc.FileName)));
|
||||
if (System.IO.File.Exists(FullFileName))
|
||||
{
|
||||
var NewFileName = Path.Combine(compilerOptions.OutputDirectory, Path.GetFileName(FullFileName));
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "8";
|
||||
public const string Build = "3";
|
||||
public const string Revision = "3250";
|
||||
public const string Revision = "3251";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=3
|
||||
%REVISION%=3250
|
||||
%MINOR%=8
|
||||
%REVISION%=3251
|
||||
%COREVERSION%=3
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
3.8.3.3250
|
||||
3.8.3.3251
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.8.3.3250'
|
||||
!define VERSION '3.8.3.3251'
|
||||
|
|
|
|||
5
TestSuite/errors/err0518_invalid_path.pas
Normal file
5
TestSuite/errors/err0518_invalid_path.pas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
//!Путь содержит недопустимые символы
|
||||
{$mainresource '|'}
|
||||
begin
|
||||
|
||||
end.
|
||||
|
|
@ -181,5 +181,6 @@ ANONYMOUS_DELEGATES_WITH_GENERIC_PARAMS_NOT_ALLOWED=Cannot deduce type of anonym
|
|||
UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Unit expected, library found
|
||||
ASSEMBLY_{0}_READING_ERROR=Error by reading assembly '{0}'
|
||||
INVALID_ASSEMBLY_PATH=Assembly path has invalid characters
|
||||
INVALID_PATH=The path has invalid characters
|
||||
INCLUDE_NAMESPACE_IN_UNIT=Cannot use includenamespace in units
|
||||
NAMESPACE_MODULE_EXPECTED=namespace expected
|
||||
|
|
@ -175,6 +175,7 @@ ANONYMOUS_DELEGATES_WITH_GENERIC_PARAMS_NOT_ALLOWED=Нельзя вывести
|
|||
%PREFIX%=COMPILATIONERROR_
|
||||
UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Ожидался модуль, а встречена библиотека
|
||||
ASSEMBLY_{0}_READING_ERROR=Ошибка при чтении сборки '{0}'
|
||||
INVALID_ASSEMBLY_PATH=Путь к сборке имеет недопустимые символы
|
||||
INVALID_ASSEMBLY_PATH=Путь к сборке содержит недопустимые символы
|
||||
INVALID_PATH=Путь содержит недопустимые символы
|
||||
INCLUDE_NAMESPACE_IN_UNIT=Использование includenamespace в модулях недопустимо
|
||||
NAMESPACE_MODULE_EXPECTED=Ожидалось пространство имен
|
||||
|
|
@ -173,5 +173,6 @@ ANONYMOUS_DELEGATES_WITH_GENERIC_PARAMS_NOT_ALLOWED=Нельзя вывести
|
|||
UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Очікувався модуль, а зустріли бібліотеку
|
||||
ASSEMBLY_{0}_READING_ERROR=Помилка при читанні збірки '{0}'
|
||||
INVALID_ASSEMBLY_PATH=Шлях до збірки має неприпустимі символи
|
||||
INVALID_PATH=Шлях має неприпустимі символи
|
||||
INCLUDE_NAMESPACE_IN_UNIT=Использование includenamespace в модулях недопустимо
|
||||
NAMESPACE_MODULE_EXPECTED=Ожидалось пространство имен
|
||||
Loading…
Reference in a new issue