Re: Yet another patch (dmd.py this time)

Bram Moolenaar <[email protected]> Sat, 24 Apr 2004 23:20:43 +0200
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
Lars Ivar Igesund wrote:

> > [about rc-style expansion giving an empty result if the expanded
> > variable is empty]
> > 
> > 
> >>It seems like this isn't implemented. How and where?
> > 
> > 
> > I implemented at least part of the RC-style expansion ideas.  The code
> > was getting complicated,, thus I only implemented what I thought was
> > necessary.
> > 
> > Can you give a few examples of what you think doesn't work correctly
> > now?
> > 
> 
> I see that it works in some cases, but it fails if you do this:
> 
> :import d
> :program foo : foo.d
> 
> The command line becomes
> #dmd -L -L+ -offoo.exe build-nt\ptest.obj
> 
> where -L comes from -L$*?DLINKFLAGS and -L+ from -L+$*?DLIBS in the
> actions in dmd.py

Ah, it only works when a variable is empty, not when the variable does
not exist.  This requires a small change in Commands.py:

--- Commands.py 19 Apr 2004 08:54:16 -0000      1.122
+++ Commands.py 24 Apr 2004 20:25:47 -0000
@@ -1665,7 +1665,7 @@
                     idx = e
 
                 # Skip over optional variable that is not defined.
-                if not (scope_found and var_found):
+                if not (scope_found and var_found) and not exp.rcstyle:
                     continue
 
                 # Find what comes after $VAR.
@@ -1682,6 +1682,11 @@
                         break
                     idx = idx + 1
                 after = arg[s:idx]
+
+                if exp.rcstyle and not (scope_found and var_found):
+                    # xxx$?var results in nothing when $var doesn't exists
+                    res = res[0:itemstart]
+                    continue
 
                 if exp.attr:
                     # Obtain any following attributes, advance to after them.


-- 
hundred-and-one symptoms of being an internet addict:
20. When looking at a pageful of someone else's links, you notice all of them
    are already highlighted in purple.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///


-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297