Menu

#667 align_assign_span and initialized arrays

0.62
works-for-me
nobody
None
C
5
2016-04-18
2016-02-26
john fong
No

Using the default configuration with the following changes:
cmt_convert_tab_to_spaces = true
align_var_def_span = 2
align_assign_span = 2

ORIGINAL FILE (array_init.c):

uint8_t a1 = 0;
uint16_t name = 1;
uint32_t long_name_is_long = 3;
uint16_t testing_really_long_variable_name = 5;


uint16_t array[4] = {0};
uint8_t  b[4] = {0};
uint_32_t array_name[DEFINED_NUMBER] = {0};

OUTPUT (array_init.unc):

uint8_t  a1                                = 0;
uint16_t name                              = 1;
uint32_t long_name_is_long                 = 3;
uint16_t testing_really_long_variable_name = 5;


uint16_t  array[4] = {0};
uint8_t   b[4] = {0};
uint_32_t array_name[DEFINED_NUMBER] = {0};

align_assign_span doesn't seem to work for the variables that are arrays. Not sure if this is a bug or if there's some other setting somewhere that needs to be set.

3 Attachments

Discussion

  • Guy Maurel

    Guy Maurel - 2016-03-15

    Are you sure you have pushed the right source?

    Using:

    define DEFINED_NUMBER 4

    void a()
    {
    int a1 = 0;
    int name = 1;
    int long_name_is_long = 3;
    int testing_really_long_variable_name = 5;

    int array[4] = {0};
    int b[4] = {0};
    int array_name[DEFINED_NUMBER] = {0};
    }

    I get exactly what you wanted to have:
    void a()
    {
    int a1 = 0;
    int name = 1;
    int long_name_is_long = 3;
    int testing_really_long_variable_name = 5;

        int array[4]                   = {0};
        int b[4]                       = {0};
        int array_name[DEFINED_NUMBER] = {0};
    

    }

     
    • john fong

      john fong - 2016-04-17

      -

       

      Last edit: john fong 2016-04-18
  • Ben Gardner

    Ben Gardner - 2016-03-18
    • status: open --> works-for-me
     
  • john fong

    john fong - 2016-04-18

    It seems to work if you enclose everything into a function like you tested it. In my original source, all those variables are global and declared outside of a function.

    When I run the attached cfg on array_init.c, I get array_init.unc which doesn't format the arrays correctly.

    When I run the attached cfg on array_init_fnc.c, I get array_init_fnc.unc which does format it as expected.

     
MongoDB Logo MongoDB