diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/format_source | 24 | ||||
-rwxr-xr-x | bin/format_source_patch | 24 | ||||
-rwxr-xr-x | bin/genparser | 7 | ||||
-rwxr-xr-x | bin/trace | 38 |
4 files changed, 80 insertions, 13 deletions
diff --git a/bin/format_source b/bin/format_source index b0b695c..1128def 100755 --- a/bin/format_source +++ b/bin/format_source @@ -1,6 +1,26 @@ #!/bin/bash +# +# Recursively format all C & C++ sources and header files, except those in the +# 'config' directory and generated files, such as H5LTanalyze.c, etc. +# +# Note that any files or directories that are excluded here should also be +# added to the 'exclude' list in .github/workflows/clang-format-check.yml +# +# (Remember to update both bin/format_source and bin/format_source_patch) + find . -type d \( -path ./config \) -prune \ - -o -iname *.h -o -iname *.c -o -iname *.cpp -o -iname *.hpp \ + -or \( \( \! \( \ + -name H5LTanalyze.c \ + -or -name H5LTparse.c \ + -or -name H5LTparse.h \ + -or -name H5Epubgen.h \ + -or -name H5Einit.h \ + -or -name H5Eterm.h \ + -or -name H5Edefin.h \ + -or -name H5version.h \ + -or -name H5overflow.h \ + \) \) \ + -and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp \) \) \ | xargs clang-format -style=file -i -fallback-style=none -exit 0
\ No newline at end of file +exit 0 diff --git a/bin/format_source_patch b/bin/format_source_patch index 4c531ea..8d6be01 100755 --- a/bin/format_source_patch +++ b/bin/format_source_patch @@ -1,6 +1,26 @@ #!/bin/bash +# +# Recursively format all C & C++ sources and header files, except those in the +# 'config' directory and generated files, such as H5LTanalyze.c, etc. +# +# Note that any files or directories that are excluded here should also be +# added to the 'exclude' list in .github/workflows/clang-format-check.yml +# +# (Remember to update both bin/format_source and bin/format_source_patch) + find . -type d \( -path ./config \) -prune \ - -o -iname *.h -o -iname *.c -o -iname *.cpp -o -iname *.hpp \ + -or \( \( \! \( \ + -name H5LTanalyze.c \ + -or -name H5LTparse.c \ + -or -name H5LTparse.h \ + -or -name H5Epubgen.h \ + -or -name H5Einit.h \ + -or -name H5Eterm.h \ + -or -name H5Edefin.h \ + -or -name H5version.h \ + -or -name H5overflow.h \ + \) \) \ + -and \( -iname *.h -or -iname *.c -or -iname *.cpp -or -iname *.hpp \) \) \ | xargs clang-format -style=file -i -fallback-style=none git diff > clang_format.patch @@ -11,4 +31,4 @@ then rm clang_format.patch fi -exit 0
\ No newline at end of file +exit 0 diff --git a/bin/genparser b/bin/genparser index 8728dea..ab40775 100755 --- a/bin/genparser +++ b/bin/genparser @@ -200,8 +200,8 @@ if [ "$verbose" = true ] ; then fi ${HDF5_FLEX} --nounistd -PH5LTyy -o ${path_to_hl_src}/H5LTanalyze.c ${path_to_hl_src}/H5LTanalyze.l -# fix H5LTparse.c to declare H5LTyyparse return type as an hid_t -# instead of int. Currently the generated function H5LTyyparse is +# fix H5LTparse.c and H5LTlparse.h to declare H5LTyyparse return type as an +# hid_t instead of int. Currently the generated function H5LTyyparse is # generated with a return value of type int, which is a mapping to the # flex yyparse function. The return value in the HL library should be # an hid_t. @@ -211,6 +211,9 @@ ${HDF5_FLEX} --nounistd -PH5LTyy -o ${path_to_hl_src}/H5LTanalyze.c ${path_to_hl perl -0777 -pi -e 's/int yyparse/hid_t yyparse/igs' ${path_to_hl_src}/H5LTparse.c perl -0777 -pi -e 's/int\nyyparse/hid_t\nyyparse/igs' ${path_to_hl_src}/H5LTparse.c perl -0777 -pi -e 's/int H5LTyyparse/hid_t H5LTyyparse/igs' ${path_to_hl_src}/H5LTparse.c +perl -0777 -pi -e 's/int yyparse/hid_t yyparse/igs' ${path_to_hl_src}/H5LTparse.h +perl -0777 -pi -e 's/int\nyyparse/hid_t\nyyparse/igs' ${path_to_hl_src}/H5LTparse.h +perl -0777 -pi -e 's/int H5LTyyparse/hid_t H5LTyyparse/igs' ${path_to_hl_src}/H5LTparse.h # Add code that disables warnings in the flex/bison-generated code. # @@ -210,6 +210,14 @@ $Source = ""; "ssize_t" => "Zs", ); + +############################################################################## +# Maximum length of H5TRACE macro line +# If the ColumnLimit in .clang-format is changed, this value will need to be updated +# +my $max_trace_macro_line_len = 110; + + ############################################################################## # Print an error message. # @@ -287,7 +295,7 @@ sub rewrite_func ($$$$$) { # Parse arguments if ($args eq "void") { - $trace = "H5TRACE0(\"$rettype\",\"\");\n"; + $trace = "H5TRACE0(\"$rettype\", \"\");\n"; } else { # Split arguments. First convert `/*in,out*/' to get rid of the # comma, then split the arguments on commas. @@ -331,18 +339,34 @@ sub rewrite_func ($$$$$) { } } } + + # Compose the trace macro $trace = "H5TRACE" . scalar(@arg_str) . "(\"$rettype\", \""; $trace .= join("", @arg_str) . "\""; - my $len = 4 + length $trace; + my $len = 4 + length $trace; # Add 4, for indenting the line for (@arg_name) { - if ($len + length >= 77) { - $trace .= ",\n $_"; - $len = 13 + length; + # Wrap lines that will be longer than the limit, after ');' is added + if ($len + length >= ($max_trace_macro_line_len - 2)) { + # Wrap line, with indention + $trace .= ",\n "; + $len = 13; # Set to 13, for indention + + # Indent an extra space to account for extra digit in 'H5TRACE' macro + if (scalar(@arg_str) >= 10) { + $trace .= " "; + $len++; + } } else { - $trace .= ", $_"; - $len += 1 + length; + $trace .= ", "; + $len += 2; # Add 2, for ', ' } + + # Append argument + $trace .= "$_"; + $len += length; # Add length of appended argument name } + + # Append final ');' for macro $trace .= ");\n"; } goto error if grep {/!/} @arg_str; |