Re: Regarding the order of the header file includes

Поиск
Список
Период
Сортировка
От Bharath Rupireddy
Тема Re: Regarding the order of the header file includes
Дата
Msg-id CALj2ACVVhf6sU0emYgO3xEdrnh6B1GjfcbOZHvOE0F-RE=zNOA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Regarding the order of the header file includes  (Richard Guo <guofenglinux@gmail.com>)
Ответы Re: Regarding the order of the header file includes  (Richard Guo <guofenglinux@gmail.com>)
Список pgsql-hackers
On Thu, Mar 7, 2024 at 12:39 PM Richard Guo <guofenglinux@gmail.com> wrote:
>
> While rebasing one of my patches I noticed that the header file includes
> in relnode.c are not sorted in order.  So I wrote a naive script to see
> if any other C files have the same issue.  The script is:
>
> #!/bin/bash
>
> find . -name "*.c" | while read -r file; do
>   headers=$(grep -o '#include "[^>]*"' "$file" |
>             grep -v "postgres.h" | grep -v "postgres_fe.h" |
>             sed 's/\.h"//g')
>
>   sorted_headers=$(echo "$headers" | sort)
>
>   results=$(diff <(echo "$headers") <(echo "$sorted_headers"))
>
>   if [[ $? != 0 ]]; then
>     echo "Headers in '$file' are out of order"
>     echo $results
>     echo
>   fi
> done

Cool. Isn't it a better idea to improve this script to auto-order the
header files and land it under src/tools/pginclude/headerssort? It can
then be reusable and be another code beautification weapon one can use
before the code release.

FWIW, I'm getting the syntax error when ran the above shell script:

headerssort.sh: 10: Syntax error: "(" unexpected

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: Stack overflow issue
Следующее
От: "Andrey M. Borodin"
Дата:
Сообщение: Re: Commitfest Manager for March