Re: Script to format the functions in a C header?



On Mon, Nov 21, 2016 at 03:49:09PM +0000, Ikey Doherty wrote:
You could use clang-format and an appropriately configured
.clang-format file to enforce coding convention within a source
tree.

I'd recommend checking: https://clangformat.com/ as a simple way
to build your .clang-format

I tend to keep an "update_format.sh" script in my repos to ensure
everything stays sane during development:

#!/bin/bash
clang-format -i $(find . -name '*.[ch]')

# Check we have no typos.
which misspell 2>/dev/null >/dev/null
if [[ $? -eq 0 ]]; then
    misspell -error $(find . -name '*.[ch]')
fi


Note that misspell is a golang package, and makes sure I have
no embarrassing typos in my code :) "diffrent" happens so often..

Ok, thanks, I can look at clang-format if it supports the GNOME/GTK+
convention for formatting function prototypes in a header.

Otherwise I can write a new script, and re-use some code from
lineup-parameters:
https://github.com/swilmet/gnome-c-utils
(it's based on regexes, so it's clearly not ideal, but it does its job).

--
Sébastien


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]