vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
1.16k stars 138 forks source link

#include doesn't work with spaces #76

Closed tueda closed 8 years ago

tueda commented 8 years ago

There is no way to include files whose name or names of folds contain spaces. It may be nice to have possibilities to include such a file by using a quoted name, for example:

#include somefile.frm # "Start diagrams"

Though the code around https://github.com/vermaseren/form/blob/7252064876df294e9dc99482b5b8602d09f01d2c/sources/pre.c#L2150 looks like trying to recognize a quoted string (for a filename), but it seems not to work.

vsht commented 8 years ago

Hi,

this seems to fix the issue with spaces in names, although admittedly not in the most beautiful way (my C knowledge is quite basic, sorry for that). spaces_in_names.txt

Cheers, Vladyslav

tueda commented 8 years ago

Hi Vladyslav,

Thanks for considering this issue. Unfortunately your patch introduces another problem: s++ when *s == 0 makes a buffer overflow and the next access of *s could give a memory issue. Actually Valgrind gives memory warnings for

#include "test.frm"

I was also wondering that maybe the line https://github.com/vermaseren/form/blob/7252064876df294e9dc99482b5b8602d09f01d2c/sources/pre.c#L2152 is something trying to accept " in "", like "a\"b\".frm". But supporting this needs more work and may be too much for now. Normally people don't like to use spaces or " in file names. Actually what I hit was a fold name containing spaces. Anyway I think the priority of this enhancement of #include is not high.

vsht commented 8 years ago

Hi Takahiro,

thanks for the kind explanation. I agree with your objections and will see how to improve the patch. By the way, is there anything special that I need to do to get the test suite running?

On Fedora 22 with make check I get

make  check-TESTS
make[1]: Entering directory '/media/Data/Projects/Physics/form/check'
./check.rb:16:in `block in <main>': undefined local variable or method `cleanup' for main:Object (NameError)
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- test/unit (LoadError)
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
    from ./check.rb:23:in `<main>'
./check.rb:16:in `block in <main>': undefined local variable or method `cleanup' for main:Object (NameError)
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- test/unit (LoadError)
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require'
    from ./check.rb:23:in `<main>'
FAIL: check-help.sh
===============================
1 of 1 test failed
Please report to form@nikhef.nl
===============================
Makefile:313: recipe for target 'check-TESTS' failed
make[1]: *** [check-TESTS] Error 1
make[1]: Leaving directory '/media/Data/Projects/Physics/form/check'
Makefile:436: recipe for target 'check-am' failed
make: *** [check-am] Error 2
tueda commented 8 years ago

Hi Vladyslav,

What is the Ruby version on your system? I guess one of the problems is the test program uses test/unit and in Ruby 2.2 this library was moved from core library to bundled library.

I don't know about Ruby on Fedora, but a quick google search finds how to install Ruby on Fedora: https://developer.fedoraproject.org/tech/languages/ruby/ruby-installation.html It says Test::Unit needs to be installed separately: rubygem-test-unit.

vsht commented 8 years ago

Hi Takahiro,

thanks, with rubygem-test-unit the test suite indeed runs.

Cheers, Vladyslav

tueda commented 8 years ago

The original problem to me (spaces in the fold names) was solved in b13522f595. The syntax is without quotes:

#include somefile.frm # Start diagrams

If someone wants to have spaces also in the file name, please open another issue for it.