Opened 5 years ago

Closed 5 years ago

#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@… 5 years ago.
gfx2_gif_error_pic__8bit.raw.s (1.9 KB ) - added by HoraK-FDF@… 5 years ago.
pic_db_Export_Pic2asm_8bit_Tiles_SP2D_GBA.lua (4.8 KB ) - added by HoraK-FDF@… 5 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by HoraK-FDF@…, 5 years ago

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 by Thomas Bernard, 5 years ago

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.

by HoraK-FDF@…, 5 years ago

Attachment: GFX2_G~1_8bit.raw.s added

by HoraK-FDF@…, 5 years ago

comment:3 by HoraK-FDF@…, 5 years ago

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

Version 0, edited 5 years ago by HoraK-FDF@… (next)

comment:4 by Thomas Bernard, 5 years ago

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 by Thomas Bernard, 5 years ago

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 by Thomas Bernard, 5 years ago

comment:7 by Thomas Bernard, 5 years ago

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

in reply to:  5 comment:8 by HoraK-FDF@…, 5 years ago

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 by HoraK-FDF@…, 5 years ago

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 by Thomas Bernard, 5 years ago

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 by Thomas Bernard, 5 years ago

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