GNU Info

Info Node: (indent.info)Breaking long lines

(indent.info)Breaking long lines


Next: Disabling Formatting Prev: Indentation Up: Indent Program
Enter node , (file) or (file)node

Breaking long lines
===================

   With the option `-lN', or `--line-lengthN', it is possible to
specify the maximum length of a line of C code, not including possible
comments that follow it.

   When lines become longer then the specified line length, GNU `indent'
tries to break the line at a logical place.  This is new as of version
2.1 however and not very intelligent or flexible yet.

   Currently there are two options that allows one to interfere with the
algorithm that determines where to break a line.

   The `-bbo' option causes GNU `indent' to prefer to break long lines
before the boolean operators `&&' and `||'.  The `-nbbo' option causes
GNU `indent' not have that preference.  For example, the default option
`-bbo' (together with `--line-length60' and `--ignore-newlines') makes
code look like this:

       if (mask
           && ((mask[0] == '\0')
               || (mask[1] == '\0'
                   && ((mask[0] == '0') || (mask[0] == '*')))))

   Using the option `-nbbo' will make it look like this:

       if (mask &&
           ((mask[0] == '\0') ||
            (mask[1] == '\0' &&
             ((mask[0] == '0') || (mask[0] == '*')))))

   The default `-hnl', however, honours newlines in the input file by
giving them the highest possible priority to break lines at.  For
example, when the input file looks like this:

       if (mask
           && ((mask[0] == '\0')
           || (mask[1] == '\0' && ((mask[0] == '0') || (mask[0] == '*')))))

then using the option `-hnl', or `--honour-newlines', together with the
previously mentioned `-nbbo' and `--line-length60', will cause the
output not to be what is given in the last example but instead will
prefer to break at the positions where the code was broken in the input
file:

       if (mask
           && ((mask[0] == '\0')
               || (mask[1] == '\0' &&
                   ((mask[0] == '0') || (mask[0] == '*')))))

   The idea behind this option is that lines which are too long, but
are already broken up, will not be touched by GNU `indent'.  Really
messy code should be run through `indent' at least once using the
`--ignore-newlines' option though.


automatically generated by info2www version 1.2.2.9