This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 122300

Summary: Project system do not support macros with spaces
Product: cnd Reporter: Alexander Simon <alexvsimon>
Component: ProjectAssignee: Thomas Preisler <thp>
Status: RESOLVED FIXED    
Severity: blocker    
Priority: P2    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 122146    

Description Alexander Simon 2007-11-19 15:24:23 UTC
Try to set following macros:
USAGE_LICENSE= "[-author?A]" "[-copyright?C]" "[-license?W]" 
Project system does not support macros value.

Example was taken from OpenSolaris project.
Command line for compiling with the macros likes to:
cc -DUSAGE_LICENSE=' "[-author?A]" "[-copyright?C]" "[-license?W]" ' ....

Usage of macros in cource code like this:
static const char usage[] =
"[-?\n@(#)$Id: msgcpp (AT&T Research) 2002-03-11 $\n]"
USAGE_LICENSE
"[+NAME?msgcpp - C language message catalog preprocessor]"
;
Comment 1 Thomas Preisler 2007-11-19 17:47:07 UTC
I'm not I understand in what context you mean. What are the steps that goes wrong?

If I go to the Preprocessor Definitions in the properties and set

USAGE_LICENSE=' "[-author?A]" "[-copyright?C]" "[-license?W]" '

it compiles the ode like this:

gcc    -c -g -DUSAGE_LICENSE=' "[-author?A]" "[-copyright?C]" "[-license?W]" ' -o build/Debug/GNU-MacOSX/src/args.o src/args.c

It seems correct to me.

So, where is it it goes wrong?
Comment 2 Alexander Simon 2007-11-20 07:58:53 UTC
If macros value is
USAGE_LICENSE= "[-author?A]" "[-copyright?C]" "[-license?W]" 
Project system return two macros:
USAGE_LICENSE=
"[-author?A]" "[-copyright?C]" "[-license?W]" 
If macros value is
USAGE_LICENSE=' "[-author?A]" "[-copyright?C]" "[-license?W]" '
Project system returns
USAGE_LICENSE=' "[-author?A]" "[-copyright?C]" "[-license?W]" '
It wrong too because macros value does not contain beginning and ending quotes.
Comment 3 Alexander Simon 2007-11-20 08:11:21 UTC
See return vector in method Item.getUserMacroDefinitions()
I think that project should change interface to keep macros.
1. String as macros storage is a bad idea. I propose a list of pairs (String,String).
2. Macros persistence should change macros delimiter. For example new line is more suitable for delimiter. 
Now macros storage do not provide a clear method for setting macros with single and double quotes.
Comment 4 Thomas Preisler 2008-02-03 19:58:23 UTC
Fixed:

changeset 6a4a75d29872 in main
details: http://hg.netbeans.org/main?cmd=changeset;node=6a4a75d29872
changeset e3683bc6fba2 in main
details: http://hg.netbeans.org/main?cmd=changeset;node=e3683bc6fba2
changeset 199dd55063ac in main
details: http://hg.netbeans.org/main?cmd=changeset;node=199dd55063ac

Changed macros from StringConfiguration to VectorConfiguration. Macros are now stored as a list of single macros instead
of a combined string and project system don't parse the values (that's where it went wrong). To keep old API (used by
ProjectBridge)
    getCCCompilerConfiguration().getPreprocessorConfiguration().setValue((String)macros)
I added the following method
    VectorConfiguration.setValue(String s)
but deprecated it. The following API should be used instead to avoid re-parsing of the macros:
    VectorConfiguration.setValue(Vector v)
    getCCCompilerConfiguration().getPreprocessorConfiguration().setValue(Vector v)
Comment 5 Vladimir Voskresensky 2008-02-03 22:17:20 UTC
As this is an API contract (called by external client), please, change Vector to List in interface (and Vector to
ArrayList in impl to prevent expensive syncronization of Vector class)
Comment 6 Thomas Preisler 2008-02-04 04:27:01 UTC
Done:
changeset 9f7fdca54a09 in main
details: http://hg.netbeans.org/main?cmd=changeset;node=9f7fdca54a09
changeset febe562d1ff5 in main
details: http://hg.netbeans.org/main?cmd=changeset;node=febe562d1ff5
Comment 7 Alexander Simon 2008-02-04 13:41:21 UTC
fix duplicated strings in configuration:
changeset fd7ced5eb54d in main
details: http://hg.netbeans.org/main?cmd=changeset;node=fd7ced5eb54d