INN indentation

Russ Allbery eagle at
Sun Sep 19 15:43:33 UTC 2021

Richard Kettlewell <rjk at> writes:

> However the reality is slightly more complicated: many files use tabs
> and spaces interchangeably, apparently with an assumption that the tab
> character represents 8 spaces, despite the coding style saying indent is
> 4 spaces.

The tabs are all legacy; I was removing them when I did a comprehensive
revisit of a file back when I was rewriting more of the code and adding
tests, but didn't get to most of them.

My preference is to never write a tab to disk in source code.  I think it
should be a purely in-editor command represented by spaces on disk.

> Would it be possible to adopt an indent rule in which either tabs match
> the indent depth, or tabs are not used at all, and reformat the source
> code accordingly?

For my personal projects, I've started using clang-format to just reformat
all of the source code and keep it consistently formatted.  It requires
some work up-front to mark some code blocks to not reformat, because it
messes up a lot of code that's carefully laid out to make it easier to
read, but once you're done you can then stop thinking about it.  It's very
similar to using black for Python.  One can then add it to the tests and
reject malformatted diffs, or even provide a Git hook to automatically fix

It's unfortunately a big flag day that breaks backporting of diffs, so
we'd probably want to do the same thing in both the main and 2.6 branches
at the same time, and it makes git annotate kind of a mess unless you
ignore whitespace.  But I thought it was worth it for my personal projects
to stop thinking about formatting.

For the record, here's the .clang-format file I use for my personal

# Configuration for clang-format automated reformatting.  -*- yaml -*-
# The canonical version of this file is maintained in the rra-c-util package,
# which can be found at <>.
# Copyright 2020 Russ Allbery <eagle at>
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.  This file is offered as-is, without any
# warranty.
# SPDX-License-Identifier: FSFAP

Language: Cpp
BasedOnStyle: LLVM
AlignConsecutiveMacros: true
AlignEscapedNewlines: Left
AlwaysBreakAfterReturnType: AllDefinitions
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: WebKit
ColumnLimit: 79
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWrappedFunctionNames: false
MaxEmptyLinesToKeep: 2
SpaceAfterCStyleCast: true

My personal style is slightly different than INN's, but they're relatively
close.  (INN has some unusual conventions for comment formatting.)  The
biggest thing that it changed in my other projects was using four-space
indentation for nested C preprocessor directives.

Russ Allbery (eagle at             <>

    Please send questions to the list rather than mailing me directly.
     <> explains why.

More information about the inn-workers mailing list