Re: [A-a-p-user] Quoting in attributes of :program targets
Brought to you by:
vimboss
From: Bram M. <Br...@mo...> - 2003-07-29 13:05:52
|
Adriaan de Groot wrote: > Thanks for all the answers yesterday. It makes quite a difference when > someone demonstrates how to do something, as opposed to trying to > figure it out from the manual and tutorial (which could certainly be > expanded; it covers some very simple cases but not much more than > that, and the overlap with the user manual is enormous -- I'll see > what I can do.). The manual already is quite long. I'm trying to avoid adding text that isn't very useful. Thus I need specific suggestions about what needs to be explained and where to put it. A patch is even better and gives you a chance to get a Zimbu award! :-) > Anyway, today's problem comes from the following "Hello World" recipe: > > LIBS=-L/usr/local/qt-3.1.1/lib > :program t { add_LIBS = -pthread -lqt-mt } : t.c > > fairly straightforward, but the attribute add_LIBS (is it an > attribute?) is handled wrongly, for when I execute AAP: > > eggs.ebn.kun.nl$aap > Aap: cc -O2 -o t build-FreeBSD4_8_STABLE/t.o -L/usr/local/qt-3.1.1/lib > "-pthread -lqt-mt" > cc: unrecognized option `-pthread -lqt-mt' > > Naturally! Those quotes there are all wrong. Trying to work around > this by assigning -pthread -lqt-mt to a variable, and using { add_LIBS > = $t_LIBADD } yields the same result. > > What to do, what to do? This would be of importance in a recipe where > multiple programs are built from a single recipe, and where you need > to specify the libraries for each. > > (Incidentally, > > :program t { LIBS = -pthread -lqt-mt } : t.c > > doesn't do what I'd expect either, but that's because LIBS is a > variable, and not an attribute (duh). Using var_LIBS = yields the same > quoting problem as with add_LIBS) The problem is that the attribute value is turned into a string (and later back into an attribute value). The string is put in quotes to include the white space inside the value, which is not the right thing to do. Some special characters should be avoided, such as "}". But since that must already have been done when giving the value, we don't need to add quotes again. Try this patch: *** /home/mool/tmp/Exec/Dictlist.py Wed Jul 2 19:02:55 2003 --- Dictlist.py Tue Jul 29 14:51:04 2003 *************** *** 308,318 **** def dictlistattr2str(dl): """Print the attributes in dictlist "dl".""" ! str = '' for k in dl.keys(): if k != "name" and k[0] != "_": ! str = str + ('{%s=%s}' % (k, listitem2str(dl[k]))) ! return str def dictlist2str(list, argexpand = None): --- 308,320 ---- def dictlistattr2str(dl): """Print the attributes in dictlist "dl".""" ! res = '' for k in dl.keys(): if k != "name" and k[0] != "_": ! # Assume no escaping is necessary, the value should already include ! # it when it's needed. ! res = res + ('{%s=%s}' % (k, str(dl[k]))) ! return res def dictlist2str(list, argexpand = None): -- No engineer can take a shower without wondering if some sort of Teflon coating would make showering unnecessary. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html /// |