diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..ee8b7ee --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,37 @@ +## Pull Request Template + +### Description + +[ description of the bug fix or new functionality ] + +[ include directions for reviewers if necessary- what or how should they test or review ] + +Fixes # (issue(s)) + +### Corresponding branches and PRs: + +[ which branches of wex, lk, and ssc should be built with this PR ] + +[ link any corresponding PRs in other repos, i.e. NREL/ssc#x ] + +### Unit Test Impact: + +[ new tests written? ] + +[ expected changes in unit tests or speed of tests? ] + +[ expected changes in test_results files? ] + +### Checklist +- [ ] requires help revision and I added that label +- [ ] adds, removes, modifies, or deletes variables in existing compute modules +- [ ] adds a new compute module +- [ ] changes defaults +- [ ] I've tagged this PR to a milestone + +### Reminders- this section can be deleted +[Checking for PySAM Incompatible API Changes] +(https://github.com/NREL/SAM/wiki/PySAM-Incompatible-API-Changes-&-Regenerating-PySAM-Files). + +[When do the PySAM files need to be regenerated?] +(https://github.com/NREL/SAM/wiki/PySAM-Incompatible-API-Changes-&-Regenerating-PySAM-Files#when-do-the-pysam-files-need-to-be-regenerated-via-export_config) diff --git a/src/stdlib.cpp b/src/stdlib.cpp index 1e8fdc1..109bc20 100644 --- a/src/stdlib.cpp +++ b/src/stdlib.cpp @@ -1862,19 +1862,55 @@ static void _ascii(lk::invoke_t &cxt) { static void _isalpha(lk::invoke_t &cxt) { LK_DOC("isalpha", "Returns true if the argument is an alphabetic character A-Z,a-z.", "(character):boolean"); lk_string s = cxt.arg(0).as_string(); - cxt.result().assign(::isalpha(s.length() > 0 ? (int) s[0] : 0) ? 1.0 : 0.0); + double x = 0; + if (!s.IsNull()) { + try { + lk_char y = s[0]; + if (y < 256 && !s.IsNull()) + x = ::isalpha(s.length() > 0 ? (int)y : 0) ? 1.0 : 0.0; + } + catch (const std::exception&) { + x = 0; + } + } + cxt.result().assign(x); + //cxt.result().assign(::isalpha(s.length() > 0 ? (int) s[0] : 0) ? 1.0 : 0.0); } static void _isdigit(lk::invoke_t &cxt) { LK_DOC("isdigit", "Returns true if the argument is a numeric digit 0-9.", "(character):boolean"); lk_string s = cxt.arg(0).as_string(); - cxt.result().assign(::isdigit(s.length() > 0 ? (int) s[0] : 0) ? 1.0 : 0.0); + double x = 0; + if (!s.IsNull()) { + try { + lk_char y = s[0]; + if (y < 256) + x = ::isdigit(s.length() > 0 ? (int)y : 0) ? 1.0 : 0.0; + } + catch (const std::exception&) { + x = 0; + } + } + cxt.result().assign(x); +// cxt.result().assign(::isdigit(s.length() > 0 ? (int) s[0] : 0) ? 1.0 : 0.0); } -static void _isalnum(lk::invoke_t &cxt) { +static void _isalnum(lk::invoke_t& cxt) { LK_DOC("isalnum", "Returns true if the argument is an alphanumeric A-Z,a-z,0-9.", "(character):boolean"); lk_string s = cxt.arg(0).as_string(); - cxt.result().assign(::isalnum(s.length() > 0 ? (int) s[0] : 0) ? 1.0 : 0.0); + double x = 0; + if (!s.IsNull()) { + try { + lk_char y = s[0]; + if (y < 256) + x = ::isalnum(s.length() > 0 ? (int)y : 0) ? 1.0 : 0.0; + } + catch (const std::exception&) { + x = 0; + } + } + cxt.result().assign(x); + // cxt.result().assign(::isalnum(s.length() > 0 ? (int) s[0] : 0) ? 1.0 : 0.0); } static void _char(lk::invoke_t &cxt) {