gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
274 stars 61 forks source link

GDL will not accept spaces in path to procedure #1846

Closed ChunkyPanda03 closed 3 months ago

ChunkyPanda03 commented 3 months ago

GDL (linux version 1.01 and windows version 1.0.5-dirty) is unable to compile (or run) a procedure that has has a path with a space in a folder name leading to the procedure. This includes gdl terminal and gdl workbench these two will spit out this example when attempting to compile or run the code gdl terminal:

GDL> .compile "/home/blaine/GDLWorkspace/test/space test/spacetest.pro"
% Error opening file. File: "/home/blaine/GDLWorkspace/test/space.
GDL> .run "/home/blaine/GDLWorkspace/test/space test/spacetest.pro"
% Error opening file. File: "/home/blaine/GDLWorkspace/test/space.
GDL> 

gdl workbench assume same location however dragged and dropped into gdl workbench: % Error opening file. File: /home/blaine/GDLWorkspace/test/space.

this is very bad as the common method (not a good method) in idl is to specify an absolute path (as opposed to project path) and have it run from there... this means that we can't just change the offending folder name as quite literally thousands of procedures would break as a result. This fix should be top priority

GillesDuvert commented 3 months ago

indeed, big bug this one.

alaingdl commented 3 months ago

I can reproduce it :cry:

Maybe just a WordExp() is missing somewhere ?

The good new : FILE_MKDIR is OK with a space in dir name

alaingdl commented 3 months ago

Following my tests, the problem appears in dinterpreter.cpp around line 850 ... A real problem is we do take the space into account as a separator when providing a list of files to be compile sppos = command.find(" ",pos); (let's say .run toto titi adir/tata.pro : three files to be compile) Then before splitting using space, we shoule "expand" the paths (if any)

At the end we need to be able to process : .r '~/toto tata/*o' "tyty tyty.pro" !

(some working example of parsing here https://stackoverflow.com/questions/14265581/parse-split-a-string-in-c-using-string-delimiter-standard-c The problem we will have we may have " and ' delimiting a path, then may it would be better to change " into ' (or reverse))

GillesDuvert commented 3 months ago

Indeed. Patch being written. I note that IDL accepts .compile a,b,c,d or .compile a b c dor even .compile a,,,b c,,,d despite the fact that doc says only .compile a,b,c,d is correct.

GillesDuvert commented 3 months ago

closed by #1847 (well, please check! :smile: )

ChunkyPanda03 commented 3 months ago

I can confirm GDL now exhibits the correct behavior

Running current GDL with CMAKE_SOURCE_DIR/src/pro and CMAKE_SOURCE_DIR/testsuite in GDL_PATH
+/home/blaine/Downloads/gdl/src/pro/:+/home/blaine/Downloads/gdl/testsuite/

*** PLPLOT ERROR, ABORTING OPERATION ***
plInitDispatchTable: Could not open drivers directory, aborting operation
  GDL - GNU Data Language, Version v1.0.6-8-g1e9f4575
- For basic information type HELP,/INFO
- Default library routine search path used (GDL_PATH/IDL_PATH env. var. not set): +/home/blaine/Downloads/gdl/src/pro/:+/home/blaine/Downloads/gdl/testsuite/
- Using WxWidgets as graphics library (windows and widgets).
- Local drivers not found --- using default ones. 
- No startup file read (GDL_STARTUP/IDL_STARTUP env. var. not set). 
- Please report bugs, feature or help requests and patches at: https://github.com/gnudatalanguage/gdl

GDL> .compile "/home/blaine/GDLWorkspace/test/space test/spacetest.pro"
% Compiled module: SPACETEST.
GDL> .run "/home/blaine/GDLWorkspace/test/space test/spacetest.pro"
% Compiled module: SPACETEST.
GDL> spacetest
this has compiled and is working well
% Interrupt encountered.
GDL>