Announcement

Collapse
No announcement yet.

Compare NNNu vs. NNN, ignore the u, compare the NNN

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compare NNNu vs. NNN, ignore the u, compare the NNN

    We are integrating updated code that fixes minor misra and other coding standard issues, such as this (side by side comparison):

    Code:
    #define symbol 23u                   #define symbol 23
    where a u is added to keep whatever checker happy. I tried ignoring something like [0123456789]+u, but that ignores the number portion as well as the u, which I don't want. I just want a line such as above to not be flagged, but say, comparing 24u to 23 does flag. (These are long lists of auto-generated code, so flagging such a change mechanically is useful.) "symbol" will change in long lists of #defines, so it aligns according to that, which I also want, not the number.

    Similar issues with u vs. UL, as well as hex numbers with u or UL added (I assume just add 0x and abcdef to the number part.)
    Last edited by AChimpNamedCornelius; 01-Feb-2021, 03:44 PM.

  • #2
    Hello,

    As you've discovered, if the defined Grammar Element includes the number, then the entire element is part of the definition. So making that one unimportant makes the whole element unimportant. You would need a definition that only matches on the "u" in this scenario, such as only a U that is at the End of Line? Such as the regex:
    u$

    Another option is to create a Text Replacement in the Text Compare's Session Settings. Load the parent Folder Compare, then click into a child file pair and go to that Session Settings, Misc tab, and create a new Replacement rule. Here you could define
    (\d+)u$
    replace with
    $1
    Which would only mark this section as Unimportant if the number (\d+) matches, and the left side has a u.

    Then, in the Text Compare Session Setting dialog, at the bottom, switch from Use only for this view to Use for all files in parent session, which will then apply for the parent folder compare session (which can be saved for future use).
    Aaron P Scooter Software

    Comment


    • #3
      I should add, Text Replacements is a Pro feature, so if you are registered for Std, you can revert to Trial mode to test it:
      https://www.scootersoftware.com/supp...?zz=kb_evalpro
      Aaron P Scooter Software

      Comment


      • #4
        Thank you, I'm not sure I want to replace anything, even temporarily. This is used during code reviews.

        For embedded systems, QAC and similar checks are used, so some of the fussier changes such as adding (or removing) things like 'u' in literal definitions is more and more of a thing.

        Comment


        • #5
          Hello,

          While we have a traditional Find/Replace that would replace the text, the "Text Replacements" feature is a rule to define a specific replacement in your file (Number with Number+U) and mark that specific change as Unimportant. It doesn't actually change the text of the file.

          Unimportance defined on an element will match on either side and mark that specific text as Unimportant (and the other side could be Important or Unimportant, depending on its grammar). Text Replacements only marks it as Unimportant of that Left vs Right value matches the rule.
          Aaron P Scooter Software

          Comment

          Working...
          X