Strip tabs and trailing white spaces, and fix end of files (#748)

* format: Strip trailing whitespaces

We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.

Commit was generated with:

    pre-commit run --all-files trailing-whitespace

* format: Files should have exactly one new line end of them

It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.

Commit was generated with:

    pre-commit run --all-files end-of-file-fixer

* format: Convert tabs to spaces

Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.

Commit was generated with:

    pre-commit run --all-files remove-tabs

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
Kari Argillander
2024-08-25 22:13:57 +03:00
committed by GitHub
parent 9e0657424e
commit 369da70f2a
455 changed files with 7147 additions and 7249 deletions
+48 -48
View File
@@ -16,68 +16,68 @@
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#options">OPTIONS</a></li>
<li><a href="#this_tool_s_api">This tool's API</a></li>
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#options">OPTIONS</a></li>
<li><a href="#this_tool_s_api">This tool's API</a></li>
<ul>
<li><a href="#readproperty">ReadProperty</a></li>
<ul>
<li><a href="#readproperty">ReadProperty</a></li>
<ul>
<li><a href="#inputs_to_readproperty">Inputs to ReadProperty</a></li>
<li><a href="#outputs_from_readproperty">Outputs from ReadProperty</a></li>
<li><a href="#example_of_readproperty">Example of ReadProperty</a></li>
</ul>
<li><a href="#inputs_to_readproperty">Inputs to ReadProperty</a></li>
<li><a href="#outputs_from_readproperty">Outputs from ReadProperty</a></li>
<li><a href="#example_of_readproperty">Example of ReadProperty</a></li>
</ul>
<li><a href="#readpropertymultiple">ReadPropertyMultiple</a></li>
<ul>
<li><a href="#readpropertymultiple">ReadPropertyMultiple</a></li>
<ul>
<li><a href="#inputs_to_readpropertymultiple">Inputs to ReadPropertyMultiple</a></li>
<li><a href="#outputs_from_readpropertymultiple">Outputs from ReadPropertyMultiple</a></li>
<li><a href="#example_of_readpropertymultiple">Example of ReadPropertyMultiple</a></li>
</ul>
<li><a href="#inputs_to_readpropertymultiple">Inputs to ReadPropertyMultiple</a></li>
<li><a href="#outputs_from_readpropertymultiple">Outputs from ReadPropertyMultiple</a></li>
<li><a href="#example_of_readpropertymultiple">Example of ReadPropertyMultiple</a></li>
</ul>
<li><a href="#writeproperty">WriteProperty</a></li>
<ul>
<li><a href="#writeproperty">WriteProperty</a></li>
<ul>
<li><a href="#inputs_to_writeproperty">Inputs to WriteProperty</a></li>
<li><a href="#outputs_from_writeproperty">Outputs from WriteProperty</a></li>
<li><a href="#example_of_writeproperty">Example of WriteProperty</a></li>
</ul>
<li><a href="#inputs_to_writeproperty">Inputs to WriteProperty</a></li>
<li><a href="#outputs_from_writeproperty">Outputs from WriteProperty</a></li>
<li><a href="#example_of_writeproperty">Example of WriteProperty</a></li>
</ul>
<li><a href="#timesync">TimeSync</a></li>
<ul>
<li><a href="#timesync">TimeSync</a></li>
<ul>
<li><a href="#inputs_to_timesync">Inputs to TimeSync</a></li>
<li><a href="#outputs_from_timesync">Outputs from TimeSync</a></li>
<li><a href="#example_of_timesync">Example of TimeSync</a></li>
</ul>
<li><a href="#inputs_to_timesync">Inputs to TimeSync</a></li>
<li><a href="#outputs_from_timesync">Outputs from TimeSync</a></li>
<li><a href="#example_of_timesync">Example of TimeSync</a></li>
</ul>
<li><a href="#log">Log</a></li>
<ul>
<li><a href="#log">Log</a></li>
<ul>
<li><a href="#inputs_to_log">Inputs to Log</a></li>
<li><a href="#example_of_log">Example of Log</a></li>
</ul>
<li><a href="#inputs_to_log">Inputs to Log</a></li>
<li><a href="#example_of_log">Example of Log</a></li>
</ul>
<li><a href="#silencelog">SilenceLog</a></li>
<ul>
<li><a href="#silencelog">SilenceLog</a></li>
<ul>
<li><a href="#inputs_to_silencelog">Inputs to SilenceLog</a></li>
<li><a href="#outputs_from_silencelog">Outputs from SilenceLog</a></li>
<li><a href="#example_of_silencelog">Example of SilenceLog</a></li>
</ul>
<li><a href="#inputs_to_silencelog">Inputs to SilenceLog</a></li>
<li><a href="#outputs_from_silencelog">Outputs from SilenceLog</a></li>
<li><a href="#example_of_silencelog">Example of SilenceLog</a></li>
</ul>
<li><a href="#retry">Retry</a></li>
<ul>
<li><a href="#retry">Retry</a></li>
<ul>
<li><a href="#inputs_to_retry">Inputs to Retry</a></li>
<li><a href="#outputs_from_retry">Outputs from Retry</a></li>
<li><a href="#example_of_retry">Example of Retry</a></li>
</ul>
<li><a href="#inputs_to_retry">Inputs to Retry</a></li>
<li><a href="#outputs_from_retry">Outputs from Retry</a></li>
<li><a href="#example_of_retry">Example of Retry</a></li>
</ul>
</ul>
</ul>
</ul>
@@ -257,7 +257,7 @@ mechanisms. NOTE: all enumerations are defined in <em class="file">bacenum.h</em
<p>This function prints out to the desired method of logging (STDOUT or file).
NewLine characters are not required when making calls to this function. If any
NewLine characters are specified, they will be stripped out. To print an empty
line, pass in a space as the message. NOTE: This function will honor previous
line, pass in a space as the message. NOTE: This function will honor previous
requests to silence the log (see SilcenseLog for details)</p>
<p>
</p>
+9 -9
View File
@@ -39,37 +39,37 @@ ul {
}
.quotedString
{
color: #0000FF;
color: #0000FF;
}
.comment
{
color: #999999;
color: #999999;
}
.operator
{
color: #00CCCC;
color: #00CCCC;
}
.builtinVariable
{
color: #CCCC00;
color: #CCCC00;
}
.variableSpecifier
{
color: #FF0000;
color: #FF0000;
}
.keyword
{
color: #AA0033;
color: #AA0033;
}
.builtinFunction
{
color: #AA00AA;
color: #AA00AA;
}
.identifier
{
color: #009900;
color: #009900;
}
.number
{
color: #9999FF;
color: #9999FF;
}
+42 -43
View File
@@ -6,7 +6,7 @@ function emulateHTMLModel()
// This function is used to generate a html string for the text properties/methods
// It replaces '\n' with "<BR"> as well as fixes consecutive white spaces
// It also repalaces some special characters
// It also repalaces some special characters
function convertTextToHTML(s) {
s = s.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<BR>").replace(/\t/g, " "); //tachyon
while (/\s\s/.test(s))
@@ -17,7 +17,7 @@ function convertTextToHTML(s) {
HTMLElement.prototype.__defineSetter__("innerText", function (sText) {
this.innerHTML = convertTextToHTML(sText);
return sText;
return sText;
});
var tmpGet;
@@ -29,7 +29,7 @@ HTMLElement.prototype.__defineGetter__("innerText", tmpGet = function () {
}
if (moz)
if (moz)
emulateHTMLModel();
@@ -45,7 +45,7 @@ RE[0] = new RegExp(re);
// comment
re = /\#.*?([\r\n]+|$)/; //tachyon
RE[1] = new RegExp(re);
// operator
re = /xor|\.\.\.|and|not|\|\|\=|cmp|\>\>\=|\<\<\=|\<\=\>|\&\&\=|or|\=\>|\!\~|\^\=|\&\=|\|\=|\.\=|x\=|\%\=|\/\=|\*\=|\-\=|\+\=|\=\~|\*\*|\-\-|\.\.|\|\||\&\&|\+\+|\-\>|ne|eq|\!\=|\=\=|ge|le|gt|lt|\>\=|\<\=|\>\>|\<\<|\,|\=|\:|\?|\^|\||x|\%|\/|\*|\<|\&|\\|\~|\!|\>|\.|\-|\+ /;
RE[2] = new RegExp(re);
@@ -86,46 +86,46 @@ var classes = new Array("quotedString", "comment", "operator", "builtinVariable
*/
function HighlightCode(object)
{
codeText = object.innerText; //HTML.replace(/<.*?>/g, "");
object.innerHTML = '';
var left;
var match;
var right;
while (codeText.length > 0)
{
var mode = -1 ;
var index = 999999999;
for (var i = 0; i < RE.length; i++)
{
if ((codeText.match(RE[i])) && (RegExp.leftContext.length < index))
{
left = RegExp.leftContext;
match = RegExp.lastMatch;
right = RegExp.rightContext;
index = RegExp.leftContext.length;
mode = i;
}
}
if (mode == -1)
{
object.appendChild(document.createTextNode(codeText)); //.replace(/\r\n/g, "\r")));
codeText = '';
}
else
{
// append the plain text to the <code> block
object.appendChild(document.createTextNode(left)); //.replace(/\r\n/g, "\r")));
codeText = object.innerText; //HTML.replace(/<.*?>/g, "");
object.innerHTML = '';
var left;
var match;
var right;
while (codeText.length > 0)
{
var mode = -1 ;
var index = 999999999;
for (var i = 0; i < RE.length; i++)
{
if ((codeText.match(RE[i])) && (RegExp.leftContext.length < index))
{
left = RegExp.leftContext;
match = RegExp.lastMatch;
right = RegExp.rightContext;
index = RegExp.leftContext.length;
mode = i;
}
}
if (mode == -1)
{
object.appendChild(document.createTextNode(codeText)); //.replace(/\r\n/g, "\r")));
codeText = '';
}
else
{
// append the plain text to the <code> block
object.appendChild(document.createTextNode(left)); //.replace(/\r\n/g, "\r")));
// create a new <span> with the current code
var span = document.createElement("span");
span.setAttribute("className", classes[mode]); // ie
span.setAttribute("class", classes[mode]); //mozilla
span.appendChild(document.createTextNode(match));
object.appendChild(span);
// create a new <span> with the current code
var span = document.createElement("span");
span.setAttribute("className", classes[mode]); // ie
span.setAttribute("class", classes[mode]); //mozilla
span.appendChild(document.createTextNode(match));
object.appendChild(span);
codeText = right;
}
}
codeText = right;
}
}
}
// little bit of JQuery to highlight code in all pre elements
@@ -134,4 +134,3 @@ $(document).ready(function(){
HighlightCode(this);
});
});
+15 -16
View File
@@ -12,7 +12,7 @@ use Carp;
=head1 NAME
bacnet.pl - Scriptable BACnet communications
bacnet.pl - Scriptable BACnet communications
=head1 DESCRIPTION
@@ -33,7 +33,7 @@ Perl documentation, see http://perldoc.perl.org
Usage: bacnet.pl [program_options] [-- script_args]
This program executes a script in perl syntax to perform BACnet/IP operations.
Possible program options:
--script=s The script to execute.
--log=s The file to log all output.
@@ -116,7 +116,7 @@ BEGIN {
}
use Inline (
C => Config =>
C => Config =>
LIBS => "-L$libDir -lbacnet -liphlpapi",
INC => ["-I$incDir1", "-I$incDir2", "-I$incDir3"],
DIRECTORY => $inlineBuildDir,
@@ -141,7 +141,7 @@ my $answer = '';
'help|?' => \$ask_help,
'script=s' => \$script,
'log=s' => \$log,
);
);
if (!defined($script) || !(-f $script))
{
@@ -150,7 +150,7 @@ if (!defined($script) || !(-f $script))
}
else
{
# Add the script's location to @INC so that they can include other scripts
# Add the script's location to @INC so that they can include other scripts
# using relative paths
my $scriptdir = File::Spec->rel2abs(dirname($script));
push @INC,$scriptdir;
@@ -308,7 +308,7 @@ sub ReadProperty {
=head2 ReadPropertyMultiple
This function implements the ReadPropertyMultiple service. There are no built in retry
mechanisms. NOTE: all enumerations are defined in F<bacenum.h>
mechanisms. NOTE: all enumerations are defined in F<bacenum.h>
=head3 Inputs to ReadPropertyMultiple
@@ -414,7 +414,7 @@ sub ReadPropertyMultiple
=head2 WriteProperty
This function implements the WriteProperty service. There are no built in retry
mechanisms. NOTE: all enumerations are defined in F<bacenum.h>
mechanisms. NOTE: all enumerations are defined in F<bacenum.h>
=head3 Inputs to WriteProperty
@@ -494,7 +494,7 @@ sub WriteProperty {
}
else
{
# a priority of 0 means we are not writing to a priority array
# a priority of 0 means we are not writing to a priority array
$priority = 0;
}
$msg .= " in Device" . '[' . $deviceInstance . "] ==> ";
@@ -553,7 +553,7 @@ This function implements the TimeSync and UTCTimeSync services
=cut
sub TimeSync
sub TimeSync
{
my $deviceInstanceNumber = shift;
my $year = shift;
@@ -574,7 +574,7 @@ sub TimeSync
# be a pessimist. Assume things will fail
$isFailure = 1;
if (defined($utcOffset))
{
$isUTC = 1;
@@ -586,7 +586,7 @@ sub TimeSync
$utcOffset = 0;
$isUTC = 0;
}
if ($year < 1900 || $year > 2099)
{
Log("Year '$year' is invalid.");
@@ -610,7 +610,7 @@ sub TimeSync
Log("Hour '$hour' is invalid.");
last;
}
if ($minute < 0 || $minute > 59)
{
Log("Minute '$minute' is invalid.");
@@ -629,7 +629,7 @@ sub TimeSync
last;
}
return $isFailure;
return $isFailure;
}
=head2 Log
@@ -637,7 +637,7 @@ sub TimeSync
This function prints out to the desired method of logging (STDOUT or file).
NewLine characters are not required when making calls to this function. If any
NewLine characters are specified, they will be stripped out. To print an empty
line, pass in a space as the message. NOTE: This function will honor previous
line, pass in a space as the message. NOTE: This function will honor previous
requests to silence the log (see SilcenseLog for details)
=head3 Inputs to Log
@@ -671,7 +671,7 @@ sub Log {
# if there is nothing to print, then don't do it
return if (scalar(@last) == 0);
# if there are newline-like characters, get rid of them.
while ($msg =~/^(.*)[\r\n]+(.*)$/)
{
@@ -866,4 +866,3 @@ sub LogAnswer {
$answer = '' unless $append;
$answer .= $newAnswer;
}
+1 -1
View File
@@ -884,7 +884,7 @@ int BacnetTimeSync(int deviceInstanceNumber,
&Target_Address, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
if (bytes_sent <= 0) {
char msg[64];
snprintf(msg, sizeof(msg),
snprintf(msg, sizeof(msg),
"Failed to Send Time-Synchronization Request (%s)!",
strerror(errno));
LogError(msg);
+3 -5
View File
@@ -1,14 +1,14 @@
The BACnet Scriptable (using Perl) Tool.
* Running this tool assumes that the library has been already built. The
* Running this tool assumes that the library has been already built. The
library should be built with a command similar to
CC=/mingw/bin/gcc BACNET_DEFINES="-DPRINT_ENABLED -DBACAPP_ALL -DBACFILE
-DINTRINSIC_REPORTING" BBMD_DEFINE=-DBBMD_ENABLED\=1 BACNET_PORT=win32 make
clean library
* Currently, the tool assumes only win32 port, but should be easily modifiable
for any port build.
for any port build.
* This tool has to be run from a path without any spaces. The presence of the
.Inline directory is required.
* Run the tool without any arguments to see usage instructions
@@ -16,5 +16,3 @@ The BACnet Scriptable (using Perl) Tool.
Value) for Device at instance 1234 run the following command
perl bacnet.pl --script example_readprop.pl -- 1234