Skip to content
This repository has been archived by the owner on Oct 23, 2019. It is now read-only.

a lot of bugfixes #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 59 additions & 59 deletions Source/ClassLibrary/DateTime.CLR/DateTime.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Source/ClassLibrary/DateTime.CLR/DateTimeParsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public struct Relative

#region Parse

public static int Parse(string/*!*/ str, DateTime utcStart, out string error)
public static long Parse(string/*!*/ str, DateTime utcStart, out string error)
{
Debug.Assert(str != null);

Expand All @@ -141,7 +141,7 @@ public static int Parse(string/*!*/ str, DateTime utcStart, out string error)

#region GetUnixTimeStamp

private int GetUnixTimeStamp(DateTime utcStart, out string error)
private long GetUnixTimeStamp(DateTime utcStart, out string error)
{
var zone = PhpTimeZone.CurrentTimeZone;
DateTime start = TimeZoneInfo.ConvertTimeFromUtc(utcStart, zone);// zone.ToLocalTime(utcStart);
Expand Down
16 changes: 9 additions & 7 deletions Source/ClassLibrary/FileSystem.CLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ private static void Clear()
statCacheUrl = null;
}

private static char[] invalidPathChars = Path.GetInvalidPathChars();

#endregion

#region Stat Basics (BuildStatArray, StatInternal, lstat, stat, fstat, clearstatcache; exists, touch)
Expand Down Expand Up @@ -510,11 +512,11 @@ public static string GetType(string path)
/// <returns>The file access time or -1 in case of failure.</returns>
[ImplementsFunction("fileatime")]
[return: CastToFalse]
public static int GetAccessTime(string path)
public static long GetAccessTime(string path)
{
bool ok = StatInternal(path, false);
if (!ok) return -1;
return unchecked((int)statCache.st_atime);
return statCache.st_atime;
}

/// <summary>
Expand Down Expand Up @@ -666,7 +668,7 @@ public static bool IsDirectory(string path)
{
StreamWrapper wrapper;

if (!string.IsNullOrEmpty(path) && StatInternalCheck(ref path, false, out wrapper)) // do not throw warning if path is null or empty
if (!string.IsNullOrEmpty(path) && path.IndexOfAny(invalidPathChars) < 0 && StatInternalCheck(ref path, false, out wrapper)) // do not throw warning if path is null or empty
{
string url;
if (StatInternalTryCache(path, out url))
Expand All @@ -693,7 +695,7 @@ public static bool IsDirectory(string path)
[ImplementsFunction("is_executable")]
public static bool IsExecutable(string path)
{
bool ok = StatInternal(path, false);
bool ok = !string.IsNullOrEmpty(path) && path.IndexOfAny(invalidPathChars) < 0 && StatInternal(path, false);
if (!ok) return false;
return ((FileModeFlags)statCache.st_mode & FileModeFlags.Execute) > 0;
}
Expand All @@ -708,7 +710,7 @@ public static bool IsFile(string path)
{
StreamWrapper wrapper;

if (StatInternalCheck(ref path, false, out wrapper))
if (!string.IsNullOrEmpty(path) && path.IndexOfAny(invalidPathChars) < 0 && StatInternalCheck(ref path, false, out wrapper))
{
string url;
if (StatInternalTryCache(path, out url))
Expand Down Expand Up @@ -744,7 +746,7 @@ public static bool IsLink(string path)
[ImplementsFunction("is_readable")]
public static bool IsReadable(string path)
{
bool ok = StatInternal(path, false);
bool ok = !string.IsNullOrEmpty(path) && path.IndexOfAny(invalidPathChars) < 0 && StatInternal(path, false);
if (!ok) return false;
return ((FileModeFlags)statCache.st_mode & FileModeFlags.Read) > 0;
}
Expand All @@ -769,7 +771,7 @@ public static bool IsWriteable(string path)
[ImplementsFunction("is_writable")]
public static bool IsWritable(string path)
{
bool ok = StatInternal(path, false);
bool ok = !string.IsNullOrEmpty(path) && path.IndexOfAny(invalidPathChars) < 0 && StatInternal(path, false);
if (!ok) return false;
return ((FileModeFlags)statCache.st_mode & FileModeFlags.Write) > 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ClassLibrary/Miscellaneous.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public static int GetCurrentProcessId()
/// </summary>
/// <returns>The UNIX timestamp or -1 on error.</returns>
[ImplementsFunction("getlastmod")]
public static int GetLastModification()
public static long GetLastModification()
{
try
{
Expand Down
17 changes: 16 additions & 1 deletion Source/ClassLibrary/Output.CLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,22 @@ public static PhpArray GetStatus(bool full)
public static void FlushHttpBuffers()
{
HttpContext http_context = HttpContext.Current;
if (http_context != null) http_context.Response.Flush();
if (http_context != null)
{
try
{
http_context.Response.Flush();
}
catch (HttpException)
{
var context = RequestContext.CurrentContext;
if (context != null && !context.TrackClientDisconnection)
{
return;
}
throw;
}
}
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/ClassLibrary/Session.CLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ protected override void Collect(string savePath, string sid, int lifetime)
{
if (dir == null) return;

int threshold = DateTimeUtils.UtcToUnixTimeStamp(DateTime.Now.ToUniversalTime().AddSeconds(-lifetime));
long threshold = DateTimeUtils.UtcToUnixTimeStamp(DateTime.Now.ToUniversalTime().AddSeconds(-lifetime));

string file_name;
while ((file_name = PhpDirectory.Read(dir)) != null)
{
if (file_name.Length >= FilePrefix.Length && file_name.Substring(0, FilePrefix.Length) == FilePrefix)
{
string full_path = Path.Combine(savePath, file_name);
int time = PhpFile.GetAccessTime(full_path);
long time = PhpFile.GetAccessTime(full_path);

if (time < threshold)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/ClassLibrary/Web.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public static string RawUrlEncode(string str)
[ImplementsFunction("urldecode")]
public static string UrlDecode(string str)
{
return HttpUtility.UrlDecode(str);
return HttpUtility.UrlDecode(str, Configuration.Application.Globalization.PageEncoding);
}

/// <summary>
Expand All @@ -387,7 +387,7 @@ public static string UrlDecode(string str)
[ImplementsFunction("urlencode")]
public static string UrlEncode(string str)
{
return UpperCaseEncodedChars(HttpUtility.UrlEncode(str));
return UpperCaseEncodedChars(HttpUtility.UrlEncode(str, Configuration.Application.Globalization.PageEncoding));
}

private static string UpperCaseEncodedChars(string encoded)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Compiler/AppCompiler.CLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ public static bool IsPureUnit(string/*!*/ value)
}

PhpAssemblyBuilder assembly_builder = PhpAssemblyBuilder.Create(applicationContext, kind, ps.Pure, ps.OutPath,
ps.DocPath, entry_point_file, ps.Version, ps.Key, ps.Icon, resource_files, config.Compiler.Debug, ps.Force32Bit);
ps.DocPath, entry_point_file, ps.Version, ps.Key, ps.Icon, resource_files, config.Compiler.DebugMode, ps.Force32Bit);

assembly_builder.IsMTA = ps.IsMTA;

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Compiler/CodeGenerator/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2950,7 +2950,7 @@ internal void EmitPhpException(ILEmitter/*!*/ il, MethodInfo/*!*/ method)
/// <param name="endColumn">Real last column of the point.</param>
internal void MarkSequencePoint(int startLine, int startColumn, int endLine, int endColumn)
{
if (context.Config.Compiler.Debug)
if (context.Config.Compiler.DebugMode != DebugMode.None)
{
// ignores #pragma inside the code span:
ISymbolDocumentWriter symbol_writer = sourceUnit.GetMappedSymbolDocumentWriter(startLine);
Expand All @@ -2971,7 +2971,7 @@ internal void MarkSequencePoint(int startLine, int startColumn, int endLine, int
}
}

/// <summary>
/// <summary>
/// Marks a sequence point (see <see cref="MarkSequencePoint"/>) using position of given <paramref name="expression"/>.
/// </summary>
/// <param name="expression">Expression which position is used to mark sequence point.</param>
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Compiler/WebServerManagers.CLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public IPhpModuleBuilder DefineModuleBuilder(CompilationUnitBase/*!*/ compiledUn

// creates a script assembly builder:
SingleScriptAssemblyBuilder builder = new SingleScriptAssemblyBuilder(applicationContext,
name, outDir, name.Name + AssemblyExt, AssemblyKinds.WebPage, context.Config.Compiler.Debug, false, context.SaveOnlyAssembly, null);
name, outDir, name.Name + AssemblyExt, AssemblyKinds.WebPage, context.Config.Compiler.DebugMode, false, context.SaveOnlyAssembly, null);

return builder.DefineScript(unit);
}
Expand Down
15 changes: 14 additions & 1 deletion Source/Core/Configuration.CLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,15 @@ internal int HashCode
hashcode += mapping.Pattern.ToString().GetHashCode();
hashcode += mapping.Replacement.GetHashCode();
}
hashcode += debug ? 897987897 : 12;
if (debug)
{
hashcode += 897987897;
}
else
{
hashcode += 12;
hashcode += genegatePdbInRelease ? 564456654 : 35;
}
}

dirty = false;
Expand All @@ -873,6 +881,7 @@ internal CompilerSection()
dirty = true;
hashcode = 0;
debug = true;
genegatePdbInRelease = true;
disabledWarnings = WarningGroups.DeferredToRuntime | WarningGroups.CompilerStrict;
disabledWarningNumbers = ArrayUtils.EmptyIntegers;

Expand Down Expand Up @@ -979,6 +988,10 @@ public bool Parse(string name, string value, XmlNode node)
debug = (value == "true");
return true;

case "GeneratePdbInRelease":
genegatePdbInRelease = (value == "true");
return true;

case "WatchSourceChanges":
{
// applicable only in run-time:
Expand Down
63 changes: 58 additions & 5 deletions Source/Core/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

namespace PHP.Core
{
public enum DebugMode
{
None,
Pdb,
Full
}
#region Language Features Enum

/// <summary>
Expand Down Expand Up @@ -222,7 +228,14 @@ public sealed partial class OutputControlSection : IPhpConfigurationSection

internal OutputControlSection DeepCopy()
{
return (OutputControlSection)MemberwiseClone();
return new OutputControlSection()
{
charSet = charSet,
contentType = contentType,
implicitFlush = implicitFlush,
outputBuffering = outputBuffering,
outputHandler = outputHandler == null ? null : outputHandler.DeepCopy()
};
}
}

Expand Down Expand Up @@ -337,7 +350,12 @@ private static string AbsolutizeLogFile(string value, System.Xml.XmlNode/*!*/nod
/// </summary>
internal ErrorControlSection DeepCopy()
{
return (ErrorControlSection)this.MemberwiseClone();
var copy = (ErrorControlSection)MemberwiseClone();
if (UserExceptionHandler != null)
copy.UserExceptionHandler = UserExceptionHandler.DeepCopy();
if (UserHandler != null)
copy.UserHandler = UserHandler.DeepCopy();
return copy;
}
}

Expand Down Expand Up @@ -422,7 +440,10 @@ public sealed partial class AssertionSection : IPhpConfigurationSection
/// </summary>
internal AssertionSection DeepCopy()
{
return (AssertionSection)this.MemberwiseClone();
var copy = (AssertionSection) MemberwiseClone();
if (Callback != null)
copy.Callback = Callback.DeepCopy();
return copy;
}
}

Expand Down Expand Up @@ -503,7 +524,12 @@ public static bool ValidateRegisteringOrder(string value)
/// </summary>
internal VariablesSection DeepCopy()
{
return (VariablesSection)this.MemberwiseClone();
var copy = (VariablesSection) MemberwiseClone();
if (DeserializationCallback != null)
{
copy.DeserializationCallback = DeserializationCallback.DeepCopy();
}
return copy;
}
}

Expand Down Expand Up @@ -787,7 +813,34 @@ public bool Debug
}
internal bool debug;

#endregion
public bool GenegatePdbInRelease {
get { return genegatePdbInRelease; }
set
{
genegatePdbInRelease = value;
#if !SILVERLIGHT
dirty = true;
#endif
}
}
internal bool genegatePdbInRelease;

public DebugMode DebugMode
{
get
{
DebugMode result;
if (debug)
result = DebugMode.Full;
else if (genegatePdbInRelease)
result = DebugMode.Pdb;
else
result = DebugMode.None;
return result;
}
}

#endregion

#region Inclusions

Expand Down
Loading