Loading ...
Sorry, an error occurred while loading the content.
 

Yet Another C/C++ reformat problem

Expand Messages
  • salmankhilji
    I inherited some code from someone and right in the middle of a C++ member function was the definition of a C macro. The definitino was: void
    Message 1 of 3 , Dec 8, 2003
      I inherited some code from someone and right in the middle of a C++
      member function was the definition of a C macro. The definitino was:

      void
      Fgu_Widget::funcPaging( PageCmd cmd, int zSel, int tSel )
      {
      OverlayType *ovly;
      int i, j;
      int currZIdx = -1;
      int currTIdx = -1;

      # define refresh() {\
      gui_check_for_edit(TRUE);\
      ACset_page_no(ovly->page_no);\
      store_selected_curves();\
      redraw_work_screen(TRUE);\
      coordinate_dialog_popup(FALSE);\
      j=0;\
      do {\
      for (i=0; i<ACnumber_of_breakpoints(AC_Zdim)-1; i++)\
      if ((ACnumber_of_breakpoints(AC_Zdim)*
      j+i)==ACget_page_no())\
      break;\
      if ((ACnumber_of_breakpoints(AC_Zdim)*j+i)==ACget_page_no())\
      break;\
      j++;\
      } while (j<ACnumber_of_breakpoints(AC_Tdim));\
      if (ACnumber_of_breakpoints(AC_Zdim))\
      currZIdx = i;\
      if (ACnumber_of_breakpoints(AC_Tdim))\
      currTIdx = j;\
      }

      .......
      .......
      .......
      }

      If I run the reformat-region command (in the Dec 2002 version), then
      the very last line of the macro---i.e the lonely "}" moves to the very
      first column. I think it should stay in the 4th column as it was
      previously.

      Salman
    • Jon Green
      ... I think I would class this as an implementation problem rather than formating problem ! Jon.
      Message 2 of 3 , Dec 8, 2003
        salmankhilji wrote:
        > I inherited some code from someone and right in the middle of a C++
        > member function was the definition of a C macro. The definitino was:
        >
        > void
        > Fgu_Widget::funcPaging( PageCmd cmd, int zSel, int tSel )
        > {
        > OverlayType *ovly;
        > int i, j;
        > int currZIdx = -1;
        > int currTIdx = -1;
        >
        > # define refresh() {\
        > gui_check_for_edit(TRUE);\
        > ACset_page_no(ovly->page_no);\
        > store_selected_curves();\
        > redraw_work_screen(TRUE);\
        > coordinate_dialog_popup(FALSE);\
        > j=0;\
        > do {\
        > for (i=0; i<ACnumber_of_breakpoints(AC_Zdim)-1; i++)\
        > if ((ACnumber_of_breakpoints(AC_Zdim)*
        > j+i)==ACget_page_no())\
        > break;\
        > if ((ACnumber_of_breakpoints(AC_Zdim)*j+i)==ACget_page_no())\
        > break;\
        > j++;\
        > } while (j<ACnumber_of_breakpoints(AC_Tdim));\
        > if (ACnumber_of_breakpoints(AC_Zdim))\
        > currZIdx = i;\
        > if (ACnumber_of_breakpoints(AC_Tdim))\
        > currTIdx = j;\
        > }
        >
        > .......
        > .......
        > .......
        > }
        >
        > If I run the reformat-region command (in the Dec 2002 version), then
        > the very last line of the macro---i.e the lonely "}" moves to the very
        > first column. I think it should stay in the 4th column as it was
        > previously.
        >
        > Salman
        >

        I think I would class this as an implementation
        problem rather than formating problem !

        Jon.
      • Phillips, Steven
        The fact that the #define is in the middle of the function seems to me to be irrelevant, the #define will always be intended at the left hand edge and indented
        Message 3 of 3 , Dec 9, 2003
          The fact that the #define is in the middle of the function seems to me to be irrelevant, the #define will always be intended at the left hand edge and indented independently of its surroundings, i.e

          {
          {
          {
          {
          #define test() { \
          printf("Hello world\n") ; \
          }

          would be an even more bizarre way to indent code and does not hilight the hideous nature of the code (i.e. the fact that someone has dumped a #define in the middle of a function),

          Steve

          -----Original Message-----
          From: salmankhilji [mailto:salmankhilji@...]
          Sent: 08 December 2003 18:59
          To: jasspa@yahoogroups.com
          Subject: [jasspa] Yet Another C/C++ reformat problem


          I inherited some code from someone and right in the middle of a C++
          member function was the definition of a C macro. The definitino was:

          void
          Fgu_Widget::funcPaging( PageCmd cmd, int zSel, int tSel )
          {
          OverlayType *ovly;
          int i, j;
          int currZIdx = -1;
          int currTIdx = -1;

          # define refresh() {\
          gui_check_for_edit(TRUE);\
          ACset_page_no(ovly->page_no);\
          store_selected_curves();\
          redraw_work_screen(TRUE);\
          coordinate_dialog_popup(FALSE);\
          j=0;\
          do {\
          for (i=0; i<ACnumber_of_breakpoints(AC_Zdim)-1; i++)\
          if ((ACnumber_of_breakpoints(AC_Zdim)*
          j+i)==ACget_page_no())\
          break;\
          if ((ACnumber_of_breakpoints(AC_Zdim)*j+i)==ACget_page_no())\
          break;\
          j++;\
          } while (j<ACnumber_of_breakpoints(AC_Tdim));\
          if (ACnumber_of_breakpoints(AC_Zdim))\
          currZIdx = i;\
          if (ACnumber_of_breakpoints(AC_Tdim))\
          currTIdx = j;\
          }

          .......
          .......
          .......
          }

          If I run the reformat-region command (in the Dec 2002 version), then
          the very last line of the macro---i.e the lonely "}" moves to the very
          first column. I think it should stay in the 4th column as it was
          previously.

          Salman



          __________________________________________________________________________

          This is an unmoderated list. JASSPA is not responsible for the content of
          any material posted to this list.

          To unsubscribe, send a mail message to

          mailto:jasspa-unsubscribe@yahoogroups.com

          or visit http://groups.yahoo.com/group/jasspa and
          modify your account settings manually.




          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        Your message has been successfully submitted and would be delivered to recipients shortly.