#123 closed defect (fixed)

lua on windows uses short file names

Reported by: HoraK-FDF@… Owned by: Thomas Bernard
Priority: major Milestone: 2.7
Component: GrafX2 Version: 2.6
Keywords: Cc:

Description

Hi,

lua doesn't use long file names anymore only the short dos names. In grafx2-2.4.2035-win32 it was working maybe there is a clue what has changed.

Attachments (3)

GFX2_G~1_8bit.raw.s (1.7 KB) - added by HoraK-FDF@… 14 months ago.
gfx2_gif_error_pic__8bit.raw.s (1.9 KB) - added by HoraK-FDF@… 14 months ago.
pic_db_Export_Pic2asm_8bit_Tiles_SP2D_GBA.lua (4.8 KB) - added by HoraK-FDF@… 14 months ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 14 months ago by HoraK-FDF@…

sorry forgot I'm using grafx2-2.7wip2726-dir_fix as newest and tested down till v2.4 it was broken since one build of v2.5

comment:2 Changed 14 months ago by Thomas Bernard

Milestone: 2.7
Owner: changed from pulkomandy to Thomas Bernard
Status: newaccepted

What has changed is the added support for unicode filename.
https://gitlab.com/GrafX2/grafX2/merge_requests/31
up to version 2.5, windows version supported only "ANSI" file/directory names.

I guess you're script running with version 2.4 with non-ansi (greek, cyrillic, chinese, etc.) names would failed to run.

Please attach the affected script and the differences between runing it under 2.4 and 2.7wip.

Changed 14 months ago by HoraK-FDF@…

Attachment: GFX2_G~1_8bit.raw.s added

Changed 14 months ago by HoraK-FDF@…

Changed 14 months ago by HoraK-FDF@…

comment:3 Changed 14 months ago by HoraK-FDF@…

the files are attached the one with the short name is the output of grafx2-2.7wip2729-issue_121.

edit:
the version I'm running that does it right is 2.5wip2171 with lua 5.3.3

Last edited 14 months ago by HoraK-FDF@… (previous) (diff)

comment:4 Changed 14 months ago by Thomas Bernard

the issue is that lua strings are 8bits strings.
getfilename() is returning the utf-8 filename under unix, but the "short" file name under Windows.

I think the good way to fix this is to return a UTF-8 conversion of the "Long" file name under Windows
(the long file name is stored as a unicode string)

comment:5 Changed 14 months ago by Thomas Bernard

anyway your code assume all characters of the filename except - %( %) + are usable in ASM identifiers/labels, that is not true. you should filter out ALL characters except the authorized ones.

comment:6 Changed 14 months ago by Thomas Bernard

comment:7 Changed 14 months ago by Thomas Bernard

By the way, lua io.open() relies on fopen() so it won't work correctly with unicode filenames. You should sanitize file names to ASCII before.

see https://gitlab.com/miniupnp/grafX2/-/jobs/220781780/artifacts/browse for build

comment:8 in reply to:  5 Changed 14 months ago by HoraK-FDF@…

Replying to Thomas Bernard:

anyway your code assume all characters of the filename except - %( %) + are usable in ASM identifiers/labels, that is not true. you should filter out ALL characters except the authorized ones.

that filtering I do by hand when naming the picture I don't use names with other characters than that I filter.

comment:9 Changed 14 months ago by HoraK-FDF@…

Thanks its seems to work at least with the characters I use in file names I tested it with all three versions.

I have a quick question I'm not sure if it is an bug or something that is like it is: every time I load a picture and don't change anything and only loaded to page 1 and let a script run (like the attached) when I then wan't to close gfx2 it comes with stay/save/discard dialog for booth pages, is that correct or must i run a special lua command in the script to avoid this? Or does gfx2 always assumes if a lua script has run something has changed?

comment:10 Changed 14 months ago by Thomas Bernard

yes GrafX2 make a backup even if the lua script doesn't change anything.
https://gitlab.com/GrafX2/grafX2/blob/master/src/factory.c#L2485
you can open a new ticket about it ;)

comment:11 Changed 14 months ago by Thomas Bernard

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.