Board index FlightGear Development Nasal

Possible bug in string.match

Nasal is the scripting language of FlightGear.

Possible bug in string.match

Postby ThomasS » Fri Jun 01, 2018 5:46 am

Hello,

running the code

Code: Select all
if (string.match("747","747*") ) print ("matches"); else print("doesn't match");


prints "doesn't match" (FG2018.2). But as stated in the wiki, '*' stands for any number (including zero) of arbitrary characters. Am I wrong here or should we consider this to be a bug?

Best Regards

Thomas
ThomasS
 
Posts: 80
Joined: Sun Sep 11, 2016 1:21 pm
Location: West of EDDK
Version: 2018.2.1
OS: Linux,MacOS,Windows

Re: Possible bug in string.match

Postby wkitty42 » Fri Jun 01, 2018 10:11 am

confirmed with 2018.3.0...

Code: Select all
string.match("747","747*")  doesn't match
string.match("747","*747")  matches
string.match("747","*747*") doesn't match


looks like the parsing to break out the wild card isn't working right... i would say that it is a bug... are you going to file a report in the bug tracker?
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 4550
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: Possible bug in string.match

Postby ThomasS » Sat Jun 02, 2018 1:30 pm

Thanks for your comment. I created ticket #2016.
ThomasS
 
Posts: 80
Joined: Sun Sep 11, 2016 1:21 pm
Location: West of EDDK
Version: 2018.2.1
OS: Linux,MacOS,Windows

Re: Possible bug in string.match

Postby Necolatis » Sat Jun 02, 2018 1:55 pm

Your test case is wrong.

That function output -1 if not found.
So since 747 is at start of string it output 0, which you evaluate as false. Hence you think it wasn't found, but it was.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro

Re: Possible bug in string.match

Postby Necolatis » Sat Jun 02, 2018 2:05 pm

Oops I was thinking of find(). nevermind.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1833
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2018.1.1
OS: Windows 10 Pro


Return to Nasal

Who is online

Users browsing this forum: No registered users and 3 guests