PDA

View Full Version : Is "string literal" in unimportant text broken?


pchady
07-Jan-2004, 01:23 PM
Hi -
(Boy I love this tool and recommend it to many!)

I have a user at my company asking how to force a particular
line within C++ comments to be treated as important by BC.
It looks like in the rules definition, that text inside
a string literal would override the "unimportant" classification, but this does not seem to work.
- Am I using it wrong?
- which way should the "all other text is unimportant" box be checked?

Here's the example:

These lines are marked as an unimportant difference:
// Text XXX
// Text YYY

I'd like those to remain unimportant, but for these
to be important:
// Text "XXX"
// Text "YYY"

Actually, what I REALLY want, is for these to be important:
//| SCCS Info: @(#) ExecSchedulers.c 1.7 03/12/05 12:41:47
//| SCCS Info: @(#) ExecSchedulers.c 1.9 03/12/06 10:03:00

and I was hoping to be able to treat the @(
as the start of a string literal, once I got the first
step to work.
This is a "version" tag line from the Tower Concepts RAZOR configuration management tool, and probably also customized for our use with source code.

I was using BC 2.0.2, and have now tried it in 2.0.3, but
seems no different.
I haven't tried the Beta yet.

Any help appreciated,
Thanks!
Pete

Craig
07-Jan-2004, 02:56 PM
Hi Pete,

The delimiter classifications don't support nesting, so it's not possible to do exactly what you're looking for.
There is a workaround though: regular expression classifiers are checked after delimiters, and they can override the delimited type. To do so you'll want the normal "Text from // to end of line" unimportant text setting, and you'll need to add a new string literal using the regular expression type. The regular expression you'll need to use is: //.*@\(.*

That will match the entire comment, so the leading "//| SCCS Info:" will be considered important text too. If that's not acceptable, and you don't care whether the @( is actually in a comment or not, you could use this instead: @\(.*

Usually "All other text is unimportant" should not be checked. You should use that in cases where you want to compare a particular type of text without worrying about the surrounding data. For example, if you had a web page translated to another language, you could define the tags as string literals and then check that box to ignore all of the translated text in order to make sure the tags weren't changed.

pchady
07-Jan-2004, 03:41 PM
Thanks,
that worked great!

It generated another question...
Is there a way for me to "share" the new rules that I just created with other users? (by use of a file perhaps)
or are those settings in the registry?

Thanks for your help!
Pete

Craig
07-Jan-2004, 03:48 PM
v2.1 has import and export commands that will allow you to share rules. v2.0 doesn't, and the rules are stored in a binary file, so it would be difficult to manually copy them.

2.1 will be officially released before the end of the week, so if you don't want to use a beta it won't be a long wait.