diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2020-10-08 14:35:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-08 14:35:57 (GMT) |
commit | 29874423bf155e23cfdc1920336c91674865f417 (patch) | |
tree | e85e80ccfa1f459a18ce715943f021afca7a72c4 /bin/trace | |
parent | 986154352fb411ab605164a7baba97f3040a4157 (diff) | |
parent | ca32c785fc456522b10e0c3fb68ed0403d659ca9 (diff) | |
download | hdf5-29874423bf155e23cfdc1920336c91674865f417.zip hdf5-29874423bf155e23cfdc1920336c91674865f417.tar.gz hdf5-29874423bf155e23cfdc1920336c91674865f417.tar.bz2 |
Merge pull request #28 from byrnHDF/hdf5_1_12
Hdf5 1 12
Diffstat (limited to 'bin/trace')
-rwxr-xr-x | bin/trace | 38 |
1 files changed, 31 insertions, 7 deletions
@@ -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; |