Menu

Home

Ben Gardner

Banish crusty code with the Uncrustify C/C++/C#/D/Java/Pawn source code beautifier. It indents, adds newlines, aligns, etc, and is highly configurable.


Project Admins:


Discussion

  • Graham Toal

    Graham Toal - 2022-05-09

    Apologies for posting here but it's the only place I can find in this project that actually allows posting. I'm using uncrustify to format code that is output from a transpiler. Some of the output consists of #if statements which (for unavoidable reasons not worth getting into here) have constant conditions - either '1' or '0'. The true branch of one of these #if statements (whether the 'if' part, or the 'else' part, depending on the value of the condition) is formatted but the false branch never is. It would be nice to handle both branches the same. I do appreciate the issues involved if one of the branches causes a different level of indentation from the other, but I would be quite happy with an implementation that assumed both branches will always apply the same indentation or even one which assumes that both branches leave the indentation as on entry. This would be no worse than the current implementation which gets one branch correct and the other completely ignored.

    #if 0 /* Target==Vme */
    K = Readdata(Chan,Startadd,Length);
    #else
      K = Readtext(Chan, Startadd, Length);
    #endif
    

    By all means move this to a support request if you want to. Thank you for giving this any consideration. (btw why are support requests disabled to normal users? Was that deliberate?)

    Graham

     
    • Guy Maurel

      Guy Maurel - 2022-05-09

      Hello!

      You may use:
      https://github.com/uncrustify/uncrustify

      and create a new Issue.
      Join your input files, the configuration used, the expected and the got output.

      guy

      Am 09.05.22 um 17:35 schrieb Graham Toal:

      Apologies for posting here but it's the only place I can find in this project that actually allows posting. I'm using uncrustify to format code that is output from a transpiler. Some of the output consists of #if statements which (for unavoidable reasons not worth getting into here) have constant conditions - either '1' or '0'. The true branch of one of these #if statements (whether the 'if' part, or the 'else' part, depending on the value of the condition) is formatted but the false branch never is. It would be nice to handle both branches the same. I do appreciate the issues involved if one of the branches causes a different level of indentation from the other, but I would be quite happy with an implementation that assumed both branches will always apply the same indentation or even one which assumes that both branches leave the indentation as on entry. This would be no worse than the current implementation which gets one branch correct and the other completely ignored.
      ~~~

      if 0 / Target==Vme /

      K = Readdata(Chan,Startadd,Length);

      else

      K = Readtext(Chan, Startadd, Length);

      endif

      ~~~

      By all means move this to a support request if you want to. Thank you for giving this any consideration. (btw why are support requests disabled to normal users? Was that deliberate?)

      Graham


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/uncrustify/wiki/Home/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

      --
      Guy Maurel
      Sebastian-Fischer-Weg 13
      89077 Ulm

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.