Jump to content

AutoIt v3.3.15.5 Beta issue with _pathsplit


Go to solution Solved by erha,

Recommended Posts

This is my first post - I hope I follow all rules 😀

I have used the portable autoit version 3.3.15.4 Beta. After switching to 3.3.15.5 Beta I could run my programs from scite but the compilation crashes.

For some reasons compile uses _PathSplit. In case the parameter $sFilePath is an empty string, _PathSplit crashes.

_PathSplit uses

Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH)


AutoIt version 3.3.15.4 returns an array with 5, AutoIt version 3.3.15.5 returns an array with 3 elements. The missing two elements are the reason for the crash.

I have used this test program:

#include "StringConstants.au3"

Local $sFilePath = ''
Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH)
MsgBox ( 0,0, UBound($aArray)  )

As a workaround I changed _PathSplit to

Func _PathSplit($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension)
    Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH)
    If @error Then ; This error should never happen.
        ReDim $aArray[5]
        $aArray[$PATH_ORIGINAL] = $sFilePath
    EndIf
    if UBound ( $aArray) < 5 Then ; ### my change
        ReDim $aArray[5]
        $aArray[$PATH_ORIGINAL] = $sFilePath
    endif
    ...

After this change I can compile my programs.

Link to comment
Share on other sites

  • Developers

Could you also post an script that uses pathsplit demonstrating your issue?

 

Ps I've split it into its own topic in support. :)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@Jos  I get also the problem on non-portable.  

#include <File.au3>
#include <Array.au3>

Local $sDrive, $sDir, $sFileName, $sExtension
Local $arr = _PathSplit("", $sDrive, $sDir, $sFileName, $sExtension)
_ArrayDisplay($arr, @AutoItVersion)

Both SRE (current and beta) are identical.  It might be the fix #2696: StringRegExp non-participating groups that causes the problem.

Link to comment
Share on other sites

@Jos

Nine has posted the script i just wanted to post too. His script crashes in the new autoit version. The error message is

"D:\System\Programme\Portable\AutoIt\Current\Include\File.au3" (1012) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$sFileName = $aArray[$PATH_FILENAME]
$sFileName = ^ ERROR

Link to comment
Share on other sites

Link to comment
Share on other sites

Same for me - The error happens almost immediately when asking for "Tools/Compile" from SCITE. It works when asking for "Tools/Build" 

......\Include\File.au3" (1012) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$sFileName = $aArray[$PATH_FILENAME]
$sFileName = ^ ERROR

No error when compilation is outside of Scite.

Edited by labichea
additional finding
Link to comment
Share on other sites

On 3/3/2022 at 7:35 PM, Nine said:

@Jos  I get also the problem on non-portable.  

#include <File.au3>
#include <Array.au3>

Local $sDrive, $sDir, $sFileName, $sExtension
Local $arr = _PathSplit("", $sDrive, $sDir, $sFileName, $sExtension)
_ArrayDisplay($arr, @AutoItVersion)

Both SRE (current and beta) are identical.  It might be the fix #2696: StringRegExp non-participating groups that causes the problem.

I tried your repro and after few more test I found out other issue AutoIt3.exe ended.rc:-1073741571 with this repro:

#AutoIt3Wrapper_AutoIt3Dir="z:\AutoItPortable\AutoIt_3_3_16_0_rc1"
#AutoIt3Wrapper_UseX64=n

ConsoleWrite("! " & @AutoItVersion & @CRLF)

_Example3()

Func _Example3()
    Local Const $s_RegExp = _ ; $s_RegExp comes from Func _PathSplit(
            '^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$'

    Local $sString = 'xxxxxxxxxx'
    For $iCounter = 1 To 11
        ConsoleWrite("- step #" & $iCounter & ' StringLen= ' & StringLen($sString) & @CRLF)
        StringRegExp($sString, $s_RegExp, 0)
        $sString &= $sString
    Next
EndFunc   ;==>_Example3

results:

Quote

! 3.3.14.5
- step #1 StringLen= 10
- step #2 StringLen= 20
- step #3 StringLen= 40
- step #4 StringLen= 80
- step #5 StringLen= 160
- step #6 StringLen= 320
- step #7 StringLen= 640
- step #8 StringLen= 1280
- step #9 StringLen= 2560
- step #10 StringLen= 5120
- step #11 StringLen= 10240
!>18:47:37 AutoIt3.exe ended.rc:-1073741571

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

@Jon this is old bug:

Quote

! 3.3.14.5
- step #1 StringLen= 10
- step #2 StringLen= 20
- step #3 StringLen= 40
- step #4 StringLen= 80
- step #5 StringLen= 160
- step #6 StringLen= 320
- step #7 StringLen= 640
- step #8 StringLen= 1280
- step #9 StringLen= 2560
- step #10 StringLen= 5120
- step #11 StringLen= 10240
!>18:51:24 AutoIt3.exe ended.rc:-1073741571
 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

even au3.3.10.0

Quote

! 3.3.10.0
- step #1 StringLen= 10
- step #2 StringLen= 20
- step #3 StringLen= 40
- step #4 StringLen= 80
- step #5 StringLen= 160
- step #6 StringLen= 320
- step #7 StringLen= 640
- step #8 StringLen= 1280
- step #9 StringLen= 2560
- step #10 StringLen= 5120
- step #11 StringLen= 10240
!>18:52:49 AutoIt3.exe ended.rc:-1073741571
 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • 3 months later...

I don't undertand what happen with 3.3.16.0-rc1

What I am sure is the propose patch  to Jon was OK. I cannot reproduce any error mention above.

I agree that the support of non participating group return difference which are the right way to return

Just use https://regex101.com/ to validate your pattern.

Previously StringRegExp() was returning extra group.

In fact nobody can give me a pattern which was ok without any adaptation to _PathSplit()

The _PathSplit() has been adapted to handle these differences.

Cheers

Edited: I recheck what was included in 3.3.16.0.rc1 and I found Jon forget to update the File.au3

Edited by jpm
Link to comment
Share on other sites

3 hours ago, jpm said:

In fact nobody can give me a pattern which was ok without any adaptation to _PathSplit()

Indeed I've been unable to find a reasonable pattern to match every form a path can have.

Local $a = [ _
    "fff", _
    "fff.ext", _
    "fff.more.ext", _
    "./fff.more.ext", _
    "..\fff.more.ext", _
    "..\fff. more .ext ", _
    "..\././.../fff. more .ext ", _
    "c:.../fff. more .ext ", _
    "..\fff. more .ext ", _
    "C:\Documents\Newsletters\Summer2018.pdf", _
    "\Program Files\Custom Utilities\StringFinder.exe", _
    "2018\January.xlsx", _
    "..\Publications\TravelBrochure.pdf", _
    "C:\Projects\apilibrary\apilibrary.sln", _
    "C:Projects\apilibrary\apilibrary.sln", _
    "\\system07\C$\", _
    "\\Server2\Share\Test\Foo.txt", _
    "\\.\C:\Test\Foo.txt", _
    "\\?\C:\Test\Foo.txt", _
    "\\.\Volume{b75e2c83-0000-0000-0000-602f00000000}\Test\Foo.txt", _
    "\\?\Volume{b75e2c83-0000-0000-0000-602f00000000}\Test\Foo.txt", _
    "\\.\UNC\Server\Share\Test\Foo.txt", _
    "\\?\UNC\Server\Share\Test\Foo.txt", _
    "\\?\server1\e:\utilities\\filecomparer\", _
    "c:\temp\test-file.txt", _
    "\\127.0.0.1\c$\temp\test-file.txt", _
    "\\LOCALHOST\c$\temp\test-file.txt", _
    "\\.\c:\temp\test-file.txt", _
    "\\?\c:\temp\test-file.txt", _
    "\\.\UNC\LOCALHOST\c$\temp\test-file.txt", _
    "\\127.0.0.1\c$\temp\test-file.txt", _
    "con", _
    "con:", _
    "lpt2", _
    "com4:", _
    "", _       ; invalid
    ".", _      ; invalid
    "Z꞉abc.xyz", _    ; dirty Unicode trick using "꞉" (ChrW(0x2236)) instead of ":" (ASCII column)
    "..", _
    "...", _
    "...a", _
    "....a", _
    "....a.", _
    "....a...", _
    ".a.b", _
    ".a.b.", _
    ".3", _
    "3." _
]

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...