Commit bb3ea92b54e016afaf5ea31ebd8a321d329bf2a4
Committed by
Stéphane Raimbault
1 parent
208a337e
Fixed style issues.
Showing
2 changed files
with
16 additions
and
21 deletions
src/win32/README.win32
| @@ -12,6 +12,8 @@ See ../../README.md | @@ -12,6 +12,8 @@ See ../../README.md | ||
| 12 | 12 | ||
| 13 | config.h and ../modbus-version.h are generated using configure.js. | 13 | config.h and ../modbus-version.h are generated using configure.js. |
| 14 | Run | 14 | Run |
| 15 | - cscript configurs.js | ||
| 16 | -to generate these files. | 15 | + cscript configure.js |
| 16 | +or | ||
| 17 | + wscript configure.js | ||
| 18 | +or double click configure.js to generate these files. | ||
| 17 | 19 |
src/win32/configure.js
| @@ -27,8 +27,7 @@ var error = 0; | @@ -27,8 +27,7 @@ var error = 0; | ||
| 27 | 27 | ||
| 28 | /* Helper function, transforms the option variable into the 'Enabled' | 28 | /* Helper function, transforms the option variable into the 'Enabled' |
| 29 | or 'Disabled' string. */ | 29 | or 'Disabled' string. */ |
| 30 | -function boolToStr(opt) | ||
| 31 | -{ | 30 | +function boolToStr(opt) { |
| 32 | if (opt == false) | 31 | if (opt == false) |
| 33 | return "no"; | 32 | return "no"; |
| 34 | else if (opt == true) | 33 | else if (opt == true) |
| @@ -39,8 +38,7 @@ function boolToStr(opt) | @@ -39,8 +38,7 @@ function boolToStr(opt) | ||
| 39 | 38 | ||
| 40 | /* Helper function, transforms the argument string into a boolean | 39 | /* Helper function, transforms the argument string into a boolean |
| 41 | value. */ | 40 | value. */ |
| 42 | -function strToBool(opt) | ||
| 43 | -{ | 41 | +function strToBool(opt) { |
| 44 | if (opt == 0 || opt == "no") | 42 | if (opt == 0 || opt == "no") |
| 45 | return false; | 43 | return false; |
| 46 | else if (opt == 1 || opt == "yes") | 44 | else if (opt == 1 || opt == "yes") |
| @@ -50,8 +48,7 @@ function strToBool(opt) | @@ -50,8 +48,7 @@ function strToBool(opt) | ||
| 50 | } | 48 | } |
| 51 | 49 | ||
| 52 | /* Displays the details about how to use this script. */ | 50 | /* Displays the details about how to use this script. */ |
| 53 | -function usage() | ||
| 54 | -{ | 51 | +function usage() { |
| 55 | var txt; | 52 | var txt; |
| 56 | txt = "Usage:\n"; | 53 | txt = "Usage:\n"; |
| 57 | txt += " cscript " + WScript.ScriptName + " <options>\n"; | 54 | txt += " cscript " + WScript.ScriptName + " <options>\n"; |
| @@ -59,26 +56,25 @@ function usage() | @@ -59,26 +56,25 @@ function usage() | ||
| 59 | txt += "Options can be specified in the form <option>=<value>, where the value is\n"; | 56 | txt += "Options can be specified in the form <option>=<value>, where the value is\n"; |
| 60 | txt += "either 'yes' or 'no', if not stated otherwise.\n\n"; | 57 | txt += "either 'yes' or 'no', if not stated otherwise.\n\n"; |
| 61 | txt += "\nModbus library configure options, default value given in parentheses:\n\n"; | 58 | txt += "\nModbus library configure options, default value given in parentheses:\n\n"; |
| 62 | - txt += " test-run: Run configure without creating files (" + (testRun? "yes" : "no") + ")\n"; | 59 | + txt += " dry-run: Run configure without creating files (" + (testRun? "yes" : "no") + ")\n"; |
| 63 | txt += "\nWin32 build options, default value given in parentheses:\n\n"; | 60 | txt += "\nWin32 build options, default value given in parentheses:\n\n"; |
| 64 | - txt += " compiler: Compiler to be used [msvc|mingw|bcb] (" + compiler + ")\n"; | 61 | + txt += " compiler: Compiler to be used [msvc|mingw] (" + compiler + ")\n"; |
| 65 | WScript.Echo(txt); | 62 | WScript.Echo(txt); |
| 66 | } | 63 | } |
| 67 | 64 | ||
| 68 | /* read the version from the configuration file */ | 65 | /* read the version from the configuration file */ |
| 69 | -function readVersion() | ||
| 70 | -{ | 66 | +function readVersion() { |
| 71 | var fso, cf, ln, s; | 67 | var fso, cf, ln, s; |
| 72 | fso = new ActiveXObject("Scripting.FileSystemObject"); | 68 | fso = new ActiveXObject("Scripting.FileSystemObject"); |
| 73 | cf = fso.OpenTextFile(configFile, 1); | 69 | cf = fso.OpenTextFile(configFile, 1); |
| 74 | while (cf.AtEndOfStream != true) { | 70 | while (cf.AtEndOfStream != true) { |
| 75 | ln = cf.ReadLine(); | 71 | ln = cf.ReadLine(); |
| 76 | s = new String(ln); | 72 | s = new String(ln); |
| 77 | - if (s.search(/^m4_define\(\[libmodbus_version_major/) != -1) { | 73 | + if (s.search(/^m4_define\(\[libmodbus_version_major/) != -1) { |
| 78 | verMajor = s.substr(s.indexOf(",") + 3, 1) | 74 | verMajor = s.substr(s.indexOf(",") + 3, 1) |
| 79 | - } else if(s.search(/^m4_define\(\[libmodbus_version_minor/) != -1) { | 75 | + } else if (s.search(/^m4_define\(\[libmodbus_version_minor/) != -1) { |
| 80 | verMinor = s.substr(s.indexOf(",") + 3, 1) | 76 | verMinor = s.substr(s.indexOf(",") + 3, 1) |
| 81 | - } else if(s.search(/^m4_define\(\[libmodbus_version_micro/) != -1) { | 77 | + } else if (s.search(/^m4_define\(\[libmodbus_version_micro/) != -1) { |
| 82 | verMicro = s.substr(s.indexOf(",") + 3, 1) | 78 | verMicro = s.substr(s.indexOf(",") + 3, 1) |
| 83 | } | 79 | } |
| 84 | } | 80 | } |
| @@ -86,8 +82,7 @@ function readVersion() | @@ -86,8 +82,7 @@ function readVersion() | ||
| 86 | } | 82 | } |
| 87 | 83 | ||
| 88 | /* create the versioned file */ | 84 | /* create the versioned file */ |
| 89 | -function createVersionedFile(newfile, unversioned) | ||
| 90 | -{ | 85 | +function createVersionedFile(newfile, unversioned) { |
| 91 | var fso, ofi, of, ln, s; | 86 | var fso, ofi, of, ln, s; |
| 92 | fso = new ActiveXObject("Scripting.FileSystemObject"); | 87 | fso = new ActiveXObject("Scripting.FileSystemObject"); |
| 93 | ofi = fso.OpenTextFile(unversioned, 1); | 88 | ofi = fso.OpenTextFile(unversioned, 1); |
| @@ -97,7 +92,7 @@ function createVersionedFile(newfile, unversioned) | @@ -97,7 +92,7 @@ function createVersionedFile(newfile, unversioned) | ||
| 97 | while (ofi.AtEndOfStream != true) { | 92 | while (ofi.AtEndOfStream != true) { |
| 98 | ln = ofi.ReadLine(); | 93 | ln = ofi.ReadLine(); |
| 99 | s = new String(ln); | 94 | s = new String(ln); |
| 100 | - if (!testRun && s.search(/\@LIBMODBUS_VERSION_MAJOR\@/) != -1) { | 95 | + if (!testRun && s.search(/\@LIBMODBUS_VERSION_MAJOR\@/) != -1) { |
| 101 | of.WriteLine(s.replace(/\@LIBMODBUS_VERSION_MAJOR\@/, verMajor)); | 96 | of.WriteLine(s.replace(/\@LIBMODBUS_VERSION_MAJOR\@/, verMajor)); |
| 102 | } else if (!testRun && s.search(/\@LIBMODBUS_VERSION_MINOR\@/) != -1) { | 97 | } else if (!testRun && s.search(/\@LIBMODBUS_VERSION_MINOR\@/) != -1) { |
| 103 | of.WriteLine(s.replace(/\@LIBMODBUS_VERSION_MINOR\@/, verMinor)); | 98 | of.WriteLine(s.replace(/\@LIBMODBUS_VERSION_MINOR\@/, verMinor)); |
| @@ -126,8 +121,6 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) { | @@ -126,8 +121,6 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) { | ||
| 126 | var arg, opt; | 121 | var arg, opt; |
| 127 | arg = WScript.Arguments(i); | 122 | arg = WScript.Arguments(i); |
| 128 | opt = arg.substring(0, arg.indexOf("=")); | 123 | opt = arg.substring(0, arg.indexOf("=")); |
| 129 | - if (opt.length == 0) | ||
| 130 | - opt = arg.substring(0, arg.indexOf(":")); | ||
| 131 | if (opt.length > 0) { | 124 | if (opt.length > 0) { |
| 132 | if (opt == "dry-run") | 125 | if (opt == "dry-run") |
| 133 | testRun = strToBool(arg.substring(opt.length + 1, arg.length)); | 126 | testRun = strToBool(arg.substring(opt.length + 1, arg.length)); |
| @@ -184,7 +177,7 @@ if (error != 0) { | @@ -184,7 +177,7 @@ if (error != 0) { | ||
| 184 | } | 177 | } |
| 185 | 178 | ||
| 186 | // Display the final configuration. | 179 | // Display the final configuration. |
| 187 | -var txtOut = "\nLIBMODBUS configuration completed\n"; | 180 | +var txtOut = "\nLibmodbus configuration completed\n"; |
| 188 | WScript.Echo(txtOut); | 181 | WScript.Echo(txtOut); |
| 189 | 182 | ||
| 190 | 183 |