Skip to content

Commit 2a37c29

Browse files
committed
Format C code with Artistic Style
1 parent 15f1934 commit 2a37c29

File tree

7 files changed

+311
-88
lines changed

7 files changed

+311
-88
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ jobs:
555555
run: |
556556
ruby -e "require 'tiny_tds'; puts TinyTds::Gem.root_path"
557557
558-
standardrb:
559-
name: standardrb
558+
formatting:
559+
name: Code formatting
560560
runs-on: ubuntu-22.04
561561
steps:
562562
- uses: actions/checkout@v4
@@ -569,3 +569,12 @@ jobs:
569569
- name: Check standardrb
570570
shell: bash
571571
run: bundle exec standardrb
572+
573+
- name: Check artistic style
574+
uses: per1234/artistic-style-action@v1
575+
with:
576+
options-file-path: "astyle.conf"
577+
target-paths: "./ext/"
578+
name-patterns: |
579+
- '*.c'
580+
- '*.h'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ $ rake TINYTDS_UNIT_HOST=mydb.host.net TINYTDS_SCHEMA=sqlserver_azure
441441

442442
### Code formatting
443443

444-
We are using `standardrb` to format our code. Just run `bundle exec standardrb --fix` to format all Ruby files.
444+
We are using `standardrb` to format the Ruby code and Artistic Style for the C code. Run `bundle exec rake format` to format both types in one operation. Artistic Style needs to be manually installed through your package manager (e.g. `apt install -y astyle`).
445445

446446
### Compiling Gems for Windows and Linux
447447

Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,8 @@ end
6565

6666
task build: [:clean, :compile]
6767
task default: [:build, :test]
68+
69+
task :format do
70+
system("bundle exec standardrb --fix")
71+
system('astyle --options=astyle.conf "./ext/*.c" "./ext/*.h"')
72+
end

astyle.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--style=1tbs
2+
--break-blocks
3+
--indent-preproc-block
4+
--indent-preproc-cond
5+
--indent=spaces=2
6+
--indent-switches
7+
--recursive
8+
--suffix=none

0 commit comments

Comments
 (0)