1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-31 21:52:59 +00:00

Cherry pick several changes back from 1.19.3

The main purpose of this is to backport the improved parse/runtime
errors to older versions. I think they're sufficiently useful that we
should try to make it as widely available as possible.

We've been running them for a week now on SC3 and the released version
and not seen any issues, so I think it's probably stable enough.

This is a pretty lazy commit: I ended up copying the whole ROM over and
then picking up a few other related changes along the way.

 - Trim spaces from file paths (b8fce1eecc)

 - Correctly format 12AM/PM with
   %I (9f48395596)

 - Fix http.request and htpt.websocketAsync not handling a few failure
   edge-cases correctly (3b42f22a4f).

 - Move the internal modules into the main package path, hidden under
   cc.internal (34a31abd9c).

 - Gather code coverage in Java instead of
   Lua (28a55349a9).

 - Make error messages in edit more
   obvious (8cfbfe7ceb).

 - Make mcfly's test methods global. This means we don't need to pass
   stub everywhere (7335a892b5).

 - Improve runtime and parse errors. This comes from numerous commits,
   but chiefly a12b405acf, and
   5502412181.

 - Hide the internal redirect methods in
   multishell (33b6f38339).

Note this does /not/ include the shebang changes (sorry Emma!). I've
tried to avoid adding any user-controllable features, mostly because I
don't know how to handle the versioning otherwise :).
This commit is contained in:
Jonathan Coates
2023-02-14 09:45:02 +00:00
parent 68f6fa9343
commit 9b3cadf57c
95 changed files with 5447 additions and 942 deletions

View File

@@ -89,7 +89,7 @@ final class LuaDateTime
formatter.appendValue( ChronoField.HOUR_OF_DAY, 2 );
break;
case 'I':
formatter.appendValue( ChronoField.HOUR_OF_AMPM, 2 );
formatter.appendValue( ChronoField.CLOCK_HOUR_OF_AMPM, 2 );
break;
case 'j':
formatter.appendValue( ChronoField.DAY_OF_YEAR, 3 );

View File

@@ -5,6 +5,7 @@
*/
package dan200.computercraft.core.filesystem;
import com.google.common.base.Splitter;
import com.google.common.io.ByteStreams;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.api.filesystem.IFileSystem;
@@ -515,10 +516,11 @@ public class FileSystem
path = cleanName.toString();
// Collapse the string into its component parts, removing ..'s
String[] parts = path.split( "/" );
Stack<String> outputParts = new Stack<>();
for( String part : parts )
ArrayDeque<String> outputParts = new ArrayDeque<>();
for( String fullPart : Splitter.on( '/' ).split( path ) )
{
String part = fullPart.trim();
if( part.isEmpty() || part.equals( "." ) || threeDotsPattern.matcher( part ).matches() )
{
// . is redundant
@@ -529,32 +531,32 @@ public class FileSystem
if( part.equals( ".." ) )
{
// .. can cancel out the last folder entered
if( !outputParts.empty() )
if( !outputParts.isEmpty() )
{
String top = outputParts.peek();
String top = outputParts.peekLast();
if( !top.equals( ".." ) )
{
outputParts.pop();
outputParts.removeLast();
}
else
{
outputParts.push( ".." );
outputParts.addLast( ".." );
}
}
else
{
outputParts.push( ".." );
outputParts.addLast( ".." );
}
}
else if( part.length() >= 255 )
{
// If part length > 255 and it is the last part
outputParts.push( part.substring( 0, 255 ) );
outputParts.addLast( part.substring( 0, 255 ).trim() );
}
else
{
// Anything else we add to the stack
outputParts.push( part );
outputParts.addLast( part );
}
}