December 04, 2009 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 --- Comment #9 from Vladimir <thecybershadow@gmail.com> 2009-12-03 18:26:16 PST --- It's really frustrating when such unannounced changes in compiler behavior break my code. Today I needed to fix up an old program I wrote, which makes extensive usage of importing files from a subdirectory tree. I couldn't use an old compiler version due to bugs... needless to say, I wasted time editing import paths and creating special-case build scripts. An undocumented breaking of functionality hardly fits a "stable" implementation... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 04, 2009 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 Leandro Lucarella <llucax@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|1.042 |1.006 Severity|enhancement |regression --- Comment #10 from Leandro Lucarella <llucax@gmail.com> 2009-12-03 19:18:41 PST --- So, this is *really* a regression then, I'm sorry I changed the severity. But are you sure it works in DMD 1.041? I tracked this down in the code and it was introduced at DMD 1.006, when the -J option got implemented, so I can't see how it could work in DMD 1.041: http://www.dsource.org/projects/dmd/changeset/121 http://www.dsource.org/projects/dmd/changeset/121#file4 (expression.c) http://www.dsource.org/projects/dmd/changeset/121#file11 (mars.c) http://www.digitalmars.com/d/1.0/changelog.html#new1_006 Before that, you could use string imports in a very promiscuous way. The specs are very brief about string imports and doesn't say anything about restrictions: The AssignExpression must evaluate at compile time to a constant string. The text contents of the string are interpreted as a file name. The file is read, and the exact contents of the file become a string literal. So, the -J option seems to be an implementation-defined behavior, as such, I guess it should be documented. For D1, I don't know if the specs should be changed, but I guess the old behavior should work (the attached patch can be used to allow secure string imports without prohibiting sub-directories altogether). I don't know if the compiler option shouldn't be documented too, it seems pretty useless to make this an implementation defined behavior, you'll have to stay always with the most restrictive implementation limitations if you want to write code that can be used with any compiler, or avoid using this feature at all. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 04, 2009 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 --- Comment #11 from Vladimir <thecybershadow@gmail.com> 2009-12-03 19:23:58 PST --- Yes, I was very careful in finding the exact version this problem was introduced. As stated in the issue description, the problem manifests in DMD 1.042 (and newer), but not 1.041. At first I thought it was an accidental regression, caused by "Fix bug where / wasn't recognized as a path separator on Windows", but as Walter has stated, this was an intentional change. And yes, I have already agreed that this needs to be better documented. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 04, 2009 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 --- Comment #12 from Leandro Lucarella <llucax@gmail.com> 2009-12-04 06:09:29 PST --- I just tried DMD 1.041 and I can't make const data = import("dir/data.txt"); work using -J. (or any other -J option for that matter). Can you try again with DMD 1.041? I can't see any change in DMD post 1.006 that can affect this behavior. The limitation was introduced in that version of the compiler. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 04, 2009 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 --- Comment #13 from Vladimir <thecybershadow@gmail.com> 2009-12-04 08:36:49 PST --- C:\Downloads\dmd.1.041\dmd\windows\bin> dmd | head -n 1 Digital Mars D Compiler v1.041 C:\Downloads\dmd.1.041\dmd\windows\bin> type test.d const data = import("dir/data.txt"); C:\Downloads\dmd.1.041\dmd\windows\bin> dir dir Volume in drive C is WS2008X64 Volume Serial Number is 4CC8-8E34 Directory of C:\Downloads\dmd.1.041\dmd\windows\bin\dir 2009.12.04 18:32 <DIR> . 2009.12.04 18:32 <DIR> .. 2009.12.04 18:32 0 data.txt 1 File(s) 0 bytes 2 Dir(s) 84,268,494,848 bytes free C:\Downloads\dmd.1.041\dmd\windows\bin> dmd -c -J. test (no output, compiles successfully) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 04, 2009 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 --- Comment #14 from Leandro Lucarella <llucax@gmail.com> 2009-12-04 10:12:16 PST --- Doesn't work on Linux, so this is a Windows-only problem (well, it was a Windows-only fix really :). Here is the fix: http://www.dsource.org/projects/dmd/changeset/156#file64 This is the entry in the DMD 1.042 changelog that fixed this problem: * Fix bug where / wasn't recognized as a path separator on Windows. Try with import("dir\\data.txt"), it should fail to compile in DMD 1.006+. So, summarizing: * DMD 1.006 introduces a regression, which is supposed to be a feature. * Supposing this is a real feature, you were relying on a bug in your programs, if you code them with DMD 1.006+ in the first place. * The specs are not clear about this, reading the specs there is no reason to think that import("a/b") shouldn't work (i.e., at least there should be a compiler switch to make it work or the specs should be fixed to reflect the reality). * There is a better solution to relax the current restrictions without being completely promiscuous about string imports (see attached patch). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 05, 2009 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 --- Comment #15 from Vladimir <thecybershadow@gmail.com> 2009-12-05 13:15:26 PST --- So, my programs relied on a bug in DMD, which was recently rightfully fixed. Well, that sucks. Hoping your patch is accepted. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 22, 2010 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 --- Comment #16 from Walter Bright <bugzilla@digitalmars.com> 2010-02-21 22:59:36 PST --- Changeset 396, for Posix only. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 09, 2010 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 --- Comment #17 from Walter Bright <bugzilla@digitalmars.com> 2010-03-08 22:20:35 PST --- Posix-only fix in dmd 1.057 and 2.041 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 07, 2010 [Issue 3420] [PATCH] Allow string import of files using subdirectories | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | http://d.puremagic.com/issues/show_bug.cgi?id=3420 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|patch | CC| |clugdbug@yahoo.com.au --- Comment #18 from Don <clugdbug@yahoo.com.au> 2010-06-07 09:08:52 PDT --- Removing 'patch' keyword -- there's no patch for the systems for which the issue still applies. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation