diff --git a/packages/seacas/applications/conjoin/CJ_Internals.C b/packages/seacas/applications/conjoin/CJ_Internals.C index 143e0e157573..912583489369 100644 --- a/packages/seacas/applications/conjoin/CJ_Internals.C +++ b/packages/seacas/applications/conjoin/CJ_Internals.C @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -150,44 +150,44 @@ int Excn::Internals::write_meta_data(const Mesh &mesh, const std::vector &mesh, const std::vector @@ -278,7 +278,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta if (status != NC_NOERR) { errmsg = fmt::format("Error: failed to define title attribute to file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } // For use later to help readers know how much memory to allocate @@ -292,7 +292,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta errmsg = fmt::format("Error: failed to define ATT_MAX_NAME_LENGTH attribute to file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } } @@ -305,7 +305,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to define name string length in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } // ...and some dimensions.. @@ -315,13 +315,13 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta errmsg = fmt::format("Error: failed to define number of dimensions in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } if ((status = nc_def_dim(exodusFilePtr, DIM_TIME, NC_UNLIMITED, &timedim)) != NC_NOERR) { errmsg = fmt::format("Error: failed to define time dimension in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } { @@ -331,7 +331,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta errmsg = fmt::format("Error: failed to define whole time step variable in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } struct ex__file_item *file = ex__find_file_item(exodusFilePtr); @@ -348,7 +348,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to define number of nodes in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } // Define the node map here to avoid a later redefine call @@ -366,7 +366,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); } - return (EX_FATAL); + return EX_FATAL; } ex__compress_variable(exodusFilePtr, varid, 1); } @@ -378,7 +378,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta errmsg = fmt::format("Error: failed to define number of elements in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } // Define the element map here to avoid a later redefine call @@ -397,7 +397,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); } - return (EX_FATAL); + return EX_FATAL; } ex__compress_variable(exodusFilePtr, varid, 1); } @@ -434,7 +434,7 @@ int Excn::Internals::put_metadata(const Mesh &mesh, const CommunicationMeta return EX_FATAL; } - return (EX_NOERR); + return EX_NOERR; } int Excn::Internals::put_metadata(const std::vector &blocks) @@ -443,7 +443,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) int status = 0; // clear error code if (blocks.empty()) { - return (EX_NOERR); + return EX_NOERR; } // Get number of element blocks defined for this file @@ -454,7 +454,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: no element blocks defined in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } int namestrdim; @@ -463,7 +463,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to get name string length in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } status = nc_inq_dimlen(exodusFilePtr, dimid, &num_elem_blk); @@ -472,7 +472,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) errmsg = fmt::format("Error: failed to get number of element blocks in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } SMART_ASSERT(blocks.size() == num_elem_blk); @@ -504,7 +504,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) blocks[iblk].id, exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); } - return (EX_FATAL); + return EX_FATAL; } int nelnoddim; @@ -516,7 +516,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) fmt::format("Error: failed to define number of nodes/element for block {} in file id {}", blocks[iblk].id, exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } // element attribute array @@ -530,7 +530,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) fmt::format("Error: failed to define number of attributes in block {} in file id {}", blocks[iblk].id, exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } int dims[] = {numelbdim, numattrdim}; @@ -543,7 +543,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) fmt::format("Error: failed to define attributes for element block {} in file id {}", blocks[iblk].id, exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } ex__compress_variable(exodusFilePtr, varid, 2); @@ -557,7 +557,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) " in file id {}", blocks[iblk].id, exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } } @@ -572,7 +572,7 @@ int Excn::Internals::put_metadata(const std::vector &blocks) errmsg = fmt::format("Error: failed to create connectivity array for block {} in file id {}", blocks[iblk].id, exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } ex__compress_variable(exodusFilePtr, connid, 1); @@ -585,10 +585,10 @@ int Excn::Internals::put_metadata(const std::vector &blocks) errmsg = fmt::format("Error: failed to store element type name {} in file id {}", blocks[iblk].elType, exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } } - return (EX_NOERR); + return EX_NOERR; } template @@ -610,7 +610,7 @@ int Excn::Internals::put_non_define_data(const std::vector &blocks) } if (put_id_array(exodusFilePtr, VAR_ID_EL_BLK, elem_blk_id) != NC_NOERR) { - return (EX_FATAL); + return EX_FATAL; } // Now, write the element block status array @@ -620,10 +620,10 @@ int Excn::Internals::put_non_define_data(const std::vector &blocks) } if (put_int_array(exodusFilePtr, VAR_STAT_EL_BLK, elem_blk_status) != NC_NOERR) { - return (EX_FATAL); + return EX_FATAL; } } - return (EX_NOERR); + return EX_NOERR; } // ======================================================================== @@ -650,7 +650,7 @@ template int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector> &nodese } if (put_id_array(exodusFilePtr, VAR_NS_IDS, nodeset_id) != NC_NOERR) { - return (EX_FATAL); + return EX_FATAL; } // Now, write the status array @@ -768,10 +768,10 @@ int Excn::Internals::put_non_define_data(const std::vector> &nodese } if (put_int_array(exodusFilePtr, VAR_NS_STAT, status) != NC_NOERR) { - return (EX_FATAL); + return EX_FATAL; } - return (EX_NOERR); + return EX_NOERR; } // ======================================================================== @@ -798,7 +798,7 @@ template int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector int Excn::Internals::put_metadata(const std::vector> &sidese } if (put_id_array(exodusFilePtr, VAR_SS_IDS, sideset_id) != NC_NOERR) { - return (EX_FATAL); + return EX_FATAL; } // Now, write the status array @@ -942,10 +942,10 @@ int Excn::Internals::put_non_define_data(const std::vector> &sidese } if (put_int_array(exodusFilePtr, VAR_SS_STAT, status) != NC_NOERR) { - return (EX_FATAL); + return EX_FATAL; } - return (EX_NOERR); + return EX_NOERR; } namespace { @@ -960,7 +960,7 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to locate {} in file id {}", var_type, exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } status = nc_put_var_int(exoid, var_id, array.data()); @@ -968,9 +968,9 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to write {} array in file id {}", var_type, exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } - return (EX_NOERR); + return EX_NOERR; } int put_id_array(int exoid, const char *var_type, const std::vector &ids) @@ -983,7 +983,7 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to locate {} in file id {}", var_type, exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } int id_type = get_type(exoid, EX_IDS_INT64_API); @@ -1009,9 +1009,9 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to write {} array in file id {}", var_type, exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } - return (EX_NOERR); + return EX_NOERR; } int define_coordinate_vars(int exodusFilePtr, size_t nodes, int node_dim, int dimension, @@ -1032,7 +1032,7 @@ namespace { errmsg = fmt::format("Error: failed to define node x coordinate array in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } ex__compress_variable(exodusFilePtr, varid, 2); } @@ -1044,7 +1044,7 @@ namespace { errmsg = fmt::format("Error: failed to define node y coordinate array in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } ex__compress_variable(exodusFilePtr, varid, 2); } @@ -1056,7 +1056,7 @@ namespace { errmsg = fmt::format("Error: failed to define node z coordinate array in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } ex__compress_variable(exodusFilePtr, varid, 2); } @@ -1072,7 +1072,7 @@ namespace { errmsg = fmt::format("Error: failed to define coordinate name array in file id {}", exodusFilePtr); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } return EX_NOERR; } @@ -1091,7 +1091,7 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to get string name dimension in file id {}", exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } status = nc_def_dim(exoid, dim_num, count, &dimid); @@ -1099,7 +1099,7 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to define number of {}s in file id {}", type, exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } // id status array: @@ -1109,7 +1109,7 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to define side {} status in file id {}", type, exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } // id array: @@ -1119,7 +1119,7 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to define {} property in file id {}", type, exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } // store property name as attribute of property array variable @@ -1129,7 +1129,7 @@ namespace { errmsg = fmt::format("Error: failed to store {} property name {} in file id {}", type, "ID", exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } dim[0] = dimid; @@ -1140,7 +1140,7 @@ namespace { ex_opts(EX_VERBOSE); errmsg = fmt::format("Error: failed to define {} name array in file id {}", type, exoid); ex_err_fn(exoid, __func__, errmsg.c_str(), status); - return (EX_FATAL); + return EX_FATAL; } return EX_NOERR; } diff --git a/packages/seacas/applications/conjoin/CJ_Variables.h b/packages/seacas/applications/conjoin/CJ_Variables.h index 02d20d0a90aa..9b82323363ba 100644 --- a/packages/seacas/applications/conjoin/CJ_Variables.h +++ b/packages/seacas/applications/conjoin/CJ_Variables.h @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -19,7 +19,7 @@ namespace Excn { struct Variables { explicit Variables(ObjectType otype, bool arg_add_status = false) - : objectType(otype), outputCount(0), addStatus(arg_add_status) + : objectType(otype), addStatus(arg_add_status) { SMART_ASSERT(otype == ObjectType::EBLK || otype == ObjectType::NSET || otype == ObjectType::SSET || otype == ObjectType::NODE || @@ -63,7 +63,7 @@ namespace Excn { bool add_status() const { return addStatus; } ObjectType objectType; - int outputCount; + int outputCount{0}; bool addStatus; IntVector index_{}; std::string type_{}; diff --git a/packages/seacas/applications/conjoin/Conjoin.C b/packages/seacas/applications/conjoin/Conjoin.C index ca30374a8bbe..90a650892dc9 100644 --- a/packages/seacas/applications/conjoin/Conjoin.C +++ b/packages/seacas/applications/conjoin/Conjoin.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -44,6 +44,14 @@ #error "Requires exodusII version 4.68 or later" #endif +#include "CJ_ExodusEntity.h" +#include "CJ_ExodusFile.h" +#include "CJ_Internals.h" +#include "CJ_ObjectType.h" +#include "CJ_SystemInterface.h" +#include "CJ_Variables.h" +#include "CJ_Version.h" + namespace { template void clear(std::vector &vec) { @@ -111,14 +119,6 @@ struct NodeInfo using GlobalMap = std::vector; using GMapIter = GlobalMap::iterator; -#include "CJ_ExodusEntity.h" -#include "CJ_ExodusFile.h" -#include "CJ_Internals.h" -#include "CJ_ObjectType.h" -#include "CJ_SystemInterface.h" -#include "CJ_Variables.h" -#include "CJ_Version.h" - extern double seacas_timer(); namespace { diff --git a/packages/seacas/applications/ejoin/EJoin.C b/packages/seacas/applications/ejoin/EJoin.C index 39487fdc1fc3..a06e3b5e7ab2 100644 --- a/packages/seacas/applications/ejoin/EJoin.C +++ b/packages/seacas/applications/ejoin/EJoin.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -257,6 +257,11 @@ int main(int argc, char *argv[]) add_to_log(argv[0], time); #ifdef SEACAS_HAVE_MPI + MPI_Comm parent_comm; + MPI_Comm_get_parent(&parent_comm); + if (parent_comm != MPI_COMM_NULL) { + MPI_Barrier(parent_comm); + } MPI_Finalize(); #endif diff --git a/packages/seacas/applications/epu/epu.C b/packages/seacas/applications/epu/epu.C index daab9699cb6a..823f919142eb 100644 --- a/packages/seacas/applications/epu/epu.C +++ b/packages/seacas/applications/epu/epu.C @@ -115,7 +115,7 @@ namespace { } } - void exodus_error(int lineno) + [[noreturn]] void exodus_error(int lineno) { std::ostringstream errmsg; fmt::print(errmsg, @@ -3895,6 +3895,7 @@ namespace { size_t maximum_nodes = edgeblocks[p][b].entity_count(); maximum_nodes *= edgeblocks[p][b].nodesPerEdge; std::vector local_linkage(maximum_nodes); + SMART_ASSERT(block_linkage != nullptr); ex_entity_id bid = edgeblocks[p][b].id; error = ex_get_conn(id, EX_EDGE_BLOCK, bid, local_linkage.data(), nullptr, nullptr); @@ -4271,6 +4272,7 @@ namespace { size_t maximum_nodes = faceblocks[p][b].entity_count(); maximum_nodes *= faceblocks[p][b].nodesPerFace; std::vector local_linkage(maximum_nodes); + SMART_ASSERT(block_linkage != nullptr); ex_entity_id bid = faceblocks[p][b].id; error = ex_get_conn(id, EX_FACE_BLOCK, bid, local_linkage.data(), nullptr, nullptr); diff --git a/packages/seacas/applications/exo_format/exo_format.c b/packages/seacas/applications/exo_format/exo_format.c index 1d1ca80a5165..303551a3ce79 100644 --- a/packages/seacas/applications/exo_format/exo_format.c +++ b/packages/seacas/applications/exo_format/exo_format.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -55,7 +55,6 @@ int main(int argc, char *argv[]) int int64_status = 0; int max_name_length = 0; int fn_idx = 1; - char cversion[9]; CPU_word_size = 0; /* float or double */ IO_word_size = 0; /* use what is stored in file */ @@ -210,7 +209,8 @@ int main(int argc, char *argv[]) } version += 0.00005F; - sprintf(cversion, "%4.2f", version); + char cversion[9]; + snprintf(cversion, 9, "%4.2f", version); k = strlen(cversion); for (j = 0; j < k; j++) { diff --git a/packages/seacas/applications/exodiff/ED_SystemInterface.C b/packages/seacas/applications/exodiff/ED_SystemInterface.C index 6ca1366558b5..13293c984fff 100644 --- a/packages/seacas/applications/exodiff/ED_SystemInterface.C +++ b/packages/seacas/applications/exodiff/ED_SystemInterface.C @@ -24,7 +24,7 @@ #include namespace { - void Parse_Die(const char *line) + [[noreturn]] void Parse_Die(const char *line) { std::string sline = line; chop_whitespace(sline); diff --git a/packages/seacas/applications/exodiff/exodiff.C b/packages/seacas/applications/exodiff/exodiff.C index 7330ee2b9707..25cdd9589c05 100644 --- a/packages/seacas/applications/exodiff/exodiff.C +++ b/packages/seacas/applications/exodiff/exodiff.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -1506,7 +1506,7 @@ bool diff_globals(ExoII_Read &file1, ExoII_Read &file2, int step1, con const std::string &name = (interFace.glob_var_names)[out_idx]; int idx1 = find_string(file1.Global_Var_Names(), name, interFace.nocase_var_names); int idx2 = find_string(file2.Global_Var_Names(), name, interFace.nocase_var_names); - if (idx1 < 0 || idx2 < 0 || vals2 == nullptr) { + if (idx1 < 0 || idx2 < 0) { Error(fmt::format("Unable to find global variable named '{}' on database.\n", name)); } gvals[out_idx] = FileDiff(vals1[idx1], vals2[idx2], interFace.output_type); @@ -1792,7 +1792,9 @@ bool diff_element(ExoII_Read &file1, ExoII_Read &file2, int step1, con if (el_flag >= 0) { if (elmt_map.empty()) { - v2 = vals2[e]; + if (vals2 != nullptr) { + v2 = vals2[e]; + } } else { // With mapping, map global index from file 1 to global index @@ -1844,7 +1846,7 @@ bool diff_element(ExoII_Read &file1, ExoII_Read &file2, int step1, con } eblock1->Free_Results(); - if (elmt_map.empty()) { + if (elmt_map.empty() && eblock2 != nullptr) { eblock2->Free_Results(); } @@ -1967,9 +1969,9 @@ bool diff_nodeset(ExoII_Read &file1, ExoII_Read &file2, int step1, con if (!interFace.quiet_flag) { Node_Set *nset = file1.Get_Node_Set_by_Id(max_diff.blk); std::string buf = fmt::format( - " {:<{}} {} diff: {:14.7e} ~ {:14.7e} ={:12.5e} (set {}, node {})", name, - name_length(), interFace.ns_var[e_idx].abrstr(), max_diff.val1, max_diff.val2, - max_diff.diff, max_diff.blk, id_map[nset->Node_Id(max_diff.id) - 1]); + " {:<{}} {} diff: {:14.7e} ~ {:14.7e} ={:12.5e} (set {}, node {})", name, + name_length(), interFace.ns_var[e_idx].abrstr(), max_diff.val1, max_diff.val2, + max_diff.diff, max_diff.blk, id_map[nset->Node_Id(max_diff.id) - 1]); DIFF_OUT(buf); } else { @@ -2077,10 +2079,10 @@ bool diff_sideset(ExoII_Read &file1, ExoII_Read &file2, int step1, con if (!interFace.quiet_flag) { Side_Set *sset = file1.Get_Side_Set_by_Id(max_diff.blk); std::string buf = fmt::format( - " {:<{}} {} diff: {:14.7e} ~ {:14.7e} ={:12.5e} (set {}, side {}.{})", name, - name_length(), interFace.ss_var[e_idx].abrstr(), max_diff.val1, max_diff.val2, - max_diff.diff, max_diff.blk, id_map[sset->Side_Id(max_diff.id).first - 1], - (int)sset->Side_Id(max_diff.id).second); + " {:<{}} {} diff: {:14.7e} ~ {:14.7e} ={:12.5e} (set {}, side {}.{})", name, + name_length(), interFace.ss_var[e_idx].abrstr(), max_diff.val1, max_diff.val2, + max_diff.diff, max_diff.blk, id_map[sset->Side_Id(max_diff.id).first - 1], + (int)sset->Side_Id(max_diff.id).second); DIFF_OUT(buf); } else { @@ -2331,9 +2333,9 @@ bool diff_edgeblock(ExoII_Read &file1, ExoII_Read &file2, int step1, c if (!interFace.quiet_flag) { Edge_Block *eblock = file1.Get_Edge_Block_by_Id(max_diff.blk); std::string buf = fmt::format( - " {:<{}} {} diff: {:14.7e} ~ {:14.7e} ={:12.5e} (edge block {}, edge {})", name, - name_length(), interFace.eb_var[e_idx].abrstr(), max_diff.val1, max_diff.val2, - max_diff.diff, max_diff.blk, eblock->Edge_Index(max_diff.id) + 1); + " {:<{}} {} diff: {:14.7e} ~ {:14.7e} ={:12.5e} (edge block {}, edge {})", name, + name_length(), interFace.eb_var[e_idx].abrstr(), max_diff.val1, max_diff.val2, + max_diff.diff, max_diff.blk, eblock->Edge_Index(max_diff.id) + 1); DIFF_OUT(buf); } else { diff --git a/packages/seacas/applications/exodiff/util.h b/packages/seacas/applications/exodiff/util.h index e21362ec02d9..9b0cb0af3031 100644 --- a/packages/seacas/applications/exodiff/util.h +++ b/packages/seacas/applications/exodiff/util.h @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -14,9 +14,9 @@ int name_length(); char **get_name_array(int size, int length); void free_name_array(char **names, int size); -void Error(const std::string &x); -void Error(std::ostringstream &buf); -void Warning(const std::string &x); -void ERR_OUT(std::ostringstream &buf); +[[noreturn]] void Error(const std::string &x); +[[noreturn]] void Error(std::ostringstream &buf); +void Warning(const std::string &x); +void ERR_OUT(std::ostringstream &buf); void DIFF_OUT(std::ostringstream &buf, fmt::detail::color_type color = fmt::color::red); void DIFF_OUT(const std::string &buf, fmt::detail::color_type color = fmt::color::red); diff --git a/packages/seacas/applications/exotec2/tec.c b/packages/seacas/applications/exotec2/tec.c index 43282fb8e9d3..991b8553f061 100644 --- a/packages/seacas/applications/exotec2/tec.c +++ b/packages/seacas/applications/exotec2/tec.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -425,17 +425,17 @@ void teczone(int nblk, int nnode, int elem_id, char *elem_type, int node_per_ele inode); char zname[80]; char eltype[16]; - sprintf(zname, "Zone %s_%d", elem_type, elem_id); + snprintf(zname, 80, "Zone %s_%d", elem_type, elem_id); if (ndim == 3 && (node_per_elem == 8 || (node_per_elem == 4 && ifac == 2) || (node_per_elem == 2 && ifac == 4))) - sprintf(eltype, "BRICK"); + snprintf(eltype, 16, "BRICK"); else if (ndim == 3 && node_per_elem == 4) - sprintf(eltype, "TETRAHEDRON"); + snprintf(eltype, 16, "TETRAHEDRON"); else if (ndim == 2 && (node_per_elem == 4 || (node_per_elem == 2 && ifac == 2))) - sprintf(eltype, "QUADRILATERAL"); + snprintf(eltype, 16, "QUADRILATERAL"); else if (ndim == 2 && node_per_elem == 3) - sprintf(eltype, "TRIANGLE"); + snprintf(eltype, 16, "TRIANGLE"); else { printf("\nBad element type found in teczone\n"); printf(" Dimensions = %d\n", ndim); diff --git a/packages/seacas/applications/nem_slice/elb_loadbal.C b/packages/seacas/applications/nem_slice/elb_loadbal.C index 37d24bf932e5..0b74097fc4c6 100644 --- a/packages/seacas/applications/nem_slice/elb_loadbal.C +++ b/packages/seacas/applications/nem_slice/elb_loadbal.C @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -149,7 +149,6 @@ int generate_loadbal(Machine_Description *machine, Problem_Description *problem, int tmp_lev; int *tmp_v2p = nullptr; - float *x_ptr = nullptr, *y_ptr = nullptr, *z_ptr = nullptr; float *x_node_ptr = nullptr, *y_node_ptr = nullptr, *z_node_ptr = nullptr; std::vector x_elem_ptr, y_elem_ptr, z_elem_ptr; float *tmp_x = nullptr, *tmp_y = nullptr, *tmp_z = nullptr; @@ -216,16 +215,15 @@ int generate_loadbal(Machine_Description *machine, Problem_Description *problem, y_node_ptr = (float *)calloc(mesh->num_nodes, sizeof(float)); z_node_ptr = (float *)calloc(mesh->num_nodes, sizeof(float)); break; + + default: Gen_Error(0, "FATAL: Invalid mesh dimension. Must be 1, 2, or 3."); return 0; } } - else { - x_node_ptr = y_node_ptr = z_node_ptr = nullptr; - } /* now set the pointers that are being sent to Chaco */ - x_ptr = x_node_ptr; - y_ptr = y_node_ptr; - z_ptr = z_node_ptr; + float *x_ptr = x_node_ptr; + float *y_ptr = y_node_ptr; + float *z_ptr = z_node_ptr; /* * For an elemental decomposition using inertial, ZPINCH, BRICK @@ -634,7 +632,8 @@ int generate_loadbal(Machine_Description *machine, Problem_Description *problem, tmp_z = z_ptr; tmp_v2p = lb->vertex2proc; - for (int cnt = 0; cnt < machine->num_dims; cnt++) { + int upper = machine->num_dims > 3 ? 3 : machine->num_dims; + for (int cnt = 0; cnt < upper; cnt++) { tmpdim[cnt] = machine->dim[cnt]; } if (machine->type == MESH) { diff --git a/packages/seacas/applications/nem_slice/fix_column_partitions.C b/packages/seacas/applications/nem_slice/fix_column_partitions.C index f0d25ad50e1e..3098f375ff9e 100644 --- a/packages/seacas/applications/nem_slice/fix_column_partitions.C +++ b/packages/seacas/applications/nem_slice/fix_column_partitions.C @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -39,8 +39,8 @@ namespace { // Get nodes of this side (face) of the element - int nsnodes = is_hex(etype) ? 4 : 3; - INT side_nodes[9]; // SHELL9 has 9 nodes on a face. + int nsnodes = is_hex(etype) ? 4 : 3; + INT side_nodes[9] = {0}; // SHELL9 has 9 nodes on a face. INT *elnodes = mesh->connect[cur_elem]; ss_to_node_list(etype, elnodes, side_id, side_nodes); @@ -48,7 +48,7 @@ namespace { // How would these side's nodes be if they were viewed from the // adjacent element - INT side_nodes_flipped[9]; // Realistically: 4, max possible: 9 + INT side_nodes_flipped[9] = {0}; // Realistically: 4, max possible: 9 get_ss_mirror(etype, side_nodes, side_id, side_nodes_flipped); for (int i = 0; i < nadj; i++) { @@ -139,7 +139,8 @@ int fix_column_partitions(LB_Description *lb, Mesh_Description const * int count = 0; for (int j = 0; j < nelfaces; j++) { - INT fnodes[9]; // Should only need 4, but ss_to_node_list can potentially access 9 (SHELL9). + INT fnodes[9] = { + 0}; // Should only need 4, but ss_to_node_list can potentially access 9 (SHELL9). int nfn = 4; if (is_wedge(etype)) { @@ -155,7 +156,7 @@ int fix_column_partitions(LB_Description *lb, Mesh_Description const * ss_to_node_list(etype, mesh->connect[i], j + 1, fnodes); // Translate global IDs of side nodes to local IDs in element - int fnodes_loc[9]; + int fnodes_loc[9] = {0}; for (int k = 0; k < nfn; k++) { bool found = false; for (int k2 = 0; k2 < nelnodes; k2++) { diff --git a/packages/seacas/applications/slice/Slice.C b/packages/seacas/applications/slice/Slice.C index 0136879548ef..5afcb42610c0 100644 --- a/packages/seacas/applications/slice/Slice.C +++ b/packages/seacas/applications/slice/Slice.C @@ -1718,7 +1718,12 @@ namespace { size_t proc_count = proc_region.size(); - size_t node_count = region.get_property("node_count").get_int(); + size_t node_count = region.get_property("node_count").get_int(); + if (node_count == 0) { + // Should never happen, but makes static analyzers happy... + return; + } + std::vector> proc_node(node_count); // Assume that the majority of nodes will be on 2 or less diff --git a/packages/seacas/libraries/aprepro_lib/CMakeLists.txt b/packages/seacas/libraries/aprepro_lib/CMakeLists.txt index 8c896e3099ed..c8d119847dec 100644 --- a/packages/seacas/libraries/aprepro_lib/CMakeLists.txt +++ b/packages/seacas/libraries/aprepro_lib/CMakeLists.txt @@ -41,7 +41,7 @@ SET(SOURCES apr_units.cc apr_tokenize.cc apr_scanner.cc - apr_getline_int.c + apr_getline.cc ${BISON_LIB_SOURCE} apr_exodus.cc apr_array.cc diff --git a/packages/seacas/libraries/aprepro_lib/apr_builtin.cc b/packages/seacas/libraries/aprepro_lib/apr_builtin.cc index 63e1e6e1c560..12683eb4d271 100644 --- a/packages/seacas/libraries/aprepro_lib/apr_builtin.cc +++ b/packages/seacas/libraries/aprepro_lib/apr_builtin.cc @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -594,7 +594,7 @@ namespace SEAMS { SEAMS::symrec *format; format = aprepro->getsym("_FORMAT"); - sprintf(tmpstr, format->value.svar.c_str(), x); + snprintf(tmpstr, 128, format->value.svar.c_str(), x); new_string(tmpstr, &tmp); return (tmp); } @@ -800,15 +800,14 @@ namespace SEAMS { // Using 'intout(val)', val will be converted to a string // using an integer format - char *tmp; - static char tmpstr[128]; + char *tmp; if (intval == 0.0) { new_string("0", &tmp); return (tmp); } - sprintf(tmpstr, "%d", static_cast(intval)); - new_string(tmpstr, &tmp); + std::string tmpstr = std::to_string(static_cast(intval)); + new_string(tmpstr.c_str(), &tmp); return (tmp); } diff --git a/packages/seacas/libraries/aprepro_lib/apr_getline.cc b/packages/seacas/libraries/aprepro_lib/apr_getline.cc new file mode 100644 index 000000000000..71af7b44ccb7 --- /dev/null +++ b/packages/seacas/libraries/aprepro_lib/apr_getline.cc @@ -0,0 +1,982 @@ + +/* + * Copyright (C) 1991, 1992, 1993, 2021, 2022, 2023 by Chris Thewalt (thewalt@ce.berkeley.edu) + * + * Permission to use, copy, modify, and distribute this software + * for any purpose and without fee is hereby granted, provided + * that the above copyright notices appear in all copies and that both the + * copyright notice and this permission notice appear in supporting + * documentation. This software is provided "as is" without express or + * implied warranty. + * + * Thanks to the following people who have provided enhancements and fixes: + * Ron Ueberschaer, Christoph Keller, Scott Schwartz, Steven List, + * DaviD W. Sanderson, Goran Bostrom, Michael Gleason, Glenn Kasten, + * Edin Hodzic, Eric J Bivona, Kai Uwe Rommel, Danny Quah, Ulrich Betzler + */ + +/* + * Note: This version has been updated by Mike Gleason + */ +#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || \ + defined(__MINGW32__) || defined(_WIN64) || defined(__MINGW64__) + +#define __windows__ 1 +#include +#include +#define NOMINMAX +#include +#define sleep(a) Sleep(a * 1000) +#ifndef write +#define write _write +#define read _read +#endif +#else + +#ifndef __unix__ +#define __unix__ 1 +#endif + +#include +struct termios io_new_termios, io_old_termios; +#endif + +/********************* C library headers ********************************/ +#include +#include +#include +#include +#include +#ifndef _MSC_VER +#include +#endif + +#include "apr_getline.h" + +namespace { + const int GL_BUF_SIZE{1024}; + + /******************** external interface *********************************/ + + bool gl_ellipses_during_completion = true; + char gl_buf[GL_BUF_SIZE]; /* input buffer */ + + int gl_init_done = -1; /* terminal mode flag */ + int gl_termw = 80; /* actual terminal width */ + int gl_scroll = 27; /* width of EOL scrolling region */ + int gl_width = 0; /* net size available for input */ + int gl_extent = 0; /* how far to redraw, 0 means all */ + int gl_overwrite = 0; /* overwrite mode */ + int gl_pos, gl_cnt = 0; /* position and size of input */ + char gl_killbuf[GL_BUF_SIZE] = ""; /* killed text */ + const char *gl_prompt; /* to save the prompt string */ + int gl_search_mode = 0; /* search mode flag */ + + void gl_init(void); /* prepare to edit a line */ + void gl_cleanup(void); /* to undo gl_init */ + void gl_char_init(void); /* get ready for no echo input */ + void gl_char_cleanup(void); /* undo gl_char_init */ + /* returns printable prompt width */ + + void gl_addchar(int c); /* install specified char */ + void gl_del(int loc, int); /* del, either left (-1) or cur (0) */ + + [[noreturn]] void gl_error(const char *const buf); /* write error msg and die */ + + void gl_fixup(const char *prompt, int change, int cursor); /* fixup state variables and screen */ + int gl_getc(void); /* read one char from terminal */ + void gl_kill(int pos); /* delete to EOL */ + void gl_newline(void); /* handle \n or \r */ + void gl_putc(int c); /* write one char to terminal */ + void gl_puts(const char *const buf); /* write a line to terminal */ + void gl_redraw(void); /* issue \n and redraw all */ + void gl_transpose(void); /* transpose two chars */ + void gl_yank(void); /* yank killed text */ + + void hist_init(void); /* initializes hist pointers */ + char *hist_next(void); /* return ptr to next item */ + char *hist_prev(void); /* return ptr to prev item */ + char *hist_save(const char *p); /* makes copy of a string, without NL */ + + void search_addchar(int c); /* increment search string */ + void search_term(void); /* reset with current contents */ + void search_back(int new_search); /* look back for current string */ + void search_forw(int new_search); /* look forw for current string */ + void gl_beep(void); /* try to play a system beep sound */ + + char *copy_string(char *dest, char const *source, long int elements) + { + char *d; + for (d = dest; d + 1 < dest + elements && *source; d++, source++) { + *d = *source; + } + *d = '\0'; + return d; + } +} // namespace +/************************ nonportable part *********************************/ + +#ifdef MSDOS +#include +#endif + +namespace { + void gl_char_init(void) /* turn off input echo */ + { +#ifdef __unix__ + tcgetattr(0, &io_old_termios); + io_new_termios = io_old_termios; + io_new_termios.c_iflag &= ~(BRKINT | ISTRIP | IXON | IXOFF); + io_new_termios.c_iflag |= (IGNBRK | IGNPAR); + io_new_termios.c_lflag &= ~(ICANON | ISIG | IEXTEN | ECHO); + io_new_termios.c_cc[VMIN] = 1; + io_new_termios.c_cc[VTIME] = 0; + tcsetattr(0, TCSANOW, &io_new_termios); +#endif /* __unix__ */ + } + + void gl_char_cleanup(void) /* undo effects of gl_char_init */ + { +#ifdef __unix__ + tcsetattr(0, TCSANOW, &io_old_termios); +#endif /* __unix__ */ + } +} // namespace +#if defined(MSDOS) || defined(__windows__) + +#define K_UP 0x48 +#define K_DOWN 0x50 +#define K_LEFT 0x4B +#define K_RIGHT 0x4D +#define K_DELETE 0x53 +#define K_INSERT 0x52 +#define K_HOME 0x47 +#define K_END 0x4F +#define K_PGUP 0x49 +#define K_PGDN 0x51 + +int pc_keymap(int c) +{ + switch (c) { + case K_UP: + case K_PGUP: + c = 16; /* up -> ^P */ + break; + case K_DOWN: + case K_PGDN: + c = 14; /* down -> ^N */ + break; + case K_LEFT: + c = 2; /* left -> ^B */ + break; + case K_RIGHT: + c = 6; /* right -> ^F */ + break; + case K_END: + c = 5; /* end -> ^E */ + break; + case K_HOME: + c = 1; /* home -> ^A */ + break; + case K_INSERT: + c = 15; /* insert -> ^O */ + break; + case K_DELETE: + c = 4; /* del -> ^D */ + break; + default: c = 0; /* make it garbage */ + } + return c; +} +#endif /* defined(MSDOS) || defined(__windows__) */ + +namespace { + int gl_getc(void) + /* get a character without echoing it to screen */ + { +#ifdef __unix__ + char ch; + int c; + while ((c = read(0, &ch, 1)) == -1) { + if (errno != EINTR) { + break; + } + } + c = (ch <= 0) ? -1 : ch; +#endif /* __unix__ */ +#ifdef MSDOS + int c = _bios_keybrd(_NKEYBRD_READ); + if ((c & 0377) == 224) { + c = pc_keymap((c >> 8) & 0377); + } + else { + c &= 0377; + } +#endif /* MSDOS */ +#ifdef __windows__ + int c = (int)_getch(); + if ((c == 0) || (c == 0xE0)) { + /* Read key code */ + c = (int)_getch(); + c = pc_keymap(c); + } + else if (c == '\r') { + /* Note: we only get \r from the console, + * and not a matching \n. + */ + c = '\n'; + } +#endif + return c; + } + + void gl_putc(int c) + { + char ch = (char)(unsigned char)c; + + write(1, &ch, 1); + if (ch == '\n') { + ch = '\r'; + write(1, &ch, 1); /* RAW mode needs '\r', does not hurt */ + } + } + + /******************** fairly portable part *********************************/ + + void gl_puts(const char *const buf) + { + if (buf) { + int len = strlen(buf); + write(1, buf, len); + } + } + + [[noreturn]] void gl_error(const char *const buf) + { + int len = strlen(buf); + + gl_cleanup(); + write(2, buf, len); + exit(1); + } + + void gl_init(void) + /* set up variables and terminal */ + { + if (gl_init_done < 0) { /* -1 only on startup */ + const char *cp = (const char *)getenv("COLUMNS"); + if (cp != nullptr) { + int w = strtol(cp, nullptr, 10); + if (w > 20) + SEAMS::gl_setwidth(w); + } + hist_init(); + } + if (isatty(0) == 0 || isatty(1) == 0) + gl_error("\n*** Error: getline(): not interactive, use stdio.\n"); + gl_char_init(); + gl_init_done = 1; + } + + void gl_cleanup(void) + /* undo effects of gl_init, as necessary */ + { + if (gl_init_done > 0) { + gl_char_cleanup(); + } + gl_init_done = 0; +#ifdef __windows__ + Sleep(40); + FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); +#endif + } +} // namespace + +namespace SEAMS { + void gl_setwidth(int w) + { + if (w > 250) { + w = 250; + } + if (w > 20) { + gl_termw = w; + gl_scroll = w / 3; + } + else { + gl_error("\n*** Error: minimum screen width is 21\n"); + } + } + + char *getline_int(const char *prompt) + { + gl_init(); + gl_prompt = (prompt) ? prompt : ""; + gl_buf[0] = '\0'; + gl_fixup(gl_prompt, -2, GL_BUF_SIZE); + +#ifdef __windows__ + FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); +#endif + + int c; + while ((c = gl_getc()) >= 0) { + gl_extent = 0; /* reset to full extent */ + if (isprint(c)) { + if (gl_search_mode) { + search_addchar(c); + } + else { + gl_addchar(c); + } + } + else { + if (gl_search_mode) { + if (c == '\033' || c == '\016' || c == '\020') { + search_term(); + c = 0; /* ignore the character */ + } + else if (c == '\010' || c == '\177') { + search_addchar(-1); /* unwind search string */ + c = 0; + } + else if (c != '\022' && c != '\023') { + search_term(); /* terminate and handle char */ + } + } + switch (c) { + case '\n': + case '\r': /* newline */ + gl_newline(); + gl_cleanup(); + return gl_buf; + case '\001': + gl_fixup(gl_prompt, -1, 0); /* ^A */ + break; + case '\002': + gl_fixup(gl_prompt, -1, gl_pos - 1); /* ^B */ + break; + case '\004': /* ^D */ + if (gl_cnt == 0) { + gl_buf[0] = '\0'; + gl_cleanup(); + gl_putc('\n'); + return gl_buf; + } + else { + gl_del(0, 1); + } + break; + case '\005': + gl_fixup(gl_prompt, -1, gl_cnt); /* ^E */ + break; + case '\006': + gl_fixup(gl_prompt, -1, gl_pos + 1); /* ^F */ + break; + case '\010': + case '\177': + gl_del(-1, 0); /* ^H and DEL */ + break; + case '\t': /* TAB */ break; + case '\013': + gl_kill(gl_pos); /* ^K */ + break; + case '\014': + gl_redraw(); /* ^L */ + break; + case '\016': /* ^N */ + copy_string(gl_buf, hist_next(), GL_BUF_SIZE); + gl_fixup(gl_prompt, 0, GL_BUF_SIZE); + break; + case '\017': + gl_overwrite = !gl_overwrite; /* ^O */ + break; + case '\020': /* ^P */ + copy_string(gl_buf, hist_prev(), GL_BUF_SIZE); + gl_fixup(gl_prompt, 0, GL_BUF_SIZE); + break; + case '\022': + search_back(1); /* ^R */ + break; + case '\023': + search_forw(1); /* ^S */ + break; + case '\024': + gl_transpose(); /* ^T */ + break; + case '\025': + gl_kill(0); /* ^U */ + break; + case '\031': + gl_yank(); /* ^Y */ + break; + default: + if (c > 0) + gl_beep(); + break; + } + } + } + gl_cleanup(); + gl_buf[0] = '\0'; + return gl_buf; + } +} // namespace SEAMS +namespace { + void gl_addchar(int c) + + /* adds the character c to the input buffer at current location */ + { + + if (gl_overwrite == 0 || gl_pos == gl_cnt) { + if (gl_cnt > GL_BUF_SIZE - 2) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + for (int i = gl_cnt; i >= gl_pos; i--) { + gl_buf[i + 1] = gl_buf[i]; + } + gl_buf[gl_pos] = (char)c; + gl_fixup(gl_prompt, gl_pos, gl_pos + 1); + } + else { + if (gl_pos > GL_BUF_SIZE - 1) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + gl_buf[gl_pos] = (char)c; + gl_extent = 1; + gl_fixup(gl_prompt, gl_pos, gl_pos + 1); + } + } + + void gl_yank(void) + /* adds the kill buffer to the input buffer at current location */ + { + int len = strlen(gl_killbuf); + if (len > 0) { + if (gl_overwrite == 0) { + if (gl_cnt + len >= GL_BUF_SIZE) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + for (int i = gl_cnt; i >= gl_pos; i--) { + gl_buf[i + len] = gl_buf[i]; + } + for (int i = 0; i < len; i++) { + gl_buf[gl_pos + i] = gl_killbuf[i]; + } + gl_fixup(gl_prompt, gl_pos, gl_pos + len); + } + else { + if (gl_pos + len >= GL_BUF_SIZE) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + if (gl_pos + len > gl_cnt) { + gl_buf[gl_pos + len] = '\0'; + } + for (int i = 0; i < len; i++) { + gl_buf[gl_pos + i] = gl_killbuf[i]; + } + gl_extent = len; + gl_fixup(gl_prompt, gl_pos, gl_pos + len); + } + } + else + gl_beep(); + } + + void gl_transpose(void) + /* switch character under cursor and to left of cursor */ + { + if (gl_pos > 0 && gl_cnt > gl_pos && gl_pos < GL_BUF_SIZE) { + int c = gl_buf[gl_pos - 1]; + gl_buf[gl_pos - 1] = gl_buf[gl_pos]; + gl_buf[gl_pos] = (char)c; + gl_extent = 2; + gl_fixup(gl_prompt, gl_pos - 1, gl_pos); + } + else { + gl_beep(); + } + } + + void gl_newline(void) + /* + * Cleans up entire line before returning to caller. A \n is appended. + * If line longer than screen, we redraw starting at beginning + */ + { + int change = gl_cnt; + int len = gl_cnt; + int loc = gl_width - 5; /* shifts line back to start position */ + + if (gl_cnt >= GL_BUF_SIZE - 1) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + if (loc > len) { + loc = len; + } + gl_fixup(gl_prompt, change, loc); /* must do this before appending \n */ + gl_buf[len] = '\n'; + gl_buf[len + 1] = '\0'; + gl_putc('\n'); + } + + void gl_del(int loc, int killsave) + + /* + * Delete a character. The loc variable can be: + * -1 : delete character to left of cursor + * 0 : delete character under cursor + */ + { + if ((loc == -1 && gl_pos > 0) || (loc == 0 && gl_pos < gl_cnt)) { + int j = 0; + for (int i = gl_pos + loc; i < gl_cnt; i++) { + if (i < GL_BUF_SIZE - 1) { + if ((j == 0) && (killsave != 0)) { + gl_killbuf[0] = gl_buf[i]; + gl_killbuf[1] = '\0'; + j = 1; + } + gl_buf[i] = gl_buf[i + 1]; + } + else { + gl_error("\n*** Error: getline(): logic error in gl_del().\n"); + } + } + gl_fixup(gl_prompt, gl_pos + loc, gl_pos + loc); + } + else { + gl_beep(); + } + } + + void gl_kill(int pos) + + /* delete from pos to the end of line */ + { + if (pos < gl_cnt && pos < GL_BUF_SIZE) { + copy_string(gl_killbuf, gl_buf + pos, GL_BUF_SIZE); + gl_buf[pos] = '\0'; + gl_fixup(gl_prompt, pos, pos); + } + else { + gl_beep(); + } + } + + void gl_redraw(void) + /* emit a newline, reset and redraw prompt and current input line */ + { + if (gl_init_done > 0) { + gl_putc('\n'); + gl_fixup(gl_prompt, -2, gl_pos); + } + } + + void gl_fixup(const char *prompt, int change, int cursor) + + /* + * This function is used both for redrawing when input changes or for + * moving within the input line. The parameters are: + * prompt: compared to last_prompt[] for changes; + * change : the index of the start of changes in the input buffer, + * with -1 indicating no changes, -2 indicating we're on + * a new line, redraw everything. + * cursor : the desired location of the cursor after the call. + * A value of GL_BUF_SIZE can be used to indicate the cursor should + * move just past the end of the input line. + */ + { + static int gl_shift; /* index of first on screen character */ + static int off_right; /* true if more text right of screen */ + static int off_left; /* true if more text left of screen */ + static char last_prompt[80] = ""; + int left = 0, right = -1; /* bounds for redraw */ + int new_right = -1; /* alternate right bound, using gl_extent */ + + if (change == -2) { /* reset */ + gl_pos = gl_cnt = gl_shift = off_right = off_left = 0; + gl_putc('\r'); + gl_puts(prompt); + copy_string(last_prompt, prompt, 80); + change = 0; + gl_width = gl_termw - strlen(prompt); + } + else if (strcmp(prompt, last_prompt) != 0) { + int l1 = strlen(last_prompt); + int l2 = strlen(prompt); + gl_cnt = gl_cnt + l1 - l2; + copy_string(last_prompt, prompt, 80); + gl_putc('\r'); + gl_puts(prompt); + gl_pos = gl_shift; + gl_width = gl_termw - l2; + change = 0; + } + /* how much to erase at end of line */ + int pad = (off_right) ? gl_width - 1 : gl_cnt - gl_shift; /* old length */ + int backup = gl_pos - gl_shift; /* how far to backup before fixing */ + if (change >= 0) { + gl_cnt = strlen(gl_buf); + if (change > gl_cnt) { + change = gl_cnt; + } + } + if (cursor > gl_cnt) { + if (cursor != GL_BUF_SIZE) { /* GL_BUF_SIZE means end of line */ + if (gl_ellipses_during_completion) { + gl_beep(); + } + } + cursor = gl_cnt; + } + if (cursor < 0) { + gl_beep(); + cursor = 0; + } + int extra = 0; /* adjusts when shift (scroll) happens */ + if (off_right || (off_left && cursor < gl_shift + gl_width - gl_scroll / 2)) { + extra = 2; /* shift the scrolling boundary */ + } + int new_shift = cursor + extra + gl_scroll - gl_width; + if (new_shift > 0) { + new_shift /= gl_scroll; + new_shift *= gl_scroll; + } + else { + new_shift = 0; + } + if (new_shift != gl_shift) { /* scroll occurs */ + gl_shift = new_shift; + off_left = (gl_shift) ? 1 : 0; + off_right = (gl_cnt > gl_shift + gl_width - 1) ? 1 : 0; + left = gl_shift; + new_right = right = (off_right) ? gl_shift + gl_width - 2 : gl_cnt; + } + else if (change >= 0) { /* no scroll, but text changed */ + if (change < gl_shift + off_left) { + left = gl_shift; + } + else { + left = change; + backup = gl_pos - change; + } + off_right = (gl_cnt > gl_shift + gl_width - 1) ? 1 : 0; + right = (off_right) ? gl_shift + gl_width - 2 : gl_cnt; + new_right = (gl_extent && (right > left + gl_extent)) ? left + gl_extent : right; + } + pad -= (off_right) ? gl_width - 1 : gl_cnt - gl_shift; + pad = (pad < 0) ? 0 : pad; + if (left <= right) { /* clean up screen */ + for (int i = 0; i < backup; i++) { + gl_putc('\b'); + } + if (left == gl_shift && off_left) { + gl_putc('$'); + left++; + } + for (int i = left; i < new_right; i++) { + gl_putc(gl_buf[i]); + } + gl_pos = new_right; + if (off_right && new_right == right) { + gl_putc('$'); + gl_pos++; + } + else { + for (int i = 0; i < pad; i++) { /* erase remains of prev line */ + gl_putc(' '); + } + gl_pos += pad; + } + } + int i = gl_pos - cursor; /* move to final cursor location */ + if (i > 0) { + while (i--) { + gl_putc('\b'); + } + } + else { + if (cursor < GL_BUF_SIZE) { + for (int ii = gl_pos; ii < cursor; ii++) { + gl_putc(gl_buf[ii]); + } + } + else { + gl_error("\n*** Error: getline(): logic error in gl_fixup().\n"); + } + } + gl_pos = cursor; + } + + /******************* History stuff **************************************/ + +#ifndef HIST_SIZE +#define HIST_SIZE 100 +#endif + + int hist_pos = 0, hist_last = 0; + char *hist_buf[HIST_SIZE]; + char hist_empty_elem[2] = ""; + + void hist_init(void) + { + hist_buf[0] = hist_empty_elem; + for (int i = 1; i < HIST_SIZE; i++) { + hist_buf[i] = nullptr; + } + } +} // namespace + +namespace SEAMS { + void gl_histadd(const char *buf) + { + static char *prev = nullptr; + + /* in case we call gl_histadd() before we call getline() */ + if (gl_init_done < 0) { /* -1 only on startup */ + hist_init(); + gl_init_done = 0; + } + const char *p = buf; + while (*p == ' ' || *p == '\t' || *p == '\n') { + p++; + } + if (*p) { + int len = strlen(buf); + if (strchr(p, '\n')) { /* previously line already has NL stripped */ + len--; + } + if ((prev == nullptr) || ((int)strlen(prev) != len) || strncmp(prev, buf, (size_t)len) != 0) { + hist_buf[hist_last] = hist_save(buf); + prev = hist_buf[hist_last]; + hist_last = (hist_last + 1) % HIST_SIZE; + if (hist_buf[hist_last] && *hist_buf[hist_last]) { + free(hist_buf[hist_last]); + } + hist_buf[hist_last] = hist_empty_elem; + } + } + hist_pos = hist_last; + } +} // namespace SEAMS +namespace { + char *hist_prev(void) + /* loads previous hist entry into input buffer, sticks on first */ + { + char *p = nullptr; + int next = (hist_pos - 1 + HIST_SIZE) % HIST_SIZE; + + if (hist_buf[hist_pos] != nullptr && next != hist_last) { + hist_pos = next; + p = hist_buf[hist_pos]; + } + if (p == nullptr) { + p = hist_empty_elem; + gl_beep(); + } + return p; + } + + char *hist_next(void) + /* loads next hist entry into input buffer, clears on last */ + { + char *p = nullptr; + + if (hist_pos != hist_last) { + hist_pos = (hist_pos + 1) % HIST_SIZE; + p = hist_buf[hist_pos]; + } + if (p == nullptr) { + p = hist_empty_elem; + gl_beep(); + } + return p; + } + + char *hist_save(const char *p) + + /* makes a copy of the string */ + { + char *s = nullptr; + size_t len = strlen(p); + const char *nl = strpbrk(p, "\n\r"); + + if (nl) { + if ((s = (char *)malloc(len)) != nullptr) { + copy_string(s, p, len); + s[len - 1] = '\0'; + } + } + else { + if ((s = (char *)malloc(len + 1)) != nullptr) { + copy_string(s, p, len + 1); + } + } + if (s == nullptr) { + gl_error("\n*** Error: hist_save() failed on malloc\n"); + } + return s; + } + + /******************* Search stuff **************************************/ + + char search_prompt[101]; /* prompt includes search string */ + char search_string[100]; + int search_pos = 0; /* current location in search_string */ + int search_forw_flg = 0; /* search direction flag */ + int search_last = 0; /* last match found */ + + void search_update(int c) + { + if (c == 0) { + search_pos = 0; + search_string[0] = '\0'; + + search_prompt[0] = '?'; + search_prompt[1] = ' '; + search_prompt[2] = '\0'; + } + else if (c > 0) { + search_string[search_pos] = (char)c; + search_string[search_pos + 1] = (char)0; + + search_prompt[search_pos] = (char)c; + search_prompt[search_pos + 1] = (char)'?'; + search_prompt[search_pos + 2] = (char)' '; + search_prompt[search_pos + 3] = (char)0; + search_pos++; + } + else { + if (search_pos > 0) { + search_pos--; + search_string[search_pos] = (char)0; + + search_prompt[search_pos] = (char)'?'; + search_prompt[search_pos + 1] = (char)' '; + search_prompt[search_pos + 2] = (char)0; + } + else { + gl_beep(); + hist_pos = hist_last; + } + } + } + + void search_addchar(int c) + { + search_update(c); + if (c < 0) { + if (search_pos > 0) { + hist_pos = search_last; + } + else { + gl_buf[0] = '\0'; + hist_pos = hist_last; + } + copy_string(gl_buf, hist_buf[hist_pos], GL_BUF_SIZE); + } + + char *loc = nullptr; + if ((loc = strstr(gl_buf, search_string)) != nullptr) { + gl_fixup(search_prompt, 0, loc - gl_buf); + } + else if (search_pos > 0) { + if (search_forw_flg) { + search_forw(0); + } + else { + search_back(0); + } + } + else { + gl_fixup(search_prompt, 0, 0); + } + } + + void search_term(void) + { + gl_search_mode = 0; + if (gl_buf[0] == 0) { /* not found, reset hist list */ + hist_pos = hist_last; + } + gl_fixup(gl_prompt, 0, gl_pos); + } + + void search_back(int new_search) + { + search_forw_flg = 0; + if (gl_search_mode == 0) { + search_last = hist_pos = hist_last; + search_update(0); + gl_search_mode = 1; + gl_buf[0] = '\0'; + gl_fixup(search_prompt, 0, 0); + } + else if (search_pos > 0) { + bool found = false; + while (!found) { + char *loc; + char *p = hist_prev(); + if (*p == 0) { /* not found, done looking */ + gl_buf[0] = '\0'; + gl_fixup(search_prompt, 0, 0); + found = true; + } + else if ((loc = strstr(p, search_string)) != nullptr) { + copy_string(gl_buf, p, GL_BUF_SIZE); + gl_fixup(search_prompt, 0, loc - p); + if (new_search) + search_last = hist_pos; + found = true; + } + } + } + else { + gl_beep(); + } + } + + void search_forw(int new_search) + { + char *loc; + + search_forw_flg = 1; + if (gl_search_mode == 0) { + search_last = hist_pos = hist_last; + search_update(0); + gl_search_mode = 1; + gl_buf[0] = '\0'; + gl_fixup(search_prompt, 0, 0); + } + else if (search_pos > 0) { + bool found = false; + while (!found) { + char *p = hist_next(); + if (*p == 0) { /* not found, done looking */ + gl_buf[0] = '\0'; + gl_fixup(search_prompt, 0, 0); + found = true; + } + else if ((loc = strstr(p, search_string)) != nullptr) { + copy_string(gl_buf, p, GL_BUF_SIZE); + gl_fixup(search_prompt, 0, loc - p); + if (new_search) + search_last = hist_pos; + found = true; + } + } + } + else { + gl_beep(); + } + } + + void gl_beep(void) + { +#ifdef __windows__ + MessageBeep(MB_OK); +#else + gl_putc('\007'); +#endif + } /* gl_beep */ +} // namespace diff --git a/packages/seacas/libraries/aprepro_lib/apr_getline.h b/packages/seacas/libraries/aprepro_lib/apr_getline.h new file mode 100644 index 000000000000..81b394a1c147 --- /dev/null +++ b/packages/seacas/libraries/aprepro_lib/apr_getline.h @@ -0,0 +1,24 @@ + +/* + * Copyright (C) 1991, 1992, 1993, 2022, 2023 by Chris Thewalt (thewalt@ce.berkeley.edu) + * + * Permission to use, copy, modify, and distribute this software + * for any purpose and without fee is hereby granted, provided + * that the above copyright notices appear in all copies and that both the + * copyright notice and this permission notice appear in supporting + * documentation. This software is provided "as is" without express or + * implied warranty. + * + * Thanks to the following people who have provided enhancements and fixes: + * Ron Ueberschaer, Christoph Keller, Scott Schwartz, Steven List, + * DaviD W. Sanderson, Goran Bostrom, Michael Gleason, Glenn Kasten, + * Edin Hodzic, Eric J Bivona, Kai Uwe Rommel, Danny Quah, Ulrich Betzler + */ + +#pragma once + +namespace SEAMS { + char *getline_int(const char *); /* read a line of input */ + void gl_setwidth(int); /* specify width of screen */ + void gl_histadd(const char *); /* adds entries to hist */ +} // namespace SEAMS diff --git a/packages/seacas/libraries/aprepro_lib/apr_getline_int.c b/packages/seacas/libraries/aprepro_lib/apr_getline_int.c deleted file mode 100644 index 0a05545b802c..000000000000 --- a/packages/seacas/libraries/aprepro_lib/apr_getline_int.c +++ /dev/null @@ -1,940 +0,0 @@ -/* - * Copyright (C) 1991, 1992, 1993, 2020, 2021, 2022, 2023 by Chris Thewalt (thewalt@ce.berkeley.edu) - * - * Permission to use, copy, modify, and distribute this software - * for any purpose and without fee is hereby granted, provided - * that the above copyright notices appear in all copies and that both the - * copyright notice and this permission notice appear in supporting - * documentation. This software is provided "as is" without express or - * implied warranty. - * - * Thanks to the following people who have provided enhancements and fixes: - * Ron Ueberschaer, Christoph Keller, Scott Schwartz, Steven List, - * DaviD W. Sanderson, Goran Bostrom, Michael Gleason, Glenn Kasten, - * Edin Hodzic, Eric J Bivona, Kai Uwe Rommel, Danny Quah, Ulrich Betzler - */ - -/* - * Note: This version has been updated by Mike Gleason - */ - -#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || \ - defined(__MINGW32__) || defined(_WIN64) || defined(__MINGW64__) - -#define __windows__ 1 -#include -#include -#define NOMINMAX -#include -#define sleep(a) Sleep(a * 1000) -#ifndef write -#define write _write -#define read _read -#endif - -#else - -#ifndef __unix__ -#define __unix__ 1 -#endif - -#include -struct termios ap_new_termios, ap_old_termios; -#endif - -/********************* C library headers ********************************/ -#include -#include -#include -#include -#include -#include - -#include "apr_getline_int.h" - -#define AP_GL_BUF_SIZE 1024 - -/******************** external interface *********************************/ - -int ap_gl_filename_quoting_desired = -1; /* default to unspecified */ -const char *ap_gl_filename_quote_characters = " \t*?<>|;&()[]$`"; -int ap_gl_ellipses_during_completion = 1; -char ap_gl_buf[AP_GL_BUF_SIZE]; /* input buffer */ - -/******************** internal interface *********************************/ - -#define AP_GL_BUF_SIZE 1024 - -static int ap_gl_init_done = -1; /* terminal mode flag */ -static int ap_gl_termw = 80; /* actual terminal width */ -static int ap_gl_scroll = 27; /* width of EOL scrolling region */ -static int ap_gl_width = 0; /* net size available for input */ -static int ap_gl_extent = 0; /* how far to redraw, 0 means all */ -static int ap_gl_overwrite = 0; /* overwrite mode */ -static int ap_gl_pos, ap_gl_cnt = 0; /* position and size of input */ -static char ap_gl_killbuf[AP_GL_BUF_SIZE] = ""; /* killed text */ -static const char *ap_gl_prompt; /* to save the prompt string */ -static int ap_gl_search_mode = 0; /* search mode flag */ - -static void ap_gl_init(void); /* prepare to edit a line */ -static void ap_gl_cleanup(void); /* to undo ap_gl_init */ -static void ap_gl_char_init(void); /* get ready for no echo input */ -static void ap_gl_char_cleanup(void); /* undo ap_gl_char_init */ - /* returns printable prompt width */ - -static void ap_gl_addchar(int c); /* install specified char */ -static void ap_gl_del(int loc, int); /* del, either left (-1) or cur (0) */ -static void ap_gl_error(const char *const buf); /* write error msg and die */ -static void ap_gl_fixup(const char *prompt, int change, - int cursor); /* fixup state variables and screen */ -static int ap_gl_getc(void); /* read one char from terminal */ -static void ap_gl_kill(int pos); /* delete to EOL */ -static void ap_gl_newline(void); /* handle \n or \r */ -static void ap_gl_putc(int c); /* write one char to terminal */ -static void ap_gl_puts(const char *const buf); /* write a line to terminal */ -static void ap_gl_redraw(void); /* issue \n and redraw all */ -static void ap_gl_transpose(void); /* transpose two chars */ -static void ap_gl_yank(void); /* yank killed text */ - -static void hist_init(void); /* initializes hist pointers */ -static char *hist_next(void); /* return ptr to next item */ -static char *hist_prev(void); /* return ptr to prev item */ -static char *hist_save(char *p); /* makes copy of a string, without NL */ - -static void search_addchar(int c); /* increment search string */ -static void search_term(void); /* reset with current contents */ -static void search_back(int new_search); /* look back for current string */ -static void search_forw(int new_search); /* look forw for current string */ -static void ap_gl_beep(void); /* try to play a system beep sound */ - -static char *copy_string(char *dest, char const *source, long int elements) -{ - char *d; - for (d = dest; d + 1 < dest + elements && *source; d++, source++) { - *d = *source; - } - *d = '\0'; - return d; -} - -/************************ nonportable part *********************************/ - -#ifdef MSDOS -#include -#endif - -static void ap_gl_char_init(void) /* turn off input echo */ -{ -#ifdef __unix__ - tcgetattr(0, &ap_old_termios); - ap_new_termios = ap_old_termios; - ap_new_termios.c_iflag &= ~(BRKINT | ISTRIP | IXON | IXOFF); - ap_new_termios.c_iflag |= (IGNBRK | IGNPAR); - ap_new_termios.c_lflag &= ~(ICANON | ISIG | IEXTEN | ECHO); - ap_new_termios.c_cc[VMIN] = 1; - ap_new_termios.c_cc[VTIME] = 0; - tcsetattr(0, TCSANOW, &ap_new_termios); -#endif /* __unix__ */ -} - -static void ap_gl_char_cleanup(void) /* undo effects of ap_gl_char_init */ -{ -#ifdef __unix__ - tcsetattr(0, TCSANOW, &ap_old_termios); -#endif /* __unix__ */ -} - -#if defined(MSDOS) || defined(__windows__) - -#define K_UP 0x48 -#define K_DOWN 0x50 -#define K_LEFT 0x4B -#define K_RIGHT 0x4D -#define K_DELETE 0x53 -#define K_INSERT 0x52 -#define K_HOME 0x47 -#define K_END 0x4F -#define K_PGUP 0x49 -#define K_PGDN 0x51 - -int pc_keymap(int c) -{ - switch (c) { - case K_UP: - case K_PGUP: - c = 16; /* up -> ^P */ - break; - case K_DOWN: - case K_PGDN: - c = 14; /* down -> ^N */ - break; - case K_LEFT: - c = 2; /* left -> ^B */ - break; - case K_RIGHT: - c = 6; /* right -> ^F */ - break; - case K_END: - c = 5; /* end -> ^E */ - break; - case K_HOME: - c = 1; /* home -> ^A */ - break; - case K_INSERT: - c = 15; /* insert -> ^O */ - break; - case K_DELETE: - c = 4; /* del -> ^D */ - break; - default: c = 0; /* make it garbage */ - } - return c; -} -#endif /* defined(MSDOS) || defined(__windows__) */ - -static int ap_gl_getc(void) -/* get a character without echoing it to screen */ -{ - int c; -#ifdef __unix__ - char ch; - while ((c = read(0, &ch, 1)) == -1) { - if (errno != EINTR) { - break; - } - } - c = (ch <= 0) ? -1 : ch; -#endif /* __unix__ */ -#ifdef MSDOS - c = _bios_keybrd(_NKEYBRD_READ); - if ((c & 0377) == 224) { - c = pc_keymap((c >> 8) & 0377); - } - else { - c &= 0377; - } -#endif /* MSDOS */ -#ifdef __windows__ - c = (int)_getch(); - if ((c == 0) || (c == 0xE0)) { - /* Read key code */ - c = (int)_getch(); - c = pc_keymap(c); - } - else if (c == '\r') { - /* Note: we only get \r from the console, - * and not a matching \n. - */ - c = '\n'; - } -#endif - return c; -} - -static void ap_gl_putc(int c) -{ - char ch = (char)(unsigned char)c; - - write(1, &ch, 1); - if (ch == '\n') { - ch = '\r'; - write(1, &ch, 1); /* RAW mode needs '\r', does not hurt */ - } -} - -/******************** fairly portable part *********************************/ - -static void ap_gl_puts(const char *const buf) -{ - if (buf) { - int len = strlen(buf); - write(1, buf, len); - } -} - -static void ap_gl_error(const char *const buf) -{ - ap_gl_cleanup(); - int len = strlen(buf); - write(2, buf, len); - exit(1); -} - -static void ap_gl_init(void) -/* set up variables and terminal */ -{ - if (ap_gl_init_done < 0) { /* -1 only on startup */ - const char *cp = (const char *)getenv("COLUMNS"); - if (cp != NULL) { - int w = strtol(cp, NULL, 10); - if (w > 20) - ap_gl_setwidth(w); - } - hist_init(); - } - if (isatty(0) == 0 || isatty(1) == 0) - ap_gl_error("\n*** Error: getline(): not interactive, use stdio.\n"); - ap_gl_char_init(); - ap_gl_init_done = 1; -} - -static void ap_gl_cleanup(void) -/* undo effects of ap_gl_init, as necessary */ -{ - if (ap_gl_init_done > 0) - ap_gl_char_cleanup(); - ap_gl_init_done = 0; -#ifdef __windows__ - Sleep(40); - FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); -#endif -} - -void ap_gl_setwidth(int w) -{ - if (w > 250) - w = 250; - if (w > 20) { - ap_gl_termw = w; - ap_gl_scroll = w / 3; - } - else { - ap_gl_error("\n*** Error: minimum screen width is 21\n"); - } -} - -char *ap_getline_int(char *prompt) -{ - ap_gl_init(); - ap_gl_prompt = (prompt) ? prompt : ""; - ap_gl_buf[0] = '\0'; - ap_gl_fixup(ap_gl_prompt, -2, AP_GL_BUF_SIZE); - -#ifdef __windows__ - FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); -#endif - - int c; - while ((c = ap_gl_getc()) >= 0) { - ap_gl_extent = 0; /* reset to full extent */ - if (isprint(c)) { - if (ap_gl_search_mode) { - search_addchar(c); - } - else { - ap_gl_addchar(c); - } - } - else { - if (ap_gl_search_mode) { - if (c == '\033' || c == '\016' || c == '\020') { - search_term(); - c = 0; /* ignore the character */ - } - else if (c == '\010' || c == '\177') { - search_addchar(-1); /* unwind search string */ - c = 0; - } - else if (c != '\022' && c != '\023') { - search_term(); /* terminate and handle char */ - } - } - switch (c) { - case '\n': - case '\r': /* newline */ - ap_gl_newline(); - ap_gl_cleanup(); - return ap_gl_buf; - /*NOTREACHED*/ - break; - case '\001': - ap_gl_fixup(ap_gl_prompt, -1, 0); /* ^A */ - break; - case '\002': - ap_gl_fixup(ap_gl_prompt, -1, ap_gl_pos - 1); /* ^B */ - break; - case '\003': /* ^C */ - case '\004': /* ^D */ - if (ap_gl_cnt == 0) { - ap_gl_buf[0] = '\0'; - ap_gl_cleanup(); - ap_gl_putc('\n'); - return ap_gl_buf; - } - else { - ap_gl_del(0, 1); - } - break; - case '\005': - ap_gl_fixup(ap_gl_prompt, -1, ap_gl_cnt); /* ^E */ - break; - case '\006': - ap_gl_fixup(ap_gl_prompt, -1, ap_gl_pos + 1); /* ^F */ - break; - case '\010': - case '\177': - ap_gl_del(-1, 0); /* ^H and DEL */ - break; - case '\t': /* TAB */ break; - case '\013': - ap_gl_kill(ap_gl_pos); /* ^K */ - break; - case '\014': - ap_gl_redraw(); /* ^L */ - break; - case '\016': /* ^N */ - copy_string(ap_gl_buf, hist_next(), AP_GL_BUF_SIZE); - ap_gl_fixup(ap_gl_prompt, 0, AP_GL_BUF_SIZE); - break; - case '\017': - ap_gl_overwrite = !ap_gl_overwrite; /* ^O */ - break; - case '\020': /* ^P */ - copy_string(ap_gl_buf, hist_prev(), AP_GL_BUF_SIZE); - ap_gl_fixup(ap_gl_prompt, 0, AP_GL_BUF_SIZE); - break; - case '\022': - search_back(1); /* ^R */ - break; - case '\023': - search_forw(1); /* ^S */ - break; - case '\024': - ap_gl_transpose(); /* ^T */ - break; - case '\025': - ap_gl_kill(0); /* ^U */ - break; - case '\031': - ap_gl_yank(); /* ^Y */ - break; - default: - if (c > 0) - ap_gl_beep(); - break; - } - } - } - ap_gl_cleanup(); - ap_gl_buf[0] = '\0'; - return ap_gl_buf; -} - -static void ap_gl_addchar(int c) - -/* adds the character c to the input buffer at current location */ -{ - if (ap_gl_cnt >= AP_GL_BUF_SIZE - 1) - ap_gl_error("\n*** Error: getline(): input buffer overflow\n"); - if (ap_gl_overwrite == 0 || ap_gl_pos == ap_gl_cnt) { - int i; - for (i = ap_gl_cnt; i >= ap_gl_pos; i--) - ap_gl_buf[i + 1] = ap_gl_buf[i]; - ap_gl_buf[ap_gl_pos] = (char)c; - ap_gl_fixup(ap_gl_prompt, ap_gl_pos, ap_gl_pos + 1); - } - else { - ap_gl_buf[ap_gl_pos] = (char)c; - ap_gl_extent = 1; - ap_gl_fixup(ap_gl_prompt, ap_gl_pos, ap_gl_pos + 1); - } -} - -static void ap_gl_yank(void) -/* adds the kill buffer to the input buffer at current location */ -{ - int len = strlen(ap_gl_killbuf); - if (len > 0) { - if (ap_gl_overwrite == 0) { - if (ap_gl_cnt + len >= AP_GL_BUF_SIZE - 1) - ap_gl_error("\n*** Error: getline(): input buffer overflow\n"); - for (int i = ap_gl_cnt; i >= ap_gl_pos; i--) - ap_gl_buf[i + len] = ap_gl_buf[i]; - for (int i = 0; i < len; i++) - ap_gl_buf[ap_gl_pos + i] = ap_gl_killbuf[i]; - ap_gl_fixup(ap_gl_prompt, ap_gl_pos, ap_gl_pos + len); - } - else { - if (ap_gl_pos + len > ap_gl_cnt) { - if (ap_gl_pos + len >= AP_GL_BUF_SIZE - 1) - ap_gl_error("\n*** Error: getline(): input buffer overflow\n"); - ap_gl_buf[ap_gl_pos + len] = 0; - } - for (int i = 0; i < len; i++) - ap_gl_buf[ap_gl_pos + i] = ap_gl_killbuf[i]; - ap_gl_extent = len; - ap_gl_fixup(ap_gl_prompt, ap_gl_pos, ap_gl_pos + len); - } - } - else - ap_gl_beep(); -} - -static void ap_gl_transpose(void) -/* switch character under cursor and to left of cursor */ -{ - if (ap_gl_pos > 0 && ap_gl_cnt > ap_gl_pos) { - int c = ap_gl_buf[ap_gl_pos - 1]; - ap_gl_buf[ap_gl_pos - 1] = ap_gl_buf[ap_gl_pos]; - ap_gl_buf[ap_gl_pos] = (char)c; - ap_gl_extent = 2; - ap_gl_fixup(ap_gl_prompt, ap_gl_pos - 1, ap_gl_pos); - } - else - ap_gl_beep(); -} - -static void ap_gl_newline(void) -/* - * Cleans up entire line before returning to caller. A \n is appended. - * If line longer than screen, we redraw starting at beginning - */ -{ - int change = ap_gl_cnt; - int len = ap_gl_cnt; - int loc = ap_gl_width - 5; /* shifts line back to start position */ - - if (ap_gl_cnt >= AP_GL_BUF_SIZE - 1) - ap_gl_error("\n*** Error: getline(): input buffer overflow\n"); - if (loc > len) - loc = len; - ap_gl_fixup(ap_gl_prompt, change, loc); /* must do this before appending \n */ - ap_gl_buf[len] = '\n'; - ap_gl_buf[len + 1] = '\0'; - ap_gl_putc('\n'); -} - -static void ap_gl_del(int loc, int killsave) - -/* - * Delete a character. The loc variable can be: - * -1 : delete character to left of cursor - * 0 : delete character under cursor - */ -{ - if ((loc == -1 && ap_gl_pos > 0) || (loc == 0 && ap_gl_pos < ap_gl_cnt)) { - for (int j = 0, i = ap_gl_pos + loc; i < ap_gl_cnt; i++) { - if ((j == 0) && (killsave != 0)) { - ap_gl_killbuf[0] = ap_gl_buf[i]; - ap_gl_killbuf[1] = '\0'; - j = 1; - } - ap_gl_buf[i] = ap_gl_buf[i + 1]; - } - ap_gl_fixup(ap_gl_prompt, ap_gl_pos + loc, ap_gl_pos + loc); - } - else - ap_gl_beep(); -} - -static void ap_gl_kill(int pos) - -/* delete from pos to the end of line */ -{ - if (pos < ap_gl_cnt) { - copy_string(ap_gl_killbuf, ap_gl_buf + pos, AP_GL_BUF_SIZE); - ap_gl_buf[pos] = '\0'; - ap_gl_fixup(ap_gl_prompt, pos, pos); - } - else - ap_gl_beep(); -} - -static void ap_gl_redraw(void) -/* emit a newline, reset and redraw prompt and current input line */ -{ - if (ap_gl_init_done > 0) { - ap_gl_putc('\n'); - ap_gl_fixup(ap_gl_prompt, -2, ap_gl_pos); - } -} - -static void ap_gl_fixup(const char *prompt, int change, int cursor) - -/* - * This function is used both for redrawing when input changes or for - * moving within the input line. The parameters are: - * prompt: compared to last_prompt[] for changes; - * change : the index of the start of changes in the input buffer, - * with -1 indicating no changes, -2 indicating we're on - * a new line, redraw everything. - * cursor : the desired location of the cursor after the call. - * A value of AP_GL_BUF_SIZE can be used to indicate the cursor should - * move just past the end of the input line. - */ -{ - static int ap_gl_shift; /* index of first on screen character */ - static int off_right; /* true if more text right of screen */ - static int off_left; /* true if more text left of screen */ - static char last_prompt[80] = ""; - int left = 0, right = -1; /* bounds for redraw */ - int pad; /* how much to erase at end of line */ - int backup; /* how far to backup before fixing */ - int new_shift; /* value of shift based on cursor */ - int extra; /* adjusts when shift (scroll) happens */ - int i; - int new_right = -1; /* alternate right bound, using ap_gl_extent */ - int l1, l2; - - if (change == -2) { /* reset */ - ap_gl_pos = ap_gl_cnt = ap_gl_shift = off_right = off_left = 0; - ap_gl_putc('\r'); - ap_gl_puts(prompt); - copy_string(last_prompt, prompt, 80); - change = 0; - ap_gl_width = ap_gl_termw - strlen(prompt); - } - else if (strcmp(prompt, last_prompt) != 0) { - l1 = strlen(last_prompt); - l2 = strlen(prompt); - ap_gl_cnt = ap_gl_cnt + l1 - l2; - copy_string(last_prompt, prompt, 80); - ap_gl_putc('\r'); - ap_gl_puts(prompt); - ap_gl_pos = ap_gl_shift; - ap_gl_width = ap_gl_termw - l2; - change = 0; - } - pad = (off_right) ? ap_gl_width - 1 : ap_gl_cnt - ap_gl_shift; /* old length */ - backup = ap_gl_pos - ap_gl_shift; - if (change >= 0) { - ap_gl_cnt = strlen(ap_gl_buf); - if (change > ap_gl_cnt) - change = ap_gl_cnt; - } - if (cursor > ap_gl_cnt) { - if (cursor != AP_GL_BUF_SIZE) { /* AP_GL_BUF_SIZE means end of line */ - if (ap_gl_ellipses_during_completion == 0) { - ap_gl_beep(); - } - } - cursor = ap_gl_cnt; - } - if (cursor < 0) { - ap_gl_beep(); - cursor = 0; - } - if (off_right || (off_left && cursor < ap_gl_shift + ap_gl_width - ap_gl_scroll / 2)) - extra = 2; /* shift the scrolling boundary */ - else - extra = 0; - new_shift = cursor + extra + ap_gl_scroll - ap_gl_width; - if (new_shift > 0) { - new_shift /= ap_gl_scroll; - new_shift *= ap_gl_scroll; - } - else - new_shift = 0; - if (new_shift != ap_gl_shift) { /* scroll occurs */ - ap_gl_shift = new_shift; - off_left = (ap_gl_shift) ? 1 : 0; - off_right = (ap_gl_cnt > ap_gl_shift + ap_gl_width - 1) ? 1 : 0; - left = ap_gl_shift; - new_right = right = (off_right) ? ap_gl_shift + ap_gl_width - 2 : ap_gl_cnt; - } - else if (change >= 0) { /* no scroll, but text changed */ - if (change < ap_gl_shift + off_left) { - left = ap_gl_shift; - } - else { - left = change; - backup = ap_gl_pos - change; - } - off_right = (ap_gl_cnt > ap_gl_shift + ap_gl_width - 1) ? 1 : 0; - right = (off_right) ? ap_gl_shift + ap_gl_width - 2 : ap_gl_cnt; - new_right = (ap_gl_extent && (right > left + ap_gl_extent)) ? left + ap_gl_extent : right; - } - pad -= (off_right) ? ap_gl_width - 1 : ap_gl_cnt - ap_gl_shift; - pad = (pad < 0) ? 0 : pad; - if (left <= right) { /* clean up screen */ - for (i = 0; i < backup; i++) - ap_gl_putc('\b'); - if (left == ap_gl_shift && off_left) { - ap_gl_putc('$'); - left++; - } - for (i = left; i < new_right; i++) - ap_gl_putc(ap_gl_buf[i]); - ap_gl_pos = new_right; - if (off_right && new_right == right) { - ap_gl_putc('$'); - ap_gl_pos++; - } - else { - for (i = 0; i < pad; i++) /* erase remains of prev line */ - ap_gl_putc(' '); - ap_gl_pos += pad; - } - } - i = ap_gl_pos - cursor; /* move to final cursor location */ - if (i > 0) { - while (i--) - ap_gl_putc('\b'); - } - else { - for (i = ap_gl_pos; i < cursor; i++) - ap_gl_putc(ap_gl_buf[i]); - } - ap_gl_pos = cursor; -} - -/******************* History stuff **************************************/ - -#ifndef HIST_SIZE -#define HIST_SIZE 100 -#endif - -static int hist_pos = 0, hist_last = 0; -static char *hist_buf[HIST_SIZE]; -static char hist_empty_elem[2] = ""; - -static void hist_init(void) -{ - hist_buf[0] = hist_empty_elem; - for (int i = 1; i < HIST_SIZE; i++) - hist_buf[i] = NULL; -} - -void ap_gl_histadd(char *buf) -{ - static char *prev = NULL; - - /* in case we call ap_gl_histadd() before we call getline() */ - if (ap_gl_init_done < 0) { /* -1 only on startup */ - hist_init(); - ap_gl_init_done = 0; - } - char *p = buf; - while (*p == ' ' || *p == '\t' || *p == '\n') - p++; - if (*p) { - int len = strlen(buf); - if (strchr(p, '\n')) /* previously line already has NL stripped */ - len--; - if ((prev == NULL) || ((int)strlen(prev) != len) || strncmp(prev, buf, (size_t)len) != 0) { - hist_buf[hist_last] = hist_save(buf); - prev = hist_buf[hist_last]; - hist_last = (hist_last + 1) % HIST_SIZE; - if (hist_buf[hist_last] && *hist_buf[hist_last]) { - free(hist_buf[hist_last]); - } - hist_buf[hist_last] = hist_empty_elem; - } - } - hist_pos = hist_last; -} - -static char *hist_prev(void) -/* loads previous hist entry into input buffer, sticks on first */ -{ - char *p = NULL; - int next = (hist_pos - 1 + HIST_SIZE) % HIST_SIZE; - - if (hist_buf[hist_pos] != NULL && next != hist_last) { - hist_pos = next; - p = hist_buf[hist_pos]; - } - if (p == NULL) { - p = hist_empty_elem; - ap_gl_beep(); - } - return p; -} - -static char *hist_next(void) -/* loads next hist entry into input buffer, clears on last */ -{ - char *p = NULL; - - if (hist_pos != hist_last) { - hist_pos = (hist_pos + 1) % HIST_SIZE; - p = hist_buf[hist_pos]; - } - if (p == NULL) { - p = hist_empty_elem; - ap_gl_beep(); - } - return p; -} - -static char *hist_save(char *p) - -/* makes a copy of the string */ -{ - char *s = NULL; - size_t len = strlen(p); - char *nl = strpbrk(p, "\n\r"); - - if (nl) { - if ((s = (char *)malloc(len)) != NULL) { - copy_string(s, p, len); - s[len - 1] = '\0'; - } - } - else { - if ((s = (char *)malloc(len + 1)) != NULL) { - copy_string(s, p, len + 1); - } - } - if (s == NULL) - ap_gl_error("\n*** Error: hist_save() failed on malloc\n"); - return s; -} - -/******************* Search stuff **************************************/ - -static char search_prompt[101]; /* prompt includes search string */ -static char search_string[100]; -static int search_pos = 0; /* current location in search_string */ -static int search_forw_flg = 0; /* search direction flag */ -static int search_last = 0; /* last match found */ - -static void search_update(int c) -{ - if (c == 0) { - search_pos = 0; - search_string[0] = 0; - search_prompt[0] = '?'; - search_prompt[1] = ' '; - search_prompt[2] = 0; - } - else if (c > 0) { - search_string[search_pos] = (char)c; - search_string[search_pos + 1] = (char)0; - search_prompt[search_pos] = (char)c; - search_prompt[search_pos + 1] = (char)'?'; - search_prompt[search_pos + 2] = (char)' '; - search_prompt[search_pos + 3] = (char)0; - search_pos++; - } - else { - if (search_pos > 0) { - search_pos--; - search_string[search_pos] = (char)0; - search_prompt[search_pos] = (char)'?'; - search_prompt[search_pos + 1] = (char)' '; - search_prompt[search_pos + 2] = (char)0; - } - else { - ap_gl_beep(); - hist_pos = hist_last; - } - } -} - -static void search_addchar(int c) -{ - search_update(c); - if (c < 0) { - if (search_pos > 0) { - hist_pos = search_last; - } - else { - ap_gl_buf[0] = '\0'; - hist_pos = hist_last; - } - copy_string(ap_gl_buf, hist_buf[hist_pos], AP_GL_BUF_SIZE); - } - char *loc; - if ((loc = strstr(ap_gl_buf, search_string)) != NULL) { - ap_gl_fixup(search_prompt, 0, loc - ap_gl_buf); - } - else if (search_pos > 0) { - if (search_forw_flg) { - search_forw(0); - } - else { - search_back(0); - } - } - else { - ap_gl_fixup(search_prompt, 0, 0); - } -} - -static void search_term(void) -{ - ap_gl_search_mode = 0; - if (ap_gl_buf[0] == '\0') /* not found, reset hist list */ - hist_pos = hist_last; - ap_gl_fixup(ap_gl_prompt, 0, ap_gl_pos); -} - -static void search_back(int new_search) -{ - int found = 0; - char *loc; - - search_forw_flg = 0; - if (ap_gl_search_mode == 0) { - search_last = hist_pos = hist_last; - search_update(0); - ap_gl_search_mode = 1; - ap_gl_buf[0] = '\0'; - ap_gl_fixup(search_prompt, 0, 0); - } - else if (search_pos > 0) { - while (!found) { - char *p = hist_prev(); - if (*p == 0) { /* not found, done looking */ - ap_gl_buf[0] = '\0'; - ap_gl_fixup(search_prompt, 0, 0); - found = 1; - } - else if ((loc = strstr(p, search_string)) != NULL) { - copy_string(ap_gl_buf, p, AP_GL_BUF_SIZE); - ap_gl_fixup(search_prompt, 0, loc - p); - if (new_search) - search_last = hist_pos; - found = 1; - } - } - } - else { - ap_gl_beep(); - } -} - -static void search_forw(int new_search) -{ - int found = 0; - char *loc; - - search_forw_flg = 1; - if (ap_gl_search_mode == 0) { - search_last = hist_pos = hist_last; - search_update(0); - ap_gl_search_mode = 1; - ap_gl_buf[0] = '\0'; - ap_gl_fixup(search_prompt, 0, 0); - } - else if (search_pos > 0) { - while (!found) { - char *p = hist_next(); - if (*p == 0) { /* not found, done looking */ - ap_gl_buf[0] = '\0'; - ap_gl_fixup(search_prompt, 0, 0); - found = 1; - } - else if ((loc = strstr(p, search_string)) != NULL) { - copy_string(ap_gl_buf, p, AP_GL_BUF_SIZE); - ap_gl_fixup(search_prompt, 0, loc - p); - if (new_search) - search_last = hist_pos; - found = 1; - } - } - } - else { - ap_gl_beep(); - } -} - -static void ap_gl_beep(void) -{ -#ifdef __windows__ - MessageBeep(MB_OK); -#else - ap_gl_putc('\007'); -#endif -} /* ap_gl_beep */ diff --git a/packages/seacas/libraries/aprepro_lib/apr_getline_int.h b/packages/seacas/libraries/aprepro_lib/apr_getline_int.h deleted file mode 100644 index 38badca8634d..000000000000 --- a/packages/seacas/libraries/aprepro_lib/apr_getline_int.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions -// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with -// NTESS, the U.S. Government retains certain rights in this software. -// -// See packages/seacas/LICENSE for details -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -char *ap_getline_int(char *); /* read a line of input */ -void ap_gl_setwidth(int); /* specify width of screen */ -void ap_gl_histadd(char *); /* adds entries to hist */ - -#ifdef __cplusplus -} /* close brackets on extern "C" declaration */ -#endif diff --git a/packages/seacas/libraries/aprepro_lib/apr_parser.cc b/packages/seacas/libraries/aprepro_lib/apr_parser.cc index 97ee208e63b3..39705890c9fd 100644 --- a/packages/seacas/libraries/aprepro_lib/apr_parser.cc +++ b/packages/seacas/libraries/aprepro_lib/apr_parser.cc @@ -2,7 +2,7 @@ // Skeleton implementation for Bison LALR(1) parsers in C++ -// Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc. +// Copyright (C) 2002-2015, 2018-2021, 2023 Free Software Foundation, Inc. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -34,24 +34,23 @@ // especially those whose name start with YY_ or yy_. They are // private implementation details that can be changed or removed. - // Take the name prefix into account. -#define yylex SEAMSlex +#define yylex SEAMSlex // First part of user prologue. #line 6 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" -#include "aprepro.h" -#include "apr_util.h" #include "apr_array.h" +#include "apr_util.h" +#include "aprepro.h" -#include -#include -#include #include -#include -#include #include +#include +#include +#include +#include +#include namespace { void reset_error() @@ -70,25 +69,21 @@ namespace { } #endif } -} +} // namespace namespace SEAMS { - extern bool echo; - } - - + extern bool echo; +} #line 82 "apr_parser.cc" - #include "aprepro_parser.h" // Second part of user prologue. #line 110 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - -#include "aprepro.h" #include "apr_scanner.h" +#include "aprepro.h" /* this "connects" the bison parser in aprepro to the flex scanner class * object. it defines the yylex() function call to pull the next token from the @@ -96,99 +91,94 @@ namespace SEAMS { #undef yylex #define yylex aprepro.lexer->lex - #line 101 "apr_parser.cc" - - #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include // FIXME: INFRINGES ON USER NAME SPACE. -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif +#if defined YYENABLE_NLS && YYENABLE_NLS +#if ENABLE_NLS +#include // FIXME: INFRINGES ON USER NAME SPACE. +#define YY_(msgid) dgettext("bison-runtime", msgid) +#endif +#endif +#ifndef YY_ +#define YY_(msgid) msgid +#endif #endif - // Whether we are compiled with exception support. #ifndef YY_EXCEPTIONS -# if defined __GNUC__ && !defined __EXCEPTIONS -# define YY_EXCEPTIONS 0 -# else -# define YY_EXCEPTIONS 1 -# endif +#if defined __GNUC__ && !defined __EXCEPTIONS +#define YY_EXCEPTIONS 0 +#else +#define YY_EXCEPTIONS 1 +#endif #endif - - // Enable debugging if requested. #if SEAMSDEBUG // A pseudo ostream that takes yydebug_ into account. -# define YYCDEBUG if (yydebug_) (*yycdebug_) - -# define YY_SYMBOL_PRINT(Title, Symbol) \ - do { \ - if (yydebug_) \ - { \ - *yycdebug_ << Title << ' '; \ - yy_print_ (*yycdebug_, Symbol); \ - *yycdebug_ << '\n'; \ - } \ +#define YYCDEBUG \ + if (yydebug_) \ + (*yycdebug_) + +#define YY_SYMBOL_PRINT(Title, Symbol) \ + do { \ + if (yydebug_) { \ + *yycdebug_ << Title << ' '; \ + yy_print_(*yycdebug_, Symbol); \ + *yycdebug_ << '\n'; \ + } \ } while (false) -# define YY_REDUCE_PRINT(Rule) \ - do { \ - if (yydebug_) \ - yy_reduce_print_ (Rule); \ +#define YY_REDUCE_PRINT(Rule) \ + do { \ + if (yydebug_) \ + yy_reduce_print_(Rule); \ } while (false) -# define YY_STACK_PRINT() \ - do { \ - if (yydebug_) \ - yy_stack_print_ (); \ +#define YY_STACK_PRINT() \ + do { \ + if (yydebug_) \ + yy_stack_print_(); \ } while (false) #else // !SEAMSDEBUG -# define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol) -# define YY_REDUCE_PRINT(Rule) static_cast (0) -# define YY_STACK_PRINT() static_cast (0) +#define YYCDEBUG \ + if (false) \ + std::cerr +#define YY_SYMBOL_PRINT(Title, Symbol) YY_USE(Symbol) +#define YY_REDUCE_PRINT(Rule) static_cast(0) +#define YY_STACK_PRINT() static_cast(0) #endif // !SEAMSDEBUG -#define yyerrok (yyerrstatus_ = 0) -#define yyclearin (yyla.clear ()) +#define yyerrok (yyerrstatus_ = 0) +#define yyclearin (yyla.clear()) -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab -#define YYRECOVERING() (!!yyerrstatus_) +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab +#define YYRECOVERING() (!!yyerrstatus_) namespace SEAMS { #line 175 "apr_parser.cc" /// Build a parser object. - Parser::Parser (class Aprepro& aprepro_yyarg) + Parser::Parser(class Aprepro &aprepro_yyarg) #if SEAMSDEBUG - : yydebug_ (false), - yycdebug_ (&std::cerr), + : yydebug_(false), yycdebug_(&std::cerr), #else - : + : #endif - aprepro (aprepro_yyarg) - {} + aprepro(aprepro_yyarg) + { + } - Parser::~Parser () - {} + Parser::~Parser() {} - Parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW - {} + Parser::syntax_error::~syntax_error() YY_NOEXCEPT YY_NOTHROW {} /*---------. | symbol. | @@ -196,140 +186,89 @@ namespace SEAMS { // basic_symbol. template - Parser::basic_symbol::basic_symbol (const basic_symbol& that) - : Base (that) - , value (that.value) - {} - + Parser::basic_symbol::basic_symbol(const basic_symbol &that) : Base(that), value(that.value) + { + } /// Constructor for valueless symbols. template - Parser::basic_symbol::basic_symbol (typename Base::kind_type t) - : Base (t) - , value () - {} + Parser::basic_symbol::basic_symbol(typename Base::kind_type t) : Base(t), value() + { + } template - Parser::basic_symbol::basic_symbol (typename Base::kind_type t, YY_RVREF (value_type) v) - : Base (t) - , value (YY_MOVE (v)) - {} - + Parser::basic_symbol::basic_symbol(typename Base::kind_type t, YY_RVREF(value_type) v) + : Base(t), value(YY_MOVE(v)) + { + } template - Parser::symbol_kind_type - Parser::basic_symbol::type_get () const YY_NOEXCEPT + Parser::symbol_kind_type Parser::basic_symbol::type_get() const YY_NOEXCEPT { - return this->kind (); + return this->kind(); } - - template - bool - Parser::basic_symbol::empty () const YY_NOEXCEPT + template bool Parser::basic_symbol::empty() const YY_NOEXCEPT { - return this->kind () == symbol_kind::S_YYEMPTY; + return this->kind() == symbol_kind::S_YYEMPTY; } - template - void - Parser::basic_symbol::move (basic_symbol& s) + template void Parser::basic_symbol::move(basic_symbol &s) { - super_type::move (s); - value = YY_MOVE (s.value); + super_type::move(s); + value = YY_MOVE(s.value); } // by_kind. - Parser::by_kind::by_kind () YY_NOEXCEPT - : kind_ (symbol_kind::S_YYEMPTY) - {} + Parser::by_kind::by_kind() YY_NOEXCEPT : kind_(symbol_kind::S_YYEMPTY) {} #if 201103L <= YY_CPLUSPLUS - Parser::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT - : kind_ (that.kind_) - { - that.clear (); - } + Parser::by_kind::by_kind(by_kind &&that) YY_NOEXCEPT : kind_(that.kind_) { that.clear(); } #endif - Parser::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT - : kind_ (that.kind_) - {} - - Parser::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT - : kind_ (yytranslate_ (t)) - {} + Parser::by_kind::by_kind(const by_kind &that) YY_NOEXCEPT : kind_(that.kind_) {} + Parser::by_kind::by_kind(token_kind_type t) YY_NOEXCEPT : kind_(yytranslate_(t)) {} + void Parser::by_kind::clear() YY_NOEXCEPT { kind_ = symbol_kind::S_YYEMPTY; } - void - Parser::by_kind::clear () YY_NOEXCEPT - { - kind_ = symbol_kind::S_YYEMPTY; - } - - void - Parser::by_kind::move (by_kind& that) + void Parser::by_kind::move(by_kind &that) { kind_ = that.kind_; - that.clear (); - } - - Parser::symbol_kind_type - Parser::by_kind::kind () const YY_NOEXCEPT - { - return kind_; - } - - - Parser::symbol_kind_type - Parser::by_kind::type_get () const YY_NOEXCEPT - { - return this->kind (); + that.clear(); } + Parser::symbol_kind_type Parser::by_kind::kind() const YY_NOEXCEPT { return kind_; } + Parser::symbol_kind_type Parser::by_kind::type_get() const YY_NOEXCEPT { return this->kind(); } // by_state. - Parser::by_state::by_state () YY_NOEXCEPT - : state (empty_state) - {} + Parser::by_state::by_state() YY_NOEXCEPT : state(empty_state) {} - Parser::by_state::by_state (const by_state& that) YY_NOEXCEPT - : state (that.state) - {} + Parser::by_state::by_state(const by_state &that) YY_NOEXCEPT : state(that.state) {} - void - Parser::by_state::clear () YY_NOEXCEPT - { - state = empty_state; - } + void Parser::by_state::clear() YY_NOEXCEPT { state = empty_state; } - void - Parser::by_state::move (by_state& that) + void Parser::by_state::move(by_state &that) { state = that.state; - that.clear (); + that.clear(); } - Parser::by_state::by_state (state_type s) YY_NOEXCEPT - : state (s) - {} + Parser::by_state::by_state(state_type s) YY_NOEXCEPT : state(s) {} - Parser::symbol_kind_type - Parser::by_state::kind () const YY_NOEXCEPT + Parser::symbol_kind_type Parser::by_state::kind() const YY_NOEXCEPT { if (state == empty_state) return symbol_kind::S_YYEMPTY; else - return YY_CAST (symbol_kind_type, yystos_[+state]); + return YY_CAST(symbol_kind_type, yystos_[+state]); } - Parser::stack_symbol_type::stack_symbol_type () - {} + Parser::stack_symbol_type::stack_symbol_type() {} - Parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that) - : super_type (YY_MOVE (that.state), YY_MOVE (that.value)) + Parser::stack_symbol_type::stack_symbol_type(YY_RVREF(stack_symbol_type) that) + : super_type(YY_MOVE(that.state), YY_MOVE(that.value)) { #if 201103L <= YY_CPLUSPLUS // that is emptied. @@ -337,24 +276,22 @@ namespace SEAMS { #endif } - Parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that) - : super_type (s, YY_MOVE (that.value)) + Parser::stack_symbol_type::stack_symbol_type(state_type s, YY_MOVE_REF(symbol_type) that) + : super_type(s, YY_MOVE(that.value)) { // that is emptied. that.kind_ = symbol_kind::S_YYEMPTY; } #if YY_CPLUSPLUS < 201103L - Parser::stack_symbol_type& - Parser::stack_symbol_type::operator= (const stack_symbol_type& that) + Parser::stack_symbol_type &Parser::stack_symbol_type::operator=(const stack_symbol_type &that) { state = that.state; value = that.value; return *this; } - Parser::stack_symbol_type& - Parser::stack_symbol_type::operator= (stack_symbol_type& that) + Parser::stack_symbol_type &Parser::stack_symbol_type::operator=(stack_symbol_type &that) { state = that.state; value = that.value; @@ -365,90 +302,62 @@ namespace SEAMS { #endif template - void - Parser::yy_destroy_ (const char* yymsg, basic_symbol& yysym) const + void Parser::yy_destroy_(const char *yymsg, basic_symbol &yysym) const { if (yymsg) - YY_SYMBOL_PRINT (yymsg, yysym); + YY_SYMBOL_PRINT(yymsg, yysym); // User destructor. - YY_USE (yysym.kind ()); + YY_USE(yysym.kind()); } #if SEAMSDEBUG template - void - Parser::yy_print_ (std::ostream& yyo, const basic_symbol& yysym) const + void Parser::yy_print_(std::ostream &yyo, const basic_symbol &yysym) const { - std::ostream& yyoutput = yyo; - YY_USE (yyoutput); - if (yysym.empty ()) + std::ostream &yyoutput = yyo; + YY_USE(yyoutput); + if (yysym.empty()) yyo << "empty symbol"; - else - { - symbol_kind_type yykind = yysym.kind (); - yyo << (yykind < YYNTOKENS ? "token" : "nterm") - << ' ' << yysym.name () << " ("; - YY_USE (yykind); - yyo << ')'; - } + else { + symbol_kind_type yykind = yysym.kind(); + yyo << (yykind < YYNTOKENS ? "token" : "nterm") << ' ' << yysym.name() << " ("; + YY_USE(yykind); + yyo << ')'; + } } #endif - void - Parser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym) + void Parser::yypush_(const char *m, YY_MOVE_REF(stack_symbol_type) sym) { if (m) - YY_SYMBOL_PRINT (m, sym); - yystack_.push (YY_MOVE (sym)); + YY_SYMBOL_PRINT(m, sym); + yystack_.push(YY_MOVE(sym)); } - void - Parser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym) + void Parser::yypush_(const char *m, state_type s, YY_MOVE_REF(symbol_type) sym) { #if 201103L <= YY_CPLUSPLUS - yypush_ (m, stack_symbol_type (s, std::move (sym))); + yypush_(m, stack_symbol_type(s, std::move(sym))); #else - stack_symbol_type ss (s, sym); - yypush_ (m, ss); + stack_symbol_type ss(s, sym); + yypush_(m, ss); #endif } - void - Parser::yypop_ (int n) YY_NOEXCEPT - { - yystack_.pop (n); - } + void Parser::yypop_(int n) YY_NOEXCEPT { yystack_.pop(n); } #if SEAMSDEBUG - std::ostream& - Parser::debug_stream () const - { - return *yycdebug_; - } - - void - Parser::set_debug_stream (std::ostream& o) - { - yycdebug_ = &o; - } + std::ostream &Parser::debug_stream() const { return *yycdebug_; } + void Parser::set_debug_stream(std::ostream &o) { yycdebug_ = &o; } - Parser::debug_level_type - Parser::debug_level () const - { - return yydebug_; - } + Parser::debug_level_type Parser::debug_level() const { return yydebug_; } - void - Parser::set_debug_level (debug_level_type l) - { - yydebug_ = l; - } + void Parser::set_debug_level(debug_level_type l) { yydebug_ = l; } #endif // SEAMSDEBUG - Parser::state_type - Parser::yy_lr_goto_state_ (state_type yystate, int yysym) + Parser::state_type Parser::yy_lr_goto_state_(state_type yystate, int yysym) { int yyr = yypgoto_[yysym - YYNTOKENS] + yystate; if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) @@ -457,33 +366,26 @@ namespace SEAMS { return yydefgoto_[yysym - YYNTOKENS]; } - bool - Parser::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT + bool Parser::yy_pact_value_is_default_(int yyvalue) YY_NOEXCEPT { return yyvalue == yypact_ninf_; } - bool - Parser::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT + bool Parser::yy_table_value_is_error_(int yyvalue) YY_NOEXCEPT { return yyvalue == yytable_ninf_; } - int - Parser::operator() () - { - return parse (); - } + int Parser::operator()() { return parse(); } - int - Parser::parse () + int Parser::parse() { int yyn; /// Length of the RHS of the rule being reduced. int yylen = 0; // Error handling. - int yynerrs_ = 0; + int yynerrs_ = 0; int yyerrstatus_ = 0; /// The lookahead symbol. @@ -495,1521 +397,1785 @@ namespace SEAMS { #if YY_EXCEPTIONS try #endif // YY_EXCEPTIONS - { - YYCDEBUG << "Starting parse\n"; - - - /* Initialize the stack. The initial state will be set in - yynewstate, since the latter expects the semantical and the - location values to have been already stored, initialize these - stacks with a primary value. */ - yystack_.clear (); - yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla)); - - /*-----------------------------------------------. - | yynewstate -- push a new symbol on the stack. | - `-----------------------------------------------*/ - yynewstate: - YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n'; - YY_STACK_PRINT (); - - // Accept? - if (yystack_[0].state == yyfinal_) - YYACCEPT; - - goto yybackup; - - - /*-----------. - | yybackup. | - `-----------*/ - yybackup: - // Try to take a decision without lookahead. - yyn = yypact_[+yystack_[0].state]; - if (yy_pact_value_is_default_ (yyn)) - goto yydefault; + { + YYCDEBUG << "Starting parse\n"; + + /* Initialize the stack. The initial state will be set in + yynewstate, since the latter expects the semantical and the + location values to have been already stored, initialize these + stacks with a primary value. */ + yystack_.clear(); + yypush_(YY_NULLPTR, 0, YY_MOVE(yyla)); + + /*-----------------------------------------------. + | yynewstate -- push a new symbol on the stack. | + `-----------------------------------------------*/ + yynewstate: + YYCDEBUG << "Entering state " << int(yystack_[0].state) << '\n'; + YY_STACK_PRINT(); + + // Accept? + if (yystack_[0].state == yyfinal_) + YYACCEPT; + + goto yybackup; + + /*-----------. + | yybackup. | + `-----------*/ + yybackup: + // Try to take a decision without lookahead. + yyn = yypact_[+yystack_[0].state]; + if (yy_pact_value_is_default_(yyn)) + goto yydefault; - // Read a lookahead token. - if (yyla.empty ()) - { + // Read a lookahead token. + if (yyla.empty()) { YYCDEBUG << "Reading a token\n"; #if YY_EXCEPTIONS try #endif // YY_EXCEPTIONS - { - yyla.kind_ = yytranslate_ (yylex (&yyla.value)); - } + { + yyla.kind_ = yytranslate_(yylex(&yyla.value)); + } #if YY_EXCEPTIONS - catch (const syntax_error& yyexc) - { - YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; - error (yyexc); - goto yyerrlab1; - } + catch (const syntax_error &yyexc) { + YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; + error(yyexc); + goto yyerrlab1; + } #endif // YY_EXCEPTIONS } - YY_SYMBOL_PRINT ("Next token is", yyla); - - if (yyla.kind () == symbol_kind::S_YYerror) - { - // The scanner already issued an error message, process directly - // to error recovery. But do not keep the error token as - // lookahead, it is too special and may lead us to an endless - // loop in error recovery. */ - yyla.kind_ = symbol_kind::S_YYUNDEF; - goto yyerrlab1; - } + YY_SYMBOL_PRINT("Next token is", yyla); + + if (yyla.kind() == symbol_kind::S_YYerror) { + // The scanner already issued an error message, process directly + // to error recovery. But do not keep the error token as + // lookahead, it is too special and may lead us to an endless + // loop in error recovery. */ + yyla.kind_ = symbol_kind::S_YYUNDEF; + goto yyerrlab1; + } - /* If the proper action on seeing token YYLA.TYPE is to reduce or - to detect an error, take that action. */ - yyn += yyla.kind (); - if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ()) - { + /* If the proper action on seeing token YYLA.TYPE is to reduce or + to detect an error, take that action. */ + yyn += yyla.kind(); + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind()) { goto yydefault; } - // Reduce or error. - yyn = yytable_[yyn]; - if (yyn <= 0) - { - if (yy_table_value_is_error_ (yyn)) + // Reduce or error. + yyn = yytable_[yyn]; + if (yyn <= 0) { + if (yy_table_value_is_error_(yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; } - // Count tokens shifted since error; after three, turn off error status. - if (yyerrstatus_) - --yyerrstatus_; - - // Shift the lookahead token. - yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla)); - goto yynewstate; - - - /*-----------------------------------------------------------. - | yydefault -- do the default action for the current state. | - `-----------------------------------------------------------*/ - yydefault: - yyn = yydefact_[+yystack_[0].state]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - - /*-----------------------------. - | yyreduce -- do a reduction. | - `-----------------------------*/ - yyreduce: - yylen = yyr2_[yyn]; - { - stack_symbol_type yylhs; - yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]); - /* If YYLEN is nonzero, implement the default value of the - action: '$$ = $1'. Otherwise, use the top of the stack. - - Otherwise, the following line sets YYLHS.VALUE to garbage. - This behavior is undocumented and Bison users should not rely - upon it. */ - if (yylen) - yylhs.value = yystack_[yylen - 1].value; - else - yylhs.value = yystack_[0].value; - - - // Perform the reduction. - YY_REDUCE_PRINT (yyn); + // Count tokens shifted since error; after three, turn off error status. + if (yyerrstatus_) + --yyerrstatus_; + + // Shift the lookahead token. + yypush_("Shifting", state_type(yyn), YY_MOVE(yyla)); + goto yynewstate; + + /*-----------------------------------------------------------. + | yydefault -- do the default action for the current state. | + `-----------------------------------------------------------*/ + yydefault: + yyn = yydefact_[+yystack_[0].state]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + /*-----------------------------. + | yyreduce -- do a reduction. | + `-----------------------------*/ + yyreduce: + yylen = yyr2_[yyn]; + { + stack_symbol_type yylhs; + yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]); + /* If YYLEN is nonzero, implement the default value of the + action: '$$ = $1'. Otherwise, use the top of the stack. + + Otherwise, the following line sets YYLHS.VALUE to garbage. + This behavior is undocumented and Bison users should not rely + upon it. */ + if (yylen) + yylhs.value = yystack_[yylen - 1].value; + else + yylhs.value = yystack_[0].value; + + // Perform the reduction. + YY_REDUCE_PRINT(yyn); #if YY_EXCEPTIONS - try + try #endif // YY_EXCEPTIONS { - switch (yyn) - { - case 4: // line: '\n' + switch (yyn) { + case 4: // line: '\n' #line 129 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { if (echo) aprepro.lexer->LexerOutput("\n", 1); } + { + if (echo) + aprepro.lexer->LexerOutput("\n", 1); + } #line 632 "apr_parser.cc" - break; + break; - case 5: // line: LBRACE exp RBRACE + case 5: // line: LBRACE exp RBRACE #line 130 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { if (echo) { - static char tmpstr[512]; - SEAMS::symrec *format = aprepro.getsym("_FORMAT"); - int len = sprintf(tmpstr, format->value.svar.c_str(), (yystack_[1].value.val)); - aprepro.lexer->LexerOutput(tmpstr, len); - } - } + { + if (echo) { + static char tmpstr[512]; + SEAMS::symrec *format = aprepro.getsym("_FORMAT"); + int len = snprintf(tmpstr, 512, format->value.svar.c_str(), (yystack_[1].value.val)); + aprepro.lexer->LexerOutput(tmpstr, len); + } + } #line 644 "apr_parser.cc" - break; + break; - case 6: // line: LBRACE sexp RBRACE + case 6: // line: LBRACE sexp RBRACE #line 137 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { if (echo && (yystack_[1].value.string) != NULL) { - aprepro.lexer->LexerOutput((yystack_[1].value.string), strlen((yystack_[1].value.string))); - } - } + { + if (echo && (yystack_[1].value.string) != NULL) { + aprepro.lexer->LexerOutput((yystack_[1].value.string), + strlen((yystack_[1].value.string))); + } + } #line 653 "apr_parser.cc" - break; + break; - case 7: // line: LBRACE aexp RBRACE + case 7: // line: LBRACE aexp RBRACE #line 141 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { } + { + } #line 659 "apr_parser.cc" - break; + break; - case 8: // line: LBRACE RBRACE + case 8: // line: LBRACE RBRACE #line 142 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { } + { + } #line 665 "apr_parser.cc" - break; + break; - case 9: // line: error RBRACE + case 9: // line: error RBRACE #line 143 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { yyerrok; } + { + yyerrok; + } #line 671 "apr_parser.cc" - break; + break; - case 10: // bool: exp LT exp + case 10: // bool: exp LT exp #line 146 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) < (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) < (yystack_[0].value.val); + } #line 677 "apr_parser.cc" - break; + break; - case 11: // bool: exp GT exp + case 11: // bool: exp GT exp #line 147 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) > (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) > (yystack_[0].value.val); + } #line 683 "apr_parser.cc" - break; + break; - case 12: // bool: NOT exp + case 12: // bool: NOT exp #line 148 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = !((yystack_[0].value.val)); } + { + (yylhs.value.val) = !((yystack_[0].value.val)); + } #line 689 "apr_parser.cc" - break; + break; - case 13: // bool: exp LE exp + case 13: // bool: exp LE exp #line 149 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) <= (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) <= (yystack_[0].value.val); + } #line 695 "apr_parser.cc" - break; + break; - case 14: // bool: exp GE exp + case 14: // bool: exp GE exp #line 150 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) >= (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) >= (yystack_[0].value.val); + } #line 701 "apr_parser.cc" - break; + break; - case 15: // bool: exp EQ exp + case 15: // bool: exp EQ exp #line 151 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) == (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) == (yystack_[0].value.val); + } #line 707 "apr_parser.cc" - break; + break; - case 16: // bool: exp NE exp + case 16: // bool: exp NE exp #line 152 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) != (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) != (yystack_[0].value.val); + } #line 713 "apr_parser.cc" - break; + break; - case 17: // bool: exp LOR exp + case 17: // bool: exp LOR exp #line 153 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) || (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) || (yystack_[0].value.val); + } #line 719 "apr_parser.cc" - break; + break; - case 18: // bool: exp LAND exp + case 18: // bool: exp LAND exp #line 154 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) && (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) && (yystack_[0].value.val); + } #line 725 "apr_parser.cc" - break; + break; - case 19: // bool: bool LOR bool + case 19: // bool: bool LOR bool #line 155 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) || (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) || (yystack_[0].value.val); + } #line 731 "apr_parser.cc" - break; + break; - case 20: // bool: bool LAND bool + case 20: // bool: bool LAND bool #line 156 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) && (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) && (yystack_[0].value.val); + } #line 737 "apr_parser.cc" - break; + break; - case 21: // bool: bool LOR exp + case 21: // bool: bool LOR exp #line 157 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) || (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) || (yystack_[0].value.val); + } #line 743 "apr_parser.cc" - break; + break; - case 22: // bool: bool LAND exp + case 22: // bool: bool LAND exp #line 158 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) && (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) && (yystack_[0].value.val); + } #line 749 "apr_parser.cc" - break; + break; - case 23: // bool: exp LOR bool + case 23: // bool: exp LOR bool #line 159 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) || (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) || (yystack_[0].value.val); + } #line 755 "apr_parser.cc" - break; + break; - case 24: // bool: exp LAND bool + case 24: // bool: exp LAND bool #line 160 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) && (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) && (yystack_[0].value.val); + } #line 761 "apr_parser.cc" - break; + break; - case 25: // bool: LPAR bool RPAR + case 25: // bool: LPAR bool RPAR #line 161 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[1].value.val); } + { + (yylhs.value.val) = (yystack_[1].value.val); + } #line 767 "apr_parser.cc" - break; + break; - case 26: // bool: sexp LT sexp + case 26: // bool: sexp LT sexp #line 164 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (strcmp((yystack_[2].value.string),(yystack_[0].value.string)) < 0 ? 1 : 0); } + { + (yylhs.value.val) = + (strcmp((yystack_[2].value.string), (yystack_[0].value.string)) < 0 ? 1 : 0); + } #line 773 "apr_parser.cc" - break; + break; - case 27: // bool: sexp GT sexp + case 27: // bool: sexp GT sexp #line 165 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (strcmp((yystack_[2].value.string),(yystack_[0].value.string)) > 0 ? 1 : 0); } + { + (yylhs.value.val) = + (strcmp((yystack_[2].value.string), (yystack_[0].value.string)) > 0 ? 1 : 0); + } #line 779 "apr_parser.cc" - break; + break; - case 28: // bool: sexp LE sexp + case 28: // bool: sexp LE sexp #line 166 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (strcmp((yystack_[2].value.string),(yystack_[0].value.string)) <= 0 ? 1 : 0); } + { + (yylhs.value.val) = + (strcmp((yystack_[2].value.string), (yystack_[0].value.string)) <= 0 ? 1 : 0); + } #line 785 "apr_parser.cc" - break; + break; - case 29: // bool: sexp GE sexp + case 29: // bool: sexp GE sexp #line 167 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (strcmp((yystack_[2].value.string),(yystack_[0].value.string)) >= 0 ? 1 : 0); } + { + (yylhs.value.val) = + (strcmp((yystack_[2].value.string), (yystack_[0].value.string)) >= 0 ? 1 : 0); + } #line 791 "apr_parser.cc" - break; + break; - case 30: // bool: sexp EQ sexp + case 30: // bool: sexp EQ sexp #line 168 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (strcmp((yystack_[2].value.string),(yystack_[0].value.string)) == 0 ? 1 : 0); } + { + (yylhs.value.val) = + (strcmp((yystack_[2].value.string), (yystack_[0].value.string)) == 0 ? 1 : 0); + } #line 797 "apr_parser.cc" - break; + break; - case 31: // bool: sexp NE sexp + case 31: // bool: sexp NE sexp #line 169 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (strcmp((yystack_[2].value.string),(yystack_[0].value.string)) != 0 ? 1 : 0); } + { + (yylhs.value.val) = + (strcmp((yystack_[2].value.string), (yystack_[0].value.string)) != 0 ? 1 : 0); + } #line 803 "apr_parser.cc" - break; + break; - case 32: // aexp: AVAR + case 32: // aexp: AVAR #line 171 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = aprepro.make_array(*((yystack_[0].value.tptr)->value.avar)); } + { + (yylhs.value.arrval) = aprepro.make_array(*((yystack_[0].value.tptr)->value.avar)); + } #line 809 "apr_parser.cc" - break; + break; - case 33: // aexp: AFNCT LPAR sexp RPAR + case 33: // aexp: AFNCT LPAR sexp RPAR #line 172 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.arrfnct_c == NULL)) - (yylhs.value.arrval) = (*((yystack_[3].value.tptr)->value.arrfnct_c))((yystack_[1].value.string)); - else - yyerrok; - } + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.arrfnct_c == NULL)) + (yylhs.value.arrval) = + (*((yystack_[3].value.tptr)->value.arrfnct_c))((yystack_[1].value.string)); + else + yyerrok; + } #line 820 "apr_parser.cc" - break; + break; - case 34: // aexp: AFNCT LPAR sexp COMMA exp RPAR + case 34: // aexp: AFNCT LPAR sexp COMMA exp RPAR #line 178 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.arrfnct_cd == NULL)) - (yylhs.value.arrval) = (*((yystack_[5].value.tptr)->value.arrfnct_cd))((yystack_[3].value.string),(yystack_[1].value.val)); - else - yyerrok; - } + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.arrfnct_cd == NULL)) + (yylhs.value.arrval) = (*((yystack_[5].value.tptr)->value.arrfnct_cd))( + (yystack_[3].value.string), (yystack_[1].value.val)); + else + yyerrok; + } #line 831 "apr_parser.cc" - break; + break; - case 35: // aexp: AFNCT LPAR sexp COMMA sexp RPAR + case 35: // aexp: AFNCT LPAR sexp COMMA sexp RPAR #line 184 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.arrfnct_cc == NULL)) - (yylhs.value.arrval) = (*((yystack_[5].value.tptr)->value.arrfnct_cc))((yystack_[3].value.string),(yystack_[1].value.string)); - else - yyerrok; - } + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.arrfnct_cc == NULL)) + (yylhs.value.arrval) = (*((yystack_[5].value.tptr)->value.arrfnct_cc))( + (yystack_[3].value.string), (yystack_[1].value.string)); + else + yyerrok; + } #line 842 "apr_parser.cc" - break; + break; - case 36: // aexp: AFNCT LPAR exp COMMA exp COMMA exp RPAR + case 36: // aexp: AFNCT LPAR exp COMMA exp COMMA exp RPAR #line 190 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[7].value.tptr), (yystack_[7].value.tptr)->value.arrfnct_ddd == NULL)) - (yylhs.value.arrval) = (*((yystack_[7].value.tptr)->value.arrfnct_ddd))((yystack_[5].value.val),(yystack_[3].value.val),(yystack_[1].value.val)); - else - yyerrok; - } + { + if (arg_check((yystack_[7].value.tptr), + (yystack_[7].value.tptr)->value.arrfnct_ddd == NULL)) + (yylhs.value.arrval) = (*((yystack_[7].value.tptr)->value.arrfnct_ddd))( + (yystack_[5].value.val), (yystack_[3].value.val), (yystack_[1].value.val)); + else + yyerrok; + } #line 853 "apr_parser.cc" - break; + break; - case 37: // aexp: AFNCT LPAR exp COMMA exp RPAR + case 37: // aexp: AFNCT LPAR exp COMMA exp RPAR #line 196 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.arrfnct_dd == NULL)) - (yylhs.value.arrval) = (*((yystack_[5].value.tptr)->value.arrfnct_dd))((yystack_[3].value.val),(yystack_[1].value.val)); - else - yyerrok; - } + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.arrfnct_dd == NULL)) + (yylhs.value.arrval) = (*((yystack_[5].value.tptr)->value.arrfnct_dd))( + (yystack_[3].value.val), (yystack_[1].value.val)); + else + yyerrok; + } #line 864 "apr_parser.cc" - break; + break; - case 38: // aexp: AFNCT LPAR exp RPAR + case 38: // aexp: AFNCT LPAR exp RPAR #line 202 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.arrfnct_d == NULL)) - (yylhs.value.arrval) = (*((yystack_[3].value.tptr)->value.arrfnct_d))((yystack_[1].value.val)); - else - yyerrok; - } + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.arrfnct_d == NULL)) + (yylhs.value.arrval) = + (*((yystack_[3].value.tptr)->value.arrfnct_d))((yystack_[1].value.val)); + else + yyerrok; + } #line 875 "apr_parser.cc" - break; + break; - case 39: // aexp: AFNCT LPAR aexp RPAR + case 39: // aexp: AFNCT LPAR aexp RPAR #line 208 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.arrfnct_a == NULL)) - (yylhs.value.arrval) = (*((yystack_[3].value.tptr)->value.arrfnct_a))((yystack_[1].value.arrval)); - else - yyerrok; - } + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.arrfnct_a == NULL)) + (yylhs.value.arrval) = + (*((yystack_[3].value.tptr)->value.arrfnct_a))((yystack_[1].value.arrval)); + else + yyerrok; + } #line 886 "apr_parser.cc" - break; + break; - case 40: // aexp: SVAR EQUAL aexp + case 40: // aexp: SVAR EQUAL aexp #line 214 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = (yystack_[0].value.arrval); - (yystack_[2].value.tptr)->value.avar = (yystack_[0].value.arrval); - redefined_warning(aprepro, (yystack_[2].value.tptr)); - set_type(aprepro, (yystack_[2].value.tptr), token::AVAR); } + { + (yylhs.value.arrval) = (yystack_[0].value.arrval); + (yystack_[2].value.tptr)->value.avar = (yystack_[0].value.arrval); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + set_type(aprepro, (yystack_[2].value.tptr), token::AVAR); + } #line 895 "apr_parser.cc" - break; + break; - case 41: // aexp: VAR EQUAL aexp + case 41: // aexp: VAR EQUAL aexp #line 218 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = (yystack_[0].value.arrval); - (yystack_[2].value.tptr)->value.avar= (yystack_[0].value.arrval); - redefined_warning(aprepro, (yystack_[2].value.tptr)); - set_type(aprepro, (yystack_[2].value.tptr), token::AVAR); } + { + (yylhs.value.arrval) = (yystack_[0].value.arrval); + (yystack_[2].value.tptr)->value.avar = (yystack_[0].value.arrval); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + set_type(aprepro, (yystack_[2].value.tptr), token::AVAR); + } #line 904 "apr_parser.cc" - break; + break; - case 42: // aexp: AVAR EQUAL aexp + case 42: // aexp: AVAR EQUAL aexp #line 222 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = (yystack_[0].value.arrval); aprepro.redefine_array((yystack_[2].value.tptr)->value.avar); (yystack_[2].value.tptr)->value.avar = (yystack_[0].value.arrval); - redefined_warning(aprepro, (yystack_[2].value.tptr)); - set_type(aprepro, (yystack_[2].value.tptr), token::AVAR); } + { + (yylhs.value.arrval) = (yystack_[0].value.arrval); + aprepro.redefine_array((yystack_[2].value.tptr)->value.avar); + (yystack_[2].value.tptr)->value.avar = (yystack_[0].value.arrval); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + set_type(aprepro, (yystack_[2].value.tptr), token::AVAR); + } #line 912 "apr_parser.cc" - break; + break; - case 43: // aexp: UNDVAR EQUAL aexp + case 43: // aexp: UNDVAR EQUAL aexp #line 225 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = (yystack_[0].value.arrval); (yystack_[2].value.tptr)->value.avar = (yystack_[0].value.arrval); - set_type(aprepro, (yystack_[2].value.tptr), token::AVAR); } + { + (yylhs.value.arrval) = (yystack_[0].value.arrval); + (yystack_[2].value.tptr)->value.avar = (yystack_[0].value.arrval); + set_type(aprepro, (yystack_[2].value.tptr), token::AVAR); + } #line 919 "apr_parser.cc" - break; + break; - case 44: // aexp: aexp PLU aexp + case 44: // aexp: aexp PLU aexp #line 227 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { if ((yystack_[2].value.arrval)->cols == (yystack_[0].value.arrval)->cols && (yystack_[2].value.arrval)->rows == (yystack_[0].value.arrval)->rows ) { - (yylhs.value.arrval) = array_add((yystack_[2].value.arrval), (yystack_[0].value.arrval)); - } - else { - yyerror(aprepro, "Arrays do not have same row and column count"); - yyerrok; - } - } + { + if ((yystack_[2].value.arrval)->cols == (yystack_[0].value.arrval)->cols && + (yystack_[2].value.arrval)->rows == (yystack_[0].value.arrval)->rows) { + (yylhs.value.arrval) = + array_add((yystack_[2].value.arrval), (yystack_[0].value.arrval)); + } + else { + yyerror(aprepro, "Arrays do not have same row and column count"); + yyerrok; + } + } #line 932 "apr_parser.cc" - break; + break; - case 45: // aexp: SUB aexp + case 45: // aexp: SUB aexp #line 235 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = array_scale((yystack_[0].value.arrval), -1.0); } + { + (yylhs.value.arrval) = array_scale((yystack_[0].value.arrval), -1.0); + } #line 938 "apr_parser.cc" - break; + break; - case 46: // aexp: aexp SUB aexp + case 46: // aexp: aexp SUB aexp #line 237 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { if ((yystack_[2].value.arrval)->cols == (yystack_[0].value.arrval)->cols && (yystack_[2].value.arrval)->rows == (yystack_[0].value.arrval)->rows ) { - (yylhs.value.arrval) = array_sub((yystack_[2].value.arrval), (yystack_[0].value.arrval)); - } - else { - yyerror(aprepro, "Arrays do not have same row and column count"); - yyerrok; - } - } + { + if ((yystack_[2].value.arrval)->cols == (yystack_[0].value.arrval)->cols && + (yystack_[2].value.arrval)->rows == (yystack_[0].value.arrval)->rows) { + (yylhs.value.arrval) = + array_sub((yystack_[2].value.arrval), (yystack_[0].value.arrval)); + } + else { + yyerror(aprepro, "Arrays do not have same row and column count"); + yyerrok; + } + } #line 951 "apr_parser.cc" - break; + break; - case 47: // aexp: aexp TIM exp + case 47: // aexp: aexp TIM exp #line 245 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = array_scale((yystack_[2].value.arrval), (yystack_[0].value.val)); } + { + (yylhs.value.arrval) = array_scale((yystack_[2].value.arrval), (yystack_[0].value.val)); + } #line 957 "apr_parser.cc" - break; + break; - case 48: // aexp: aexp DIV exp + case 48: // aexp: aexp DIV exp #line 246 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = array_scale((yystack_[2].value.arrval), 1.0/(yystack_[0].value.val)); } + { + (yylhs.value.arrval) = + array_scale((yystack_[2].value.arrval), 1.0 / (yystack_[0].value.val)); + } #line 963 "apr_parser.cc" - break; + break; - case 49: // aexp: exp TIM aexp + case 49: // aexp: exp TIM aexp #line 247 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.arrval) = array_scale((yystack_[0].value.arrval), (yystack_[2].value.val)); } + { + (yylhs.value.arrval) = array_scale((yystack_[0].value.arrval), (yystack_[2].value.val)); + } #line 969 "apr_parser.cc" - break; + break; - case 50: // aexp: aexp TIM aexp + case 50: // aexp: aexp TIM aexp #line 248 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { if ((yystack_[2].value.arrval)->cols == (yystack_[0].value.arrval)->rows) { - (yylhs.value.arrval) = array_mult((yystack_[2].value.arrval), (yystack_[0].value.arrval)); - } - else { - yyerror(aprepro, "Column count of first array does not match row count of second array"); - yyerrok; - } - } + { + if ((yystack_[2].value.arrval)->cols == (yystack_[0].value.arrval)->rows) { + (yylhs.value.arrval) = + array_mult((yystack_[2].value.arrval), (yystack_[0].value.arrval)); + } + else { + yyerror(aprepro, + "Column count of first array does not match row count of second array"); + yyerrok; + } + } #line 982 "apr_parser.cc" - break; + break; - case 51: // sexp: QSTRING + case 51: // sexp: QSTRING #line 257 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = (yystack_[0].value.string); } + { + (yylhs.value.string) = (yystack_[0].value.string); + } #line 988 "apr_parser.cc" - break; + break; - case 52: // sexp: SVAR + case 52: // sexp: SVAR #line 258 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = (char*)(yystack_[0].value.tptr)->value.svar.c_str(); } + { + (yylhs.value.string) = (char *)(yystack_[0].value.tptr)->value.svar.c_str(); + } #line 994 "apr_parser.cc" - break; + break; - case 53: // sexp: IMMSVAR + case 53: // sexp: IMMSVAR #line 259 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = (char*)(yystack_[0].value.tptr)->value.svar.c_str(); } + { + (yylhs.value.string) = (char *)(yystack_[0].value.tptr)->value.svar.c_str(); + } #line 1000 "apr_parser.cc" - break; + break; - case 54: // sexp: UNDVAR EQUAL sexp + case 54: // sexp: UNDVAR EQUAL sexp #line 260 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = (yystack_[0].value.string); (yystack_[2].value.tptr)->value.svar = (yystack_[0].value.string); - set_type(aprepro, (yystack_[2].value.tptr), Parser::token::SVAR); } + { + (yylhs.value.string) = (yystack_[0].value.string); + (yystack_[2].value.tptr)->value.svar = (yystack_[0].value.string); + set_type(aprepro, (yystack_[2].value.tptr), Parser::token::SVAR); + } #line 1007 "apr_parser.cc" - break; + break; - case 55: // sexp: SVAR EQUAL sexp + case 55: // sexp: SVAR EQUAL sexp #line 262 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = (yystack_[0].value.string); - (yystack_[2].value.tptr)->value.svar = (yystack_[0].value.string); - redefined_warning(aprepro, (yystack_[2].value.tptr)); } -#line 1015 "apr_parser.cc" - break; + { + (yylhs.value.string) = (yystack_[0].value.string); + (yystack_[2].value.tptr)->value.svar = (yystack_[0].value.string); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + } +#line 1015 "apr_parser.cc" + break; - case 56: // sexp: VAR EQUAL sexp + case 56: // sexp: VAR EQUAL sexp #line 265 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = (yystack_[0].value.string); - (yystack_[2].value.tptr)->value.svar= (yystack_[0].value.string); - redefined_warning(aprepro, (yystack_[2].value.tptr)); - set_type(aprepro, (yystack_[2].value.tptr), token::SVAR); } + { + (yylhs.value.string) = (yystack_[0].value.string); + (yystack_[2].value.tptr)->value.svar = (yystack_[0].value.string); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + set_type(aprepro, (yystack_[2].value.tptr), token::SVAR); + } #line 1024 "apr_parser.cc" - break; + break; - case 57: // sexp: AVAR EQUAL sexp + case 57: // sexp: AVAR EQUAL sexp #line 269 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = (yystack_[0].value.string); - aprepro.redefine_array((yystack_[2].value.tptr)->value.avar); - (yystack_[2].value.tptr)->value.svar= (yystack_[0].value.string); - redefined_warning(aprepro, (yystack_[2].value.tptr)); - set_type(aprepro, (yystack_[2].value.tptr), token::SVAR); } + { + (yylhs.value.string) = (yystack_[0].value.string); + aprepro.redefine_array((yystack_[2].value.tptr)->value.avar); + (yystack_[2].value.tptr)->value.svar = (yystack_[0].value.string); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + set_type(aprepro, (yystack_[2].value.tptr), token::SVAR); + } #line 1034 "apr_parser.cc" - break; + break; - case 58: // sexp: IMMSVAR EQUAL sexp + case 58: // sexp: IMMSVAR EQUAL sexp #line 274 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = (char*)(yystack_[2].value.tptr)->value.svar.c_str(); immutable_modify(aprepro, (yystack_[2].value.tptr)); } + { + (yylhs.value.string) = (char *)(yystack_[2].value.tptr)->value.svar.c_str(); + immutable_modify(aprepro, (yystack_[2].value.tptr)); + } #line 1040 "apr_parser.cc" - break; + break; - case 59: // sexp: IMMVAR EQUAL sexp + case 59: // sexp: IMMVAR EQUAL sexp #line 275 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { immutable_modify(aprepro, (yystack_[2].value.tptr)); YYERROR; } + { + immutable_modify(aprepro, (yystack_[2].value.tptr)); + YYERROR; + } #line 1046 "apr_parser.cc" - break; + break; - case 60: // sexp: SFNCT LPAR sexp RPAR + case 60: // sexp: SFNCT LPAR sexp RPAR #line 276 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.strfnct_c == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[3].value.tptr)->value.strfnct_c))((yystack_[1].value.string)); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.strfnct_c == NULL)) + (yylhs.value.string) = (char *)(*((yystack_[3].value.tptr)->value.strfnct_c))( + (yystack_[1].value.string)); + else + (yylhs.value.string) = (char *)""; + } #line 1057 "apr_parser.cc" - break; + break; - case 61: // sexp: SFNCT LPAR RPAR + case 61: // sexp: SFNCT LPAR RPAR #line 282 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[2].value.tptr), (yystack_[2].value.tptr)->value.strfnct == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[2].value.tptr)->value.strfnct))(); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[2].value.tptr), + (yystack_[2].value.tptr)->value.strfnct == NULL)) + (yylhs.value.string) = (char *)(*((yystack_[2].value.tptr)->value.strfnct))(); + else + (yylhs.value.string) = (char *)""; + } #line 1068 "apr_parser.cc" - break; + break; - case 62: // sexp: SFNCT LPAR exp RPAR + case 62: // sexp: SFNCT LPAR exp RPAR #line 288 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.strfnct_d == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[3].value.tptr)->value.strfnct_d))((yystack_[1].value.val)); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.strfnct_d == NULL)) + (yylhs.value.string) = + (char *)(*((yystack_[3].value.tptr)->value.strfnct_d))((yystack_[1].value.val)); + else + (yylhs.value.string) = (char *)""; + } #line 1079 "apr_parser.cc" - break; + break; - case 63: // sexp: SFNCT LPAR aexp RPAR + case 63: // sexp: SFNCT LPAR aexp RPAR #line 294 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.strfnct_a == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[3].value.tptr)->value.strfnct_a))((yystack_[1].value.arrval)); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.strfnct_a == NULL)) + (yylhs.value.string) = (char *)(*((yystack_[3].value.tptr)->value.strfnct_a))( + (yystack_[1].value.arrval)); + else + (yylhs.value.string) = (char *)""; + } #line 1090 "apr_parser.cc" - break; + break; - case 64: // sexp: sexp CONCAT sexp + case 64: // sexp: sexp CONCAT sexp #line 300 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { concat_string((yystack_[2].value.string), (yystack_[0].value.string), &(yylhs.value.string)); } + { + concat_string((yystack_[2].value.string), (yystack_[0].value.string), + &(yylhs.value.string)); + } #line 1096 "apr_parser.cc" - break; + break; - case 65: // sexp: SFNCT LPAR exp COMMA exp RPAR + case 65: // sexp: SFNCT LPAR exp COMMA exp RPAR #line 301 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.strfnct_dd == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[5].value.tptr)->value.strfnct_dd))((yystack_[3].value.val), (yystack_[1].value.val)); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.strfnct_dd == NULL)) + (yylhs.value.string) = (char *)(*((yystack_[5].value.tptr)->value.strfnct_dd))( + (yystack_[3].value.val), (yystack_[1].value.val)); + else + (yylhs.value.string) = (char *)""; + } #line 1107 "apr_parser.cc" - break; + break; - case 66: // sexp: SFNCT LPAR exp COMMA sexp COMMA sexp COMMA sexp COMMA sexp RPAR + case 66: // sexp: SFNCT LPAR exp COMMA sexp COMMA sexp COMMA sexp COMMA sexp RPAR #line 307 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[11].value.tptr), (yystack_[11].value.tptr)->value.strfnct_dcccc == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[11].value.tptr)->value.strfnct_dcccc))((yystack_[9].value.val), (yystack_[7].value.string), (yystack_[5].value.string), (yystack_[3].value.string), (yystack_[1].value.string)); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[11].value.tptr), + (yystack_[11].value.tptr)->value.strfnct_dcccc == NULL)) + (yylhs.value.string) = (char *)(*((yystack_[11].value.tptr)->value.strfnct_dcccc))( + (yystack_[9].value.val), (yystack_[7].value.string), (yystack_[5].value.string), + (yystack_[3].value.string), (yystack_[1].value.string)); + else + (yylhs.value.string) = (char *)""; + } #line 1118 "apr_parser.cc" - break; + break; - case 67: // sexp: SFNCT LPAR exp COMMA sexp COMMA sexp RPAR + case 67: // sexp: SFNCT LPAR exp COMMA sexp COMMA sexp RPAR #line 313 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[7].value.tptr), (yystack_[7].value.tptr)->value.strfnct_dcc == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[7].value.tptr)->value.strfnct_dcc))((yystack_[5].value.val), (yystack_[3].value.string), (yystack_[1].value.string)); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[7].value.tptr), + (yystack_[7].value.tptr)->value.strfnct_dcc == NULL)) + (yylhs.value.string) = (char *)(*((yystack_[7].value.tptr)->value.strfnct_dcc))( + (yystack_[5].value.val), (yystack_[3].value.string), (yystack_[1].value.string)); + else + (yylhs.value.string) = (char *)""; + } #line 1129 "apr_parser.cc" - break; + break; - case 68: // sexp: SFNCT LPAR sexp COMMA sexp COMMA sexp RPAR + case 68: // sexp: SFNCT LPAR sexp COMMA sexp COMMA sexp RPAR #line 319 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[7].value.tptr), (yystack_[7].value.tptr)->value.strfnct_ccc == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[7].value.tptr)->value.strfnct_ccc))((yystack_[5].value.string), (yystack_[3].value.string), (yystack_[1].value.string)); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[7].value.tptr), + (yystack_[7].value.tptr)->value.strfnct_ccc == NULL)) + (yylhs.value.string) = (char *)(*((yystack_[7].value.tptr)->value.strfnct_ccc))( + (yystack_[5].value.string), (yystack_[3].value.string), + (yystack_[1].value.string)); + else + (yylhs.value.string) = (char *)""; + } #line 1140 "apr_parser.cc" - break; + break; - case 69: // sexp: SFNCT LPAR sexp COMMA sexp RPAR + case 69: // sexp: SFNCT LPAR sexp COMMA sexp RPAR #line 325 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.strfnct_cc == NULL)) - (yylhs.value.string) = (char*)(*((yystack_[5].value.tptr)->value.strfnct_cc))((yystack_[3].value.string), (yystack_[1].value.string)); - else - (yylhs.value.string) = (char*)""; - } + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.strfnct_cc == NULL)) + (yylhs.value.string) = (char *)(*((yystack_[5].value.tptr)->value.strfnct_cc))( + (yystack_[3].value.string), (yystack_[1].value.string)); + else + (yylhs.value.string) = (char *)""; + } #line 1151 "apr_parser.cc" - break; + break; - case 70: // sexp: bool QUEST sexp COLON sexp + case 70: // sexp: bool QUEST sexp COLON sexp #line 331 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.string) = ((yystack_[4].value.val)) ? ((yystack_[2].value.string)) : ((yystack_[0].value.string)); } + { + (yylhs.value.string) = ((yystack_[4].value.val)) ? ((yystack_[2].value.string)) + : ((yystack_[0].value.string)); + } #line 1157 "apr_parser.cc" - break; + break; - case 71: // exp: NUM + case 71: // exp: NUM #line 333 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[0].value.val); + } #line 1163 "apr_parser.cc" - break; + break; - case 72: // exp: INC NUM + case 72: // exp: INC NUM #line 334 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val) + 1; } + { + (yylhs.value.val) = (yystack_[0].value.val) + 1; + } #line 1169 "apr_parser.cc" - break; + break; - case 73: // exp: DEC NUM + case 73: // exp: DEC NUM #line 335 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val) - 1; } + { + (yylhs.value.val) = (yystack_[0].value.val) - 1; + } #line 1175 "apr_parser.cc" - break; + break; - case 74: // exp: VAR + case 74: // exp: VAR #line 336 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; } + { + (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; + } #line 1181 "apr_parser.cc" - break; + break; - case 75: // exp: IMMVAR + case 75: // exp: IMMVAR #line 337 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; } + { + (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; + } #line 1187 "apr_parser.cc" - break; + break; - case 76: // exp: INC VAR + case 76: // exp: INC VAR #line 338 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = ++((yystack_[0].value.tptr)->value.var); } + { + (yylhs.value.val) = ++((yystack_[0].value.tptr)->value.var); + } #line 1193 "apr_parser.cc" - break; + break; - case 77: // exp: DEC VAR + case 77: // exp: DEC VAR #line 339 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = --((yystack_[0].value.tptr)->value.var); } + { + (yylhs.value.val) = --((yystack_[0].value.tptr)->value.var); + } #line 1199 "apr_parser.cc" - break; + break; - case 78: // exp: VAR INC + case 78: // exp: VAR INC #line 340 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = ((yystack_[1].value.tptr)->value.var)++; } + { + (yylhs.value.val) = ((yystack_[1].value.tptr)->value.var)++; + } #line 1205 "apr_parser.cc" - break; + break; - case 79: // exp: VAR DEC + case 79: // exp: VAR DEC #line 341 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = ((yystack_[1].value.tptr)->value.var)--; } + { + (yylhs.value.val) = ((yystack_[1].value.tptr)->value.var)--; + } #line 1211 "apr_parser.cc" - break; + break; - case 80: // exp: VAR EQUAL exp + case 80: // exp: VAR EQUAL exp #line 342 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val); (yystack_[2].value.tptr)->value.var = (yystack_[0].value.val); - redefined_warning(aprepro, (yystack_[2].value.tptr)); } + { + (yylhs.value.val) = (yystack_[0].value.val); + (yystack_[2].value.tptr)->value.var = (yystack_[0].value.val); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + } #line 1218 "apr_parser.cc" - break; + break; - case 81: // exp: SVAR EQUAL exp + case 81: // exp: SVAR EQUAL exp #line 344 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val); (yystack_[2].value.tptr)->value.var = (yystack_[0].value.val); - redefined_warning(aprepro, (yystack_[2].value.tptr)); - set_type(aprepro, (yystack_[2].value.tptr), token::VAR); } + { + (yylhs.value.val) = (yystack_[0].value.val); + (yystack_[2].value.tptr)->value.var = (yystack_[0].value.val); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + set_type(aprepro, (yystack_[2].value.tptr), token::VAR); + } #line 1226 "apr_parser.cc" - break; + break; - case 82: // exp: AVAR EQUAL exp + case 82: // exp: AVAR EQUAL exp #line 347 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val); - aprepro.redefine_array((yystack_[2].value.tptr)->value.avar); - (yystack_[2].value.tptr)->value.var= (yystack_[0].value.val); - redefined_warning(aprepro, (yystack_[2].value.tptr)); - set_type(aprepro, (yystack_[2].value.tptr), token::VAR); } + { + (yylhs.value.val) = (yystack_[0].value.val); + aprepro.redefine_array((yystack_[2].value.tptr)->value.avar); + (yystack_[2].value.tptr)->value.var = (yystack_[0].value.val); + redefined_warning(aprepro, (yystack_[2].value.tptr)); + set_type(aprepro, (yystack_[2].value.tptr), token::VAR); + } #line 1236 "apr_parser.cc" - break; + break; - case 83: // exp: VAR EQ_PLUS exp + case 83: // exp: VAR EQ_PLUS exp #line 352 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yystack_[2].value.tptr)->value.var += (yystack_[0].value.val); (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; } + { + (yystack_[2].value.tptr)->value.var += (yystack_[0].value.val); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + } #line 1242 "apr_parser.cc" - break; + break; - case 84: // exp: VAR EQ_MINUS exp + case 84: // exp: VAR EQ_MINUS exp #line 353 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yystack_[2].value.tptr)->value.var -= (yystack_[0].value.val); (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; } + { + (yystack_[2].value.tptr)->value.var -= (yystack_[0].value.val); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + } #line 1248 "apr_parser.cc" - break; + break; - case 85: // exp: VAR EQ_TIME exp + case 85: // exp: VAR EQ_TIME exp #line 354 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yystack_[2].value.tptr)->value.var *= (yystack_[0].value.val); (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; } + { + (yystack_[2].value.tptr)->value.var *= (yystack_[0].value.val); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + } #line 1254 "apr_parser.cc" - break; + break; - case 86: // exp: VAR EQ_DIV exp + case 86: // exp: VAR EQ_DIV exp #line 355 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yystack_[2].value.tptr)->value.var /= (yystack_[0].value.val); (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; } + { + (yystack_[2].value.tptr)->value.var /= (yystack_[0].value.val); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + } #line 1260 "apr_parser.cc" - break; + break; - case 87: // exp: VAR EQ_POW exp + case 87: // exp: VAR EQ_POW exp #line 356 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { reset_error(); - (yystack_[2].value.tptr)->value.var = std::pow((yystack_[2].value.tptr)->value.var,(yystack_[0].value.val)); - (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; - SEAMS::math_error(aprepro, "Power"); - } + { + reset_error(); + (yystack_[2].value.tptr)->value.var = + std::pow((yystack_[2].value.tptr)->value.var, (yystack_[0].value.val)); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + SEAMS::math_error(aprepro, "Power"); + } #line 1270 "apr_parser.cc" - break; + break; - case 88: // exp: INC IMMVAR + case 88: // exp: INC IMMVAR #line 361 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[0].value.tptr)); } + { + (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[0].value.tptr)); + } #line 1276 "apr_parser.cc" - break; + break; - case 89: // exp: DEC IMMVAR + case 89: // exp: DEC IMMVAR #line 362 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[0].value.tptr)); } + { + (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[0].value.tptr)); + } #line 1282 "apr_parser.cc" - break; + break; - case 90: // exp: IMMVAR INC + case 90: // exp: IMMVAR INC #line 363 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[1].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[1].value.tptr)); } + { + (yylhs.value.val) = (yystack_[1].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[1].value.tptr)); + } #line 1288 "apr_parser.cc" - break; + break; - case 91: // exp: IMMVAR DEC + case 91: // exp: IMMVAR DEC #line 364 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[1].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[1].value.tptr)); } + { + (yylhs.value.val) = (yystack_[1].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[1].value.tptr)); + } #line 1294 "apr_parser.cc" - break; + break; - case 92: // exp: IMMVAR EQUAL exp + case 92: // exp: IMMVAR EQUAL exp #line 365 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[2].value.tptr)); } + { + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[2].value.tptr)); + } #line 1300 "apr_parser.cc" - break; + break; - case 93: // exp: IMMSVAR EQUAL exp + case 93: // exp: IMMSVAR EQUAL exp #line 366 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { immutable_modify(aprepro, (yystack_[2].value.tptr)); YYERROR; } + { + immutable_modify(aprepro, (yystack_[2].value.tptr)); + YYERROR; + } #line 1306 "apr_parser.cc" - break; + break; - case 94: // exp: IMMVAR EQ_PLUS exp + case 94: // exp: IMMVAR EQ_PLUS exp #line 367 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[2].value.tptr)); } + { + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[2].value.tptr)); + } #line 1312 "apr_parser.cc" - break; + break; - case 95: // exp: IMMVAR EQ_MINUS exp + case 95: // exp: IMMVAR EQ_MINUS exp #line 368 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[2].value.tptr)); } + { + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[2].value.tptr)); + } #line 1318 "apr_parser.cc" - break; + break; - case 96: // exp: IMMVAR EQ_TIME exp + case 96: // exp: IMMVAR EQ_TIME exp #line 369 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[2].value.tptr)); } + { + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[2].value.tptr)); + } #line 1324 "apr_parser.cc" - break; + break; - case 97: // exp: IMMVAR EQ_DIV exp + case 97: // exp: IMMVAR EQ_DIV exp #line 370 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[2].value.tptr)); } + { + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[2].value.tptr)); + } #line 1330 "apr_parser.cc" - break; + break; - case 98: // exp: IMMVAR EQ_POW exp + case 98: // exp: IMMVAR EQ_POW exp #line 371 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; immutable_modify(aprepro, (yystack_[2].value.tptr)); } + { + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + immutable_modify(aprepro, (yystack_[2].value.tptr)); + } #line 1336 "apr_parser.cc" - break; + break; - case 99: // exp: UNDVAR + case 99: // exp: UNDVAR #line 373 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; - undefined_error(aprepro, (yystack_[0].value.tptr)->name); } + { + (yylhs.value.val) = (yystack_[0].value.tptr)->value.var; + undefined_error(aprepro, (yystack_[0].value.tptr)->name); + } #line 1343 "apr_parser.cc" - break; + break; - case 100: // exp: INC UNDVAR + case 100: // exp: INC UNDVAR #line 375 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = ++((yystack_[0].value.tptr)->value.var); - set_type(aprepro, (yystack_[0].value.tptr), token::VAR); - undefined_error(aprepro, (yystack_[0].value.tptr)->name); } + { + (yylhs.value.val) = ++((yystack_[0].value.tptr)->value.var); + set_type(aprepro, (yystack_[0].value.tptr), token::VAR); + undefined_error(aprepro, (yystack_[0].value.tptr)->name); + } #line 1351 "apr_parser.cc" - break; + break; - case 101: // exp: DEC UNDVAR + case 101: // exp: DEC UNDVAR #line 378 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = --((yystack_[0].value.tptr)->value.var); - set_type(aprepro, (yystack_[0].value.tptr), token::VAR); - undefined_error(aprepro, (yystack_[0].value.tptr)->name); } + { + (yylhs.value.val) = --((yystack_[0].value.tptr)->value.var); + set_type(aprepro, (yystack_[0].value.tptr), token::VAR); + undefined_error(aprepro, (yystack_[0].value.tptr)->name); + } #line 1359 "apr_parser.cc" - break; + break; - case 102: // exp: UNDVAR INC + case 102: // exp: UNDVAR INC #line 381 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = ((yystack_[1].value.tptr)->value.var)++; - set_type(aprepro, (yystack_[1].value.tptr), token::VAR); - undefined_error(aprepro, (yystack_[1].value.tptr)->name); } + { + (yylhs.value.val) = ((yystack_[1].value.tptr)->value.var)++; + set_type(aprepro, (yystack_[1].value.tptr), token::VAR); + undefined_error(aprepro, (yystack_[1].value.tptr)->name); + } #line 1367 "apr_parser.cc" - break; + break; - case 103: // exp: UNDVAR DEC + case 103: // exp: UNDVAR DEC #line 384 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = ((yystack_[1].value.tptr)->value.var)--; - set_type(aprepro, (yystack_[1].value.tptr), token::VAR); - undefined_error(aprepro, (yystack_[1].value.tptr)->name); } + { + (yylhs.value.val) = ((yystack_[1].value.tptr)->value.var)--; + set_type(aprepro, (yystack_[1].value.tptr), token::VAR); + undefined_error(aprepro, (yystack_[1].value.tptr)->name); + } #line 1375 "apr_parser.cc" - break; + break; - case 104: // exp: UNDVAR EQUAL exp + case 104: // exp: UNDVAR EQUAL exp #line 387 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val); (yystack_[2].value.tptr)->value.var = (yystack_[0].value.val); - set_type(aprepro, (yystack_[2].value.tptr), token::VAR); } + { + (yylhs.value.val) = (yystack_[0].value.val); + (yystack_[2].value.tptr)->value.var = (yystack_[0].value.val); + set_type(aprepro, (yystack_[2].value.tptr), token::VAR); + } #line 1382 "apr_parser.cc" - break; + break; - case 105: // exp: UNDVAR EQ_PLUS exp + case 105: // exp: UNDVAR EQ_PLUS exp #line 389 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yystack_[2].value.tptr)->value.var += (yystack_[0].value.val); (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; - set_type(aprepro, (yystack_[2].value.tptr), token::VAR); - undefined_error(aprepro, (yystack_[2].value.tptr)->name); } + { + (yystack_[2].value.tptr)->value.var += (yystack_[0].value.val); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + set_type(aprepro, (yystack_[2].value.tptr), token::VAR); + undefined_error(aprepro, (yystack_[2].value.tptr)->name); + } #line 1390 "apr_parser.cc" - break; + break; - case 106: // exp: UNDVAR EQ_MINUS exp + case 106: // exp: UNDVAR EQ_MINUS exp #line 392 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yystack_[2].value.tptr)->value.var -= (yystack_[0].value.val); (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; - set_type(aprepro, (yystack_[2].value.tptr), token::VAR); - undefined_error(aprepro, (yystack_[2].value.tptr)->name); } + { + (yystack_[2].value.tptr)->value.var -= (yystack_[0].value.val); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + set_type(aprepro, (yystack_[2].value.tptr), token::VAR); + undefined_error(aprepro, (yystack_[2].value.tptr)->name); + } #line 1398 "apr_parser.cc" - break; + break; - case 107: // exp: UNDVAR EQ_TIME exp + case 107: // exp: UNDVAR EQ_TIME exp #line 395 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yystack_[2].value.tptr)->value.var *= (yystack_[0].value.val); (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; - set_type(aprepro, (yystack_[2].value.tptr), token::VAR); - undefined_error(aprepro, (yystack_[2].value.tptr)->name); } + { + (yystack_[2].value.tptr)->value.var *= (yystack_[0].value.val); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + set_type(aprepro, (yystack_[2].value.tptr), token::VAR); + undefined_error(aprepro, (yystack_[2].value.tptr)->name); + } #line 1406 "apr_parser.cc" - break; + break; - case 108: // exp: UNDVAR EQ_DIV exp + case 108: // exp: UNDVAR EQ_DIV exp #line 398 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yystack_[2].value.tptr)->value.var /= (yystack_[0].value.val); (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; - set_type(aprepro, (yystack_[2].value.tptr), token::VAR); - undefined_error(aprepro, (yystack_[2].value.tptr)->name); } + { + (yystack_[2].value.tptr)->value.var /= (yystack_[0].value.val); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + set_type(aprepro, (yystack_[2].value.tptr), token::VAR); + undefined_error(aprepro, (yystack_[2].value.tptr)->name); + } #line 1414 "apr_parser.cc" - break; + break; - case 109: // exp: UNDVAR EQ_POW exp + case 109: // exp: UNDVAR EQ_POW exp #line 401 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { reset_error(); - (yystack_[2].value.tptr)->value.var = std::pow((yystack_[2].value.tptr)->value.var,(yystack_[0].value.val)); - (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; - set_type(aprepro, (yystack_[2].value.tptr), token::VAR); - SEAMS::math_error(aprepro, "Power"); - undefined_error(aprepro, (yystack_[2].value.tptr)->name); } + { + reset_error(); + (yystack_[2].value.tptr)->value.var = + std::pow((yystack_[2].value.tptr)->value.var, (yystack_[0].value.val)); + (yylhs.value.val) = (yystack_[2].value.tptr)->value.var; + set_type(aprepro, (yystack_[2].value.tptr), token::VAR); + SEAMS::math_error(aprepro, "Power"); + undefined_error(aprepro, (yystack_[2].value.tptr)->name); + } #line 1425 "apr_parser.cc" - break; + break; - case 110: // exp: FNCT LPAR RPAR + case 110: // exp: FNCT LPAR RPAR #line 408 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[2].value.tptr), (yystack_[2].value.tptr)->value.fnctptr == NULL)) - (yylhs.value.val) = (*((yystack_[2].value.tptr)->value.fnctptr))(); - else - (yylhs.value.val) = 0.0; + { + if (arg_check((yystack_[2].value.tptr), + (yystack_[2].value.tptr)->value.fnctptr == NULL)) + (yylhs.value.val) = (*((yystack_[2].value.tptr)->value.fnctptr))(); + else + (yylhs.value.val) = 0.0; } #line 1436 "apr_parser.cc" - break; + break; - case 111: // exp: FNCT LPAR exp RPAR + case 111: // exp: FNCT LPAR exp RPAR #line 415 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.fnctptr_d == NULL)) - (yylhs.value.val) = (*((yystack_[3].value.tptr)->value.fnctptr_d))((yystack_[1].value.val)); - else - (yylhs.value.val) = 0.0; + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.fnctptr_d == NULL)) + (yylhs.value.val) = + (*((yystack_[3].value.tptr)->value.fnctptr_d))((yystack_[1].value.val)); + else + (yylhs.value.val) = 0.0; } #line 1447 "apr_parser.cc" - break; + break; - case 112: // exp: FNCT LPAR sexp RPAR + case 112: // exp: FNCT LPAR sexp RPAR #line 422 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.fnctptr_c == NULL)) - (yylhs.value.val) = (*((yystack_[3].value.tptr)->value.fnctptr_c))((yystack_[1].value.string)); - else - (yylhs.value.val) = 0.0; + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.fnctptr_c == NULL)) + (yylhs.value.val) = + (*((yystack_[3].value.tptr)->value.fnctptr_c))((yystack_[1].value.string)); + else + (yylhs.value.val) = 0.0; } #line 1458 "apr_parser.cc" - break; + break; - case 113: // exp: FNCT LPAR aexp RPAR + case 113: // exp: FNCT LPAR aexp RPAR #line 429 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[3].value.tptr), (yystack_[3].value.tptr)->value.fnctptr_a == NULL)) - (yylhs.value.val) = (*((yystack_[3].value.tptr)->value.fnctptr_a))((yystack_[1].value.arrval)); - else - (yylhs.value.val) = 0.0; + { + if (arg_check((yystack_[3].value.tptr), + (yystack_[3].value.tptr)->value.fnctptr_a == NULL)) + (yylhs.value.val) = + (*((yystack_[3].value.tptr)->value.fnctptr_a))((yystack_[1].value.arrval)); + else + (yylhs.value.val) = 0.0; } #line 1469 "apr_parser.cc" - break; + break; - case 114: // exp: FNCT LPAR sexp COMMA exp RPAR + case 114: // exp: FNCT LPAR sexp COMMA exp RPAR #line 436 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.fnctptr_cd == NULL)) - (yylhs.value.val) = (*((yystack_[5].value.tptr)->value.fnctptr_cd))((yystack_[3].value.string), (yystack_[1].value.val)); + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.fnctptr_cd == NULL)) + (yylhs.value.val) = (*((yystack_[5].value.tptr)->value.fnctptr_cd))( + (yystack_[3].value.string), (yystack_[1].value.val)); else (yylhs.value.val) = 0.0; } #line 1480 "apr_parser.cc" - break; + break; - case 115: // exp: FNCT LPAR exp COMMA sexp RPAR + case 115: // exp: FNCT LPAR exp COMMA sexp RPAR #line 443 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.fnctptr_dc == NULL)) - (yylhs.value.val) = (*((yystack_[5].value.tptr)->value.fnctptr_dc))((yystack_[3].value.val), (yystack_[1].value.string)); - else - (yylhs.value.val) = 0.0; + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.fnctptr_dc == NULL)) + (yylhs.value.val) = (*((yystack_[5].value.tptr)->value.fnctptr_dc))( + (yystack_[3].value.val), (yystack_[1].value.string)); + else + (yylhs.value.val) = 0.0; } #line 1491 "apr_parser.cc" - break; + break; - case 116: // exp: FNCT LPAR sexp COMMA sexp RPAR + case 116: // exp: FNCT LPAR sexp COMMA sexp RPAR #line 450 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.fnctptr_cc == NULL)) - (yylhs.value.val) = (*((yystack_[5].value.tptr)->value.fnctptr_cc))((yystack_[3].value.string), (yystack_[1].value.string)); + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.fnctptr_cc == NULL)) + (yylhs.value.val) = (*((yystack_[5].value.tptr)->value.fnctptr_cc))( + (yystack_[3].value.string), (yystack_[1].value.string)); else (yylhs.value.val) = 0.0; } #line 1502 "apr_parser.cc" - break; + break; - case 117: // exp: FNCT LPAR sexp COMMA sexp COMMA sexp RPAR + case 117: // exp: FNCT LPAR sexp COMMA sexp COMMA sexp RPAR #line 457 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[7].value.tptr), (yystack_[7].value.tptr)->value.fnctptr_ccc == NULL)) - (yylhs.value.val) = (*((yystack_[7].value.tptr)->value.fnctptr_ccc))((yystack_[5].value.string),(yystack_[3].value.string),(yystack_[1].value.string)); - else - yyerrok; - } + { + if (arg_check((yystack_[7].value.tptr), + (yystack_[7].value.tptr)->value.fnctptr_ccc == NULL)) + (yylhs.value.val) = (*((yystack_[7].value.tptr)->value.fnctptr_ccc))( + (yystack_[5].value.string), (yystack_[3].value.string), + (yystack_[1].value.string)); + else + yyerrok; + } #line 1513 "apr_parser.cc" - break; + break; - case 118: // exp: FNCT LPAR exp COMMA exp RPAR + case 118: // exp: FNCT LPAR exp COMMA exp RPAR #line 464 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[5].value.tptr), (yystack_[5].value.tptr)->value.fnctptr_dd == NULL)) - (yylhs.value.val) = (*((yystack_[5].value.tptr)->value.fnctptr_dd))((yystack_[3].value.val), (yystack_[1].value.val)); + { + if (arg_check((yystack_[5].value.tptr), + (yystack_[5].value.tptr)->value.fnctptr_dd == NULL)) + (yylhs.value.val) = (*((yystack_[5].value.tptr)->value.fnctptr_dd))( + (yystack_[3].value.val), (yystack_[1].value.val)); else (yylhs.value.val) = 0.0; } #line 1524 "apr_parser.cc" - break; + break; - case 119: // exp: FNCT LPAR exp COMMA exp COMMA exp RPAR + case 119: // exp: FNCT LPAR exp COMMA exp COMMA exp RPAR #line 470 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[7].value.tptr), (yystack_[7].value.tptr)->value.fnctptr_ddd == NULL)) - (yylhs.value.val) = (*((yystack_[7].value.tptr)->value.fnctptr_ddd))((yystack_[5].value.val), (yystack_[3].value.val), (yystack_[1].value.val)); + { + if (arg_check((yystack_[7].value.tptr), + (yystack_[7].value.tptr)->value.fnctptr_ddd == NULL)) + (yylhs.value.val) = (*((yystack_[7].value.tptr)->value.fnctptr_ddd))( + (yystack_[5].value.val), (yystack_[3].value.val), (yystack_[1].value.val)); else (yylhs.value.val) = 0.0; } #line 1535 "apr_parser.cc" - break; + break; - case 120: // exp: FNCT LPAR sexp COMMA sexp COMMA exp RPAR + case 120: // exp: FNCT LPAR sexp COMMA sexp COMMA exp RPAR #line 476 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[7].value.tptr), (yystack_[7].value.tptr)->value.fnctptr_ccd == NULL)) - (yylhs.value.val) = (*((yystack_[7].value.tptr)->value.fnctptr_ccd))((yystack_[5].value.string), (yystack_[3].value.string), (yystack_[1].value.val)); + { + if (arg_check((yystack_[7].value.tptr), + (yystack_[7].value.tptr)->value.fnctptr_ccd == NULL)) + (yylhs.value.val) = (*((yystack_[7].value.tptr)->value.fnctptr_ccd))( + (yystack_[5].value.string), (yystack_[3].value.string), (yystack_[1].value.val)); else (yylhs.value.val) = 0.0; } #line 1546 "apr_parser.cc" - break; + break; - case 121: // exp: FNCT LPAR exp COMMA exp SEMI exp COMMA exp RPAR + case 121: // exp: FNCT LPAR exp COMMA exp SEMI exp COMMA exp RPAR #line 482 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[9].value.tptr), (yystack_[9].value.tptr)->value.fnctptr_dddd == NULL)) - (yylhs.value.val) = (*((yystack_[9].value.tptr)->value.fnctptr_dddd))((yystack_[7].value.val), (yystack_[5].value.val), (yystack_[3].value.val), (yystack_[1].value.val)); + { + if (arg_check((yystack_[9].value.tptr), + (yystack_[9].value.tptr)->value.fnctptr_dddd == NULL)) + (yylhs.value.val) = (*((yystack_[9].value.tptr)->value.fnctptr_dddd))( + (yystack_[7].value.val), (yystack_[5].value.val), (yystack_[3].value.val), + (yystack_[1].value.val)); else (yylhs.value.val) = 0.0; } #line 1557 "apr_parser.cc" - break; + break; - case 122: // exp: FNCT LPAR exp COMMA exp COMMA exp COMMA exp RPAR + case 122: // exp: FNCT LPAR exp COMMA exp COMMA exp COMMA exp RPAR #line 488 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[9].value.tptr), (yystack_[9].value.tptr)->value.fnctptr_dddd == NULL)) - (yylhs.value.val) = (*((yystack_[9].value.tptr)->value.fnctptr_dddd))((yystack_[7].value.val), (yystack_[5].value.val), (yystack_[3].value.val), (yystack_[1].value.val)); + { + if (arg_check((yystack_[9].value.tptr), + (yystack_[9].value.tptr)->value.fnctptr_dddd == NULL)) + (yylhs.value.val) = (*((yystack_[9].value.tptr)->value.fnctptr_dddd))( + (yystack_[7].value.val), (yystack_[5].value.val), (yystack_[3].value.val), + (yystack_[1].value.val)); else (yylhs.value.val) = 0.0; } #line 1568 "apr_parser.cc" - break; + break; - case 123: // exp: FNCT LPAR exp COMMA exp COMMA exp COMMA exp COMMA sexp RPAR + case 123: // exp: FNCT LPAR exp COMMA exp COMMA exp COMMA exp COMMA sexp RPAR #line 494 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[11].value.tptr), (yystack_[11].value.tptr)->value.fnctptr_ddddc == NULL)) - (yylhs.value.val) = (*((yystack_[11].value.tptr)->value.fnctptr_ddddc))((yystack_[9].value.val), (yystack_[7].value.val), (yystack_[5].value.val), (yystack_[3].value.val), (yystack_[1].value.string)); + { + if (arg_check((yystack_[11].value.tptr), + (yystack_[11].value.tptr)->value.fnctptr_ddddc == NULL)) + (yylhs.value.val) = (*((yystack_[11].value.tptr)->value.fnctptr_ddddc))( + (yystack_[9].value.val), (yystack_[7].value.val), (yystack_[5].value.val), + (yystack_[3].value.val), (yystack_[1].value.string)); else (yylhs.value.val) = 0.0; } #line 1579 "apr_parser.cc" - break; + break; - case 124: // exp: FNCT LPAR exp COMMA exp COMMA exp COMMA exp COMMA exp COMMA exp RPAR + case 124: // exp: FNCT LPAR exp COMMA exp COMMA exp COMMA exp COMMA exp COMMA exp RPAR #line 500 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { - if (arg_check((yystack_[13].value.tptr), (yystack_[13].value.tptr)->value.fnctptr_dddddd == NULL)) - (yylhs.value.val) = (*((yystack_[13].value.tptr)->value.fnctptr_dddddd))((yystack_[11].value.val), (yystack_[9].value.val), (yystack_[7].value.val), (yystack_[5].value.val), (yystack_[3].value.val), (yystack_[1].value.val)); + { + if (arg_check((yystack_[13].value.tptr), + (yystack_[13].value.tptr)->value.fnctptr_dddddd == NULL)) + (yylhs.value.val) = (*((yystack_[13].value.tptr)->value.fnctptr_dddddd))( + (yystack_[11].value.val), (yystack_[9].value.val), (yystack_[7].value.val), + (yystack_[5].value.val), (yystack_[3].value.val), (yystack_[1].value.val)); else (yylhs.value.val) = 0.0; } #line 1590 "apr_parser.cc" - break; + break; - case 125: // exp: exp PLU exp + case 125: // exp: exp PLU exp #line 506 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) + (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) + (yystack_[0].value.val); + } #line 1596 "apr_parser.cc" - break; + break; - case 126: // exp: exp SUB exp + case 126: // exp: exp SUB exp #line 507 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) - (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) - (yystack_[0].value.val); + } #line 1602 "apr_parser.cc" - break; + break; - case 127: // exp: exp TIM exp + case 127: // exp: exp TIM exp #line 508 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[2].value.val) * (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[2].value.val) * (yystack_[0].value.val); + } #line 1608 "apr_parser.cc" - break; + break; - case 128: // exp: exp DIV exp + case 128: // exp: exp DIV exp #line 509 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { if ((yystack_[0].value.val) == 0.) - { - yyerror(aprepro, "Zero divisor"); - yyerrok; - } - else - (yylhs.value.val) = (yystack_[2].value.val) / (yystack_[0].value.val); } + { + if ((yystack_[0].value.val) == 0.) { + yyerror(aprepro, "Zero divisor"); + yyerrok; + } + else + (yylhs.value.val) = (yystack_[2].value.val) / (yystack_[0].value.val); + } #line 1620 "apr_parser.cc" - break; + break; - case 129: // exp: exp MOD exp + case 129: // exp: exp MOD exp #line 516 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { if ((yystack_[0].value.val) == 0.) - { - yyerror(aprepro, "Zero divisor"); - yyerrok; - } - else - (yylhs.value.val) = (int)(yystack_[2].value.val) % (int)(yystack_[0].value.val); } + { + if ((yystack_[0].value.val) == 0.) { + yyerror(aprepro, "Zero divisor"); + yyerrok; + } + else + (yylhs.value.val) = (int)(yystack_[2].value.val) % (int)(yystack_[0].value.val); + } #line 1632 "apr_parser.cc" - break; + break; - case 130: // exp: SUB exp + case 130: // exp: SUB exp #line 523 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = -(yystack_[0].value.val); } + { + (yylhs.value.val) = -(yystack_[0].value.val); + } #line 1638 "apr_parser.cc" - break; + break; - case 131: // exp: PLU exp + case 131: // exp: PLU exp #line 524 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val); } + { + (yylhs.value.val) = (yystack_[0].value.val); + } #line 1644 "apr_parser.cc" - break; + break; - case 132: // exp: exp POW exp + case 132: // exp: exp POW exp #line 525 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { reset_error(); - (yylhs.value.val) = std::pow((yystack_[2].value.val), (yystack_[0].value.val)); - SEAMS::math_error(aprepro, "Power"); } + { + reset_error(); + (yylhs.value.val) = std::pow((yystack_[2].value.val), (yystack_[0].value.val)); + SEAMS::math_error(aprepro, "Power"); + } #line 1652 "apr_parser.cc" - break; + break; - case 133: // exp: LPAR exp RPAR + case 133: // exp: LPAR exp RPAR #line 528 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[1].value.val); } + { + (yylhs.value.val) = (yystack_[1].value.val); + } #line 1658 "apr_parser.cc" - break; + break; - case 134: // exp: LBRACK exp RBRACK + case 134: // exp: LBRACK exp RBRACK #line 529 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { reset_error(); - (yylhs.value.val) = (double)((yystack_[1].value.val) < 0 ? -floor(-((yystack_[1].value.val))): floor((yystack_[1].value.val)) ); - SEAMS::math_error(aprepro, "floor (int)"); } + { + reset_error(); + (yylhs.value.val) = + (double)((yystack_[1].value.val) < 0 ? -floor(-((yystack_[1].value.val))) + : floor((yystack_[1].value.val))); + SEAMS::math_error(aprepro, "floor (int)"); + } #line 1666 "apr_parser.cc" - break; + break; - case 135: // exp: bool + case 135: // exp: bool #line 532 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = ((yystack_[0].value.val)) ? 1 : 0; } + { + (yylhs.value.val) = ((yystack_[0].value.val)) ? 1 : 0; + } #line 1672 "apr_parser.cc" - break; + break; - case 136: // exp: bool QUEST exp COLON exp + case 136: // exp: bool QUEST exp COLON exp #line 533 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = ((yystack_[4].value.val)) ? ((yystack_[2].value.val)) : ((yystack_[0].value.val)); } + { + (yylhs.value.val) = + ((yystack_[4].value.val)) ? ((yystack_[2].value.val)) : ((yystack_[0].value.val)); + } #line 1678 "apr_parser.cc" - break; + break; - case 137: // exp: AVAR LBRACK exp RBRACK + case 137: // exp: AVAR LBRACK exp RBRACK #line 534 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = array_value((yystack_[3].value.tptr)->value.avar, (yystack_[1].value.val), 0); } + { + (yylhs.value.val) = + array_value((yystack_[3].value.tptr)->value.avar, (yystack_[1].value.val), 0); + } #line 1684 "apr_parser.cc" - break; + break; - case 138: // exp: AVAR LBRACK exp COMMA exp RBRACK + case 138: // exp: AVAR LBRACK exp COMMA exp RBRACK #line 535 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = array_value((yystack_[5].value.tptr)->value.avar, (yystack_[3].value.val), (yystack_[1].value.val)); } + { + (yylhs.value.val) = array_value((yystack_[5].value.tptr)->value.avar, + (yystack_[3].value.val), (yystack_[1].value.val)); + } #line 1690 "apr_parser.cc" - break; + break; - case 139: // exp: AVAR LBRACK exp RBRACK EQUAL exp + case 139: // exp: AVAR LBRACK exp RBRACK EQUAL exp #line 537 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val); - array *arr = (yystack_[5].value.tptr)->value.avar; - int cols = arr->cols; - if (cols > 1) { - yyerror(aprepro, "Cannot use [index] array access with multi-column array"); - yyerrok; - } - int rows = arr->rows; - int row = (yystack_[3].value.val); - if (aprepro.ap_options.one_based_index) { - row--; - } - if (row < rows) { - int offset = row*cols; - (yystack_[5].value.tptr)->value.avar->data[offset] = (yystack_[0].value.val); - } - else { - yyerror(aprepro, "Row or Column index out of range"); - yyerrok; - } - } + { + (yylhs.value.val) = (yystack_[0].value.val); + array *arr = (yystack_[5].value.tptr)->value.avar; + int cols = arr->cols; + if (cols > 1) { + yyerror(aprepro, "Cannot use [index] array access with multi-column array"); + yyerrok; + } + int rows = arr->rows; + int row = (yystack_[3].value.val); + if (aprepro.ap_options.one_based_index) { + row--; + } + if (row < rows) { + int offset = row * cols; + (yystack_[5].value.tptr)->value.avar->data[offset] = (yystack_[0].value.val); + } + else { + yyerror(aprepro, "Row or Column index out of range"); + yyerrok; + } + } #line 1716 "apr_parser.cc" - break; + break; - case 140: // exp: AVAR LBRACK exp COMMA exp RBRACK EQUAL exp + case 140: // exp: AVAR LBRACK exp COMMA exp RBRACK EQUAL exp #line 559 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - { (yylhs.value.val) = (yystack_[0].value.val); - array *arr = (yystack_[7].value.tptr)->value.avar; - int cols = arr->cols; - int rows = arr->rows; - int row = (yystack_[5].value.val); - int col = (yystack_[3].value.val); - if (aprepro.ap_options.one_based_index) { - row--; - col--; - } - if (row < rows && col < cols) { - int offset = row*cols+col; - (yystack_[7].value.tptr)->value.avar->data[offset] = (yystack_[0].value.val); - } - else { - yyerror(aprepro, "Row or Column index out of range"); - yyerrok; - } - } + { + (yylhs.value.val) = (yystack_[0].value.val); + array *arr = (yystack_[7].value.tptr)->value.avar; + int cols = arr->cols; + int rows = arr->rows; + int row = (yystack_[5].value.val); + int col = (yystack_[3].value.val); + if (aprepro.ap_options.one_based_index) { + row--; + col--; + } + if (row < rows && col < cols) { + int offset = row * cols + col; + (yystack_[7].value.tptr)->value.avar->data[offset] = (yystack_[0].value.val); + } + else { + yyerror(aprepro, "Row or Column index out of range"); + yyerrok; + } + } #line 1740 "apr_parser.cc" - break; - + break; #line 1744 "apr_parser.cc" - default: - break; - } + default: break; + } } #if YY_EXCEPTIONS - catch (const syntax_error& yyexc) - { + catch (const syntax_error &yyexc) { YYCDEBUG << "Caught exception: " << yyexc.what() << '\n'; - error (yyexc); + error(yyexc); YYERROR; } #endif // YY_EXCEPTIONS - YY_SYMBOL_PRINT ("-> $$ =", yylhs); - yypop_ (yylen); - yylen = 0; - - // Shift the result of the reduction. - yypush_ (YY_NULLPTR, YY_MOVE (yylhs)); - } - goto yynewstate; - + YY_SYMBOL_PRINT("-> $$ =", yylhs); + yypop_(yylen); + yylen = 0; - /*--------------------------------------. - | yyerrlab -- here on detecting error. | - `--------------------------------------*/ - yyerrlab: - // If not already recovering from an error, report this error. - if (!yyerrstatus_) - { + // Shift the result of the reduction. + yypush_(YY_NULLPTR, YY_MOVE(yylhs)); + } + goto yynewstate; + + /*--------------------------------------. + | yyerrlab -- here on detecting error. | + `--------------------------------------*/ + yyerrlab: + // If not already recovering from an error, report this error. + if (!yyerrstatus_) { ++yynerrs_; - context yyctx (*this, yyla); - std::string msg = yysyntax_error_ (yyctx); - error (YY_MOVE (msg)); + context yyctx(*this, yyla); + std::string msg = yysyntax_error_(yyctx); + error(YY_MOVE(msg)); } - - if (yyerrstatus_ == 3) - { + if (yyerrstatus_ == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ // Return failure if at end of input. - if (yyla.kind () == symbol_kind::S_YYEOF) + if (yyla.kind() == symbol_kind::S_YYEOF) YYABORT; - else if (!yyla.empty ()) - { - yy_destroy_ ("Error: discarding", yyla); - yyla.clear (); - } + else if (!yyla.empty()) { + yy_destroy_("Error: discarding", yyla); + yyla.clear(); + } } - // Else will try to reuse lookahead token after shifting the error token. - goto yyerrlab1; - - - /*---------------------------------------------------. - | yyerrorlab -- error raised explicitly by YYERROR. | - `---------------------------------------------------*/ - yyerrorlab: - /* Pacify compilers when the user code never invokes YYERROR and - the label yyerrorlab therefore never appears in user code. */ - if (false) - YYERROR; - - /* Do not reclaim the symbols of the rule whose action triggered - this YYERROR. */ - yypop_ (yylen); - yylen = 0; - YY_STACK_PRINT (); - goto yyerrlab1; - - - /*-------------------------------------------------------------. - | yyerrlab1 -- common code for both syntax error and YYERROR. | - `-------------------------------------------------------------*/ - yyerrlab1: - yyerrstatus_ = 3; // Each real token shifted decrements this. - // Pop stack until we find a state that shifts the error token. - for (;;) - { + // Else will try to reuse lookahead token after shifting the error token. + goto yyerrlab1; + + /*---------------------------------------------------. + | yyerrorlab -- error raised explicitly by YYERROR. | + `---------------------------------------------------*/ + yyerrorlab: + /* Pacify compilers when the user code never invokes YYERROR and + the label yyerrorlab therefore never appears in user code. */ + if (false) + YYERROR; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + yypop_(yylen); + yylen = 0; + YY_STACK_PRINT(); + goto yyerrlab1; + + /*-------------------------------------------------------------. + | yyerrlab1 -- common code for both syntax error and YYERROR. | + `-------------------------------------------------------------*/ + yyerrlab1: + yyerrstatus_ = 3; // Each real token shifted decrements this. + // Pop stack until we find a state that shifts the error token. + for (;;) { yyn = yypact_[+yystack_[0].state]; - if (!yy_pact_value_is_default_ (yyn)) - { - yyn += symbol_kind::S_YYerror; - if (0 <= yyn && yyn <= yylast_ - && yycheck_[yyn] == symbol_kind::S_YYerror) - { - yyn = yytable_[yyn]; - if (0 < yyn) - break; - } + if (!yy_pact_value_is_default_(yyn)) { + yyn += symbol_kind::S_YYerror; + if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == symbol_kind::S_YYerror) { + yyn = yytable_[yyn]; + if (0 < yyn) + break; } + } // Pop the current state because it cannot handle the error token. - if (yystack_.size () == 1) + if (yystack_.size() == 1) YYABORT; - yy_destroy_ ("Error: popping", yystack_[0]); - yypop_ (); - YY_STACK_PRINT (); + yy_destroy_("Error: popping", yystack_[0]); + yypop_(); + YY_STACK_PRINT(); } - { - stack_symbol_type error_token; - - - // Shift the error token. - error_token.state = state_type (yyn); - yypush_ ("Shifting", YY_MOVE (error_token)); - } - goto yynewstate; - - - /*-------------------------------------. - | yyacceptlab -- YYACCEPT comes here. | - `-------------------------------------*/ - yyacceptlab: - yyresult = 0; - goto yyreturn; - - - /*-----------------------------------. - | yyabortlab -- YYABORT comes here. | - `-----------------------------------*/ - yyabortlab: - yyresult = 1; - goto yyreturn; - - - /*-----------------------------------------------------. - | yyreturn -- parsing is finished, return the result. | - `-----------------------------------------------------*/ - yyreturn: - if (!yyla.empty ()) - yy_destroy_ ("Cleanup: discarding lookahead", yyla); - - /* Do not reclaim the symbols of the rule whose action triggered - this YYABORT or YYACCEPT. */ - yypop_ (yylen); - YY_STACK_PRINT (); - while (1 < yystack_.size ()) { - yy_destroy_ ("Cleanup: popping", yystack_[0]); - yypop_ (); + stack_symbol_type error_token; + + // Shift the error token. + error_token.state = state_type(yyn); + yypush_("Shifting", YY_MOVE(error_token)); + } + goto yynewstate; + + /*-------------------------------------. + | yyacceptlab -- YYACCEPT comes here. | + `-------------------------------------*/ + yyacceptlab: + yyresult = 0; + goto yyreturn; + + /*-----------------------------------. + | yyabortlab -- YYABORT comes here. | + `-----------------------------------*/ + yyabortlab: + yyresult = 1; + goto yyreturn; + + /*-----------------------------------------------------. + | yyreturn -- parsing is finished, return the result. | + `-----------------------------------------------------*/ + yyreturn: + if (!yyla.empty()) + yy_destroy_("Cleanup: discarding lookahead", yyla); + + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + yypop_(yylen); + YY_STACK_PRINT(); + while (1 < yystack_.size()) { + yy_destroy_("Cleanup: popping", yystack_[0]); + yypop_(); } - return yyresult; - } + return yyresult; + } #if YY_EXCEPTIONS - catch (...) - { - YYCDEBUG << "Exception caught: cleaning lookahead and stack\n"; - // Do not try to display the values of the reclaimed symbols, - // as their printers might throw an exception. - if (!yyla.empty ()) - yy_destroy_ (YY_NULLPTR, yyla); - - while (1 < yystack_.size ()) - { - yy_destroy_ (YY_NULLPTR, yystack_[0]); - yypop_ (); - } - throw; + catch (...) { + YYCDEBUG << "Exception caught: cleaning lookahead and stack\n"; + // Do not try to display the values of the reclaimed symbols, + // as their printers might throw an exception. + if (!yyla.empty()) + yy_destroy_(YY_NULLPTR, yyla); + + while (1 < yystack_.size()) { + yy_destroy_(YY_NULLPTR, yystack_[0]); + yypop_(); } + throw; + } #endif // YY_EXCEPTIONS } - void - Parser::error (const syntax_error& yyexc) - { - error (yyexc.what ()); - } + void Parser::error(const syntax_error &yyexc) { error(yyexc.what()); } /* Return YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. */ - std::string - Parser::yytnamerr_ (const char *yystr) + std::string Parser::yytnamerr_(const char *yystr) { - if (*yystr == '"') - { - std::string yyr; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - else - goto append; - - append: - default: - yyr += *yyp; - break; + if (*yystr == '"') { + std::string yyr; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) { + case '\'': + case ',': goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + else + goto append; - case '"': - return yyr; - } - do_not_strip_quotes: ; - } + append: + default: yyr += *yyp; break; + + case '"': return yyr; + } + do_not_strip_quotes:; + } return yystr; } - std::string - Parser::symbol_name (symbol_kind_type yysymbol) + std::string Parser::symbol_name(symbol_kind_type yysymbol) { - return yytnamerr_ (yytname_[yysymbol]); + return yytnamerr_(yytname_[yysymbol]); } - - // Parser::context. - Parser::context::context (const Parser& yyparser, const symbol_type& yyla) - : yyparser_ (yyparser) - , yyla_ (yyla) - {} + Parser::context::context(const Parser &yyparser, const symbol_type &yyla) + : yyparser_(yyparser), yyla_(yyla) + { + } - int - Parser::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const + int Parser::context::expected_tokens(symbol_kind_type yyarg[], int yyargn) const { // Actual number of expected tokens int yycount = 0; const int yyn = yypact_[+yyparser_.yystack_[0].state]; - if (!yy_pact_value_is_default_ (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - const int yyxbegin = yyn < 0 ? -yyn : 0; - // Stay within bounds of both yycheck and yytname. - const int yychecklim = yylast_ - yyn + 1; - const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - for (int yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::S_YYerror - && !yy_table_value_is_error_ (yytable_[yyx + yyn])) - { - if (!yyarg) - ++yycount; - else if (yycount == yyargn) - return 0; - else - yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx); - } - } + if (!yy_pact_value_is_default_(yyn)) { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + const int yyxbegin = yyn < 0 ? -yyn : 0; + // Stay within bounds of both yycheck and yytname. + const int yychecklim = yylast_ - yyn + 1; + const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + for (int yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::S_YYerror && + !yy_table_value_is_error_(yytable_[yyx + yyn])) { + if (!yyarg) + ++yycount; + else if (yycount == yyargn) + return 0; + else + yyarg[yycount++] = YY_CAST(symbol_kind_type, yyx); + } + } if (yyarg && yycount == 0 && 0 < yyargn) yyarg[0] = symbol_kind::S_YYEMPTY; return yycount; } - - - - - - int - Parser::yy_syntax_error_arguments_ (const context& yyctx, - symbol_kind_type yyarg[], int yyargn) const + int Parser::yy_syntax_error_arguments_(const context &yyctx, symbol_kind_type yyarg[], + int yyargn) const { /* There are many possibilities here to consider: - If this state is a consistent state with a default action, then @@ -2036,621 +2202,401 @@ namespace SEAMS { accepted due to an error action in a later state. */ - if (!yyctx.lookahead ().empty ()) - { - if (yyarg) - yyarg[0] = yyctx.token (); - int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1); - return yyn + 1; - } + if (!yyctx.lookahead().empty()) { + if (yyarg) + yyarg[0] = yyctx.token(); + int yyn = yyctx.expected_tokens(yyarg ? yyarg + 1 : yyarg, yyargn - 1); + return yyn + 1; + } return 0; } // Generate an error message. - std::string - Parser::yysyntax_error_ (const context& yyctx) const + std::string Parser::yysyntax_error_(const context &yyctx) const { // Its maximum. enum { YYARGS_MAX = 5 }; // Arguments of yyformat. symbol_kind_type yyarg[YYARGS_MAX]; - int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX); - - char const* yyformat = YY_NULLPTR; - switch (yycount) - { -#define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - default: // Avoid compiler warnings. - YYCASE_ (0, YY_("syntax error")); - YYCASE_ (1, YY_("syntax error, unexpected %s")); - YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); + int yycount = yy_syntax_error_arguments_(yyctx, yyarg, YYARGS_MAX); + + char const *yyformat = YY_NULLPTR; + switch (yycount) { +#define YYCASE_(N, S) \ + case N: yyformat = S; break + default: // Avoid compiler warnings. + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); #undef YYCASE_ - } + } std::string yyres; // Argument number. std::ptrdiff_t yyi = 0; - for (char const* yyp = yyformat; *yyp; ++yyp) - if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) - { - yyres += symbol_name (yyarg[yyi++]); - ++yyp; - } + for (char const *yyp = yyformat; *yyp; ++yyp) + if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) { + yyres += symbol_name(yyarg[yyi++]); + ++yyp; + } else yyres += *yyp; return yyres; } - const signed char Parser::yypact_ninf_ = -37; const signed char Parser::yytable_ninf_ = -1; - const short - Parser::yypact_[] = - { - -37, 2, -37, -7, 281, -37, -37, -37, -37, -37, - 233, 284, 0, 311, 11, -5, 19, 27, 35, 399, - 399, -37, 399, 384, 399, 116, 163, 175, 178, 41, - 1151, 384, 399, 399, 399, 399, 399, -37, -37, 384, - 399, 399, 399, 399, 399, -37, -37, 384, 399, 399, - 399, 399, 399, 399, -37, -37, 399, 399, 384, 225, - 339, 384, 482, 625, 36, 73, 399, 101, 1199, 889, - 1103, 14, -37, 14, 14, -37, -37, -37, -37, -37, - -37, -37, -37, 399, 399, 399, -37, 384, 384, 399, - 384, -37, 399, 399, 399, 399, 399, 399, 399, -37, - 399, 399, 399, 399, 399, 399, 399, 399, 399, 399, - 399, 384, 399, 399, 29, 1199, 1218, 1234, 1234, 1234, - 1234, 1234, 29, 1199, 1218, 1234, 1234, 1234, 1234, 1234, - 29, 1199, 1218, 1199, 1234, 1234, 1234, 1234, 1234, 1234, - 1199, 1234, 624, 29, 1199, 1218, -37, -15, 78, 654, - -37, 25, 418, 684, 100, 425, 714, 399, 399, 399, - 399, 14, -37, -37, 399, -37, 1165, 1185, 51, 1265, - -37, 1279, -36, 1218, -36, 1250, -37, 1250, 12, 1234, - 12, 12, 12, 12, 12, -37, 51, 1265, -37, 1279, - -31, -31, -31, -31, -31, -31, 155, 155, 14, -37, - 14, 14, 14, 399, 69, -37, 399, -37, 399, -37, - -37, 399, -37, 399, -37, -37, 399, -37, 399, -37, - 1234, 1234, 1234, 1234, 14, 399, 399, 1128, 399, 449, - 916, 141, 595, 455, 485, 943, 515, 970, 744, 1199, - 1234, 96, 1234, 399, -37, -37, -37, 399, -37, 399, - 399, -37, 399, -37, -37, -37, 399, -37, 399, 537, - 997, 774, 833, 543, 479, 1024, 1234, -37, -37, 399, - -37, 399, -37, 399, -37, -37, 804, 1051, 509, 399, - -37, -37, 399, 565, 862, 571, -37, 399, -37, 1078, - -37 - }; - - const unsigned char - Parser::yydefact_[] = - { - 2, 0, 1, 0, 0, 4, 3, 9, 71, 51, - 99, 74, 52, 75, 53, 32, 0, 0, 0, 0, - 0, 8, 0, 0, 0, 0, 0, 135, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 102, 103, 0, - 0, 0, 0, 0, 0, 78, 79, 0, 0, 0, - 0, 0, 0, 0, 90, 91, 0, 0, 0, 0, - 0, 0, 99, 74, 52, 0, 0, 135, 0, 0, - 0, 131, 45, 130, 12, 72, 100, 76, 88, 73, - 101, 77, 89, 0, 0, 0, 7, 0, 0, 0, - 0, 6, 0, 0, 0, 0, 0, 0, 0, 5, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 43, 54, 104, 105, 106, 107, - 108, 109, 41, 56, 80, 83, 84, 85, 86, 87, - 40, 55, 81, 59, 92, 94, 95, 96, 97, 98, - 58, 93, 0, 42, 57, 82, 110, 0, 0, 0, - 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 130, 25, 133, 0, 134, 0, 0, 19, 21, - 20, 22, 44, 0, 46, 48, 50, 47, 26, 0, - 27, 28, 29, 30, 31, 64, 23, 17, 24, 18, - 10, 11, 13, 14, 15, 16, 125, 126, 128, 49, - 127, 129, 132, 0, 137, 113, 0, 112, 0, 111, - 63, 0, 60, 0, 62, 39, 0, 33, 0, 38, - 104, 80, 81, 82, 127, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, - 136, 138, 139, 0, 116, 114, 115, 0, 118, 0, - 0, 69, 0, 65, 35, 34, 0, 37, 0, 0, - 0, 0, 0, 0, 0, 0, 140, 117, 120, 0, - 119, 0, 68, 0, 67, 36, 0, 0, 0, 0, - 122, 121, 0, 0, 0, 0, 123, 0, 66, 0, - 124 - }; - - const signed char - Parser::yypgoto_[] = - { - -37, -37, -37, -13, 104, 89, -4 - }; - - const unsigned char - Parser::yydefgoto_[] = - { - 0, 1, 6, 27, 28, 68, 179 - }; - - const short - Parser::yytable_[] = - { - 30, 205, 2, 3, 89, 90, 67, 108, 109, 110, - 164, 112, 57, 7, 113, 69, 70, 58, 71, 73, - 74, 4, 47, 87, 88, 89, 90, 116, 117, 118, - 119, 120, 121, 56, 59, 124, 125, 126, 127, 128, - 129, 210, 60, 132, 134, 135, 136, 137, 138, 139, - 61, 5, 141, 142, 145, 149, 153, 156, 159, 113, - 98, 91, 161, 87, 88, 89, 90, 87, 88, 89, - 90, 168, 170, 92, 93, 94, 95, 96, 97, 167, - 169, 171, 85, 173, 173, 175, 177, 186, 188, 98, - 57, 228, 206, 29, 207, 160, 187, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 200, 201, 202, - 92, 93, 94, 95, 96, 97, 215, 162, 258, 75, - 115, 76, 77, 0, 78, 0, 98, 72, 123, 83, - 0, 84, 85, 0, 0, 114, 131, 133, 87, 88, - 89, 90, 0, 122, 0, 140, 0, 144, 148, 152, - 155, 130, 0, 220, 221, 222, 223, 246, 0, 0, - 224, 0, 143, 147, 151, 154, 79, 0, 80, 81, - 0, 82, 166, 92, 93, 94, 95, 96, 97, 0, - 0, 178, 180, 181, 182, 183, 184, 185, 0, 98, - 0, 172, 174, 0, 176, 110, 164, 112, 86, 227, - 113, 0, 230, 83, 232, 84, 85, 0, 0, 235, - 0, 0, 237, 0, 238, 199, 87, 88, 89, 90, - 0, 0, 240, 0, 242, 0, 0, 0, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 260, - 19, 146, 20, 261, 0, 262, 115, 123, 131, 144, - 0, 0, 265, 0, 266, 31, 32, 33, 34, 35, - 36, 0, 0, 22, 23, 276, 0, 277, 0, 24, - 0, 25, 26, 0, 0, 284, 0, 0, 0, 37, - 38, 0, 0, 289, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 229, 19, 231, 20, 0, - 233, 21, 234, 0, 0, 236, 39, 40, 41, 42, - 43, 44, 0, 0, 239, 0, 0, 0, 0, 22, - 23, 0, 0, 0, 0, 24, 0, 25, 26, 0, - 45, 46, 259, 48, 49, 50, 51, 52, 53, 263, - 0, 264, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 0, 19, 150, 20, 54, 55, 0, - 0, 0, 278, 0, 0, 0, 0, 0, 283, 0, - 0, 285, 0, 0, 0, 0, 0, 22, 23, 0, - 0, 0, 0, 24, 0, 25, 26, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 0, 19, - 0, 20, 8, 9, 62, 63, 64, 13, 14, 65, - 16, 17, 0, 0, 19, 0, 20, 0, 0, 0, - 0, 0, 22, 23, 0, 0, 0, 0, 24, 0, - 25, 26, 211, 0, 212, 0, 0, 22, 66, 216, - 0, 217, 0, 24, 0, 25, 26, 0, 0, 0, - 92, 93, 94, 95, 96, 97, 0, 92, 93, 94, - 95, 96, 97, 243, 0, 244, 98, 0, 0, 250, - 0, 251, 0, 98, 0, 0, 0, 0, 0, 0, - 0, 92, 93, 94, 95, 96, 97, 92, 93, 94, - 95, 96, 97, 273, 0, 274, 0, 98, 0, 252, - 0, 0, 0, 98, 157, 32, 33, 34, 35, 36, - 0, 92, 93, 94, 95, 96, 97, 92, 93, 94, - 95, 96, 97, 282, 0, 0, 0, 98, 37, 38, - 0, 254, 0, 98, 0, 0, 0, 0, 0, 0, - 0, 92, 93, 94, 95, 96, 97, 92, 93, 94, - 95, 96, 97, 267, 0, 0, 0, 98, 0, 272, - 0, 0, 0, 98, 0, 0, 0, 0, 0, 92, - 93, 94, 95, 96, 97, 92, 93, 94, 95, 96, - 97, 286, 0, 0, 0, 98, 0, 288, 0, 0, - 0, 98, 0, 0, 0, 0, 0, 92, 93, 94, - 95, 96, 97, 92, 93, 94, 95, 96, 97, 247, - 0, 248, 0, 98, 0, 0, 249, 0, 0, 98, - 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 164, 112, 203, 0, - 113, 0, 204, 0, 0, 0, 0, 158, 40, 41, - 42, 43, 44, 0, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 164, 112, 0, 208, 113, - 209, 45, 46, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 0, 213, 113, - 214, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 0, 218, 113, - 219, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 0, 256, 113, - 257, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 164, 112, 0, 269, 113, - 270, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 164, 112, 0, 279, 113, - 280, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 164, 112, 271, 0, 113, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 164, 112, 287, 0, 113, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 164, 112, 163, 0, 113, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 164, 112, 245, 0, 113, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 164, 112, 253, - 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 164, 112, 255, 0, 113, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 164, 112, 268, 0, 113, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, - 275, 0, 113, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 164, 112, 281, 0, 113, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 164, 112, 290, 0, 113, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, - 112, 165, 0, 113, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 164, 112, 241, 0, 113, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, - 112, 99, 0, 113, 0, 0, 0, 0, 0, 0, - 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 111, 112, 225, 0, 113, 92, 93, 94, - 95, 96, 97, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 98, 226, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 164, 112, 0, 0, - 113, 92, 93, 94, 95, 96, 97, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 98, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 0, 0, 113, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 164, 112, 0, 0, 113, - 100, 101, 102, 103, 104, 105, 106, 107, 0, 0, - 0, 0, 112, 0, 0, 113, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 164, 112, 0, 0, - 113, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 164, 112, 0, 0, 113 - }; - - const short - Parser::yycheck_[] = - { - 4, 16, 0, 1, 40, 41, 19, 38, 39, 40, - 41, 42, 17, 20, 45, 19, 20, 22, 22, 23, - 24, 19, 22, 38, 39, 40, 41, 31, 32, 33, - 34, 35, 36, 22, 15, 39, 40, 41, 42, 43, - 44, 16, 15, 47, 48, 49, 50, 51, 52, 53, - 15, 49, 56, 57, 58, 59, 60, 61, 22, 45, - 48, 20, 66, 38, 39, 40, 41, 38, 39, 40, - 41, 84, 85, 32, 33, 34, 35, 36, 37, 83, - 84, 85, 31, 87, 88, 89, 90, 100, 101, 48, - 17, 22, 14, 4, 16, 22, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 32, 33, 34, 35, 36, 37, 16, 16, 22, 3, - 31, 5, 6, -1, 8, -1, 48, 23, 39, 28, - -1, 30, 31, -1, -1, 31, 47, 48, 38, 39, - 40, 41, -1, 39, -1, 56, -1, 58, 59, 60, - 61, 47, -1, 157, 158, 159, 160, 16, -1, -1, - 164, -1, 58, 59, 60, 61, 3, -1, 5, 6, - -1, 8, 83, 32, 33, 34, 35, 36, 37, -1, - -1, 92, 93, 94, 95, 96, 97, 98, -1, 48, - -1, 87, 88, -1, 90, 40, 41, 42, 20, 203, - 45, -1, 206, 28, 208, 30, 31, -1, -1, 213, - -1, -1, 216, -1, 218, 111, 38, 39, 40, 41, - -1, -1, 226, -1, 228, -1, -1, -1, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 243, - 15, 16, 17, 247, -1, 249, 157, 158, 159, 160, - -1, -1, 256, -1, 258, 22, 23, 24, 25, 26, - 27, -1, -1, 38, 39, 269, -1, 271, -1, 44, - -1, 46, 47, -1, -1, 279, -1, -1, -1, 46, - 47, -1, -1, 287, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 206, 15, 208, 17, -1, - 211, 20, 213, -1, -1, 216, 22, 23, 24, 25, - 26, 27, -1, -1, 225, -1, -1, -1, -1, 38, - 39, -1, -1, -1, -1, 44, -1, 46, 47, -1, - 46, 47, 243, 22, 23, 24, 25, 26, 27, 250, - -1, 252, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, -1, 15, 16, 17, 46, 47, -1, - -1, -1, 273, -1, -1, -1, -1, -1, 279, -1, - -1, 282, -1, -1, -1, -1, -1, 38, 39, -1, - -1, -1, -1, 44, -1, 46, 47, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, -1, 15, - -1, 17, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, -1, -1, 15, -1, 17, -1, -1, -1, - -1, -1, 38, 39, -1, -1, -1, -1, 44, -1, - 46, 47, 14, -1, 16, -1, -1, 38, 39, 14, - -1, 16, -1, 44, -1, 46, 47, -1, -1, -1, - 32, 33, 34, 35, 36, 37, -1, 32, 33, 34, - 35, 36, 37, 14, -1, 16, 48, -1, -1, 14, - -1, 16, -1, 48, -1, -1, -1, -1, -1, -1, - -1, 32, 33, 34, 35, 36, 37, 32, 33, 34, - 35, 36, 37, 14, -1, 16, -1, 48, -1, 14, - -1, -1, -1, 48, 22, 23, 24, 25, 26, 27, - -1, 32, 33, 34, 35, 36, 37, 32, 33, 34, - 35, 36, 37, 14, -1, -1, -1, 48, 46, 47, - -1, 16, -1, 48, -1, -1, -1, -1, -1, -1, - -1, 32, 33, 34, 35, 36, 37, 32, 33, 34, - 35, 36, 37, 16, -1, -1, -1, 48, -1, 16, - -1, -1, -1, 48, -1, -1, -1, -1, -1, 32, - 33, 34, 35, 36, 37, 32, 33, 34, 35, 36, - 37, 16, -1, -1, -1, 48, -1, 16, -1, -1, - -1, 48, -1, -1, -1, -1, -1, 32, 33, 34, - 35, 36, 37, 32, 33, 34, 35, 36, 37, 14, - -1, 16, -1, 48, -1, -1, 21, -1, -1, 48, - -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 14, -1, - 45, -1, 18, -1, -1, -1, -1, 22, 23, 24, - 25, 26, 27, -1, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, - 16, 46, 47, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, - 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, - 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, - 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, - 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, - 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 14, -1, 45, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 14, -1, 45, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 16, -1, 45, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 16, -1, 45, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 16, - -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 16, -1, 45, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 16, -1, 45, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 16, -1, 45, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 16, -1, 45, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 16, -1, 45, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 18, -1, 45, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 18, -1, 45, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 20, -1, 45, -1, -1, -1, -1, -1, -1, - -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 29, -1, 45, 32, 33, 34, - 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 48, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, -1, -1, - 45, 32, 33, 34, 35, 36, 37, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 48, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, -1, -1, 45, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, -1, -1, 45, - 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, - -1, -1, 42, -1, -1, 45, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, -1, -1, - 45, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, -1, -1, 45 - }; - - const signed char - Parser::yystos_[] = - { - 0, 51, 0, 1, 19, 49, 52, 20, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, - 17, 20, 38, 39, 44, 46, 47, 53, 54, 55, - 56, 22, 23, 24, 25, 26, 27, 46, 47, 22, - 23, 24, 25, 26, 27, 46, 47, 22, 22, 23, - 24, 25, 26, 27, 46, 47, 22, 17, 22, 15, - 15, 15, 5, 6, 7, 10, 39, 53, 55, 56, - 56, 56, 54, 56, 56, 3, 5, 6, 8, 3, - 5, 6, 8, 28, 30, 31, 20, 38, 39, 40, - 41, 20, 32, 33, 34, 35, 36, 37, 48, 20, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 45, 54, 55, 56, 56, 56, 56, - 56, 56, 54, 55, 56, 56, 56, 56, 56, 56, - 54, 55, 56, 55, 56, 56, 56, 56, 56, 56, - 55, 56, 56, 54, 55, 56, 16, 54, 55, 56, - 16, 54, 55, 56, 54, 55, 56, 22, 22, 22, - 22, 56, 16, 16, 41, 18, 55, 56, 53, 56, - 53, 56, 54, 56, 54, 56, 54, 56, 55, 56, - 55, 55, 55, 55, 55, 55, 53, 56, 53, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 54, - 56, 56, 56, 14, 18, 16, 14, 16, 14, 16, - 16, 14, 16, 14, 16, 16, 14, 16, 14, 16, - 56, 56, 56, 56, 56, 29, 29, 56, 22, 55, - 56, 55, 56, 55, 55, 56, 55, 56, 56, 55, - 56, 18, 56, 14, 16, 16, 16, 14, 16, 21, - 14, 16, 14, 16, 16, 16, 14, 16, 22, 55, - 56, 56, 56, 55, 55, 56, 56, 16, 16, 14, - 16, 14, 16, 14, 16, 16, 56, 56, 55, 14, - 16, 16, 14, 55, 56, 55, 16, 14, 16, 56, - 16 - }; - - const signed char - Parser::yyr1_[] = - { - 0, 50, 51, 51, 52, 52, 52, 52, 52, 52, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, - 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56 - }; - - const signed char - Parser::yyr2_[] = - { - 0, 2, 0, 2, 1, 3, 3, 3, 2, 2, - 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 1, 4, 6, 6, 8, 6, 4, 4, - 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, - 3, 1, 1, 1, 3, 3, 3, 3, 3, 3, - 4, 3, 4, 4, 3, 6, 12, 8, 8, 6, - 5, 1, 2, 2, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, - 2, 2, 3, 3, 3, 3, 3, 3, 3, 1, - 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, - 3, 4, 4, 4, 6, 6, 6, 8, 6, 8, - 8, 10, 10, 12, 14, 3, 3, 3, 3, 3, - 2, 2, 3, 3, 3, 1, 5, 4, 6, 6, - 8 - }; - + const short Parser::yypact_[] = { + -37, 2, -37, -7, 281, -37, -37, -37, -37, -37, 233, 284, 0, 311, 11, + -5, 19, 27, 35, 399, 399, -37, 399, 384, 399, 116, 163, 175, 178, 41, + 1151, 384, 399, 399, 399, 399, 399, -37, -37, 384, 399, 399, 399, 399, 399, + -37, -37, 384, 399, 399, 399, 399, 399, 399, -37, -37, 399, 399, 384, 225, + 339, 384, 482, 625, 36, 73, 399, 101, 1199, 889, 1103, 14, -37, 14, 14, + -37, -37, -37, -37, -37, -37, -37, -37, 399, 399, 399, -37, 384, 384, 399, + 384, -37, 399, 399, 399, 399, 399, 399, 399, -37, 399, 399, 399, 399, 399, + 399, 399, 399, 399, 399, 399, 384, 399, 399, 29, 1199, 1218, 1234, 1234, 1234, + 1234, 1234, 29, 1199, 1218, 1234, 1234, 1234, 1234, 1234, 29, 1199, 1218, 1199, 1234, + 1234, 1234, 1234, 1234, 1234, 1199, 1234, 624, 29, 1199, 1218, -37, -15, 78, 654, + -37, 25, 418, 684, 100, 425, 714, 399, 399, 399, 399, 14, -37, -37, 399, + -37, 1165, 1185, 51, 1265, -37, 1279, -36, 1218, -36, 1250, -37, 1250, 12, 1234, + 12, 12, 12, 12, 12, -37, 51, 1265, -37, 1279, -31, -31, -31, -31, -31, + -31, 155, 155, 14, -37, 14, 14, 14, 399, 69, -37, 399, -37, 399, -37, + -37, 399, -37, 399, -37, -37, 399, -37, 399, -37, 1234, 1234, 1234, 1234, 14, + 399, 399, 1128, 399, 449, 916, 141, 595, 455, 485, 943, 515, 970, 744, 1199, + 1234, 96, 1234, 399, -37, -37, -37, 399, -37, 399, 399, -37, 399, -37, -37, + -37, 399, -37, 399, 537, 997, 774, 833, 543, 479, 1024, 1234, -37, -37, 399, + -37, 399, -37, 399, -37, -37, 804, 1051, 509, 399, -37, -37, 399, 565, 862, + 571, -37, 399, -37, 1078, -37}; + + const unsigned char Parser::yydefact_[] = { + 2, 0, 1, 0, 0, 4, 3, 9, 71, 51, 99, 74, 52, 75, 53, 32, 0, 0, 0, + 0, 0, 8, 0, 0, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, + 103, 0, 0, 0, 0, 0, 0, 78, 79, 0, 0, 0, 0, 0, 0, 0, 90, 91, 0, + 0, 0, 0, 0, 0, 99, 74, 52, 0, 0, 135, 0, 0, 0, 131, 45, 130, 12, 72, + 100, 76, 88, 73, 101, 77, 89, 0, 0, 0, 7, 0, 0, 0, 0, 6, 0, 0, 0, + 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 43, 54, 104, 105, 106, 107, 108, 109, 41, 56, 80, 83, 84, 85, 86, 87, 40, 55, 81, + 59, 92, 94, 95, 96, 97, 98, 58, 93, 0, 42, 57, 82, 110, 0, 0, 0, 61, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 130, 25, 133, 0, 134, 0, 0, 19, 21, 20, + 22, 44, 0, 46, 48, 50, 47, 26, 0, 27, 28, 29, 30, 31, 64, 23, 17, 24, 18, + 10, 11, 13, 14, 15, 16, 125, 126, 128, 49, 127, 129, 132, 0, 137, 113, 0, 112, 0, + 111, 63, 0, 60, 0, 62, 39, 0, 33, 0, 38, 104, 80, 81, 82, 127, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 136, 138, 139, 0, 116, 114, 115, + 0, 118, 0, 0, 69, 0, 65, 35, 34, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, + 140, 117, 120, 0, 119, 0, 68, 0, 67, 36, 0, 0, 0, 0, 122, 121, 0, 0, 0, + 0, 123, 0, 66, 0, 124}; + + const signed char Parser::yypgoto_[] = {-37, -37, -37, -13, 104, 89, -4}; + + const unsigned char Parser::yydefgoto_[] = {0, 1, 6, 27, 28, 68, 179}; + + const short Parser::yytable_[] = { + 30, 205, 2, 3, 89, 90, 67, 108, 109, 110, 164, 112, 57, 7, 113, 69, 70, 58, 71, + 73, 74, 4, 47, 87, 88, 89, 90, 116, 117, 118, 119, 120, 121, 56, 59, 124, 125, 126, + 127, 128, 129, 210, 60, 132, 134, 135, 136, 137, 138, 139, 61, 5, 141, 142, 145, 149, 153, + 156, 159, 113, 98, 91, 161, 87, 88, 89, 90, 87, 88, 89, 90, 168, 170, 92, 93, 94, + 95, 96, 97, 167, 169, 171, 85, 173, 173, 175, 177, 186, 188, 98, 57, 228, 206, 29, 207, + 160, 187, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 200, 201, 202, 92, 93, 94, 95, + 96, 97, 215, 162, 258, 75, 115, 76, 77, 0, 78, 0, 98, 72, 123, 83, 0, 84, 85, + 0, 0, 114, 131, 133, 87, 88, 89, 90, 0, 122, 0, 140, 0, 144, 148, 152, 155, 130, + 0, 220, 221, 222, 223, 246, 0, 0, 224, 0, 143, 147, 151, 154, 79, 0, 80, 81, 0, + 82, 166, 92, 93, 94, 95, 96, 97, 0, 0, 178, 180, 181, 182, 183, 184, 185, 0, 98, + 0, 172, 174, 0, 176, 110, 164, 112, 86, 227, 113, 0, 230, 83, 232, 84, 85, 0, 0, + 235, 0, 0, 237, 0, 238, 199, 87, 88, 89, 90, 0, 0, 240, 0, 242, 0, 0, 0, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 260, 19, 146, 20, 261, 0, 262, 115, + 123, 131, 144, 0, 0, 265, 0, 266, 31, 32, 33, 34, 35, 36, 0, 0, 22, 23, 276, + 0, 277, 0, 24, 0, 25, 26, 0, 0, 284, 0, 0, 0, 37, 38, 0, 0, 289, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 229, 19, 231, 20, 0, 233, 21, 234, 0, + 0, 236, 39, 40, 41, 42, 43, 44, 0, 0, 239, 0, 0, 0, 0, 22, 23, 0, 0, + 0, 0, 24, 0, 25, 26, 0, 45, 46, 259, 48, 49, 50, 51, 52, 53, 263, 0, 264, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0, 19, 150, 20, 54, 55, 0, 0, + 0, 278, 0, 0, 0, 0, 0, 283, 0, 0, 285, 0, 0, 0, 0, 0, 22, 23, 0, + 0, 0, 0, 24, 0, 25, 26, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 0, + 19, 0, 20, 8, 9, 62, 63, 64, 13, 14, 65, 16, 17, 0, 0, 19, 0, 20, 0, + 0, 0, 0, 0, 22, 23, 0, 0, 0, 0, 24, 0, 25, 26, 211, 0, 212, 0, 0, + 22, 66, 216, 0, 217, 0, 24, 0, 25, 26, 0, 0, 0, 92, 93, 94, 95, 96, 97, + 0, 92, 93, 94, 95, 96, 97, 243, 0, 244, 98, 0, 0, 250, 0, 251, 0, 98, 0, + 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 97, 92, 93, 94, 95, 96, 97, 273, + 0, 274, 0, 98, 0, 252, 0, 0, 0, 98, 157, 32, 33, 34, 35, 36, 0, 92, 93, + 94, 95, 96, 97, 92, 93, 94, 95, 96, 97, 282, 0, 0, 0, 98, 37, 38, 0, 254, + 0, 98, 0, 0, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 97, 92, 93, 94, 95, + 96, 97, 267, 0, 0, 0, 98, 0, 272, 0, 0, 0, 98, 0, 0, 0, 0, 0, 92, + 93, 94, 95, 96, 97, 92, 93, 94, 95, 96, 97, 286, 0, 0, 0, 98, 0, 288, 0, + 0, 0, 98, 0, 0, 0, 0, 0, 92, 93, 94, 95, 96, 97, 92, 93, 94, 95, 96, + 97, 247, 0, 248, 0, 98, 0, 0, 249, 0, 0, 98, 0, 0, 0, 0, 0, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 203, 0, 113, 0, 204, 0, 0, 0, + 0, 158, 40, 41, 42, 43, 44, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 164, 112, 0, 208, 113, 209, 45, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 213, 113, 214, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 0, 218, 113, 219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 0, 256, 113, + 257, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 164, 112, 0, 269, 113, 270, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, + 0, 279, 113, 280, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 271, 0, 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, + 164, 112, 287, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, + 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 163, 0, 113, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, + 112, 245, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 164, 112, 253, 0, 113, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 255, 0, + 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 164, 112, 268, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 275, 0, 113, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + 110, 164, 112, 281, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, + 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 290, 0, 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, + 165, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 164, 112, 241, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, + 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 99, 0, 113, 0, 0, 0, 0, + 0, 0, 0, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 225, 0, 113, + 92, 93, 94, 95, 96, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 226, 100, + 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 0, 0, 113, 92, 93, 94, 95, + 96, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 0, 0, 113, 100, 101, 102, 103, 104, 105, 106, 107, 108, + 109, 110, 164, 112, 0, 0, 113, 100, 101, 102, 103, 104, 105, 106, 107, 0, 0, 0, 0, + 112, 0, 0, 113, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 0, 0, 113, + 102, 103, 104, 105, 106, 107, 108, 109, 110, 164, 112, 0, 0, 113}; + + const short Parser::yycheck_[] = { + 4, 16, 0, 1, 40, 41, 19, 38, 39, 40, 41, 42, 17, 20, 45, 19, 20, 22, 22, + 23, 24, 19, 22, 38, 39, 40, 41, 31, 32, 33, 34, 35, 36, 22, 15, 39, 40, 41, + 42, 43, 44, 16, 15, 47, 48, 49, 50, 51, 52, 53, 15, 49, 56, 57, 58, 59, 60, + 61, 22, 45, 48, 20, 66, 38, 39, 40, 41, 38, 39, 40, 41, 84, 85, 32, 33, 34, + 35, 36, 37, 83, 84, 85, 31, 87, 88, 89, 90, 100, 101, 48, 17, 22, 14, 4, 16, + 22, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 32, 33, 34, 35, + 36, 37, 16, 16, 22, 3, 31, 5, 6, -1, 8, -1, 48, 23, 39, 28, -1, 30, 31, + -1, -1, 31, 47, 48, 38, 39, 40, 41, -1, 39, -1, 56, -1, 58, 59, 60, 61, 47, + -1, 157, 158, 159, 160, 16, -1, -1, 164, -1, 58, 59, 60, 61, 3, -1, 5, 6, -1, + 8, 83, 32, 33, 34, 35, 36, 37, -1, -1, 92, 93, 94, 95, 96, 97, 98, -1, 48, + -1, 87, 88, -1, 90, 40, 41, 42, 20, 203, 45, -1, 206, 28, 208, 30, 31, -1, -1, + 213, -1, -1, 216, -1, 218, 111, 38, 39, 40, 41, -1, -1, 226, -1, 228, -1, -1, -1, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 243, 15, 16, 17, 247, -1, 249, 157, + 158, 159, 160, -1, -1, 256, -1, 258, 22, 23, 24, 25, 26, 27, -1, -1, 38, 39, 269, + -1, 271, -1, 44, -1, 46, 47, -1, -1, 279, -1, -1, -1, 46, 47, -1, -1, 287, 3, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 206, 15, 208, 17, -1, 211, 20, 213, -1, + -1, 216, 22, 23, 24, 25, 26, 27, -1, -1, 225, -1, -1, -1, -1, 38, 39, -1, -1, + -1, -1, 44, -1, 46, 47, -1, 46, 47, 243, 22, 23, 24, 25, 26, 27, 250, -1, 252, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, 15, 16, 17, 46, 47, -1, -1, + -1, 273, -1, -1, -1, -1, -1, 279, -1, -1, 282, -1, -1, -1, -1, -1, 38, 39, -1, + -1, -1, -1, 44, -1, 46, 47, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, + 15, -1, 17, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, 15, -1, 17, -1, + -1, -1, -1, -1, 38, 39, -1, -1, -1, -1, 44, -1, 46, 47, 14, -1, 16, -1, -1, + 38, 39, 14, -1, 16, -1, 44, -1, 46, 47, -1, -1, -1, 32, 33, 34, 35, 36, 37, + -1, 32, 33, 34, 35, 36, 37, 14, -1, 16, 48, -1, -1, 14, -1, 16, -1, 48, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, 35, 36, 37, 32, 33, 34, 35, 36, 37, 14, + -1, 16, -1, 48, -1, 14, -1, -1, -1, 48, 22, 23, 24, 25, 26, 27, -1, 32, 33, + 34, 35, 36, 37, 32, 33, 34, 35, 36, 37, 14, -1, -1, -1, 48, 46, 47, -1, 16, + -1, 48, -1, -1, -1, -1, -1, -1, -1, 32, 33, 34, 35, 36, 37, 32, 33, 34, 35, + 36, 37, 16, -1, -1, -1, 48, -1, 16, -1, -1, -1, 48, -1, -1, -1, -1, -1, 32, + 33, 34, 35, 36, 37, 32, 33, 34, 35, 36, 37, 16, -1, -1, -1, 48, -1, 16, -1, + -1, -1, 48, -1, -1, -1, -1, -1, 32, 33, 34, 35, 36, 37, 32, 33, 34, 35, 36, + 37, 14, -1, 16, -1, 48, -1, -1, 21, -1, -1, 48, -1, -1, -1, -1, -1, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 14, -1, 45, -1, 18, -1, -1, -1, + -1, 22, 23, 24, 25, 26, 27, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, -1, 14, 45, 16, 46, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, 16, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, -1, 14, 45, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, + 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, -1, 14, 45, 16, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + -1, 14, 45, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 14, -1, 45, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 14, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 16, -1, 45, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 16, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 16, -1, 45, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 16, -1, + 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 16, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 16, -1, 45, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 16, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 16, -1, 45, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 18, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 18, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 20, -1, 45, -1, -1, -1, -1, + -1, -1, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 29, -1, 45, + 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 48, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, -1, 45, 32, 33, 34, 35, + 36, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 48, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, -1, -1, 45, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, -1, -1, 45, 30, 31, 32, 33, 34, 35, 36, 37, -1, -1, -1, -1, + 42, -1, -1, 45, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, -1, 45, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, -1, -1, 45}; + + const signed char Parser::yystos_[] = { + 0, 51, 0, 1, 19, 49, 52, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 20, 38, + 39, 44, 46, 47, 53, 54, 55, 56, 22, 23, 24, 25, 26, 27, 46, 47, 22, 23, 24, 25, 26, 27, 46, + 47, 22, 22, 23, 24, 25, 26, 27, 46, 47, 22, 17, 22, 15, 15, 15, 5, 6, 7, 10, 39, 53, 55, + 56, 56, 56, 54, 56, 56, 3, 5, 6, 8, 3, 5, 6, 8, 28, 30, 31, 20, 38, 39, 40, 41, 20, + 32, 33, 34, 35, 36, 37, 48, 20, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 54, + 55, 56, 56, 56, 56, 56, 56, 54, 55, 56, 56, 56, 56, 56, 56, 54, 55, 56, 55, 56, 56, 56, 56, + 56, 56, 55, 56, 56, 54, 55, 56, 16, 54, 55, 56, 16, 54, 55, 56, 54, 55, 56, 22, 22, 22, 22, + 56, 16, 16, 41, 18, 55, 56, 53, 56, 53, 56, 54, 56, 54, 56, 54, 56, 55, 56, 55, 55, 55, 55, + 55, 55, 53, 56, 53, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 54, 56, 56, 56, 14, 18, 16, 14, + 16, 14, 16, 16, 14, 16, 14, 16, 16, 14, 16, 14, 16, 56, 56, 56, 56, 56, 29, 29, 56, 22, 55, + 56, 55, 56, 55, 55, 56, 55, 56, 56, 55, 56, 18, 56, 14, 16, 16, 16, 14, 16, 21, 14, 16, 14, + 16, 16, 16, 14, 16, 22, 55, 56, 56, 56, 55, 55, 56, 56, 16, 16, 14, 16, 14, 16, 14, 16, 16, + 56, 56, 55, 14, 16, 16, 14, 55, 56, 55, 16, 14, 16, 56, 16}; + + const signed char Parser::yyr1_[] = { + 0, 50, 51, 51, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56}; + + const signed char Parser::yyr2_[] = { + 0, 2, 0, 2, 1, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 1, 4, 6, 6, 8, 6, 4, 4, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 1, 1, 1, 3, 3, 3, 3, + 3, 3, 4, 3, 4, 4, 3, 6, 12, 8, 8, 6, 5, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 6, 6, + 6, 8, 6, 8, 8, 10, 10, 12, 14, 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 1, 5, 4, 6, 6, 8}; #if SEAMSDEBUG || 1 // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. // First, the terminals, then, starting at \a YYNTOKENS, nonterminals. - const char* - const Parser::yytname_[] = - { - "\"end of file\"", "error", "\"invalid token\"", "NUM", "QSTRING", - "UNDVAR", "VAR", "SVAR", "IMMVAR", "IMMSVAR", "AVAR", "FNCT", "SFNCT", - "AFNCT", "COMMA", "LPAR", "RPAR", "LBRACK", "RBRACK", "LBRACE", "RBRACE", - "SEMI", "EQUAL", "EQ_PLUS", "EQ_MINUS", "EQ_TIME", "EQ_DIV", "EQ_POW", - "QUEST", "COLON", "LOR", "LAND", "LT", "GT", "LE", "GE", "EQ", "NE", - "PLU", "SUB", "DIV", "TIM", "MOD", "UNARY", "NOT", "POW", "INC", "DEC", - "CONCAT", "'\\n'", "$accept", "input", "line", "bool", "aexp", "sexp", - "exp", YY_NULLPTR - }; + const char *const Parser::yytname_[] = {"\"end of file\"", + "error", + "\"invalid token\"", + "NUM", + "QSTRING", + "UNDVAR", + "VAR", + "SVAR", + "IMMVAR", + "IMMSVAR", + "AVAR", + "FNCT", + "SFNCT", + "AFNCT", + "COMMA", + "LPAR", + "RPAR", + "LBRACK", + "RBRACK", + "LBRACE", + "RBRACE", + "SEMI", + "EQUAL", + "EQ_PLUS", + "EQ_MINUS", + "EQ_TIME", + "EQ_DIV", + "EQ_POW", + "QUEST", + "COLON", + "LOR", + "LAND", + "LT", + "GT", + "LE", + "GE", + "EQ", + "NE", + "PLU", + "SUB", + "DIV", + "TIM", + "MOD", + "UNARY", + "NOT", + "POW", + "INC", + "DEC", + "CONCAT", + "'\\n'", + "$accept", + "input", + "line", + "bool", + "aexp", + "sexp", + "exp", + YY_NULLPTR}; #endif - #if SEAMSDEBUG - const short - Parser::yyrline_[] = - { - 0, 125, 125, 126, 129, 130, 137, 141, 142, 143, - 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, - 156, 157, 158, 159, 160, 161, 164, 165, 166, 167, - 168, 169, 171, 172, 178, 184, 190, 196, 202, 208, - 214, 218, 222, 225, 227, 235, 237, 245, 246, 247, - 248, 257, 258, 259, 260, 262, 265, 269, 274, 275, - 276, 282, 288, 294, 300, 301, 307, 313, 319, 325, - 331, 333, 334, 335, 336, 337, 338, 339, 340, 341, - 342, 344, 347, 352, 353, 354, 355, 356, 361, 362, - 363, 364, 365, 366, 367, 368, 369, 370, 371, 373, - 375, 378, 381, 384, 387, 389, 392, 395, 398, 401, - 408, 415, 422, 429, 436, 443, 450, 457, 464, 470, - 476, 482, 488, 494, 500, 506, 507, 508, 509, 516, - 523, 524, 525, 528, 529, 532, 533, 534, 535, 536, - 558 - }; - - void - Parser::yy_stack_print_ () const + const short Parser::yyrline_[] = { + 0, 125, 125, 126, 129, 130, 137, 141, 142, 143, 146, 147, 148, 149, 150, 151, 152, 153, + 154, 155, 156, 157, 158, 159, 160, 161, 164, 165, 166, 167, 168, 169, 171, 172, 178, 184, + 190, 196, 202, 208, 214, 218, 222, 225, 227, 235, 237, 245, 246, 247, 248, 257, 258, 259, + 260, 262, 265, 269, 274, 275, 276, 282, 288, 294, 300, 301, 307, 313, 319, 325, 331, 333, + 334, 335, 336, 337, 338, 339, 340, 341, 342, 344, 347, 352, 353, 354, 355, 356, 361, 362, + 363, 364, 365, 366, 367, 368, 369, 370, 371, 373, 375, 378, 381, 384, 387, 389, 392, 395, + 398, 401, 408, 415, 422, 429, 436, 443, 450, 457, 464, 470, 476, 482, 488, 494, 500, 506, + 507, 508, 509, 516, 523, 524, 525, 528, 529, 532, 533, 534, 535, 536, 558}; + + void Parser::yy_stack_print_() const { *yycdebug_ << "Stack now"; - for (stack_type::const_iterator - i = yystack_.begin (), - i_end = yystack_.end (); - i != i_end; ++i) - *yycdebug_ << ' ' << int (i->state); + for (stack_type::const_iterator i = yystack_.begin(), i_end = yystack_.end(); i != i_end; ++i) + *yycdebug_ << ' ' << int(i->state); *yycdebug_ << '\n'; } - void - Parser::yy_reduce_print_ (int yyrule) const + void Parser::yy_reduce_print_(int yyrule) const { - int yylno = yyrline_[yyrule]; + int yylno = yyrline_[yyrule]; int yynrhs = yyr2_[yyrule]; // Print the symbols being reduced, and their result. - *yycdebug_ << "Reducing stack by rule " << yyrule - 1 - << " (line " << yylno << "):\n"; + *yycdebug_ << "Reducing stack by rule " << yyrule - 1 << " (line " << yylno << "):\n"; // The symbols being reduced. for (int yyi = 0; yyi < yynrhs; yyi++) - YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", - yystack_[(yynrhs) - (yyi + 1)]); + YY_SYMBOL_PRINT(" $" << yyi + 1 << " =", yystack_[(yynrhs) - (yyi + 1)]); } #endif // SEAMSDEBUG - Parser::symbol_kind_type - Parser::yytranslate_ (int t) YY_NOEXCEPT + Parser::symbol_kind_type Parser::yytranslate_(int t) YY_NOEXCEPT { // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to // TOKEN-NUM as returned by yylex. - static - const signed char - translate_table[] = - { - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 49, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48 - }; + static const signed char translate_table[] = { + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 49, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}; // Last valid token kind. const int code_max = 303; if (t <= 0) return symbol_kind::S_YYEOF; else if (t <= code_max) - return static_cast (translate_table[t]); + return static_cast(translate_table[t]); else return symbol_kind::S_YYUNDEF; } -} // SEAMS +} // namespace SEAMS #line 2649 "apr_parser.cc" #line 581 "/Users/gdsjaar/src/seacas/packages/seacas/libraries/aprepro_lib/aprepro.yy" - -void SEAMS::Parser::error(const std::string& m) -{ - aprepro.error(m); -} +void SEAMS::Parser::error(const std::string &m) { aprepro.error(m); } diff --git a/packages/seacas/libraries/aprepro_lib/apr_scanner.cc b/packages/seacas/libraries/aprepro_lib/apr_scanner.cc index 1306e4f30911..c00575dee7d7 100644 --- a/packages/seacas/libraries/aprepro_lib/apr_scanner.cc +++ b/packages/seacas/libraries/aprepro_lib/apr_scanner.cc @@ -992,7 +992,7 @@ static yyconst flex_int16_t yy_rule_linenum[102] = { #include #include -#include "apr_getline_int.h" +#include "apr_getline.h" #include "apr_scanner.h" #include "apr_util.h" #include "aprepro.h" @@ -3241,7 +3241,7 @@ namespace SEAMS { } if (aprepro.ap_options.interactive && yyin == &std::cin && isatty(0) != 0 && isatty(1) != 0) { - char *line = ap_getline_int(nullptr); + char *line = SEAMS::getline_int(nullptr); if (strlen(line) == 0) { return 0; @@ -3252,7 +3252,7 @@ namespace SEAMS { "be parsed incorrectly."); } - ap_gl_histadd(line); + SEAMS::gl_histadd(line); if (strlen(line) > (size_t)max_size - 2) { yyerror("input line is too long"); diff --git a/packages/seacas/libraries/aprepro_lib/aprepro.yy b/packages/seacas/libraries/aprepro_lib/aprepro.yy index 846a1ec3fd9f..5adb46d60ceb 100644 --- a/packages/seacas/libraries/aprepro_lib/aprepro.yy +++ b/packages/seacas/libraries/aprepro_lib/aprepro.yy @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -130,7 +130,7 @@ line: '\n' { if (echo) aprepro.lexer->LexerOutput("\n", 1); | LBRACE exp RBRACE { if (echo) { static char tmpstr[512]; SEAMS::symrec *format = aprepro.getsym("_FORMAT"); - int len = sprintf(tmpstr, format->value.svar.c_str(), $2); + int len = snprintf(tmpstr, 512, format->value.svar.c_str(), $2); aprepro.lexer->LexerOutput(tmpstr, len); } } diff --git a/packages/seacas/libraries/chaco/submain/submain.c b/packages/seacas/libraries/chaco/submain/submain.c index 4a21cce9453f..6ae2540c4aed 100644 --- a/packages/seacas/libraries/chaco/submain/submain.c +++ b/packages/seacas/libraries/chaco/submain/submain.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020, 2022, 2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2022, 2022, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -277,9 +277,9 @@ int submain(struct vtx_data **graph, /* data structure for graph */ for (i = 0; i < nsets; i++) { hop_mtx[i][i] = 0; for (j = 0; j < i; j++) { + hop_mtx[i][j] = 0; if (KL_METRIC == 2) { /* Count hypercube hops */ - hop_mtx[i][j] = 0; - bits = i ^ j; + bits = i ^ j; while (bits) { if (bits & 1) { ++hop_mtx[i][j]; diff --git a/packages/seacas/libraries/exoIIv2for32/src/exo_jack_32.c b/packages/seacas/libraries/exoIIv2for32/src/exo_jack_32.c index d2726a6b3f9a..686b6ca56988 100644 --- a/packages/seacas/libraries/exoIIv2for32/src/exo_jack_32.c +++ b/packages/seacas/libraries/exoIIv2for32/src/exo_jack_32.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -104,15 +104,20 @@ static void ex_fcdcpy(char *fstring, /* output string to be blank-filled */ static void ex_fstrncpy(char *target, /* space to be copied into */ char *source, /* string to be copied */ int maxlen) -{ /* maximum length of *source */ - int len = maxlen; +{ + if (*source == '\0') { + *target = '\0'; + return; + } + int len = maxlen; + int lcp = 0; while (len-- && *source != '\0') { *target++ = *source++; + lcp++; } - len = maxlen; - while (len-- && *(--target) == ' ') { + while (lcp-- && *(--target) == ' ') { ; /* strip blanks */ } *(++target) = '\0'; /* insert new EOS marker */ diff --git a/packages/seacas/libraries/exodus/src/ex_cvt_nodes_to_sides.c b/packages/seacas/libraries/exodus/src/ex_cvt_nodes_to_sides.c index 33692338f6f4..85864bd4d8cb 100644 --- a/packages/seacas/libraries/exodus/src/ex_cvt_nodes_to_sides.c +++ b/packages/seacas/libraries/exodus/src/ex_cvt_nodes_to_sides.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -8,6 +8,7 @@ #include "exodusII.h" // for ex_err, ex_block, etc #include "exodusII_int.h" // for elem_blk_parm, EX_FATAL, etc +#include #include static int64_t get_node(void_int *connect, size_t index, size_t int_size) @@ -202,7 +203,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n is also the side number. */ - /* 1 2 3 4 node 1 */ + /* 1 2 3 4 node 1 */ static int shell_table[2][8] = { {2, 4, 3, 1, 4, 2, 1, 3}, /* node 2 */ {1, 2, 1, 2, 1, 2, 1, 2} /* side # */ @@ -214,7 +215,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n {3, 6, 4, 3, 5, 4, 6, 5} /* side # */ }; - /* 1 2 3 node 1 */ + /* 1 2 3 node 1 */ static int trishell_table[2][6] = { {2, 3, 3, 1, 1, 2}, /* node 2 */ {1, 2, 1, 2, 1, 2} /* side # */ @@ -235,7 +236,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n #endif static int hex_table[2][24] = { - /* 1 2 3 4 5 6 7 8 node 1 */ + /* 1 2 3 4 5 6 7 8 node 1 */ {4, 2, 5, 1, 3, 6, 7, 4, 2, 3, 1, 8, 6, 8, 1, 5, 2, 7, 8, 6, 3, 7, 5, 4}, /* node 2 */ {5, 1, 4, 5, 2, 1, 2, 3, 5, 5, 4, 3, 6, 4, 1, 1, 2, 6, 6, 2, 3, 3, 6, 4} /* side # */ }; @@ -287,13 +288,11 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n distinguish between 2d TRIs and 3d TRIs */ ndim = ex_inquire_int(exoid, EX_INQ_DIM); - int_size = sizeof(int); - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { - int_size = sizeof(int64_t); - } + bool ints_64 = ex_int64_status(exoid) & EX_BULK_INT64_API; + int_size = ints_64 ? sizeof(int64_t) : sizeof(int); /* First count up # of elements in the side sets*/ - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + if (ints_64) { for (i = 0; i < num_side_sets; i++) { tot_num_ss_elem += ((int64_t *)num_elem_per_set)[i]; } @@ -334,7 +333,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n /* Allocate space for the element block ids */ ids_size = sizeof(int); - if (ex_int64_status(exoid) & EX_IDS_INT64_API) { + if (ints_64) { ids_size = sizeof(int64_t); } @@ -366,7 +365,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n elem_ctr = 0; for (i = 0; i < num_elem_blks; i++) { ex_entity_id id; - if (ex_int64_status(exoid) & EX_IDS_INT64_API) { + if (ints_64) { id = ((int64_t *)elem_blk_ids)[i]; } else { @@ -420,7 +419,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n } same_elem_type[0] = true; - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + if (ints_64) { elem_ctr = ((int64_t *)num_elem_per_set)[0]; for (i = 0, k = 0; i < tot_num_ss_elem; i++) { int64_t elem = ((int64_t *)side_sets_elem_list)[i]; @@ -679,6 +678,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n } case EX_EL_TRISHELL: { /* use table to find which node to compare to next */ + assert(n < 3); if (ss_node1 == get_node(connect, num_nodes_per_elem * (elem_num_pos) + (trishell_table[0][2 * n] - 1), @@ -693,13 +693,6 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n /* Assume only front or back, no edges... */ put_side(side_sets_side_list, idx, trishell_table[1][2 * n + 1], int_size); } - else if (ss_node1 == get_node(connect, - num_nodes_per_elem * (elem_num_pos) + - (trishell_table[0][2 * n + 2] - 1), - int_size)) { - /* Assume only front or back, no edges... */ - put_side(side_sets_side_list, idx, trishell_table[1][2 * n + 2], int_size); - } else { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to find TRIANGULAR SHELL element %" PRId64 ", node %" PRId64 @@ -713,8 +706,9 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n } case EX_EL_SHELL: { /* use table to find which node to compare to next */ + assert(n < 4); - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + if (ints_64) { num_node_per_side = ((int64_t *)ss_elem_node_ndx)[idx + 1] - ((int64_t *)ss_elem_node_ndx)[idx]; } @@ -722,57 +716,62 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n num_node_per_side = ((int *)ss_elem_node_ndx)[idx + 1] - ((int *)ss_elem_node_ndx)[idx]; } - if (ss_node1 == - get_node(connect, num_nodes_per_elem * (elem_num_pos) + (shell_table[0][2 * n] - 1), - int_size)) { - if (num_node_per_side >= 4) { + if (num_node_per_side >= 4) { + /* Front or Back side of shell */ + if (ss_node1 == + get_node(connect, num_nodes_per_elem * (elem_num_pos) + (shell_table[0][2 * n] - 1), + int_size)) { /* 4- or 8-node side (front or back face) */ put_side(side_sets_side_list, idx, shell_table[1][2 * n], int_size); } - else { - /* 2- or 3-node side (edge of shell) */ - put_side(side_sets_side_list, idx, shell_edge_table[1][2 * n], int_size); - } - } - else if (ss_node1 == - get_node(connect, - num_nodes_per_elem * (elem_num_pos) + (shell_table[0][2 * n + 1] - 1), - int_size)) { - if (num_node_per_side >= 4) { + else if (ss_node1 == + get_node(connect, + num_nodes_per_elem * (elem_num_pos) + (shell_table[0][2 * n + 1] - 1), + int_size)) { /* 4- or 8-node side (front or back face) */ put_side(side_sets_side_list, idx, shell_table[1][2 * n + 1], int_size); } else { - /* 2- or 3-node side (edge of shell) */ - put_side(side_sets_side_list, idx, shell_edge_table[1][2 * n + 1], int_size); + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to find SHELL element %" PRId64 ", node %" PRId64 + " in connectivity array %" PRId64 " for file id %d", + elem_num + 1, ss_node1, elem_blk_parms[p_ndx].elem_blk_id, exoid); + ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM); + err_stat = EX_FATAL; + goto cleanup; } } - else if (ss_node1 == - get_node(connect, - num_nodes_per_elem * (elem_num_pos) + (shell_table[0][2 * n + 2] - 1), - int_size)) { - if (num_node_per_side >= 4) { - /* 4- or 8-node side (front or back face) */ - put_side(side_sets_side_list, idx, shell_table[1][2 * n + 2], int_size); + else { + /* Edge sides of shell */ + if (ss_node1 == + get_node(connect, + num_nodes_per_elem * (elem_num_pos) + (shell_edge_table[0][2 * n] - 1), + int_size)) { + /* 2- or 3-node side (edge of shell) */ + put_side(side_sets_side_list, idx, shell_edge_table[1][2 * n], int_size); } - else { + else if (ss_node1 == get_node(connect, + num_nodes_per_elem * (elem_num_pos) + + (shell_edge_table[0][2 * n + 1] - 1), + int_size)) { /* 2- or 3-node side (edge of shell) */ - put_side(side_sets_side_list, idx, shell_edge_table[1][2 * n + 2], int_size); + put_side(side_sets_side_list, idx, shell_edge_table[1][2 * n + 1], int_size); + } + else { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: failed to find SHELL element %" PRId64 ", node %" PRId64 + " in connectivity array %" PRId64 " for file id %d", + elem_num + 1, ss_node1, elem_blk_parms[p_ndx].elem_blk_id, exoid); + ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM); + err_stat = EX_FATAL; + goto cleanup; } - } - else { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: failed to find SHELL element %" PRId64 ", node %" PRId64 - " in connectivity array %" PRId64 " for file id %d", - elem_num + 1, ss_node1, elem_blk_parms[p_ndx].elem_blk_id, exoid); - ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM); - err_stat = EX_FATAL; - goto cleanup; } break; } case EX_EL_HEX: { /* use table to find which node to compare to next */ + assert(n < 8); if (ss_node1 == get_node(connect, num_nodes_per_elem * (elem_num_pos) + (hex_table[0][3 * n] - 1), @@ -804,6 +803,7 @@ int ex_cvt_nodes_to_sides(int exoid, void_int *num_elem_per_set, void_int *num_n } case EX_EL_TETRA: { /* use table to find which node to compare to next */ + assert(n < 4); if (ss_node1 == get_node(connect, num_nodes_per_elem * (elem_num_pos) + (tetra_table[0][3 * n] - 1), diff --git a/packages/seacas/libraries/exodus/src/ex_get_concat_side_set_node_count.c b/packages/seacas/libraries/exodus/src/ex_get_concat_side_set_node_count.c index 9090a79469c6..8dba4598d661 100644 --- a/packages/seacas/libraries/exodus/src/ex_get_concat_side_set_node_count.c +++ b/packages/seacas/libraries/exodus/src/ex_get_concat_side_set_node_count.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -36,7 +36,6 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list) void_int *side_set_elem_list = NULL; void_int *side_set_side_list = NULL; size_t elem_ctr; - int int_size, ids_size; int status; struct ex__elem_blk_parm *elem_blk_parms = NULL; @@ -89,13 +88,11 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list) EX_FUNC_LEAVE(EX_FATAL); } - int_size = sizeof(int); - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { - int_size = sizeof(int64_t); - } + bool ints_64 = ex_int64_status(exoid) & EX_BULK_INT64_API; + int int_size = ints_64 ? sizeof(int64_t) : sizeof(int); /* Allocate space for the element block ids */ - ids_size = sizeof(int); + int ids_size = sizeof(int); if (ex_int64_status(exoid) & EX_IDS_INT64_API) { ids_size = sizeof(int64_t); } @@ -253,7 +250,7 @@ int ex_get_concat_side_set_node_count(int exoid, int *side_set_node_cnt_list) int64_t elem_ndx; int64_t elem; int64_t side; - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + if (ints_64) { elem_ndx = ((int64_t *)ss_elem_ndx)[ii]; elem = ((int64_t *)side_set_elem_list)[elem_ndx]; side = ((int64_t *)side_set_side_list)[elem_ndx] - 1; diff --git a/packages/seacas/libraries/exodus/src/ex_get_side_set_node_count.c b/packages/seacas/libraries/exodus/src/ex_get_side_set_node_count.c index a931c3693d46..355facf19522 100644 --- a/packages/seacas/libraries/exodus/src/ex_get_side_set_node_count.c +++ b/packages/seacas/libraries/exodus/src/ex_get_side_set_node_count.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -101,10 +101,8 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se EX_FUNC_LEAVE(EX_FATAL); } - int int_size = sizeof(int); - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { - int_size = sizeof(int64_t); - } + bool ints_64 = ex_int64_status(exoid) & EX_BULK_INT64_API; + int int_size = ints_64 ? sizeof(int64_t) : sizeof(int); /* First determine the # of elements in the side set*/ int err; @@ -248,51 +246,53 @@ int ex_get_side_set_node_count(int exoid, ex_entity_id side_set_id, int *side_se * side set. */ - /* There is not partial read for this function, but all ranks must call because exodus runs NC_COLLECTIVE - * for all variables. Typically, either all ranks call and get same data, or one rank reads. To do the - * one rank read, we only store the data if `side_set_node_cnt_list != NULL` + /* There is not partial read for this function, but all ranks must call because exodus runs + * NC_COLLECTIVE for all variables. Typically, either all ranks call and get same data, or one + * rank reads. To do the one rank read, we only store the data if `side_set_node_cnt_list != + * NULL` */ if (side_set_node_cnt_list != NULL) { - j = 0; /* The current element block... */ - for (ii = 0; ii < tot_num_ss_elem; ii++) { + j = 0; /* The current element block... */ + for (ii = 0; ii < tot_num_ss_elem; ii++) { - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { - i = ((int64_t *)ss_elem_ndx)[ii]; - elem = ((int64_t *)side_set_elem_list)[i]; - side = ((int64_t *)side_set_side_list)[i] - 1; /* Convert to 0-based sides */ - } - else { - i = ((int *)ss_elem_ndx)[ii]; - elem = ((int *)side_set_elem_list)[i]; - side = ((int *)side_set_side_list)[i] - 1; /* Convert to 0-based sides */ - } + if (ints_64) { + i = ((int64_t *)ss_elem_ndx)[ii]; + elem = ((int64_t *)side_set_elem_list)[i]; + side = ((int64_t *)side_set_side_list)[i] - 1; /* Convert to 0-based sides */ + } + else { + i = ((int *)ss_elem_ndx)[ii]; + elem = ((int *)side_set_elem_list)[i]; + side = ((int *)side_set_side_list)[i] - 1; /* Convert to 0-based sides */ + } - /* - * Since the elements are being accessed in sorted, order, the - * block that contains the elements must progress sequentially - * from block 0 to block[num_elem_blks-1]. Once we find an element - * not in this block, find a following block that contains it... - */ - for (; j < num_elem_blks; j++) { - if (elem <= elem_blk_parms[j].elem_ctr) { - break; + /* + * Since the elements are being accessed in sorted, order, the + * block that contains the elements must progress sequentially + * from block 0 to block[num_elem_blks-1]. Once we find an element + * not in this block, find a following block that contains it... + */ + for (; j < num_elem_blks; j++) { + if (elem <= elem_blk_parms[j].elem_ctr) { + break; + } } - } - if (j < num_elem_blks) { - assert(side < elem_blk_parms[j].num_sides); - side_set_node_cnt_list[i] = elem_blk_parms[j].num_nodes_per_side[side]; - } - else { - snprintf(errmsg, MAX_ERR_LENGTH, - "ERROR: Invalid element number %" PRId64 " found in side set %" PRId64 " in file %d", - elem, side_set_id, exoid); - ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM); - err_stat = EX_FATAL; - goto cleanup; + if (j < num_elem_blks) { + assert(side < elem_blk_parms[j].num_sides); + side_set_node_cnt_list[i] = elem_blk_parms[j].num_nodes_per_side[side]; + } + else { + snprintf(errmsg, MAX_ERR_LENGTH, + "ERROR: Invalid element number %" PRId64 " found in side set %" PRId64 + " in file %d", + elem, side_set_id, exoid); + ex_err_fn(exoid, __func__, errmsg, EX_BADPARAM); + err_stat = EX_FATAL; + goto cleanup; + } } } - } /* All done: release connectivity array space, element block ids * array, element block parameters array, and side set element index diff --git a/packages/seacas/libraries/exodus/src/ex_get_side_set_node_list_len.c b/packages/seacas/libraries/exodus/src/ex_get_side_set_node_list_len.c index 64206011d149..db149251666e 100644 --- a/packages/seacas/libraries/exodus/src/ex_get_side_set_node_list_len.c +++ b/packages/seacas/libraries/exodus/src/ex_get_side_set_node_list_len.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -60,7 +60,8 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id, EX_FUNC_LEAVE(EX_FATAL); } - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + bool ints_64 = ex_int64_status(exoid) & EX_BULK_INT64_API; + if (ints_64) { *(int64_t *)side_set_node_list_len = 0; /* default value */ } else { @@ -111,7 +112,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id, } /* First determine the # of elements in the side set*/ - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + if (ints_64) { status = ex_get_set_param(exoid, EX_SIDE_SET, side_set_id, &tot_num_ss_elem, &num_df); } else { @@ -136,10 +137,8 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id, /* Allocate space for the side set element list */ { - int int_size = sizeof(int); - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { - int_size = sizeof(int64_t); - } + int int_size = ints_64 ? sizeof(int64_t) : sizeof(int); + if (!(side_set_elem_list = malloc(tot_num_ss_elem * int_size))) { snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: failed to allocate space for side set element " @@ -189,7 +188,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id, } /* Sort side set element list into index array - non-destructive */ - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + if (ints_64) { for (i = 0; i < tot_num_ss_elem; i++) { ss_elem_ndx_64[i] = i; /* init index array to current position */ } @@ -264,7 +263,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id, for (ii = 0; ii < tot_num_ss_elem; ii++) { size_t elem; size_t side; - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + if (ints_64) { i = ss_elem_ndx_64[ii]; elem = ((int64_t *)side_set_elem_list)[i]; side = ((int64_t *)side_set_side_list)[i]; @@ -300,7 +299,7 @@ int ex_get_side_set_node_list_len(int exoid, ex_entity_id side_set_id, list_len += elem_blk_parms[j].num_nodes_per_side[side - 1]; } - if (ex_int64_status(exoid) & EX_BULK_INT64_API) { + if (ints_64) { *(int64_t *)side_set_node_list_len = list_len; } else { diff --git a/packages/seacas/libraries/exodus/src/ex_put_init_ext.c b/packages/seacas/libraries/exodus/src/ex_put_init_ext.c index 59ec62cb075c..82b0e2809dd6 100644 --- a/packages/seacas/libraries/exodus/src/ex_put_init_ext.c +++ b/packages/seacas/libraries/exodus/src/ex_put_init_ext.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -209,11 +209,26 @@ static void invalidate_id_status(int exoid, const char *var_stat, const char *va int ex_put_init_ext(int exoid, const ex_init_params *model) { - int numdimdim, numnoddim, elblkdim, edblkdim, fablkdim, esetdim, fsetdim, elsetdim, nsetdim, - ssetdim, dim_str_name, dim[2], temp; - int nmapdim, edmapdim, famapdim, emapdim, timedim; - int status; - int title_len; + int numdimdim = 0; + int numnoddim = 0; + int elblkdim = 0; + int edblkdim = 0; + int fablkdim = 0; + int esetdim = 0; + int fsetdim = 0; + int elsetdim = 0; + int nsetdim = 0; + int ssetdim = 0; + int dim_str_name = 0; + int dim[2]; + int temp = 0; + int nmapdim = 0; + int edmapdim = 0; + int famapdim = 0; + int emapdim = 0; + int timedim = 0; + int status = 0; + int title_len = 0; #if 0 /* used for header size calculations which are turned off for now */ int header_size, fixed_var_size, iows; diff --git a/packages/seacas/libraries/exodus/src/ex_utils.c b/packages/seacas/libraries/exodus/src/ex_utils.c index 12b877b83018..f7d7caa47ef2 100644 --- a/packages/seacas/libraries/exodus/src/ex_utils.c +++ b/packages/seacas/libraries/exodus/src/ex_utils.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -69,93 +69,97 @@ extern char *ncmpi_inq_libvers(); const char *ex_config(void) { static char buffer[2048]; - int j = - sprintf(buffer, "\tExodus Version %s, Released %s\n", EXODUS_VERSION, EXODUS_RELEASE_DATE); + int buffer_size = sizeof(buffer) / sizeof(buffer[0]); + + int j = snprintf(buffer, buffer_size, "\tExodus Version %s, Released %s\n", EXODUS_VERSION, + EXODUS_RELEASE_DATE); #if defined(PARALLEL_AWARE_EXODUS) - j += sprintf(buffer + j, "\t\tParallel enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel enabled\n"); #else - j += sprintf(buffer + j, "\t\tParallel NOT enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel NOT enabled\n"); #endif #if defined(EXODUS_THREADSAFE) - j += sprintf(buffer + j, "\t\tThread Safe enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tThread Safe enabled\n"); #else - j += sprintf(buffer + j, "\t\tThread Safe NOT enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tThread Safe NOT enabled\n"); #endif #if defined(SEACAS_HIDE_DEPRECATED_CODE) - j += sprintf(buffer + j, "\t\tDeprecated Functions NOT built\n\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tDeprecated Functions NOT built\n\n"); #else - j += sprintf(buffer + j, "\t\tDeprecated Functions available\n\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tDeprecated Functions available\n\n"); #endif #if defined(NC_VERSION) - j += sprintf(buffer + j, "\tNetCDF Version %s\n", NC_VERSION); + j += snprintf(buffer + j, buffer_size - j, "\tNetCDF Version %s\n", NC_VERSION); #else - j += sprintf(buffer + j, "\tNetCDF Version < 4.3.3\n"); + j += snprintf(buffer + j, buffer_size - j, "\tNetCDF Version < 4.3.3\n"); #endif #if NC_HAS_CDF5 - j += sprintf(buffer + j, "\t\tCDF5 enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tCDF5 enabled\n"); #endif #ifndef _MSC_VER #if NC_HAS_HDF5 { unsigned major, minor, release; H5get_libversion(&major, &minor, &release); - j += sprintf(buffer + j, "\t\tHDF5 enabled (%u.%u.%u)\n", major, minor, release); + j += snprintf(buffer + j, buffer_size - j, "\t\tHDF5 enabled (%u.%u.%u)\n", major, minor, + release); } - j += sprintf(buffer + j, "\t\tZlib Compression (read/write) enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tZlib Compression (read/write) enabled\n"); #if NC_HAS_SZIP_WRITE == 1 - j += sprintf(buffer + j, "\t\tSZip Compression (read/write) enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tSZip Compression (read/write) enabled\n"); #else - j += sprintf(buffer + j, "\t\tSZip Compression (read/write) NOT enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tSZip Compression (read/write) NOT enabled\n"); #endif #endif #endif #if defined(PARALLEL_AWARE_EXODUS) #if NC_HAS_PARALLEL - j += sprintf(buffer + j, "\t\tParallel IO enabled via HDF5 and/or PnetCDF\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel IO enabled via HDF5 and/or PnetCDF\n"); #else - j += sprintf(buffer + j, + j += + snprintf(buffer + j, buffer_size - j, "\t\tParallel IO *NOT* enabled via HDF5 and/or PnetCDF (PROBABLY A BUILD ERROR!)\n"); #endif #if NC_HAS_PARALLEL4 - j += sprintf(buffer + j, "\t\tParallel IO enabled via HDF5\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel IO enabled via HDF5\n"); #else - j += sprintf(buffer + j, "\t\tParallel IO *NOT* enabled via HDF5\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel IO *NOT* enabled via HDF5\n"); #endif #if NC_HAS_PAR_FILTERS - j += sprintf(buffer + j, "\t\tParallel IO supports filters\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel IO supports filters\n"); #endif #if NC_HAS_PNETCDF { #if 0 char *libver = ncmpi_inq_libvers(); - j += sprintf(buffer + j, "\t\tParallel IO enabled via PnetCDF (%s)\n", libver); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel IO enabled via PnetCDF (%s)\n", libver); #else - j += sprintf(buffer + j, "\t\tParallel IO enabled via PnetCDF.\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel IO enabled via PnetCDF.\n"); #endif } #else - j += sprintf(buffer + j, "\t\tParallel IO *NOT* enabled via PnetCDF\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tParallel IO *NOT* enabled via PnetCDF\n"); #endif #endif /* PARALLEL_AWARE_EXODUS */ #if NC_HAS_ERANGE_FILL - j += sprintf(buffer + j, "\t\tERANGE_FILL support\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tERANGE_FILL support\n"); #endif #if NC_RELAX_COORD_BOUND - j += sprintf(buffer + j, "\t\tRELAX_COORD_BOUND defined\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tRELAX_COORD_BOUND defined\n"); #endif #if defined(NC_COMPACT) - j += sprintf(buffer + j, "\t\tNC_COMPACT defined\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tNC_COMPACT defined\n"); #endif #if defined(NC_HAVE_META_H) - j += sprintf(buffer + j, "\t\tNC_HAVE_META_H defined\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tNC_HAVE_META_H defined\n"); #endif #if NC_HAS_NC2 - j += sprintf(buffer + j, "\t\tAPI Version 2 support enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tAPI Version 2 support enabled\n"); #else - j += sprintf(buffer + j, "\t\tAPI Version 2 support NOT enabled\n"); + j += snprintf(buffer + j, buffer_size - j, "\t\tAPI Version 2 support NOT enabled\n"); #endif - j += sprintf(buffer + j, "\n"); + j += snprintf(buffer + j, buffer_size - j, "\n"); assert(j < 2048); return buffer; @@ -194,10 +198,10 @@ int ex__check_file_type(const char *path, int *type) ex_err(__func__, errmsg, EX_WRONGFILETYPE); EX_FUNC_LEAVE(EX_FATAL); } - int i = fread(magic, MAGIC_NUMBER_LEN, 1, fp); + int i = fread(magic, 1, MAGIC_NUMBER_LEN, fp); magic[MAGIC_NUMBER_LEN] = '\0'; fclose(fp); - if (i != 1) { + if (i != MAGIC_NUMBER_LEN) { char errmsg[MAX_ERR_LENGTH]; snprintf(errmsg, MAX_ERR_LENGTH, "ERROR: Could not read magic data from file '%s', err = %s.", path, strerror(errno)); @@ -513,7 +517,7 @@ char *ex__catstr(const char *string, int num) { /* Only called from an already locked function */ char *tmp_string = cur_string; - cur_string += sprintf(cur_string, "%s%d", string, num) + 1; + cur_string += snprintf(cur_string, MAX_VAR_NAME_LENGTH + 1, "%s%d", string, num) + 1; if (cur_string - ret_string > 9 * (MAX_VAR_NAME_LENGTH + 1)) { cur_string = ret_string; } @@ -529,7 +533,8 @@ char *ex__catstr2(const char *string1, int num1, const char *string2, int num2) { /* Only called from an already locked function */ char *tmp_string = cur_string; - cur_string += sprintf(cur_string, "%s%d%s%d", string1, num1, string2, num2) + 1; + cur_string += + snprintf(cur_string, MAX_VAR_NAME_LENGTH + 1, "%s%d%s%d", string1, num1, string2, num2) + 1; if (cur_string - ret_string > 9 * (MAX_VAR_NAME_LENGTH + 1)) { cur_string = ret_string; } diff --git a/packages/seacas/libraries/exodus/test/create_mesh.c b/packages/seacas/libraries/exodus/test/create_mesh.c index cbce487a95bf..3f8e56d0b95a 100644 --- a/packages/seacas/libraries/exodus/test/create_mesh.c +++ b/packages/seacas/libraries/exodus/test/create_mesh.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -634,7 +634,7 @@ void write_exo_mesh(int debug, char *file_name, INT map_origin, INT num_nodes, I var_name = malloc(num_nodal_fields * sizeof(char *)); for (INT j = 0; j < num_nodal_fields; j++) { var_name[j] = malloc((MAX_STRING_LEN + 1) * sizeof(char)); - sprintf(var_name[j], "node_field_%" PRId64, j + 1); + snprintf(var_name[j], MAX_STRING_LEN + 1, "node_field_%" PRId64, j + 1); } err = ex_put_variable_names(exoid, EX_NODAL, num_nodal_fields, var_name); if (err) { @@ -653,7 +653,7 @@ void write_exo_mesh(int debug, char *file_name, INT map_origin, INT num_nodes, I var_name = malloc(num_global_fields * sizeof(char *)); for (INT j = 0; j < num_global_fields; j++) { var_name[j] = malloc((MAX_STRING_LEN + 1) * sizeof(char)); - sprintf(var_name[j], "global_field_%" PRId64, j + 1); + snprintf(var_name[j], MAX_STRING_LEN + 1, "global_field_%" PRId64, j + 1); globals[j] = j; } err = ex_put_variable_names(exoid, EX_GLOBAL, num_global_fields, var_name); @@ -673,7 +673,7 @@ void write_exo_mesh(int debug, char *file_name, INT map_origin, INT num_nodes, I var_name = malloc(num_element_fields * sizeof(char *)); for (INT j = 0; j < num_element_fields; j++) { var_name[j] = malloc((MAX_STRING_LEN + 1) * sizeof(char)); - sprintf(var_name[j], "element_field_%" PRId64, j + 1); + snprintf(var_name[j], MAX_STRING_LEN + 1, "element_field_%" PRId64, j + 1); } err = ex_put_variable_names(exoid, EX_ELEM_BLOCK, num_element_fields, var_name); if (err) { @@ -912,7 +912,7 @@ void get_file_name(const char *base, const char *ext, int rank, int nprocs, cons } while (iTemp1 >= 1); char cTemp[128]; - sprintf(cTemp, "%d", nprocs); + snprintf(cTemp, 128, "%d", nprocs); strcat(output, "."); strcat(output, cTemp); @@ -925,7 +925,7 @@ void get_file_name(const char *base, const char *ext, int rank, int nprocs, cons strcat(output, "0"); } - sprintf(cTemp, "%d", rank); + snprintf(cTemp, 128, "%d", rank); strcat(output, cTemp); } } diff --git a/packages/seacas/libraries/exodus/test/rd_wt_mesh.c b/packages/seacas/libraries/exodus/test/rd_wt_mesh.c index 1499f864aebf..8f6c1d11ac42 100644 --- a/packages/seacas/libraries/exodus/test/rd_wt_mesh.c +++ b/packages/seacas/libraries/exodus/test/rd_wt_mesh.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -239,14 +239,13 @@ int main(int argc, char **argv) num_element_fields, num_timesteps, files_per_domain, sleep_time, num_iterations, loc_num_nodes, node_map, loc_num_elems, elem_map, x_coords, y_coords, z_coords, loc_connect, close_files); - - free(elem_map); - free(loc_connect); - free(node_map); - free(x_coords); - free(y_coords); - free(z_coords); } + free(elem_map); + free(loc_connect); + free(node_map); + free(x_coords); + free(y_coords); + free(z_coords); } #ifdef PARALLEL_AWARE_EXODUS MPI_Finalize(); @@ -742,7 +741,7 @@ int write_exo_mesh(char *file_name, int rank, int num_dim, int num_domains, int for (npd = 0; npd < files_per_domain; npd++) { /* create the EXODUS file */ - sprintf(base_name, "%s_%d", file_name, npd); + snprintf(base_name, MAX_STRING_LEN, "%s_%d", file_name, npd); get_file_name(base_name, EXODUS_FILE_TYPE, rank, num_domains, WRITE_FILE_TYPE, tmp_name); exoid[npd] = ex_create(tmp_name, EX_CLOBBER, &CPU_word_size, &IO_word_size); @@ -768,12 +767,20 @@ int write_exo_mesh(char *file_name, int rank, int num_dim, int num_domains, int if (close_files) { /* create the EXODUS file */ - sprintf(base_name, "%s_%d", file_name, npd); + snprintf(base_name, MAX_STRING_LEN, "%s_%d", file_name, npd); get_file_name(base_name, EXODUS_FILE_TYPE, rank, num_domains, WRITE_FILE_TYPE, tmp_name); exoid[npd] = ex_create(tmp_name, EX_CLOBBER, &CPU_word_size, &IO_word_size); if (exoid[npd] < 0) { printf("after ex_create\n"); + if (elem_var_tab) { + free(elem_var_tab); + elem_var_tab = NULL; + } + if (globals) { + free(globals); + globals = NULL; + } free(exoid); return (1); } @@ -906,7 +913,7 @@ int write_exo_mesh(char *file_name, int rank, int num_dim, int num_domains, int assert(nvar_name); for (j = 0; j < num_nodal_fields; j++) { nvar_name[j] = malloc((MAX_STRING_LEN + 1) * sizeof(char)); - sprintf(nvar_name[j], "node_field_%d", j + 1); + snprintf(nvar_name[j], MAX_STRING_LEN + 1, "node_field_%d", j + 1); } } err = ex_put_variable_names(exoid[npd], EX_NODAL, num_nodal_fields, nvar_name); @@ -924,7 +931,7 @@ int write_exo_mesh(char *file_name, int rank, int num_dim, int num_domains, int gvar_name = malloc(num_global_fields * sizeof(char *)); for (j = 0; j < num_global_fields; j++) { gvar_name[j] = malloc((MAX_STRING_LEN + 1) * sizeof(char)); - sprintf(gvar_name[j], "global_field_%d", j + 1); + snprintf(gvar_name[j], MAX_STRING_LEN + 1, "global_field_%d", j + 1); globals[j] = j; } } @@ -944,7 +951,7 @@ int write_exo_mesh(char *file_name, int rank, int num_dim, int num_domains, int evar_name = malloc(num_element_fields * sizeof(char *)); for (j = 0; j < num_element_fields; j++) { evar_name[j] = malloc((MAX_STRING_LEN + 1) * sizeof(char)); - sprintf(evar_name[j], "element_field_%d", j + 1); + snprintf(evar_name[j], MAX_STRING_LEN + 1, "element_field_%d", j + 1); } } @@ -952,6 +959,7 @@ int write_exo_mesh(char *file_name, int rank, int num_dim, int num_domains, int if (npd == files_per_domain - 1) { free(elem_var_tab); + elem_var_tab = NULL; for (j = 0; j < num_element_fields; j++) { free(evar_name[j]); } @@ -976,7 +984,7 @@ int write_exo_mesh(char *file_name, int rank, int num_dim, int num_domains, int if (close_files) { float version; - sprintf(base_name, "%s_%d", file_name, npd); + snprintf(base_name, MAX_STRING_LEN, "%s_%d", file_name, npd); t_tmp1 = my_timer(); get_file_name(base_name, EXODUS_FILE_TYPE, rank, num_domains, WRITE_FILE_TYPE, tmp_name); @@ -1174,6 +1182,7 @@ int write_exo_mesh(char *file_name, int rank, int num_dim, int num_domains, int free(exoid); if (num_global_fields > 0) { free(globals); + globals = NULL; } return (0); } @@ -1213,7 +1222,7 @@ void get_file_name(const char *base, const char *ext, int rank, int nprocs, cons strcat(output, "."); char cTemp[128]; - sprintf(cTemp, "%d", nprocs); + snprintf(cTemp, 128, "%d", nprocs); strcat(output, cTemp); strcat(output, "."); @@ -1224,7 +1233,7 @@ void get_file_name(const char *base, const char *ext, int rank, int nprocs, cons strcat(output, "0"); } - sprintf(cTemp, "%d", rank); + snprintf(cTemp, 128, "%d", rank); strcat(output, cTemp); } } diff --git a/packages/seacas/libraries/exodus/test/test1.dmp b/packages/seacas/libraries/exodus/test/test1.dmp index 4be33e53b48e..e02d071af199 100644 --- a/packages/seacas/libraries/exodus/test/test1.dmp +++ b/packages/seacas/libraries/exodus/test/test1.dmp @@ -84,11 +84,11 @@ variables: float attrib1(num_el_in_blk1, num_att_in_blk1) ; char attrib_name1(num_att_in_blk1, len_name) ; int connect1(num_el_in_blk1, num_nod_per_el1) ; - connect1:elem_type = "quad" ; + connect1:elem_type = "shell" ; float attrib2(num_el_in_blk2, num_att_in_blk2) ; char attrib_name2(num_att_in_blk2, len_name) ; int connect2(num_el_in_blk2, num_nod_per_el2) ; - connect2:elem_type = "quad" ; + connect2:elem_type = "shell" ; float attrib3(num_el_in_blk3, num_att_in_blk3) ; char attrib_name3(num_att_in_blk3, len_name) ; int connect3(num_el_in_blk3, num_nod_per_el3) ; @@ -339,13 +339,13 @@ data: elem_ss1 = 3, 3 ; - side_ss1 = 4, 2 ; + side_ss1 = 6, 4 ; dist_fact_ss1 = 30, 30.1, 30.2, 30.3 ; elem_ss2 = 1, 3 ; - side_ss2 = 2, 3 ; + side_ss2 = 4, 5 ; dist_fact_ss2 = 31, 31.1, 31.2, 31.3 ; diff --git a/packages/seacas/libraries/exodus/test/test_ts_errval.c b/packages/seacas/libraries/exodus/test/test_ts_errval.c index ca4ce963033a..80f1bc61708e 100644 --- a/packages/seacas/libraries/exodus/test/test_ts_errval.c +++ b/packages/seacas/libraries/exodus/test/test_ts_errval.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -34,7 +34,7 @@ void *error_test(void *varg) const char *message; int err_num; /* ex_opts(EX_VERBOSE); */ - sprintf(name, "Thread%ld", arg->threadid); + snprintf(name, 32, "Thread%ld", arg->threadid); for (i = EX_MEMFAIL; i <= EX_INTERNAL; i++) { ex_err(name, "Testing thread-safe exodus", i); ex_get_err(&message, &routine, &err_num); diff --git a/packages/seacas/libraries/exodus/test/test_ts_files.c b/packages/seacas/libraries/exodus/test/test_ts_files.c index 4c6c59e38f83..22cf029fd444 100644 --- a/packages/seacas/libraries/exodus/test/test_ts_files.c +++ b/packages/seacas/libraries/exodus/test/test_ts_files.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -55,7 +55,7 @@ void *init_file(void *varg) char name[32]; /* Name is "test_{thread}.exo" */ - sprintf(name, "test%ld.exo", arg->threadid); + snprintf(name, 32, "test%ld.exo", arg->threadid); ex_opts(EX_VERBOSE); diff --git a/packages/seacas/libraries/exodus/test/test_ts_nvar.c b/packages/seacas/libraries/exodus/test/test_ts_nvar.c index ffe1bcfd566d..7765faefab0f 100644 --- a/packages/seacas/libraries/exodus/test/test_ts_nvar.c +++ b/packages/seacas/libraries/exodus/test/test_ts_nvar.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -49,7 +49,7 @@ void *output_nodal_var(void *varg) } char name[33]; - sprintf(name, "NodalVar%ld", arg->threadid + 1); + snprintf(name, 33, "NodalVar%ld", arg->threadid + 1); ex_put_variable_name(arg->exoid, EX_NODAL, arg->threadid + 1, name); ex_put_var(arg->exoid, arg->timestep, EX_NODAL, arg->threadid + 1, 1, num_node, data); diff --git a/packages/seacas/libraries/exodus/test/test_ts_nvar_rd.c b/packages/seacas/libraries/exodus/test/test_ts_nvar_rd.c index 41557d0480eb..c469ec3d9c43 100644 --- a/packages/seacas/libraries/exodus/test/test_ts_nvar_rd.c +++ b/packages/seacas/libraries/exodus/test/test_ts_nvar_rd.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -100,7 +100,7 @@ void *input_nodal_var(void *varg) } } - sprintf(ex_name, "NodalVar%ld", arg->threadid + 1); + snprintf(ex_name, 33, "NodalVar%ld", arg->threadid + 1); ex_get_variable_name(arg->exoid, EX_NODAL, arg->threadid + 1, db_name); if (strcmp(db_name, ex_name) != 0) { fprintf(stderr, diff --git a/packages/seacas/libraries/exodus/test/test_ts_partial_nvar.c b/packages/seacas/libraries/exodus/test/test_ts_partial_nvar.c index 8aabc3082643..e9f2ecca4a0d 100644 --- a/packages/seacas/libraries/exodus/test/test_ts_partial_nvar.c +++ b/packages/seacas/libraries/exodus/test/test_ts_partial_nvar.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -50,7 +50,7 @@ void *output_nodal_var(void *varg) if (arg->threadid < NUM_NODAL_VAR) { char name[33]; - sprintf(name, "NodalVar%ld", arg->threadid + 1); + snprintf(name, 33, "NodalVar%ld", arg->threadid + 1); ex_put_variable_name(arg->exoid, EX_NODAL, arg->threadid + 1, name); } diff --git a/packages/seacas/libraries/exodus/test/test_ts_partial_nvar_rd.c b/packages/seacas/libraries/exodus/test/test_ts_partial_nvar_rd.c index aa94e75f435e..2e716504bdc6 100644 --- a/packages/seacas/libraries/exodus/test/test_ts_partial_nvar_rd.c +++ b/packages/seacas/libraries/exodus/test/test_ts_partial_nvar_rd.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -97,7 +97,7 @@ void *input_nodal_var(void *varg) char db_name[33]; char ex_name[33]; - sprintf(ex_name, "NodalVar%ld", arg->threadid + 1); + snprintf(ex_name, 33, "NodalVar%ld", arg->threadid + 1); ex_get_variable_name(arg->exoid, EX_NODAL, arg->threadid + 1, db_name); if (strcmp(db_name, ex_name) != 0) { fprintf(stderr, diff --git a/packages/seacas/libraries/exodus/test/testrd-assembly.c b/packages/seacas/libraries/exodus/test/testrd-assembly.c index 44e48e027d9c..f10f39a313f8 100644 --- a/packages/seacas/libraries/exodus/test/testrd-assembly.c +++ b/packages/seacas/libraries/exodus/test/testrd-assembly.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -295,8 +295,11 @@ int main(int argc, char **argv) for (int k = 0; k < num_assembly; k++) { EXCHECK(ex_get_reduction_vars(exoid, i + 1, EX_ASSEMBLY, assmbly[k].id, num_assembly_vars, var_values)); - printf("Values for Assembly %" PRId64 " at step %d: %f\t%f\t%f\t%f\n", assmbly[k].id, - i + 1, var_values[0], var_values[1], var_values[2], var_values[3]); + printf("Values for Assembly %" PRId64 " at step %d:", assmbly[k].id, i + 1); + for (int kk = 0; kk < num_assembly_vars; kk++) { + printf("\t%f", var_values[kk]); + } + printf("\n"); } } free(var_values); diff --git a/packages/seacas/libraries/exodus/test/testrd-long-name.c b/packages/seacas/libraries/exodus/test/testrd-long-name.c index 124d4f19ca85..98324a651d63 100644 --- a/packages/seacas/libraries/exodus/test/testrd-long-name.c +++ b/packages/seacas/libraries/exodus/test/testrd-long-name.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -394,7 +394,7 @@ int main(int argc, char **argv) printf("name = '%s'\n", nset_names[i]); free(nset_names[i]); node_list = (int *)calloc(num_nodes_in_set, sizeof(int)); - dist_fact = (float *)calloc(num_nodes_in_set, sizeof(float)); + dist_fact = (float *)calloc(num_df_in_set, sizeof(float)); error = ex_get_set(exoid, EX_NODE_SET, ids[i], node_list, NULL); printf("\nafter ex_get_node_set, error = %3d\n", error); diff --git a/packages/seacas/libraries/exodus/test/testrd1.dmp b/packages/seacas/libraries/exodus/test/testrd1.dmp index b8026880d361..dd4a05c55d46 100644 --- a/packages/seacas/libraries/exodus/test/testrd1.dmp +++ b/packages/seacas/libraries/exodus/test/testrd1.dmp @@ -192,14 +192,14 @@ after ex_get_elem_blk_ids, error = 0 after ex_get_elem_block, error = 0 element block id = 10 -element type = 'quad' +element type = 'shell' num_elem_in_block = 1 num_nodes_per_elem = 4 num_attr = 3 after ex_get_elem_block, error = 0 element block id = 11 -element type = 'quad' +element type = 'shell' num_elem_in_block = 2 num_nodes_per_elem = 4 num_attr = 3 @@ -465,8 +465,8 @@ element list for side set 30 3 3 side list for side set 30 + 6 4 - 2 node list for side set 30 8 5 @@ -492,8 +492,8 @@ element list for side set 31 1 3 side list for side set 31 - 2 - 3 + 4 + 5 node list for side set 31 2 3 @@ -686,10 +686,10 @@ elem_list = 6 7 side_list = + 6 4 - 2 - 2 - 3 + 4 + 5 5 3 3 diff --git a/packages/seacas/libraries/exodus/test/testwt1.c b/packages/seacas/libraries/exodus/test/testwt1.c index 170049e3bf71..94e17bb2fb2a 100644 --- a/packages/seacas/libraries/exodus/test/testwt1.c +++ b/packages/seacas/libraries/exodus/test/testwt1.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -288,16 +288,16 @@ int main(int argc, char **argv) /* write element block parameters */ - num_elem_in_block[0] = 1; /* element 1: Quad 1 */ - num_elem_in_block[1] = 2; /* elements 2, 3: Quad 1 & 2 */ + num_elem_in_block[0] = 1; /* element 1: Shell 1 */ + num_elem_in_block[1] = 2; /* elements 2, 3: Shell 1 & 2 */ num_elem_in_block[2] = 1; /* element 4: Hex */ num_elem_in_block[3] = 1; /* element 5: Tetra */ num_elem_in_block[4] = 1; /* element 6: Circle */ num_elem_in_block[5] = 1; /* element 7: Sphere */ num_elem_in_block[6] = 1; /* element 8: Wedge */ - num_nodes_per_elem[0] = 4; /* elements in block #1 are 4-node quads */ - num_nodes_per_elem[1] = 4; /* elements in block #2 are 4-node quads */ + num_nodes_per_elem[0] = 4; /* elements in block #1 are 4-node shells */ + num_nodes_per_elem[1] = 4; /* elements in block #2 are 4-node shells */ num_nodes_per_elem[2] = 8; /* elements in block #3 are 8-node hexes */ num_nodes_per_elem[3] = 4; /* elements in block #3 are 4-node tetras */ num_nodes_per_elem[4] = 1; /* elements in block #4 are 1-node circles */ @@ -320,11 +320,11 @@ int main(int argc, char **argv) num_attr[5] = 3; num_attr[6] = 3; - error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[0], "quad", num_elem_in_block[0], + error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[0], "shell", num_elem_in_block[0], num_nodes_per_elem[0], 0, 0, num_attr[0]); printf("after ex_put_elem_block, error = %d\n", error); - error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[1], "quad", num_elem_in_block[1], + error = ex_put_block(exoid, EX_ELEM_BLOCK, ebids[1], "shell", num_elem_in_block[1], num_nodes_per_elem[1], 0, 0, num_attr[1]); printf("after ex_put_elem_block, error = %d\n", error); @@ -554,7 +554,7 @@ int main(int argc, char **argv) ids[4] = 34; ids[5] = 35; - /* side set #1 - quad */ + /* side set #1 - shell */ node_list[0] = 8; node_list[1] = 5; elem_list[0] = 3; @@ -562,7 +562,7 @@ int main(int argc, char **argv) node_list[3] = 7; elem_list[1] = 3; - /* side set #2 - quad/hex, spanning 2 element types */ + /* side set #2 - shell/hex, spanning 2 element types */ node_list[4] = 2; node_list[5] = 3; elem_list[2] = 1; diff --git a/packages/seacas/libraries/exodus/test/testwtm.c b/packages/seacas/libraries/exodus/test/testwtm.c index 0fe0151e8986..26d02187b49c 100644 --- a/packages/seacas/libraries/exodus/test/testwtm.c +++ b/packages/seacas/libraries/exodus/test/testwtm.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -91,7 +91,7 @@ int main(int argc, char **argv) printf(" cpu word size: %d io word size: %d\n", CPU_word_size, IO_word_size); for (n = 0; n < nexofiles; n++) { - sprintf(exofname, "test%d.exo", n); + snprintf(exofname, 256, "test%d.exo", n); printf("test file name: %s\n", exofname); exoidm[n] = ex_create(exofname, /* filename path */ EX_CLOBBER, /* create mode */ @@ -124,7 +124,7 @@ int main(int argc, char **argv) num_side_sets2 = 5; for (n = 0; n < nexofiles; n++) { - sprintf(tmpstr, "This is test %d", n); + snprintf(tmpstr, 80, "This is test %d", n); error = ex_put_init(exoidm[n], tmpstr, num_dim2, num_nodes2, num_elem2, num_elem_blk2, num_node_sets2, num_side_sets2); diff --git a/packages/seacas/libraries/exodus_for/src/exo_jack-windows.c b/packages/seacas/libraries/exodus_for/src/exo_jack-windows.c index 1a6cd80491e4..e8b80a75ccd6 100644 --- a/packages/seacas/libraries/exodus_for/src/exo_jack-windows.c +++ b/packages/seacas/libraries/exodus_for/src/exo_jack-windows.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -46,7 +46,7 @@ #if defined(Build64) && !defined(DEFAULT_REAL_INT) /* 64-bit */ -#define real double +#define real double #define entity_id ex_entity_id #ifdef ADDC_ #define F2C(name) name##4_ @@ -56,7 +56,7 @@ #else /* 32-bit */ -#define real float +#define real float #define entity_id int #ifdef ADDC_ #define F2C(name) name##_ @@ -94,9 +94,13 @@ static void ex_fcdcpy(char *fstring, /* output string to be blank-filled */ static void ex_fstrncpy(char *target, /* space to be copied into */ char *source, /* string to be copied */ int maxlen) -{ /* maximum length of *source */ - int len = maxlen; +{ + if (*source == '\0') { + *target = '\0'; + return; + } + int len = maxlen; while (len-- && *source != '\0') *target++ = *source++; @@ -282,8 +286,8 @@ void F2C(EXPQA)(int *idexo, int *num_qa_records, char *qa_record, int *ierr, int free(sptr); /* free up array ptr space */ *ierr = EX_MEMFAIL; char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to allocate space for qa record %d for file id %d", i, - *idexo); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to allocate space for qa record %d for file id %d", i, *idexo); ex_err(__func__, errmsg, EX_MEMFAIL); return; } @@ -1034,7 +1038,8 @@ void F2C(EXGPN)(int *idexo, int *obj_type, char *prop_names, int *ierr, int prop default: exerrval = EX_BADPARAM; *ierr = EX_BADPARAM; - sprintf(errmsg, "Error: object type %d not supported; file id %d", *obj_type, *idexo); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: object type %d not supported; file id %d", *obj_type, + *idexo); ex_err(__func__, errmsg, exerrval); return; } @@ -2273,7 +2278,8 @@ void F2C(EXGII)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, if (ftypelen != 1) { #if defined(EXODUS_STRING_LENGTH_WARNING) char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Warning: file type string length is %lu in file id %d\n", ftypelen, *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Warning: file type string length is %lu in file id %d\n", + ftypelen, *idne); ex_err(__func__, errmsg, EX_MSG); #endif slen = ftypelen; @@ -2283,7 +2289,8 @@ void F2C(EXGII)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, if ((*ierr = ex_get_init_info(*idne, nproc, nproc_in_f, file_type)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to get initial information from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to get initial information from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } @@ -2306,7 +2313,8 @@ void F2C(EXPII)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, slen = ftypelen; #if defined(EXODUS_STRING_LENGTH_WARNING) char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Warning: file type string length is %lu in file id %d\n", ftypelen, *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Warning: file type string length is %lu in file id %d\n", + ftypelen, *idne); ex_err(__func__, errmsg, EX_MSG); #endif } @@ -2317,7 +2325,8 @@ void F2C(EXPII)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, if ((*ierr = ex_put_init_info(*idne, *nproc, *nproc_in_f, file_type)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to put initial information in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to put initial information in file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } @@ -2333,7 +2342,8 @@ void F2C(EXGIG)(int *idne, void_int *nnodes_g, void_int *nelems_g, void_int *nel if ((*ierr = ex_get_init_global(*idne, nnodes_g, nelems_g, nelem_blks_g, nnode_sets_g, nside_sets_g)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read initial global information from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read initial global information from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2365,7 +2375,8 @@ void F2C(EXPIG)(int *idne, void_int *nnodes_g, void_int *nelems_g, void_int *nel if (*ierr != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store initial global information in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to store initial global information in file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2380,7 +2391,8 @@ void F2C(EXGLBP)(int *idne, void_int *nint_nodes, void_int *nbor_nodes, void_int if ((*ierr = ex_get_loadbal_param(*idne, nint_nodes, nbor_nodes, next_nodes, nint_elems, nbor_elems, nnode_cmaps, nelem_cmaps, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read load balance parameters from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read load balance parameters from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2416,7 +2428,8 @@ void F2C(EXPLBP)(int *idne, void_int *nint_nodes, void_int *nbor_nodes, void_int } if (*ierr != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store load balance parameters in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to store load balance parameters in file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2431,7 +2444,8 @@ void F2C(EXPLBPC)(int *idne, void_int *nint_nodes, void_int *nbor_nodes, void_in if ((*ierr = ex_put_loadbal_param_cc(*idne, nint_nodes, nbor_nodes, next_nodes, nint_elems, nbor_elems, nnode_cmaps, nelem_cmaps)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store load balance parameters in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to store load balance parameters in file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2444,7 +2458,8 @@ void F2C(EXGNSPG)(int *idne, void_int *ns_ids_glob, void_int *ns_n_cnt_glob, { if ((*ierr = ex_get_ns_param_global(*idne, ns_ids_glob, ns_n_cnt_glob, ns_df_cnt_glob)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read global node set parameters from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read global node set parameters from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2457,7 +2472,8 @@ void F2C(EXPNSPG)(int *idne, void_int *global_ids, void_int *global_n_cnts, { if ((*ierr = ex_put_ns_param_global(*idne, global_ids, global_n_cnts, global_df_cnts)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store global node set parameters in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to store global node set parameters in file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2471,7 +2487,8 @@ void F2C(EXGSSPG)(int *idne, void_int *ss_ids_glob, void_int *ss_n_cnt_glob, if ((*ierr = ex_get_ss_param_global(*idne, ss_ids_glob, ss_n_cnt_glob, ss_df_cnt_glob)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read global side set parameters from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read global side set parameters from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2484,7 +2501,8 @@ void F2C(EXPSSPG)(int *idne, void_int *global_ids, void_int *global_el_cnts, { if ((*ierr = ex_put_ss_param_global(*idne, global_ids, global_el_cnts, global_df_cnts)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store global side set parameters in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to store global side set parameters in file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2496,7 +2514,8 @@ void F2C(EXGEBIG)(int *idne, void_int *el_blk_ids, void_int *el_blk_cnts, int *i { if ((*ierr = ex_get_eb_info_global(*idne, el_blk_ids, el_blk_cnts)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read global element block info from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read global element block info from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2508,7 +2527,8 @@ void F2C(EXPEBIG)(int *idne, void_int *el_blk_ids, void_int *el_blk_cnts, int *i { if ((*ierr = ex_put_eb_info_global(*idne, el_blk_ids, el_blk_cnts)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store global element block info in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to store global element block info in file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2531,7 +2551,8 @@ void F2C(EXGNSS)(int *idne, entity_id *ss_id, void_int *start, void_int *count, if ((*ierr = ex_get_n_side_set(*idne, *ss_id, st, cnt, ss_elem_list, ss_side_list)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read side set element list from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read side set element list from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2554,7 +2575,8 @@ void F2C(EXPNSS)(int *idne, entity_id *ss_id, void_int *start, void_int *count, if ((*ierr = ex_put_n_side_set(*idne, *ss_id, st, cnt, ss_elem_list, ss_side_list)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write side set element list to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write side set element list to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2577,7 +2599,8 @@ void F2C(EXGNSSD)(int *idne, entity_id *ss_id, void_int *start, void_int *count, if ((*ierr = ex_get_n_side_set_df(*idne, *ss_id, st, cnt, ss_df)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read side set dist factor from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read side set dist factor from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2600,7 +2623,8 @@ void F2C(EXPNSSD)(int *idne, entity_id *ss_id, void_int *start, void_int *count, if ((*ierr = ex_put_n_side_set_df(*idne, *ss_id, st, cnt, ss_df)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write side set dist factor to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write side set dist factor to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2623,7 +2647,8 @@ void F2C(EXGNNS)(int *idne, entity_id *ns_id, void_int *start, void_int *count, if ((*ierr = ex_get_n_node_set(*idne, *ns_id, st, cnt, ns_node_list)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read node set node list from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read node set node list from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2646,7 +2671,8 @@ void F2C(EXPNNS)(int *idne, entity_id *ns_id, void_int *start, void_int *count, if ((*ierr = ex_put_n_node_set(*idne, *ns_id, st, cnt, ns_node_list)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write node set node list to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write node set node list to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2669,7 +2695,8 @@ void F2C(EXGNNSD)(int *idne, entity_id *ns_id, void_int *start, void_int *count, if ((*ierr = ex_get_n_node_set_df(*idne, *ns_id, st, cnt, ns_df)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read node set dist factor from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read node set dist factor from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2692,7 +2719,8 @@ void F2C(EXPNNSD)(int *idne, entity_id *ns_id, void_int *start, void_int *count, if ((*ierr = ex_put_n_node_set_df(*idne, *ns_id, st, cnt, ns_df)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write node set dist factor to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write node set dist factor to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2715,7 +2743,8 @@ void F2C(EXGNCOR)(int *idne, void_int *start, void_int *count, real *x_coor, rea if ((*ierr = ex_get_n_coord(*idne, st, cnt, x_coor, y_coor, z_coor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read node coordinates from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read node coordinates from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2738,7 +2767,8 @@ void F2C(EXPNCOR)(int *idne, void_int *start, void_int *count, real *x_coor, rea if ((*ierr = ex_put_n_coord(*idne, st, cnt, x_coor, y_coor, z_coor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write node coordinates to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write node coordinates to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2761,7 +2791,8 @@ void F2C(EXGNEC)(int *idne, entity_id *elem_blk_id, void_int *start, void_int *c if ((*ierr = ex_get_n_elem_conn(*idne, *elem_blk_id, st, cnt, connect)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element block connectivity from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read element block connectivity from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2784,7 +2815,8 @@ void F2C(EXPNEC)(int *idne, entity_id *elem_blk_id, void_int *start, void_int *c if ((*ierr = ex_put_n_elem_conn(*idne, *elem_blk_id, st, cnt, connect)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write element block connectivity to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to write element block connectivity to file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2807,7 +2839,8 @@ void F2C(EXGNEAT)(int *idne, entity_id *elem_blk_id, void_int *start, void_int * if ((*ierr = ex_get_n_elem_attr(*idne, *elem_blk_id, st, cnt, attrib)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element block attribute from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read element block attribute from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2830,7 +2863,8 @@ void F2C(EXPNEAT)(int *idne, entity_id *elem_blk_id, void_int *start, void_int * if ((*ierr = ex_put_n_elem_attr(*idne, *elem_blk_id, st, cnt, attrib)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write element block attribute to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write element block attribute to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2847,8 +2881,8 @@ void F2C(EXGELT)(int *idne, entity_id *elem_blk_id, char *elem_type, int *ierr, if (elem_typelen != MAX_STR_LENGTH) { #if defined(EXODUS_STRING_LENGTH_WARNING) char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Warning: element type string length is %lu in file id %d\n", elem_typelen, - *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Warning: element type string length is %lu in file id %d\n", + elem_typelen, *idne); ex_err(__func__, errmsg, EX_MSG); #endif slen = elem_typelen; @@ -2858,7 +2892,8 @@ void F2C(EXGELT)(int *idne, entity_id *elem_blk_id, char *elem_type, int *ierr, if ((*ierr = ex_get_elem_type(*idne, *elem_blk_id, etype)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element block type from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read element block type from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } @@ -2888,7 +2923,8 @@ void F2C(EXGNEV)(int *idne, int *time_step, int *elem_var_index, entity_id *elem if ((*ierr = ex_get_n_var(*idne, *time_step, EX_ELEM_BLOCK, *elem_var_index, *elem_blk_id, st, cnt, elem_var_vals)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element block variable from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read element block variable from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2912,7 +2948,8 @@ void F2C(EXPEVS)(int *idne, int *time_step, int *elem_var_index, entity_id *elem if ((*ierr = ex_put_elem_var_slab(*idne, *time_step, *elem_var_index, *elem_blk_id, st, cnt, elem_var_vals)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write elem block variable slab to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to write elem block variable slab to file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2936,7 +2973,7 @@ void F2C(EXGNNV)(int *idne, int *time_step, int *nodal_var_index, void_int *star if ((*ierr = ex_get_n_var(*idne, *time_step, EX_NODAL, *nodal_var_index, 1, st, cnt, nodal_vars)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read nodal variable from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read nodal variable from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2960,7 +2997,8 @@ void F2C(EXPNVS)(int *idne, int *time_step, int *nodal_var_index, void_int *star if ((*ierr = ex_put_nodal_var_slab(*idne, *time_step, *nodal_var_index, st, cnt, nodal_var_vals)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write nodal variable slab to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write nodal variable slab to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -2982,7 +3020,8 @@ void F2C(EXGNENM)(int *idne, void_int *starte, void_int *num_ent, void_int *elem if ((*ierr = ex_get_n_elem_num_map(*idne, st, cnt, elem_map)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element numbering map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read element numbering map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3004,7 +3043,8 @@ void F2C(EXPNENM)(int *idne, void_int *starte, void_int *num_ent, void_int *elem if ((*ierr = ex_put_partial_id_map(*idne, EX_ELEM_MAP, st, cnt, elem_map)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write element numbering map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write element numbering map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3026,7 +3066,8 @@ void F2C(EXGNNNM)(int *idne, void_int *startn, void_int *num_ent, void_int *node if ((*ierr = ex_get_n_node_num_map(*idne, st, cnt, node_map)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read node numbering map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read node numbering map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3048,7 +3089,8 @@ void F2C(EXPNNNM)(int *idne, void_int *startn, void_int *num_ent, void_int *node if ((*ierr = ex_put_partial_id_map(*idne, EX_NODE_MAP, st, cnt, node_map)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write node numbering map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write node numbering map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3062,7 +3104,8 @@ void F2C(EXGNMP)(int *idne, void_int *node_mapi, void_int *node_mapb, void_int * if ((*ierr = ex_get_processor_node_maps(*idne, node_mapi, node_mapb, node_mape, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read processor node map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read processor node map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3076,7 +3119,8 @@ void F2C(EXPNMP)(int *idne, void_int *node_mapi, void_int *node_mapb, void_int * if ((*ierr = ex_put_processor_node_maps(*idne, node_mapi, node_mapb, node_mape, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write processor node map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write processor node map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3088,7 +3132,8 @@ void F2C(EXGEMP)(int *idne, void_int *elem_mapi, void_int *elem_mapb, int *proce { if ((*ierr = ex_get_processor_elem_maps(*idne, elem_mapi, elem_mapb, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read processor element map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read processor element map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3100,7 +3145,8 @@ void F2C(EXPEMP)(int *idne, void_int *elem_mapi, void_int *elem_mapb, int *proce { if ((*ierr = ex_put_processor_elem_maps(*idne, elem_mapi, elem_mapb, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write processor element map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write processor element map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3114,7 +3160,8 @@ void F2C(EXGCMP)(int *idne, void_int *ncmap_ids, void_int *ncmap_node_cnts, void if ((*ierr = ex_get_cmap_params(*idne, ncmap_ids, ncmap_node_cnts, ecmap_ids, ecmap_elem_cnts, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read comm map parameters from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read comm map parameters from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3128,7 +3175,8 @@ void F2C(EXPCMP)(int *idne, void_int *nmap_ids, void_int *nmap_node_cnts, void_i if ((*ierr = ex_put_cmap_params(*idne, nmap_ids, nmap_node_cnts, emap_ids, emap_elem_cnts, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write comm map parameters to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write comm map parameters to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3142,7 +3190,8 @@ void F2C(EXPCMPC)(int *idne, void_int *nmap_ids, void_int *nmap_node_cnts, void_ if ((*ierr = ex_put_cmap_params_cc(*idne, nmap_ids, nmap_node_cnts, nproc_ptrs, emap_ids, emap_elem_cnts, eproc_ptrs)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write comm map parameters to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write comm map parameters to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3155,7 +3204,8 @@ void F2C(EXGNCM)(int *idne, entity_id *map_id, void_int *node_ids, void_int *pro { if ((*ierr = ex_get_node_cmap(*idne, *map_id, node_ids, proc_ids, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read nodal communications map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read nodal communications map from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3168,7 +3218,8 @@ void F2C(EXPNCM)(int *idne, entity_id *map_id, void_int *node_ids, void_int *pro { if ((*ierr = ex_put_node_cmap(*idne, *map_id, node_ids, proc_ids, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write nodal communications map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to write nodal communications map to file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3181,7 +3232,8 @@ void F2C(EXGECM)(int *idne, entity_id *map_id, void_int *elem_ids, void_int *sid { if ((*ierr = ex_get_elem_cmap(*idne, *map_id, elem_ids, side_ids, proc_ids, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read elemental comm map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read elemental comm map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -3194,7 +3246,8 @@ void F2C(EXPECM)(int *idne, entity_id *map_id, void_int *elem_ids, void_int *sid { if ((*ierr = ex_put_elem_cmap(*idne, *map_id, elem_ids, side_ids, proc_ids, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write elemental comm map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write elemental comm map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } diff --git a/packages/seacas/libraries/exodus_for/src/exo_jack.c b/packages/seacas/libraries/exodus_for/src/exo_jack.c index d2726a6b3f9a..d5160017bfb4 100644 --- a/packages/seacas/libraries/exodus_for/src/exo_jack.c +++ b/packages/seacas/libraries/exodus_for/src/exo_jack.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -104,15 +104,20 @@ static void ex_fcdcpy(char *fstring, /* output string to be blank-filled */ static void ex_fstrncpy(char *target, /* space to be copied into */ char *source, /* string to be copied */ int maxlen) -{ /* maximum length of *source */ - int len = maxlen; +{ + if (*source == '\0') { + *target = '\0'; + return; + } + int len = maxlen; + int lcp = 0; while (len-- && *source != '\0') { *target++ = *source++; + lcp++; } - len = maxlen; - while (len-- && *(--target) == ' ') { + while (lcp-- && *(--target) == ' ') { ; /* strip blanks */ } *(++target) = '\0'; /* insert new EOS marker */ @@ -2710,7 +2715,7 @@ void F2C(exgii, EXGII)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int /* WARNING: ftypelen SHOULD be 1, but may not be depending on how the Fortran programmer passed it. It is best at this time to hard code it per NEPII spec. */ - if (ftypelen != 1) { + if (ftypelen > 1) { #if defined(EXODUS_STRING_LENGTH_WARNING) char errmsg[MAX_ERR_LENGTH]; snprintf(errmsg, MAX_ERR_LENGTH, "Warning: file type string length is %lu in file id %d\n", @@ -2747,7 +2752,7 @@ void F2C(expii, EXPII)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int /* WARNING: ftypelen SHOULD be 1, but may not be depending on how the Fortran programmer passed it. It is best at this time to hard code it per NEPII spec. */ - if (ftypelen != 1) { + if (ftypelen > 1) { slen = ftypelen; #if defined(EXODUS_STRING_LENGTH_WARNING) char errmsg[MAX_ERR_LENGTH]; @@ -3343,7 +3348,7 @@ void F2C(expneat, EXPNEAT)(int *idne, entity_id *elem_blk_id, void_int *start, v void F2C(exgelt, EXGELT)(int *idne, entity_id *elem_blk_id, char *elem_type, int *ierr, size_t elem_typelen) { - /* WARNING: ftypelen SHOULD be MAX_STR_LENGTH, but may not be depending + /* WARNING: elem_typelen SHOULD be MAX_STR_LENGTH, but may not be depending on how the Fortran programmer passed it. It is best at this time to hard code it per NEMESIS spec. */ size_t slen = MAX_STR_LENGTH; diff --git a/packages/seacas/libraries/ioss/src/Ioss_ConcreteVariableType.C b/packages/seacas/libraries/ioss/src/Ioss_ConcreteVariableType.C index 34a8b46293f2..5e0df9cc69ca 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ConcreteVariableType.C +++ b/packages/seacas/libraries/ioss/src/Ioss_ConcreteVariableType.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -107,13 +107,10 @@ Ioss::Scalar::Scalar() : Ioss::VariableType(scalar(), 1) Ioss::VariableType::alias("scalar", "unsigned integer"); } -std::string Ioss::Scalar::label(int which, const char /*suffix_sep*/) const +std::string Ioss::Scalar::label(IOSS_MAYBE_UNUSED int which, const char /*suffix_sep*/) const { assert(which > 0 && which <= component_count()); - switch (which) { - case 1: return ""; - default: return ""; - } + return ""; } std::string Ioss::Scalar::label_name(const std::string &base, int /*which*/, diff --git a/packages/seacas/libraries/ioss/src/Ioss_DBUsage.h b/packages/seacas/libraries/ioss/src/Ioss_DBUsage.h index 95d5e2c69b26..bdfc3196c4e0 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DBUsage.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DBUsage.h @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -22,8 +22,11 @@ namespace Ioss { WRITE_HISTORY = 16, /**< Global results data, such as total energy, will be written to this database. */ WRITE_HEARTBEAT = - 32 /**< Text-based results data for particular nodes, edges, faces, elements, + 32, /**< Text-based results data for particular nodes, edges, faces, elements, or global variables at particular times will be written to this database. */ + QUERY_TIMESTEPS_ONLY = 64 /**< Special mode where the application is *only* going to query + the number of timesteps and the timestep values on the database. + All other region data will not exist. */ }; enum IfDatabaseExistsBehavior { @@ -38,6 +41,7 @@ namespace Ioss { inline bool is_input_event(Ioss::DatabaseUsage db_usage) { - return db_usage == Ioss::READ_MODEL || db_usage == Ioss::READ_RESTART; + return db_usage == Ioss::READ_MODEL || db_usage == Ioss::READ_RESTART || + db_usage == Ioss::QUERY_TIMESTEPS_ONLY; } } // namespace Ioss diff --git a/packages/seacas/libraries/ioss/src/Ioss_Getline.C b/packages/seacas/libraries/ioss/src/Ioss_Getline.C index a4f902686047..c9ca1314f3a1 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Getline.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Getline.C @@ -18,7 +18,6 @@ /* * Note: This version has been updated by Mike Gleason */ - #if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || \ defined(__MINGW32__) || defined(_WIN64) @@ -54,48 +53,45 @@ struct termios io_new_termios, io_old_termios; #include "Ioss_Getline.h" -const int IO_GL_BUF_SIZE{1024}; - -/******************** external interface *********************************/ - -int io_gl_filename_quoting_desired = -1; /* default to unspecified */ -const char *io_gl_filename_quote_characters = " \t*?<>|;&()[]$`"; -int io_gl_ellipses_during_completion = 1; -char io_gl_buf[IO_GL_BUF_SIZE]; /* input buffer */ - -/******************** internal interface *********************************/ - namespace { - int io_gl_init_done = -1; /* terminal mode flag */ - int io_gl_termw = 80; /* actual terminal width */ - int io_gl_scroll = 27; /* width of EOL scrolling region */ - int io_gl_width = 0; /* net size available for input */ - int io_gl_extent = 0; /* how far to redraw, 0 means all */ - int io_gl_overwrite = 0; /* overwrite mode */ - int io_gl_pos, io_gl_cnt = 0; /* position and size of input */ - char io_gl_killbuf[IO_GL_BUF_SIZE] = ""; /* killed text */ - const char *io_gl_prompt; /* to save the prompt string */ - int io_gl_search_mode = 0; /* search mode flag */ - - void io_gl_init(void); /* prepare to edit a line */ - void io_gl_cleanup(void); /* to undo io_gl_init */ - void io_gl_char_init(void); /* get ready for no echo input */ - void io_gl_char_cleanup(void); /* undo io_gl_char_init */ - /* returns printable prompt width */ - - void io_gl_addchar(int c); /* install specified char */ - void io_gl_del(int loc, int); /* del, either left (-1) or cur (0) */ - void io_gl_error(const char *const buf); /* write error msg and die */ - void io_gl_fixup(const char *prompt, int change, - int cursor); /* fixup state variables and screen */ - int io_gl_getc(void); /* read one char from terminal */ - void io_gl_kill(int pos); /* delete to EOL */ - void io_gl_newline(void); /* handle \n or \r */ - void io_gl_putc(int c); /* write one char to terminal */ - void io_gl_puts(const char *const buf); /* write a line to terminal */ - void io_gl_redraw(void); /* issue \n and redraw all */ - void io_gl_transpose(void); /* transpose two chars */ - void io_gl_yank(void); /* yank killed text */ + const int GL_BUF_SIZE{1024}; + + /******************** external interface *********************************/ + + bool gl_ellipses_during_completion = true; + char gl_buf[GL_BUF_SIZE]; /* input buffer */ + + int gl_init_done = -1; /* terminal mode flag */ + int gl_termw = 80; /* actual terminal width */ + int gl_scroll = 27; /* width of EOL scrolling region */ + int gl_width = 0; /* net size available for input */ + int gl_extent = 0; /* how far to redraw, 0 means all */ + int gl_overwrite = 0; /* overwrite mode */ + int gl_pos, gl_cnt = 0; /* position and size of input */ + char gl_killbuf[GL_BUF_SIZE] = ""; /* killed text */ + const char *gl_prompt; /* to save the prompt string */ + int gl_search_mode = 0; /* search mode flag */ + + void gl_init(void); /* prepare to edit a line */ + void gl_cleanup(void); /* to undo gl_init */ + void gl_char_init(void); /* get ready for no echo input */ + void gl_char_cleanup(void); /* undo gl_char_init */ + /* returns printable prompt width */ + + void gl_addchar(int c); /* install specified char */ + void gl_del(int loc, int); /* del, either left (-1) or cur (0) */ + + [[noreturn]] void gl_error(const char *const buf); /* write error msg and die */ + + void gl_fixup(const char *prompt, int change, int cursor); /* fixup state variables and screen */ + int gl_getc(void); /* read one char from terminal */ + void gl_kill(int pos); /* delete to EOL */ + void gl_newline(void); /* handle \n or \r */ + void gl_putc(int c); /* write one char to terminal */ + void gl_puts(const char *const buf); /* write a line to terminal */ + void gl_redraw(void); /* issue \n and redraw all */ + void gl_transpose(void); /* transpose two chars */ + void gl_yank(void); /* yank killed text */ void hist_init(void); /* initializes hist pointers */ char *hist_next(void); /* return ptr to next item */ @@ -106,7 +102,7 @@ namespace { void search_term(void); /* reset with current contents */ void search_back(int new_search); /* look back for current string */ void search_forw(int new_search); /* look forw for current string */ - void io_gl_beep(void); /* try to play a system beep sound */ + void gl_beep(void); /* try to play a system beep sound */ char *copy_string(char *dest, char const *source, long int elements) { @@ -125,7 +121,7 @@ namespace { #endif namespace { - void io_gl_char_init(void) /* turn off input echo */ + void gl_char_init(void) /* turn off input echo */ { #ifdef __unix__ tcgetattr(0, &io_old_termios); @@ -139,7 +135,7 @@ namespace { #endif /* __unix__ */ } - void io_gl_char_cleanup(void) /* undo effects of io_gl_char_init */ + void gl_char_cleanup(void) /* undo effects of gl_char_init */ { #ifdef __unix__ tcsetattr(0, TCSANOW, &io_old_termios); @@ -195,7 +191,7 @@ int pc_keymap(int c) #endif /* defined(MSDOS) || defined(__windows__) */ namespace { - int io_gl_getc(void) + int gl_getc(void) /* get a character without echoing it to screen */ { #ifdef __unix__ @@ -234,7 +230,7 @@ namespace { return c; } - void io_gl_putc(int c) + void gl_putc(int c) { char ch = (char)(unsigned char)c; @@ -247,7 +243,7 @@ namespace { /******************** fairly portable part *********************************/ - void io_gl_puts(const char *const buf) + void gl_puts(const char *const buf) { if (buf) { int len = strlen(buf); @@ -255,39 +251,40 @@ namespace { } } - void io_gl_error(const char *const buf) + [[noreturn]] void gl_error(const char *const buf) { int len = strlen(buf); - io_gl_cleanup(); + gl_cleanup(); write(2, buf, len); exit(1); } - void io_gl_init(void) + void gl_init(void) /* set up variables and terminal */ { - if (io_gl_init_done < 0) { /* -1 only on startup */ + if (gl_init_done < 0) { /* -1 only on startup */ const char *cp = (const char *)getenv("COLUMNS"); - if (cp != NULL) { - int w = strtol(cp, NULL, 10); + if (cp != nullptr) { + int w = strtol(cp, nullptr, 10); if (w > 20) - io_gl_setwidth(w); + Ioss::gl_setwidth(w); } hist_init(); } if (isatty(0) == 0 || isatty(1) == 0) - io_gl_error("\n*** Error: getline(): not interactive, use stdio.\n"); - io_gl_char_init(); - io_gl_init_done = 1; + gl_error("\n*** Error: getline(): not interactive, use stdio.\n"); + gl_char_init(); + gl_init_done = 1; } - void io_gl_cleanup(void) - /* undo effects of io_gl_init, as necessary */ + void gl_cleanup(void) + /* undo effects of gl_init, as necessary */ { - if (io_gl_init_done > 0) - io_gl_char_cleanup(); - io_gl_init_done = 0; + if (gl_init_done > 0) { + gl_char_cleanup(); + } + gl_init_done = 0; #ifdef __windows__ Sleep(40); FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); @@ -295,219 +292,234 @@ namespace { } } // namespace -void io_gl_setwidth(int w) -{ - if (w > 250) - w = 250; - if (w > 20) { - io_gl_termw = w; - io_gl_scroll = w / 3; - } - else { - io_gl_error("\n*** Error: minimum screen width is 21\n"); +namespace Ioss { + void gl_setwidth(int w) + { + if (w > 250) { + w = 250; + } + if (w > 20) { + gl_termw = w; + gl_scroll = w / 3; + } + else { + gl_error("\n*** Error: minimum screen width is 21\n"); + } } -} -char *io_getline_int(const char *prompt) -{ - io_gl_init(); - io_gl_prompt = (prompt) ? prompt : ""; - io_gl_buf[0] = '\0'; - io_gl_fixup(io_gl_prompt, -2, IO_GL_BUF_SIZE); + char *getline_int(const char *prompt) + { + gl_init(); + gl_prompt = (prompt) ? prompt : ""; + gl_buf[0] = '\0'; + gl_fixup(gl_prompt, -2, GL_BUF_SIZE); #ifdef __windows__ - FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); + FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); #endif - int c; - while ((c = io_gl_getc()) >= 0) { - io_gl_extent = 0; /* reset to full extent */ - if (isprint(c)) { - if (io_gl_search_mode) { - search_addchar(c); - } - else { - io_gl_addchar(c); - } - } - else { - if (io_gl_search_mode) { - if (c == '\033' || c == '\016' || c == '\020') { - search_term(); - c = 0; /* ignore the character */ + int c; + while ((c = gl_getc()) >= 0) { + gl_extent = 0; /* reset to full extent */ + if (isprint(c)) { + if (gl_search_mode) { + search_addchar(c); } - else if (c == '\010' || c == '\177') { - search_addchar(-1); /* unwind search string */ - c = 0; - } - else if (c != '\022' && c != '\023') { - search_term(); /* terminate and handle char */ + else { + gl_addchar(c); } } - switch (c) { - case '\n': - case '\r': /* newline */ - io_gl_newline(); - io_gl_cleanup(); - return io_gl_buf; - case '\001': - io_gl_fixup(io_gl_prompt, -1, 0); /* ^A */ - break; - case '\002': - io_gl_fixup(io_gl_prompt, -1, io_gl_pos - 1); /* ^B */ - break; - case '\004': /* ^D */ - if (io_gl_cnt == 0) { - io_gl_buf[0] = '\0'; - io_gl_cleanup(); - io_gl_putc('\n'); - return io_gl_buf; + else { + if (gl_search_mode) { + if (c == '\033' || c == '\016' || c == '\020') { + search_term(); + c = 0; /* ignore the character */ + } + else if (c == '\010' || c == '\177') { + search_addchar(-1); /* unwind search string */ + c = 0; + } + else if (c != '\022' && c != '\023') { + search_term(); /* terminate and handle char */ + } } - else { - io_gl_del(0, 1); + switch (c) { + case '\n': + case '\r': /* newline */ + gl_newline(); + gl_cleanup(); + return gl_buf; + case '\001': + gl_fixup(gl_prompt, -1, 0); /* ^A */ + break; + case '\002': + gl_fixup(gl_prompt, -1, gl_pos - 1); /* ^B */ + break; + case '\004': /* ^D */ + if (gl_cnt == 0) { + gl_buf[0] = '\0'; + gl_cleanup(); + gl_putc('\n'); + return gl_buf; + } + else { + gl_del(0, 1); + } + break; + case '\005': + gl_fixup(gl_prompt, -1, gl_cnt); /* ^E */ + break; + case '\006': + gl_fixup(gl_prompt, -1, gl_pos + 1); /* ^F */ + break; + case '\010': + case '\177': + gl_del(-1, 0); /* ^H and DEL */ + break; + case '\t': /* TAB */ break; + case '\013': + gl_kill(gl_pos); /* ^K */ + break; + case '\014': + gl_redraw(); /* ^L */ + break; + case '\016': /* ^N */ + copy_string(gl_buf, hist_next(), GL_BUF_SIZE); + gl_fixup(gl_prompt, 0, GL_BUF_SIZE); + break; + case '\017': + gl_overwrite = !gl_overwrite; /* ^O */ + break; + case '\020': /* ^P */ + copy_string(gl_buf, hist_prev(), GL_BUF_SIZE); + gl_fixup(gl_prompt, 0, GL_BUF_SIZE); + break; + case '\022': + search_back(1); /* ^R */ + break; + case '\023': + search_forw(1); /* ^S */ + break; + case '\024': + gl_transpose(); /* ^T */ + break; + case '\025': + gl_kill(0); /* ^U */ + break; + case '\031': + gl_yank(); /* ^Y */ + break; + default: + if (c > 0) + gl_beep(); + break; } - break; - case '\005': - io_gl_fixup(io_gl_prompt, -1, io_gl_cnt); /* ^E */ - break; - case '\006': - io_gl_fixup(io_gl_prompt, -1, io_gl_pos + 1); /* ^F */ - break; - case '\010': - case '\177': - io_gl_del(-1, 0); /* ^H and DEL */ - break; - case '\t': /* TAB */ break; - case '\013': - io_gl_kill(io_gl_pos); /* ^K */ - break; - case '\014': - io_gl_redraw(); /* ^L */ - break; - case '\016': /* ^N */ - copy_string(io_gl_buf, hist_next(), IO_GL_BUF_SIZE); - io_gl_fixup(io_gl_prompt, 0, IO_GL_BUF_SIZE); - break; - case '\017': - io_gl_overwrite = !io_gl_overwrite; /* ^O */ - break; - case '\020': /* ^P */ - copy_string(io_gl_buf, hist_prev(), IO_GL_BUF_SIZE); - io_gl_fixup(io_gl_prompt, 0, IO_GL_BUF_SIZE); - break; - case '\022': - search_back(1); /* ^R */ - break; - case '\023': - search_forw(1); /* ^S */ - break; - case '\024': - io_gl_transpose(); /* ^T */ - break; - case '\025': - io_gl_kill(0); /* ^U */ - break; - case '\031': - io_gl_yank(); /* ^Y */ - break; - default: - if (c > 0) - io_gl_beep(); - break; } } + gl_cleanup(); + gl_buf[0] = '\0'; + return gl_buf; } - io_gl_cleanup(); - io_gl_buf[0] = '\0'; - return io_gl_buf; -} - +} // namespace Ioss namespace { - void io_gl_addchar(int c) + void gl_addchar(int c) /* adds the character c to the input buffer at current location */ { - if (io_gl_cnt >= IO_GL_BUF_SIZE - 1) - io_gl_error("\n*** Error: getline(): input buffer overflow\n"); - if (io_gl_overwrite == 0 || io_gl_pos == io_gl_cnt) { - int i; - for (i = io_gl_cnt; i >= io_gl_pos; i--) - io_gl_buf[i + 1] = io_gl_buf[i]; - io_gl_buf[io_gl_pos] = (char)c; - io_gl_fixup(io_gl_prompt, io_gl_pos, io_gl_pos + 1); + + if (gl_overwrite == 0 || gl_pos == gl_cnt) { + if (gl_cnt > GL_BUF_SIZE - 2) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + for (int i = gl_cnt; i >= gl_pos; i--) { + gl_buf[i + 1] = gl_buf[i]; + } + gl_buf[gl_pos] = (char)c; + gl_fixup(gl_prompt, gl_pos, gl_pos + 1); } else { - io_gl_buf[io_gl_pos] = (char)c; - io_gl_extent = 1; - io_gl_fixup(io_gl_prompt, io_gl_pos, io_gl_pos + 1); + if (gl_pos > GL_BUF_SIZE - 1) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + gl_buf[gl_pos] = (char)c; + gl_extent = 1; + gl_fixup(gl_prompt, gl_pos, gl_pos + 1); } } - void io_gl_yank(void) + void gl_yank(void) /* adds the kill buffer to the input buffer at current location */ { - int len = strlen(io_gl_killbuf); + int len = strlen(gl_killbuf); if (len > 0) { - if (io_gl_overwrite == 0) { - if (io_gl_cnt + len >= IO_GL_BUF_SIZE - 1) - io_gl_error("\n*** Error: getline(): input buffer overflow\n"); - for (int i = io_gl_cnt; i >= io_gl_pos; i--) - io_gl_buf[i + len] = io_gl_buf[i]; - for (int i = 0; i < len; i++) - io_gl_buf[io_gl_pos + i] = io_gl_killbuf[i]; - io_gl_fixup(io_gl_prompt, io_gl_pos, io_gl_pos + len); + if (gl_overwrite == 0) { + if (gl_cnt + len >= GL_BUF_SIZE) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + for (int i = gl_cnt; i >= gl_pos; i--) { + gl_buf[i + len] = gl_buf[i]; + } + for (int i = 0; i < len; i++) { + gl_buf[gl_pos + i] = gl_killbuf[i]; + } + gl_fixup(gl_prompt, gl_pos, gl_pos + len); } else { - if (io_gl_pos + len > io_gl_cnt) { - if (io_gl_pos + len >= IO_GL_BUF_SIZE - 1) - io_gl_error("\n*** Error: getline(): input buffer overflow\n"); - io_gl_buf[io_gl_pos + len] = '\0'; + if (gl_pos + len >= GL_BUF_SIZE) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + if (gl_pos + len > gl_cnt) { + gl_buf[gl_pos + len] = '\0'; + } + for (int i = 0; i < len; i++) { + gl_buf[gl_pos + i] = gl_killbuf[i]; } - for (int i = 0; i < len; i++) - io_gl_buf[io_gl_pos + i] = io_gl_killbuf[i]; - io_gl_extent = len; - io_gl_fixup(io_gl_prompt, io_gl_pos, io_gl_pos + len); + gl_extent = len; + gl_fixup(gl_prompt, gl_pos, gl_pos + len); } } else - io_gl_beep(); + gl_beep(); } - void io_gl_transpose(void) + void gl_transpose(void) /* switch character under cursor and to left of cursor */ { - if (io_gl_pos > 0 && io_gl_cnt > io_gl_pos) { - int c = io_gl_buf[io_gl_pos - 1]; - io_gl_buf[io_gl_pos - 1] = io_gl_buf[io_gl_pos]; - io_gl_buf[io_gl_pos] = (char)c; - io_gl_extent = 2; - io_gl_fixup(io_gl_prompt, io_gl_pos - 1, io_gl_pos); + if (gl_pos > 0 && gl_cnt > gl_pos && gl_pos < GL_BUF_SIZE) { + int c = gl_buf[gl_pos - 1]; + gl_buf[gl_pos - 1] = gl_buf[gl_pos]; + gl_buf[gl_pos] = (char)c; + gl_extent = 2; + gl_fixup(gl_prompt, gl_pos - 1, gl_pos); + } + else { + gl_beep(); } - else - io_gl_beep(); } - void io_gl_newline(void) + void gl_newline(void) /* * Cleans up entire line before returning to caller. A \n is appended. * If line longer than screen, we redraw starting at beginning */ { - int change = io_gl_cnt; - int len = io_gl_cnt; - int loc = io_gl_width - 5; /* shifts line back to start position */ + int change = gl_cnt; + int len = gl_cnt; + int loc = gl_width - 5; /* shifts line back to start position */ - if (io_gl_cnt >= IO_GL_BUF_SIZE - 1) - io_gl_error("\n*** Error: getline(): input buffer overflow\n"); - if (loc > len) + if (gl_cnt >= GL_BUF_SIZE - 1) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + if (loc > len) { loc = len; - io_gl_fixup(io_gl_prompt, change, loc); /* must do this before appending \n */ - io_gl_buf[len] = '\n'; - io_gl_buf[len + 1] = '\0'; - io_gl_putc('\n'); + } + gl_fixup(gl_prompt, change, loc); /* must do this before appending \n */ + gl_buf[len] = '\n'; + gl_buf[len + 1] = '\0'; + gl_putc('\n'); } - void io_gl_del(int loc, int killsave) + void gl_del(int loc, int killsave) /* * Delete a character. The loc variable can be: @@ -515,45 +527,52 @@ namespace { * 0 : delete character under cursor */ { - if ((loc == -1 && io_gl_pos > 0) || (loc == 0 && io_gl_pos < io_gl_cnt)) { + if ((loc == -1 && gl_pos > 0) || (loc == 0 && gl_pos < gl_cnt)) { int j = 0; - for (int i = io_gl_pos + loc; i < io_gl_cnt; i++) { - if ((j == 0) && (killsave != 0)) { - io_gl_killbuf[0] = io_gl_buf[i]; - io_gl_killbuf[1] = '\0'; - j = 1; + for (int i = gl_pos + loc; i < gl_cnt; i++) { + if (i < GL_BUF_SIZE - 1) { + if ((j == 0) && (killsave != 0)) { + gl_killbuf[0] = gl_buf[i]; + gl_killbuf[1] = '\0'; + j = 1; + } + gl_buf[i] = gl_buf[i + 1]; + } + else { + gl_error("\n*** Error: getline(): logic error in gl_del().\n"); } - io_gl_buf[i] = io_gl_buf[i + 1]; } - io_gl_fixup(io_gl_prompt, io_gl_pos + loc, io_gl_pos + loc); + gl_fixup(gl_prompt, gl_pos + loc, gl_pos + loc); + } + else { + gl_beep(); } - else - io_gl_beep(); } - void io_gl_kill(int pos) + void gl_kill(int pos) /* delete from pos to the end of line */ { - if (pos < io_gl_cnt) { - copy_string(io_gl_killbuf, io_gl_buf + pos, IO_GL_BUF_SIZE); - io_gl_buf[pos] = '\0'; - io_gl_fixup(io_gl_prompt, pos, pos); + if (pos < gl_cnt && pos < GL_BUF_SIZE) { + copy_string(gl_killbuf, gl_buf + pos, GL_BUF_SIZE); + gl_buf[pos] = '\0'; + gl_fixup(gl_prompt, pos, pos); + } + else { + gl_beep(); } - else - io_gl_beep(); } - void io_gl_redraw(void) + void gl_redraw(void) /* emit a newline, reset and redraw prompt and current input line */ { - if (io_gl_init_done > 0) { - io_gl_putc('\n'); - io_gl_fixup(io_gl_prompt, -2, io_gl_pos); + if (gl_init_done > 0) { + gl_putc('\n'); + gl_fixup(gl_prompt, -2, gl_pos); } } - void io_gl_fixup(const char *prompt, int change, int cursor) + void gl_fixup(const char *prompt, int change, int cursor) /* * This function is used both for redrawing when input changes or for @@ -563,118 +582,130 @@ namespace { * with -1 indicating no changes, -2 indicating we're on * a new line, redraw everything. * cursor : the desired location of the cursor after the call. - * A value of IO_GL_BUF_SIZE can be used to indicate the cursor should + * A value of GL_BUF_SIZE can be used to indicate the cursor should * move just past the end of the input line. */ { - static int io_gl_shift; /* index of first on screen character */ - static int off_right; /* true if more text right of screen */ - static int off_left; /* true if more text left of screen */ + static int gl_shift; /* index of first on screen character */ + static int off_right; /* true if more text right of screen */ + static int off_left; /* true if more text left of screen */ static char last_prompt[80] = ""; int left = 0, right = -1; /* bounds for redraw */ - int new_right = -1; /* alternate right bound, using io_gl_extent */ + int new_right = -1; /* alternate right bound, using gl_extent */ if (change == -2) { /* reset */ - io_gl_pos = io_gl_cnt = io_gl_shift = off_right = off_left = 0; - io_gl_putc('\r'); - io_gl_puts(prompt); + gl_pos = gl_cnt = gl_shift = off_right = off_left = 0; + gl_putc('\r'); + gl_puts(prompt); copy_string(last_prompt, prompt, 80); - change = 0; - io_gl_width = io_gl_termw - strlen(prompt); + change = 0; + gl_width = gl_termw - strlen(prompt); } else if (strcmp(prompt, last_prompt) != 0) { - int l1 = strlen(last_prompt); - int l2 = strlen(prompt); - io_gl_cnt = io_gl_cnt + l1 - l2; + int l1 = strlen(last_prompt); + int l2 = strlen(prompt); + gl_cnt = gl_cnt + l1 - l2; copy_string(last_prompt, prompt, 80); - io_gl_putc('\r'); - io_gl_puts(prompt); - io_gl_pos = io_gl_shift; - io_gl_width = io_gl_termw - l2; - change = 0; + gl_putc('\r'); + gl_puts(prompt); + gl_pos = gl_shift; + gl_width = gl_termw - l2; + change = 0; } /* how much to erase at end of line */ - int pad = (off_right) ? io_gl_width - 1 : io_gl_cnt - io_gl_shift; /* old length */ - int backup = io_gl_pos - io_gl_shift; /* how far to backup before fixing */ + int pad = (off_right) ? gl_width - 1 : gl_cnt - gl_shift; /* old length */ + int backup = gl_pos - gl_shift; /* how far to backup before fixing */ if (change >= 0) { - io_gl_cnt = strlen(io_gl_buf); - if (change > io_gl_cnt) - change = io_gl_cnt; - } - if (cursor > io_gl_cnt) { - if (cursor != IO_GL_BUF_SIZE) { /* IO_GL_BUF_SIZE means end of line */ - if (io_gl_ellipses_during_completion == 0) { - io_gl_beep(); + gl_cnt = strlen(gl_buf); + if (change > gl_cnt) { + change = gl_cnt; + } + } + if (cursor > gl_cnt) { + if (cursor != GL_BUF_SIZE) { /* GL_BUF_SIZE means end of line */ + if (gl_ellipses_during_completion) { + gl_beep(); } } - cursor = io_gl_cnt; + cursor = gl_cnt; } if (cursor < 0) { - io_gl_beep(); + gl_beep(); cursor = 0; } int extra = 0; /* adjusts when shift (scroll) happens */ - if (off_right || (off_left && cursor < io_gl_shift + io_gl_width - io_gl_scroll / 2)) { + if (off_right || (off_left && cursor < gl_shift + gl_width - gl_scroll / 2)) { extra = 2; /* shift the scrolling boundary */ } - int new_shift = cursor + extra + io_gl_scroll - io_gl_width; + int new_shift = cursor + extra + gl_scroll - gl_width; if (new_shift > 0) { - new_shift /= io_gl_scroll; - new_shift *= io_gl_scroll; + new_shift /= gl_scroll; + new_shift *= gl_scroll; } - else + else { new_shift = 0; - if (new_shift != io_gl_shift) { /* scroll occurs */ - io_gl_shift = new_shift; - off_left = (io_gl_shift) ? 1 : 0; - off_right = (io_gl_cnt > io_gl_shift + io_gl_width - 1) ? 1 : 0; - left = io_gl_shift; - new_right = right = (off_right) ? io_gl_shift + io_gl_width - 2 : io_gl_cnt; + } + if (new_shift != gl_shift) { /* scroll occurs */ + gl_shift = new_shift; + off_left = (gl_shift) ? 1 : 0; + off_right = (gl_cnt > gl_shift + gl_width - 1) ? 1 : 0; + left = gl_shift; + new_right = right = (off_right) ? gl_shift + gl_width - 2 : gl_cnt; } else if (change >= 0) { /* no scroll, but text changed */ - if (change < io_gl_shift + off_left) { - left = io_gl_shift; + if (change < gl_shift + off_left) { + left = gl_shift; } else { left = change; - backup = io_gl_pos - change; + backup = gl_pos - change; } - off_right = (io_gl_cnt > io_gl_shift + io_gl_width - 1) ? 1 : 0; - right = (off_right) ? io_gl_shift + io_gl_width - 2 : io_gl_cnt; - new_right = (io_gl_extent && (right > left + io_gl_extent)) ? left + io_gl_extent : right; + off_right = (gl_cnt > gl_shift + gl_width - 1) ? 1 : 0; + right = (off_right) ? gl_shift + gl_width - 2 : gl_cnt; + new_right = (gl_extent && (right > left + gl_extent)) ? left + gl_extent : right; } - pad -= (off_right) ? io_gl_width - 1 : io_gl_cnt - io_gl_shift; + pad -= (off_right) ? gl_width - 1 : gl_cnt - gl_shift; pad = (pad < 0) ? 0 : pad; if (left <= right) { /* clean up screen */ - for (int i = 0; i < backup; i++) - io_gl_putc('\b'); - if (left == io_gl_shift && off_left) { - io_gl_putc('$'); + for (int i = 0; i < backup; i++) { + gl_putc('\b'); + } + if (left == gl_shift && off_left) { + gl_putc('$'); left++; } - for (int i = left; i < new_right; i++) - io_gl_putc(io_gl_buf[i]); - io_gl_pos = new_right; + for (int i = left; i < new_right; i++) { + gl_putc(gl_buf[i]); + } + gl_pos = new_right; if (off_right && new_right == right) { - io_gl_putc('$'); - io_gl_pos++; + gl_putc('$'); + gl_pos++; } else { - for (int i = 0; i < pad; i++) /* erase remains of prev line */ - io_gl_putc(' '); - io_gl_pos += pad; + for (int i = 0; i < pad; i++) { /* erase remains of prev line */ + gl_putc(' '); + } + gl_pos += pad; } } - int i = io_gl_pos - cursor; /* move to final cursor location */ + int i = gl_pos - cursor; /* move to final cursor location */ if (i > 0) { - while (i--) - io_gl_putc('\b'); + while (i--) { + gl_putc('\b'); + } } else { - for (int ii = io_gl_pos; ii < cursor; ii++) - io_gl_putc(io_gl_buf[ii]); + if (cursor < GL_BUF_SIZE) { + for (int ii = gl_pos; ii < cursor; ii++) { + gl_putc(gl_buf[ii]); + } + } + else { + gl_error("\n*** Error: getline(): logic error in gl_fixup().\n"); + } } - io_gl_pos = cursor; + gl_pos = cursor; } /******************* History stuff **************************************/ @@ -690,53 +721,58 @@ namespace { void hist_init(void) { hist_buf[0] = hist_empty_elem; - for (int i = 1; i < HIST_SIZE; i++) - hist_buf[i] = NULL; + for (int i = 1; i < HIST_SIZE; i++) { + hist_buf[i] = nullptr; + } } } // namespace -void io_gl_histadd(const char *buf) -{ - static char *prev = NULL; - /* in case we call io_gl_histadd() before we call getline() */ - if (io_gl_init_done < 0) { /* -1 only on startup */ - hist_init(); - io_gl_init_done = 0; - } - const char *p = buf; - while (*p == ' ' || *p == '\t' || *p == '\n') - p++; - if (*p) { - int len = strlen(buf); - if (strchr(p, '\n')) /* previously line already has NL stripped */ - len--; - if ((prev == NULL) || ((int)strlen(prev) != len) || strncmp(prev, buf, (size_t)len) != 0) { - hist_buf[hist_last] = hist_save(buf); - prev = hist_buf[hist_last]; - hist_last = (hist_last + 1) % HIST_SIZE; - if (hist_buf[hist_last] && *hist_buf[hist_last]) { - free(hist_buf[hist_last]); +namespace Ioss { + void gl_histadd(const char *buf) + { + static char *prev = nullptr; + + /* in case we call gl_histadd() before we call getline() */ + if (gl_init_done < 0) { /* -1 only on startup */ + hist_init(); + gl_init_done = 0; + } + const char *p = buf; + while (*p == ' ' || *p == '\t' || *p == '\n') { + p++; + } + if (*p) { + int len = strlen(buf); + if (strchr(p, '\n')) { /* previously line already has NL stripped */ + len--; + } + if ((prev == nullptr) || ((int)strlen(prev) != len) || strncmp(prev, buf, (size_t)len) != 0) { + hist_buf[hist_last] = hist_save(buf); + prev = hist_buf[hist_last]; + hist_last = (hist_last + 1) % HIST_SIZE; + if (hist_buf[hist_last] && *hist_buf[hist_last]) { + free(hist_buf[hist_last]); + } + hist_buf[hist_last] = hist_empty_elem; } - hist_buf[hist_last] = hist_empty_elem; } + hist_pos = hist_last; } - hist_pos = hist_last; -} - +} // namespace Ioss namespace { char *hist_prev(void) /* loads previous hist entry into input buffer, sticks on first */ { - char *p = NULL; + char *p = nullptr; int next = (hist_pos - 1 + HIST_SIZE) % HIST_SIZE; - if (hist_buf[hist_pos] != NULL && next != hist_last) { + if (hist_buf[hist_pos] != nullptr && next != hist_last) { hist_pos = next; p = hist_buf[hist_pos]; } - if (p == NULL) { + if (p == nullptr) { p = hist_empty_elem; - io_gl_beep(); + gl_beep(); } return p; } @@ -744,15 +780,15 @@ namespace { char *hist_next(void) /* loads next hist entry into input buffer, clears on last */ { - char *p = NULL; + char *p = nullptr; if (hist_pos != hist_last) { hist_pos = (hist_pos + 1) % HIST_SIZE; p = hist_buf[hist_pos]; } - if (p == NULL) { + if (p == nullptr) { p = hist_empty_elem; - io_gl_beep(); + gl_beep(); } return p; } @@ -761,23 +797,24 @@ namespace { /* makes a copy of the string */ { - char *s = NULL; + char *s = nullptr; size_t len = strlen(p); const char *nl = strpbrk(p, "\n\r"); if (nl) { - if ((s = (char *)malloc(len)) != NULL) { + if ((s = (char *)malloc(len)) != nullptr) { copy_string(s, p, len); s[len - 1] = '\0'; } } else { - if ((s = (char *)malloc(len + 1)) != NULL) { + if ((s = (char *)malloc(len + 1)) != nullptr) { copy_string(s, p, len + 1); } } - if (s == NULL) - io_gl_error("\n*** Error: hist_save() failed on malloc\n"); + if (s == nullptr) { + gl_error("\n*** Error: hist_save() failed on malloc\n"); + } return s; } @@ -794,6 +831,7 @@ namespace { if (c == 0) { search_pos = 0; search_string[0] = '\0'; + search_prompt[0] = '?'; search_prompt[1] = ' '; search_prompt[2] = '\0'; @@ -801,6 +839,7 @@ namespace { else if (c > 0) { search_string[search_pos] = (char)c; search_string[search_pos + 1] = (char)0; + search_prompt[search_pos] = (char)c; search_prompt[search_pos + 1] = (char)'?'; search_prompt[search_pos + 2] = (char)' '; @@ -810,13 +849,14 @@ namespace { else { if (search_pos > 0) { search_pos--; - search_string[search_pos] = (char)0; + search_string[search_pos] = (char)0; + search_prompt[search_pos] = (char)'?'; search_prompt[search_pos + 1] = (char)' '; search_prompt[search_pos + 2] = (char)0; } else { - io_gl_beep(); + gl_beep(); hist_pos = hist_last; } } @@ -830,15 +870,15 @@ namespace { hist_pos = search_last; } else { - io_gl_buf[0] = '\0'; - hist_pos = hist_last; + gl_buf[0] = '\0'; + hist_pos = hist_last; } - copy_string(io_gl_buf, hist_buf[hist_pos], IO_GL_BUF_SIZE); + copy_string(gl_buf, hist_buf[hist_pos], GL_BUF_SIZE); } - char *loc = NULL; - if ((loc = strstr(io_gl_buf, search_string)) != NULL) { - io_gl_fixup(search_prompt, 0, loc - io_gl_buf); + char *loc = nullptr; + if ((loc = strstr(gl_buf, search_string)) != nullptr) { + gl_fixup(search_prompt, 0, loc - gl_buf); } else if (search_pos > 0) { if (search_forw_flg) { @@ -849,49 +889,50 @@ namespace { } } else { - io_gl_fixup(search_prompt, 0, 0); + gl_fixup(search_prompt, 0, 0); } } void search_term(void) { - io_gl_search_mode = 0; - if (io_gl_buf[0] == 0) /* not found, reset hist list */ + gl_search_mode = 0; + if (gl_buf[0] == 0) { /* not found, reset hist list */ hist_pos = hist_last; - io_gl_fixup(io_gl_prompt, 0, io_gl_pos); + } + gl_fixup(gl_prompt, 0, gl_pos); } void search_back(int new_search) { search_forw_flg = 0; - if (io_gl_search_mode == 0) { + if (gl_search_mode == 0) { search_last = hist_pos = hist_last; search_update(0); - io_gl_search_mode = 1; - io_gl_buf[0] = '\0'; - io_gl_fixup(search_prompt, 0, 0); + gl_search_mode = 1; + gl_buf[0] = '\0'; + gl_fixup(search_prompt, 0, 0); } else if (search_pos > 0) { - int found = 0; + bool found = false; while (!found) { char *loc; char *p = hist_prev(); if (*p == 0) { /* not found, done looking */ - io_gl_buf[0] = '\0'; - io_gl_fixup(search_prompt, 0, 0); - found = 1; + gl_buf[0] = '\0'; + gl_fixup(search_prompt, 0, 0); + found = true; } - else if ((loc = strstr(p, search_string)) != NULL) { - copy_string(io_gl_buf, p, IO_GL_BUF_SIZE); - io_gl_fixup(search_prompt, 0, loc - p); + else if ((loc = strstr(p, search_string)) != nullptr) { + copy_string(gl_buf, p, GL_BUF_SIZE); + gl_fixup(search_prompt, 0, loc - p); if (new_search) search_last = hist_pos; - found = 1; + found = true; } } } else { - io_gl_beep(); + gl_beep(); } } @@ -900,42 +941,42 @@ namespace { char *loc; search_forw_flg = 1; - if (io_gl_search_mode == 0) { + if (gl_search_mode == 0) { search_last = hist_pos = hist_last; search_update(0); - io_gl_search_mode = 1; - io_gl_buf[0] = '\0'; - io_gl_fixup(search_prompt, 0, 0); + gl_search_mode = 1; + gl_buf[0] = '\0'; + gl_fixup(search_prompt, 0, 0); } else if (search_pos > 0) { - int found = 0; + bool found = false; while (!found) { char *p = hist_next(); if (*p == 0) { /* not found, done looking */ - io_gl_buf[0] = '\0'; - io_gl_fixup(search_prompt, 0, 0); - found = 1; + gl_buf[0] = '\0'; + gl_fixup(search_prompt, 0, 0); + found = true; } - else if ((loc = strstr(p, search_string)) != NULL) { - copy_string(io_gl_buf, p, IO_GL_BUF_SIZE); - io_gl_fixup(search_prompt, 0, loc - p); + else if ((loc = strstr(p, search_string)) != nullptr) { + copy_string(gl_buf, p, GL_BUF_SIZE); + gl_fixup(search_prompt, 0, loc - p); if (new_search) search_last = hist_pos; - found = 1; + found = true; } } } else { - io_gl_beep(); + gl_beep(); } } - void io_gl_beep(void) + void gl_beep(void) { #ifdef __windows__ MessageBeep(MB_OK); #else - io_gl_putc('\007'); + gl_putc('\007'); #endif - } /* io_gl_beep */ + } /* gl_beep */ } // namespace diff --git a/packages/seacas/libraries/ioss/src/Ioss_Getline.h b/packages/seacas/libraries/ioss/src/Ioss_Getline.h index 52cd43554094..5245f8c9d7c1 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Getline.h +++ b/packages/seacas/libraries/ioss/src/Ioss_Getline.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 1991, 1992, 1993, 2022 by Chris Thewalt (thewalt@ce.berkeley.edu) + * Copyright (C) 1991, 1992, 1993, 2022, 2023 by Chris Thewalt (thewalt@ce.berkeley.edu) * * Permission to use, copy, modify, and distribute this software * for any purpose and without fee is hereby granted, provided @@ -19,14 +19,8 @@ #include "ioss_export.h" -#ifdef __cplusplus -extern "C" { -#endif - -IOSS_EXPORT char *io_getline_int(const char *); /* read a line of input */ -IOSS_EXPORT void io_gl_setwidth(int); /* specify width of screen */ -IOSS_EXPORT void io_gl_histadd(const char *); /* adds entries to hist */ - -#ifdef __cplusplus -} /* close brackets on extern "C" declaration */ -#endif +namespace Ioss { + IOSS_EXPORT char *getline_int(const char *); /* read a line of input */ + IOSS_EXPORT void gl_setwidth(int); /* specify width of screen */ + IOSS_EXPORT void gl_histadd(const char *); /* adds entries to hist */ +} // namespace Ioss diff --git a/packages/seacas/libraries/ioss/src/Ioss_Sort.h b/packages/seacas/libraries/ioss/src/Ioss_Sort.h index 84e99e3c336b..6537a6a7abd0 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Sort.h +++ b/packages/seacas/libraries/ioss/src/Ioss_Sort.h @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -6,134 +6,17 @@ #pragma once +#if !defined(IOSS_USE_STD_SORT) #include +#endif #include #include -#if 0 - -// This is used instead of the std::sort since we were having issues -// with the std::sort on some compiler versions with certain options -// enabled (-fopenmp). If this shows up as a hotspot in performance -// measurements, then we can use std::sort on most platforms and just -// use this version where there are compiler issues. - -namespace { - const int QSORT_CUTOFF = 12; - - template void SWAP(INT *V, size_t I, size_t J) { std::swap(V[I], V[J]); } - - template void order3(INT v[], size_t left, size_t center, size_t right) - { - if (v[left] > v[center]) { - SWAP(v, left, center); - } - if (v[left] > v[right]) { - SWAP(v, left, right); - } - if (v[center] > v[right]) { - SWAP(v, center, right); - } - } - - template size_t median3(INT v[], size_t left, size_t right) - { - size_t center = (left + right) / 2; - size_t pl = left; - size_t pm = center; - size_t pr = right; - - if (right - left > 40) { - size_t s = (right - left) / 8; - order3(v, left, left + s, left + 2 * s); - order3(v, center - s, center, center + s); - order3(v, right - 2 * s, right - s, right); - - // Now set up to get median of the 3 medians... - pl = left + s; - pm = center; - pr = right - s; - } - order3(v, pl, pm, pr); - - SWAP(v, center, right - 1); - return right - 1; - } - - template void qsort_int(INT v[], size_t left, size_t right) - { - if (left + QSORT_CUTOFF < right) { - size_t pivot = median3(v, left, right); - size_t i = left; - size_t j = right - 1; - - for (;;) { - while (v[++i] < v[pivot]) { - ; - } - while (v[--j] > v[pivot]) { - ; - } - if (i < j) { - SWAP(v, i, j); - } - else { - break; - } - } - - SWAP(v, i, right - 1); - qsort_int(v, left, i - 1); - qsort_int(v, i + 1, right); - } - } - - template void isort_int(INT v[], size_t N) - { - size_t j; - size_t ndx = 0; - - if (N <= 1) { - return; - } - INT small = v[0]; - for (size_t i = 1; i < N; i++) { - if (v[i] < small) { - small = v[i]; - ndx = i; - } - } - /* Put smallest value in slot 0 */ - SWAP(v, 0, ndx); - - for (size_t i = 1; i < N; i++) { - INT tmp = v[i]; - for (j = i; tmp < v[j - 1]; j--) { - v[j] = v[j - 1]; - } - v[j] = tmp; - } - } -} // namespace -#endif namespace Ioss { - template void sort(std::vector &v) - { - if (v.size() <= 1) { - return; - } -#if 0 - qsort_int(v.data(), 0, v.size() - 1); - isort_int(v.data(), v.size()); -#else - pdqsort(v.begin(), v.end()); -#endif - } - template inline void sort(Iter begin, Iter end, Comp compare) { -#if USE_STD_SORT +#if defined(IOSS_USE_STD_SORT) std::sort(begin, end, compare); #else pdqsort(begin, end, compare); @@ -142,10 +25,19 @@ namespace Ioss { template inline void sort(Iter begin, Iter end) { -#if USE_STD_SORT +#if defined(IOSS_USE_STD_SORT) std::sort(begin, end); #else pdqsort(begin, end); #endif } + + template void sort(std::vector &v) + { + if (v.size() <= 1) { + return; + } + Ioss::sort(v.begin(), v.end()); + } + } // namespace Ioss diff --git a/packages/seacas/libraries/ioss/src/Ioss_Wedge12.C b/packages/seacas/libraries/ioss/src/Ioss_Wedge12.C index 66f787674404..8d7da4054b52 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Wedge12.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Wedge12.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2021 National Technology & Engineering Solutions +// Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -114,6 +114,7 @@ int Ioss::Wedge12::number_edges_face(int face) const Ioss::IntVector Ioss::Wedge12::edge_connectivity(int edge_number) const { + assert(edge_number > 0 && edge_number <= number_edges()); Ioss::IntVector connectivity(number_nodes_edge(edge_number)); for (int i = 0; i < number_nodes_edge(edge_number); i++) { diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C b/packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C index e6ffc25e37c1..72f086ab13fb 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -74,26 +74,20 @@ namespace { const size_t max_line_length = MAX_LINE_LENGTH; - std::string SEP() { return std::string("@"); } // Separator for attribute offset storage - const char *complex_suffix[] = {".re", ".im"}; + const std::string SEP() { return std::string("@"); } // Separator for attribute offset storage + const std::array complex_suffix{".re", ".im"}; void get_connectivity_data(int exoid, void *data, ex_entity_type type, ex_entity_id id, int position) { int ierr = 0; if ((ex_int64_status(exoid) & EX_BULK_INT64_API) != 0) { - int64_t *conn[3]; - conn[0] = nullptr; - conn[1] = nullptr; - conn[2] = nullptr; + std::array conn{nullptr, nullptr, nullptr}; conn[position] = static_cast(data); ierr = ex_get_conn(exoid, type, id, conn[0], conn[1], conn[2]); } else { - int *conn[3]; - conn[0] = nullptr; - conn[1] = nullptr; - conn[2] = nullptr; + std::array conn{nullptr, nullptr, nullptr}; conn[position] = static_cast(data); ierr = ex_get_conn(exoid, type, id, conn[0], conn[1], conn[2]); } @@ -164,8 +158,8 @@ namespace Ioex { open_create_behavior() == Ioss::DB_APPEND_GROUP || open_create_behavior() == Ioss::DB_MODIFY) { // Append to file if it already exists -- See if the file exists. - Ioss::FileInfo file = Ioss::FileInfo(decoded_filename()); - fileExists = file.exists(); + auto file = Ioss::FileInfo(decoded_filename()); + fileExists = file.exists(); } } @@ -479,7 +473,7 @@ namespace Ioex { // of the output database should be the same except we don't write // anything since it is already there. We do need the number of // steps though... - if (open_create_behavior() == Ioss::DB_APPEND) { + if (open_create_behavior() == Ioss::DB_APPEND || dbUsage == Ioss::QUERY_TIMESTEPS_ONLY) { get_step_times__(); return; } @@ -2421,8 +2415,8 @@ int64_t DatabaseIO::get_field_internal(const Ioss::ElementBlock *eb, const Ioss: // The connectivity is stored in a 1D array. // The element_face index varies fastest if (my_element_count > 0) { - int face_count = field.get_component_count(Ioss::Field::InOut::INPUT); - get_connectivity_data(get_file_pointer(), data, EX_ELEM_BLOCK, id, 2); + int face_count = field.get_component_count(Ioss::Field::InOut::INPUT); + get_connectivity_data(get_file_pointer(), data, EX_ELEM_BLOCK, id, 2); get_map(EX_FACE_BLOCK).map_data(data, field, num_to_get * face_count); } } @@ -2430,7 +2424,7 @@ int64_t DatabaseIO::get_field_internal(const Ioss::ElementBlock *eb, const Ioss: // The connectivity is stored in a 1D array. // The element_edge index varies fastest if (my_element_count > 0) { - int edge_count = field.get_component_count(Ioss::Field::InOut::INPUT); + int edge_count = field.get_component_count(Ioss::Field::InOut::INPUT); get_connectivity_data(get_file_pointer(), data, EX_ELEM_BLOCK, id, 1); get_map(EX_EDGE_BLOCK).map_data(data, field, num_to_get * edge_count); } @@ -2585,8 +2579,8 @@ int64_t DatabaseIO::get_field_internal(const Ioss::FaceBlock *eb, const Ioss::Fi // The connectivity is stored in a 1D array. // The face_node index varies fastet if (my_face_count > 0) { - int face_nodes = eb->topology()->number_nodes(); - assert(field.get_component_count(Ioss::Field::InOut::INPUT) == face_nodes); + int face_nodes = eb->topology()->number_nodes(); + assert(field.get_component_count(Ioss::Field::InOut::INPUT) == face_nodes); get_connectivity_data(get_file_pointer(), data, EX_FACE_BLOCK, id, 0); get_map(EX_NODE_BLOCK).map_data(data, field, num_to_get * face_nodes); @@ -2596,7 +2590,7 @@ int64_t DatabaseIO::get_field_internal(const Ioss::FaceBlock *eb, const Ioss::Fi // The connectivity is stored in a 1D array. // The face_edge index varies fastest if (my_face_count > 0) { - int edge_count = field.get_component_count(Ioss::Field::InOut::INPUT); + int edge_count = field.get_component_count(Ioss::Field::InOut::INPUT); get_connectivity_data(get_file_pointer(), data, EX_FACE_BLOCK, id, 1); get_map(EX_EDGE_BLOCK).map_data(data, field, num_to_get * edge_count); } @@ -2605,9 +2599,9 @@ int64_t DatabaseIO::get_field_internal(const Ioss::FaceBlock *eb, const Ioss::Fi // The connectivity is stored in a 1D array. // The face_node index varies fastet if (my_face_count > 0) { - // "connectivity_raw" has nodes in local id space (1-based) - assert(field.get_component_count(Ioss::Field::InOut::INPUT) == - eb->topology()->number_nodes()); + // "connectivity_raw" has nodes in local id space (1-based) + assert(field.get_component_count(Ioss::Field::InOut::INPUT) == + eb->topology()->number_nodes()); get_connectivity_data(get_file_pointer(), data, EX_FACE_BLOCK, id, 0); } diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C b/packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C index 21c4b107aa7a..01704a8d2080 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C @@ -84,7 +84,7 @@ namespace { const size_t max_line_length = MAX_LINE_LENGTH; const std::string SEP() { return std::string("@"); } // Separator for attribute offset storage - const char *complex_suffix[] = {".re", ".im"}; + const std::array complex_suffix{".re", ".im"}; void check_node_owning_processor_data(const Ioss::IntVector &nop, size_t file_node_count) { @@ -118,19 +118,13 @@ namespace { { int ierr = 0; if (int_size_api == 8) { - int64_t *conn[3]; - conn[0] = nullptr; - conn[1] = nullptr; - conn[2] = nullptr; + std::array conn{nullptr, nullptr, nullptr}; conn[position] = static_cast(data); assert(1 == 0 && "Unimplemented fixme"); ierr = ex_get_conn(exoid, type, id, conn[0], conn[1], conn[2]); // FIXME } else { - int *conn[3]; - conn[0] = nullptr; - conn[1] = nullptr; - conn[2] = nullptr; + std::array conn{nullptr, nullptr, nullptr}; conn[position] = static_cast(data); assert(1 == 0 && "Unimplemented fixme"); ierr = ex_get_conn(exoid, type, id, conn[0], conn[1], conn[2]); // FIXME @@ -338,8 +332,8 @@ namespace Ioex { open_create_behavior() == Ioss::DB_APPEND_GROUP || open_create_behavior() == Ioss::DB_MODIFY) { // Append to file if it already exists -- See if the file exists. - Ioss::FileInfo file = Ioss::FileInfo(get_filename()); - fileExists = file.exists(); + auto file = Ioss::FileInfo(get_filename()); + fileExists = file.exists(); if (fileExists && myProcessor == 0) { fmt::print(Ioss::WarnOut(), "Appending to existing database in parallel single-file " @@ -722,7 +716,7 @@ namespace Ioex { // defining of the output database should be the same except // we don't write anything since it is already there. We do // need the number of steps though... - if (open_create_behavior() == Ioss::DB_APPEND) { + if (open_create_behavior() == Ioss::DB_APPEND || dbUsage == Ioss::QUERY_TIMESTEPS_ONLY) { get_step_times__(); return; } @@ -3886,7 +3880,7 @@ int64_t ParallelDatabaseIO::put_field_internal(const Ioss::ElementBlock *eb, } auto eb_offset = eb->get_offset(); // Offset of beginning of the element block elements for this block - int index = + int index = -1 * (field.get_index() + comp); // Negative since specifying index, not id to exodus API. ierr = ex_put_partial_num_map(get_file_pointer(), EX_ELEM_MAP, index, diff --git a/packages/seacas/libraries/ioss/src/main/info_interface.C b/packages/seacas/libraries/ioss/src/main/info_interface.C index 4af49e7eeb56..7f05aac03ed4 100644 --- a/packages/seacas/libraries/ioss/src/main/info_interface.C +++ b/packages/seacas/libraries/ioss/src/main/info_interface.C @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -151,6 +151,8 @@ void Info::Interface::enroll_options() options_.enroll("group_name", Ioss::GetLongOption::MandatoryValue, "List information only for the specified group.", nullptr, nullptr, true); + options_.enroll("query_timesteps_only", Ioss::GetLongOption::NoValue, + "Only read and output the timestep data on the file", nullptr); options_.enroll("64-bit", Ioss::GetLongOption::NoValue, "Use 64-bit integers", nullptr); options_.enroll("version", Ioss::GetLongOption::NoValue, "Print version and exit", nullptr); @@ -180,7 +182,8 @@ bool Info::Interface::parse_options(int argc, char **argv) options_.usage(std::cerr); fmt::print(stderr, "\n\tCan also set options via IO_INFO_OPTIONS environment variable.\n\n" - "\tDocumentation: https://sandialabs.github.io/seacas-docs/sphinx/html/index.html#io-info\n\n" + "\tDocumentation: " + "https://sandialabs.github.io/seacas-docs/sphinx/html/index.html#io-info\n\n" "\t->->-> Send email to gdsjaar@sandia.gov for {} support.<-<-<-\n", options_.program_name()); exit(EXIT_SUCCESS); @@ -200,6 +203,7 @@ bool Info::Interface::parse_options(int argc, char **argv) useGenericNames_ = options_.retrieve("use_generic_names") != nullptr; summary_ = options_.retrieve("summary") != nullptr; showConfig_ = options_.retrieve("configuration") != nullptr; + queryTimeOnly_ = options_.retrieve("query_timesteps_only") != nullptr; filetype_ = options_.get_option_value("db_type", filetype_); filetype_ = options_.get_option_value("in_type", filetype_); diff --git a/packages/seacas/libraries/ioss/src/main/info_interface.h b/packages/seacas/libraries/ioss/src/main/info_interface.h index 0b988b165e6b..71f6e397e857 100644 --- a/packages/seacas/libraries/ioss/src/main/info_interface.h +++ b/packages/seacas/libraries/ioss/src/main/info_interface.h @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -32,6 +32,7 @@ namespace Info { bool ints_64_bit() const { return ints64Bit_; } bool list_groups() const { return listGroups_; } bool show_config() const { return showConfig_; } + bool query_timesteps_only() const { return queryTimeOnly_; } int surface_split_scheme() const { return surfaceSplitScheme_; } char field_suffix_separator() const { return fieldSuffixSeparator_; } @@ -65,6 +66,7 @@ namespace Info { bool disableFieldRecognition_{false}; bool showConfig_{false}; bool summary_{false}; + bool queryTimeOnly_{false}; char fieldSuffixSeparator_{'_'}; diff --git a/packages/seacas/libraries/ioss/src/main/io_info.C b/packages/seacas/libraries/ioss/src/main/io_info.C index 53a162bf06ea..330df932b583 100644 --- a/packages/seacas/libraries/ioss/src/main/io_info.C +++ b/packages/seacas/libraries/ioss/src/main/io_info.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -18,6 +18,7 @@ // ======================================================================== namespace { + void info_timesteps(Ioss::Region ®ion); void info_nodeblock(Ioss::Region ®ion, const Info::Interface &interFace); void info_edgeblock(Ioss::Region ®ion); void info_faceblock(Ioss::Region ®ion); @@ -150,10 +151,6 @@ namespace { std::string inpfile = interFace.filename(); std::string input_type = interFace.type(); - //======================================================================== - // INPUT ... - // NOTE: The "READ_RESTART" mode ensures that the node and element ids will be mapped. - //======================================================================== Ioss::PropertyManager properties = set_properties(interFace); const auto custom_field = interFace.custom_field(); @@ -164,14 +161,24 @@ namespace { } } - Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(input_type, inpfile, Ioss::READ_RESTART, + //======================================================================== + // INPUT ... + // NOTE: The "READ_RESTART" mode ensures that the node and element ids will be mapped. + //======================================================================== + auto mode = interFace.query_timesteps_only() ? Ioss::QUERY_TIMESTEPS_ONLY : Ioss::READ_RESTART; + Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(input_type, inpfile, mode, Ioss::ParallelUtils::comm_world(), properties); Ioss::io_info_set_db_properties(interFace, dbi); // NOTE: 'region' owns 'db' pointer at this time... Ioss::Region region(dbi, "region_1"); - Ioss::io_info_file_info(interFace, region); + if (interFace.query_timesteps_only()) { + info_timesteps(region); + } + else { + Ioss::io_info_file_info(interFace, region); + } } void info_nodeblock(Ioss::Region ®ion, const Ioss::NodeBlock &nb, @@ -206,8 +213,10 @@ namespace { info_aliases(region, &nb, false, true); } Ioss::Utils::info_fields(&nb, Ioss::Field::MAP, prefix + "\tMap Fields: ", "\n\t\t" + prefix); - Ioss::Utils::info_fields(&nb, Ioss::Field::ATTRIBUTE, prefix + "\tAttributes: ", "\n\t\t" + prefix); - Ioss::Utils::info_fields(&nb, Ioss::Field::TRANSIENT, prefix + "\tTransient: ", "\n\t\t" + prefix); + Ioss::Utils::info_fields(&nb, Ioss::Field::ATTRIBUTE, + prefix + "\tAttributes: ", "\n\t\t" + prefix); + Ioss::Utils::info_fields(&nb, Ioss::Field::TRANSIENT, + prefix + "\tTransient: ", "\n\t\t" + prefix); if (interFace.compute_bbox()) { print_bbox(nb); @@ -544,6 +553,23 @@ namespace { } } + void info_timesteps(Ioss::Region ®ion) + { + int step_count = (int)region.get_property("state_count").get_int(); + std::vector steps(step_count); + + for (int step = 0; step < step_count; step++) { + double db_time = region.get_state_time(step + 1); + steps[step] = db_time; + } + auto mm = std::minmax_element(steps.begin(), steps.end()); + + fmt::print("\nThere are {} time steps on the database.\n", step_count); + fmt::print("\tMinimum Time = {:12.6e}, Maximum Time = {:12.6e}\n\n", *mm.first, *mm.second); + + fmt::print("\tStep Times: {:12.6e}\n", fmt::join(steps, ", ")); + } + } // namespace namespace Ioss { diff --git a/packages/seacas/libraries/ioss/src/main/io_modify.C b/packages/seacas/libraries/ioss/src/main/io_modify.C index bd26d1d2f6ec..b817d37b1354 100644 --- a/packages/seacas/libraries/ioss/src/main/io_modify.C +++ b/packages/seacas/libraries/ioss/src/main/io_modify.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -146,7 +146,7 @@ namespace { const std::vector &filter); void rotate_filtered_coordinates(Ioss::Region ®ion, real rotation_matrix[3][3], const std::vector &filter); - void update_rotation_matrix(real rotation_matrix[3][3], const std::string &axis, double angle); + bool update_rotation_matrix(real rotation_matrix[3][3], const std::string &axis, double angle); void set_db_properties(const Modify::Interface &interFace, Ioss::DatabaseIO *dbi); @@ -328,12 +328,12 @@ int main(int argc, char *argv[]) std::string input; if (from_term) { fmt::print(fg(fmt::terminal_color::magenta), "\n"); - const char *cinput = io_getline_int("COMMAND> "); + const char *cinput = Ioss::getline_int("COMMAND> "); if (cinput && cinput[0] == '\0') { break; } if (cinput) { - io_gl_histadd(cinput); + Ioss::gl_histadd(cinput); } input = cinput; } @@ -1308,7 +1308,10 @@ namespace { do { std::string axis = tokens[idx++]; double angle = std::stod(tokens[idx++]); - update_rotation_matrix(rotation_matrix, axis, angle); + auto ok = update_rotation_matrix(rotation_matrix, axis, angle); + if (!ok) { + return false; + } } while (idx < tokens.size()); // Do the rotation... @@ -1649,7 +1652,7 @@ namespace { std::string out_file = interFace.filename() + ".mod"; std::string file_type = interFace.type(); Ioss::DatabaseIO *dbo = Ioss::IOFactory::create( - file_type, out_file, Ioss::WRITE_RESTART, Ioss::ParallelUtils::comm_world(), properties); + file_type, out_file, Ioss::WRITE_RESTART, Ioss::ParallelUtils::comm_world(), properties); if (dbo == nullptr || !dbo->ok(true)) { std::exit(EXIT_FAILURE); @@ -1797,7 +1800,7 @@ namespace { nb->put_field_data("mesh_model_coordinates", coord); } - void update_rotation_matrix(real rotation_matrix[3][3], const std::string &axis, double angle) + bool update_rotation_matrix(real rotation_matrix[3][3], const std::string &axis, double angle) { int n1 = 0; int n2 = 0; @@ -1818,6 +1821,12 @@ namespace { n2 = 1; n3 = 2; } + else { + fmt::print(stderr, fg(fmt::color::red), + "ERROR: Requested rotation axis '{}' is not valid. Must be 'x', 'y', or 'z'\n", + axis); + return false; + } static real degang = std::atan2(0.0L, -1.0L) / 180.0; real ang_rad = angle * degang; @@ -1850,6 +1859,7 @@ namespace { rotation_matrix[i][j] = res[i][j]; } } + return true; } void modify_time(Ioss::Region ®ion, double scale, double offset) diff --git a/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMesh.C b/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMesh.C index a43857e4220c..872050daa69c 100644 --- a/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMesh.C +++ b/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMesh.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2023 National Technology & Engineering Solutions +// Copyright(C) 1999-2022 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // diff --git a/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMesh.h b/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMesh.h index 20b909da1a58..5b5f8378113a 100644 --- a/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMesh.h +++ b/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMesh.h @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2023 National Technology & Engineering Solutions +// Copyright(C) 1999-2022 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // diff --git a/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMeshFuncs.h b/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMeshFuncs.h index 67512baa63b2..38416a9413ce 100644 --- a/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMeshFuncs.h +++ b/packages/seacas/libraries/ioss/src/text_mesh/Iotm_TextMeshFuncs.h @@ -6,8 +6,8 @@ // ####################### Start Clang Header Tool Managed Headers ######################## // clang-format off -#include // for toupper -#include // for size_t +#include // for toupper +#include // for size_t #include // for remove, etc #include // for insert_iterator #include diff --git a/packages/seacas/libraries/ioss/src/utest/Utst_blob_write_read.C b/packages/seacas/libraries/ioss/src/utest/Utst_blob_write_read.C index 11389fb3b650..7cc24abbd769 100644 --- a/packages/seacas/libraries/ioss/src/utest/Utst_blob_write_read.C +++ b/packages/seacas/libraries/ioss/src/utest/Utst_blob_write_read.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2022 National Technology & Engineering Solutions +// Copyright(C) 1999-2023 National Technology & Engineering Solutions // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with // NTESS, the U.S. Government retains certain rights in this software. // @@ -170,7 +170,7 @@ void write_blob() region.begin_mode(Ioss::STATE_TRANSIENT); const size_t num_ts = 10; for (size_t ts = 0; ts < num_ts; ts++) { - double time = ts / 10.0; + double time = ts; auto step = region.add_state(time); region.begin_state(step); @@ -277,6 +277,12 @@ bool read_blob() if (data != gold) { std::cout << "Difference for field " << field << " on blob " << blob->name() << " at step " << step << "\n"; + for (size_t i = 0; i < data.size(); i++) { + if (data[i] != gold[i]) { + std::cout << "Difference at index " << i << ", Data[i] = " << data[i] + << ", Gold[i] = " << gold[i] << "\n"; + } + } diff = true; } } diff --git a/packages/seacas/libraries/ioss/src/visualization/catalyst/ioss2catalyst/IossApplication.cxx b/packages/seacas/libraries/ioss/src/visualization/catalyst/ioss2catalyst/IossApplication.cxx index e2d8bc3a8083..c7044db03ba1 100644 --- a/packages/seacas/libraries/ioss/src/visualization/catalyst/ioss2catalyst/IossApplication.cxx +++ b/packages/seacas/libraries/ioss/src/visualization/catalyst/ioss2catalyst/IossApplication.cxx @@ -298,14 +298,14 @@ void IossApplication::setOutputCopyOfInputDatabase(bool status) { copyDatabase = bool IossApplication::outputCatalystMeshOneFileON() { return writeCatalystMeshOneFile; } -bool IossApplication::setOutputCatalystMeshOneFile(bool status) +void IossApplication::setOutputCatalystMeshOneFile(bool status) { writeCatalystMeshOneFile = status; } bool IossApplication::outputCatalystMeshFilePerProcON() { return writeCatalystMeshFilePerProc; } -bool IossApplication::setOutputCatalystMeshFilePerProc(bool status) +void IossApplication::setOutputCatalystMeshFilePerProc(bool status) { writeCatalystMeshFilePerProc = status; } @@ -372,11 +372,11 @@ void IossApplication::setCatalystStopTimeStep(int timeStep) bool IossApplication::forceCGNSOutputON() { return forceCGNSOutput; } -bool IossApplication::setForceCGNSOutput(bool status) { forceCGNSOutput = status; } +void IossApplication::setForceCGNSOutput(bool status) { forceCGNSOutput = status; } bool IossApplication::forceExodusOutputON() { return forceExodusOutput; } -bool IossApplication::setForceExodusOutput(bool status) { forceExodusOutput = status; } +void IossApplication::setForceExodusOutput(bool status) { forceExodusOutput = status; } bool IossApplication::useIOSSInputDBTypeON() { return useIOSSInputDBType; } diff --git a/packages/seacas/libraries/ioss/src/visualization/catalyst/ioss2catalyst/IossApplication.h b/packages/seacas/libraries/ioss/src/visualization/catalyst/ioss2catalyst/IossApplication.h index f3dc35740018..88fba392998f 100644 --- a/packages/seacas/libraries/ioss/src/visualization/catalyst/ioss2catalyst/IossApplication.h +++ b/packages/seacas/libraries/ioss/src/visualization/catalyst/ioss2catalyst/IossApplication.h @@ -35,16 +35,16 @@ class IossApplication void setOutputCopyOfInputDatabase(bool status); bool outputCatalystMeshOneFileON(); - bool setOutputCatalystMeshOneFile(bool status); + void setOutputCatalystMeshOneFile(bool status); bool outputCatalystMeshFilePerProcON(); - bool setOutputCatalystMeshFilePerProc(bool status); + void setOutputCatalystMeshFilePerProc(bool status); bool forceCGNSOutputON(); - bool setForceCGNSOutput(bool status); + void setForceCGNSOutput(bool status); bool forceExodusOutputON(); - bool setForceExodusOutput(bool status); + void setForceExodusOutput(bool status); bool useIOSSInputDBTypeON(); std::string getIOSSInputDBType(); diff --git a/packages/seacas/libraries/ioss/src/visualization/exodus/Iovs_exodus_DatabaseIO.C b/packages/seacas/libraries/ioss/src/visualization/exodus/Iovs_exodus_DatabaseIO.C index 611b8f975a6a..57fd76721b4b 100644 --- a/packages/seacas/libraries/ioss/src/visualization/exodus/Iovs_exodus_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/visualization/exodus/Iovs_exodus_DatabaseIO.C @@ -26,6 +26,7 @@ namespace { // Internal helper functions int64_t get_id(const Ioss::GroupingEntity *entity, Iovs_exodus::EntityIdSet *idset); bool set_id(const Ioss::GroupingEntity *entity, Iovs_exodus::EntityIdSet *idset); int64_t extract_id(const std::string &name_id); + size_t get_num_to_get(const Ioss::Field &field, size_t data_size); } // End anonymous namespace namespace Iovs_exodus { @@ -38,8 +39,8 @@ namespace Iovs_exodus { : Ioss::DatabaseIO(region, Iovs::Utils::getInstance().getDatabaseOutputFilePath(filename, props), db_usage, communicator, props), - isInput(false), singleProcOnly(false), doLogging(false), - nodeBlockCount(0), elementBlockCount(0) + isInput(false), singleProcOnly(false), doLogging(false), nodeBlockCount(0), + elementBlockCount(0) { Iovs::Utils::DatabaseInfo dbinfo; @@ -65,7 +66,7 @@ namespace Iovs_exodus { if (state == Ioss::STATE_MODEL) { CatalystExodusMeshBase::ElementBlockIdNameList ebinList; - Ioss::ElementBlockContainer const &ebc = region->get_element_blocks(); + Ioss::ElementBlockContainer const &ebc = region->get_element_blocks(); for (auto i : ebc) { ebinList.emplace_back(get_id(i, &ids_), i->name()); } @@ -131,11 +132,9 @@ namespace Iovs_exodus { for (I = element_blocks.begin(); I != element_blocks.end(); ++I) { int bid = get_id((*I), &ids_); int64_t eb_offset = (*I)->get_offset(); - this->catExoMesh->CreateElementVariable("ids", 1, bid, - &this->elemMap.map()[eb_offset + 1]); + this->catExoMesh->CreateElementVariable("ids", 1, bid, &this->elemMap.map()[eb_offset + 1]); std::vector object_id((*I)->entity_count(), bid); - this->catExoMesh->CreateElementVariable("object_id", 1, bid, - object_id.data()); + this->catExoMesh->CreateElementVariable("object_id", 1, bid, object_id.data()); } this->catExoMesh->CreateNodalVariable("ids", 1, &this->nodeMap.map()[1]); @@ -226,9 +225,9 @@ namespace Iovs_exodus { } } else if (role == Ioss::Field::TRANSIENT) { - Ioss::Field::BasicType ioss_type = field.get_type(); - int comp_count = field.get_component_count(Ioss::Field::InOut::OUTPUT); - std::string field_name = field.get_name(); + Ioss::Field::BasicType ioss_type = field.get_type(); + int comp_count = field.get_component_count(Ioss::Field::InOut::OUTPUT); + std::string field_name = field.get_name(); if (ioss_type == Ioss::Field::COMPLEX) { comp_count *= 2; @@ -312,10 +311,10 @@ namespace Iovs_exodus { /* TODO */ } else if (role == Ioss::Field::TRANSIENT) { - Ioss::Field::BasicType ioss_type = field.get_type(); - int comp_count = field.get_component_count(Ioss::Field::InOut::OUTPUT); - int bid = get_id(eb, &ids_); - std::string field_name = field.get_name(); + Ioss::Field::BasicType ioss_type = field.get_type(); + int comp_count = field.get_component_count(Ioss::Field::InOut::OUTPUT); + int bid = get_id(eb, &ids_); + std::string field_name = field.get_name(); if (ioss_type == Ioss::Field::COMPLEX) { comp_count *= 2; @@ -567,10 +566,78 @@ namespace Iovs_exodus { << field.get_name() << "'"; return -4; } + + int64_t DatabaseIO::put_field_internal(const Ioss::EdgeBlock * /*eb*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::FaceBlock * /*fb*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::SideBlock * /*sb*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::NodeSet * /*ns*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::EdgeSet * /*es*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::FaceSet * /*fs*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::ElementSet * /*es*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::SideSet * /*ss*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::CommSet * /*cs*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::StructuredBlock * /*sb*/, + const Ioss::Field &field, void * /*data*/, + size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::Assembly * /*as*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } + int64_t DatabaseIO::put_field_internal(const Ioss::Blob * /*bl*/, const Ioss::Field &field, + void * /*data*/, size_t data_size) const + { + return get_num_to_get(field, data_size); + } } // namespace Iovs_exodus namespace { + size_t get_num_to_get(const Ioss::Field &field, size_t data_size) + { + size_t num_to_get = field.verify(data_size); + return num_to_get; + } + int64_t get_id(const Ioss::GroupingEntity *entity, Iovs_exodus::EntityIdSet *idset) { // Sierra uses names to refer to grouping entities; however, diff --git a/packages/seacas/libraries/ioss/src/visualization/exodus/Iovs_exodus_DatabaseIO.h b/packages/seacas/libraries/ioss/src/visualization/exodus/Iovs_exodus_DatabaseIO.h index 0f405fe1059a..7f372256857e 100644 --- a/packages/seacas/libraries/ioss/src/visualization/exodus/Iovs_exodus_DatabaseIO.h +++ b/packages/seacas/libraries/ioss/src/visualization/exodus/Iovs_exodus_DatabaseIO.h @@ -47,10 +47,7 @@ namespace Iovs_exodus { // unsigned int with the supported Ioss::EntityTypes or'ed // together. If "return_value & Ioss::EntityType" is set, then the // database supports that type (e.g. return_value & Ioss::FACESET) - unsigned entity_field_support() const override - { - return Ioss::NODEBLOCK | Ioss::ELEMENTBLOCK; - } + unsigned entity_field_support() const override { return Ioss::NODEBLOCK | Ioss::ELEMENTBLOCK; } // static int parseCatalystFile(const std::string &filepath, std::string &json_result); @@ -147,72 +144,34 @@ namespace Iovs_exodus { int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data, size_t data_size) const override; - - int64_t put_field_internal(const Ioss::NodeBlock * nb, const Ioss::Field & field, - void * data, size_t data_size) const override; - int64_t put_field_internal(const Ioss::EdgeBlock * /*eb*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /* data_size */) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::FaceBlock * /*fb*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /* data_size */) const override - { - return 0; - } + int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::EdgeBlock *eb, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::FaceBlock *fb, const Ioss::Field &field, void *data, + size_t data_size) const override; int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data, size_t data_size) const override; - int64_t put_field_internal(const Ioss::SideBlock * /*sb*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /*data_size*/) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::NodeSet * /*ns*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /*data_size*/) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::EdgeSet * /*es*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /* data_size */) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::FaceSet * /*fs*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /* data_size */) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::ElementSet * /*es*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /* data_size */) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::SideSet * /*ss*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /*data_size*/) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::CommSet * /*cs*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /* data_size */) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::StructuredBlock * /*sb*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /* data_size */) const override - { - return 0; - } - int64_t put_field_internal(const Ioss::Assembly * /*as*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /*data_size*/) const override - { - return 0; - } - - int64_t put_field_internal(const Ioss::Blob * /*bl*/, const Ioss::Field & /*field*/, - void * /*data*/, size_t /*data_size*/) const override - { - return 0; - } + int64_t put_field_internal(const Ioss::SideBlock *sb, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::EdgeSet *es, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::FaceSet *fs, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::ElementSet *es, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::SideSet *ss, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field, + void *data, size_t data_size) const override; + int64_t put_field_internal(const Ioss::Assembly *as, const Ioss::Field &field, void *data, + size_t data_size) const override; + int64_t put_field_internal(const Ioss::Blob *bl, const Ioss::Field &field, void *data, + size_t data_size) const override; void write_meta_data(); diff --git a/packages/seacas/libraries/nemesis/CMakeLists.txt b/packages/seacas/libraries/nemesis/CMakeLists.txt index cfee14ffa13a..9a0c30b26b18 100644 --- a/packages/seacas/libraries/nemesis/CMakeLists.txt +++ b/packages/seacas/libraries/nemesis/CMakeLists.txt @@ -28,11 +28,13 @@ TRIBITS_ADD_LIBRARY( SOURCES ${SOURCES} ) +IF (${PACKAGE_NAME}_ENABLE_TESTS) TRIBITS_ADD_EXECUTABLE_AND_TEST( ne_ctest_wrap NAME ne_ctest_wrap SOURCES ne_ctest_wrap.c NUM_MPI_PROCS 1 ) +ENDIF() TRIBITS_SUBPACKAGE_POSTPROCESS() diff --git a/packages/seacas/libraries/nemesis/cmake/Dependencies.cmake b/packages/seacas/libraries/nemesis/cmake/Dependencies.cmake index 26f8eebdb219..c9aded64b75d 100644 --- a/packages/seacas/libraries/nemesis/cmake/Dependencies.cmake +++ b/packages/seacas/libraries/nemesis/cmake/Dependencies.cmake @@ -1,3 +1,6 @@ TRIBITS_PACKAGE_DEFINE_DEPENDENCIES( LIB_REQUIRED_PACKAGES SEACASExodus + LIB_REQUIRED_TPLS Netcdf + LIB_OPTIONAL_TPLS Pthread HDF5 Pnetcdf MPI + TEST_REQUIRED_TPLS Netcdf ) diff --git a/packages/seacas/libraries/nemesis/forbind/ne_jack.c b/packages/seacas/libraries/nemesis/forbind/ne_jack.c index 22a6e705f3a9..7b628ab66e87 100644 --- a/packages/seacas/libraries/nemesis/forbind/ne_jack.c +++ b/packages/seacas/libraries/nemesis/forbind/ne_jack.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -126,7 +126,7 @@ static void ex_fstrncpy(char *target, char *source, size_t maxlen) void F2C(negii)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, size_t ftypelen) { size_t slen = 1; - char * file_type; + char *file_type; /* WARNING: ftypelen SHOULD be 1, but may not be depending on how the Fortran programmer passed it. It is best at @@ -134,7 +134,8 @@ void F2C(negii)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, if (ftypelen != 1) { #if defined(EXODUS_STRING_LENGTH_WARNING) char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Warning: file type string length is %lu in file id %d\n", ftypelen, *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Warning: file type string length is %lu in file id %d\n", + ftypelen, *idne); ex_err(__func__, errmsg, EX_MSG); #endif slen = ftypelen; @@ -144,7 +145,8 @@ void F2C(negii)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, if ((*ierr = ex_get_init_info(*idne, nproc, nproc_in_f, file_type)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to get initial information from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to get initial information from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } @@ -163,7 +165,7 @@ void F2C(nepii)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, char errmsg[MAX_ERR_LENGTH]; size_t slen = 1; - char * file_type; + char *file_type; /* WARNING: ftypelen SHOULD be 1, but may not be depending on how the Fortran programmer passed it. It is best at @@ -171,7 +173,8 @@ void F2C(nepii)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, if (ftypelen != 1) { slen = ftypelen; #if defined(EXODUS_STRING_LENGTH_WARNING) - sprintf(errmsg, "Warning: file type string length is %lu in file id %d\n", ftypelen, *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Warning: file type string length is %lu in file id %d\n", + ftypelen, *idne); ex_err(__func__, errmsg, EX_MSG); #endif } @@ -181,7 +184,8 @@ void F2C(nepii)(int *idne, int *nproc, int *nproc_in_f, char *ftype, int *ierr, ex_fstrncpy(file_type, ftype, slen); if ((*ierr = ex_put_init_info(*idne, *nproc, *nproc_in_f, file_type)) != 0) { - sprintf(errmsg, "Error: failed to put initial information in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to put initial information in file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } @@ -197,7 +201,8 @@ void F2C(negig)(int *idne, void_int *nnodes_g, void_int *nelems_g, void_int *nel if ((*ierr = ex_get_init_global(*idne, nnodes_g, nelems_g, nelem_blks_g, nnode_sets_g, nside_sets_g)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read initial global information from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read initial global information from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -229,7 +234,8 @@ void F2C(nepig)(int *idne, void_int *nnodes_g, void_int *nelems_g, void_int *nel if (*ierr != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store initial global information in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to store initial global information in file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -244,7 +250,8 @@ void F2C(neglbp)(int *idne, void_int *nint_nodes, void_int *nbor_nodes, void_int if ((*ierr = ex_get_loadbal_param(*idne, nint_nodes, nbor_nodes, next_nodes, nint_elems, nbor_elems, nnode_cmaps, nelem_cmaps, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read load balance parameters from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read load balance parameters from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -280,7 +287,8 @@ void F2C(neplbp)(int *idne, void_int *nint_nodes, void_int *nbor_nodes, void_int } if (*ierr != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store load balance parameters in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to store load balance parameters in file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -295,7 +303,8 @@ void F2C(neplbpc)(int *idne, void_int *nint_nodes, void_int *nbor_nodes, void_in if ((*ierr = ex_put_loadbal_param_cc(*idne, nint_nodes, nbor_nodes, next_nodes, nint_elems, nbor_elems, nnode_cmaps, nelem_cmaps)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store load balance parameters in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to store load balance parameters in file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -308,7 +317,8 @@ void F2C(negnspg)(int *idne, void_int *ns_ids_glob, void_int *ns_n_cnt_glob, { if ((*ierr = ex_get_ns_param_global(*idne, ns_ids_glob, ns_n_cnt_glob, ns_df_cnt_glob)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read global node set parameters from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read global node set parameters from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -321,7 +331,8 @@ void F2C(nepnspg)(int *idne, void_int *global_ids, void_int *global_n_cnts, { if ((*ierr = ex_put_ns_param_global(*idne, global_ids, global_n_cnts, global_df_cnts)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store global node set parameters in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to store global node set parameters in file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -335,7 +346,8 @@ void F2C(negsspg)(int *idne, void_int *ss_ids_glob, void_int *ss_n_cnt_glob, if ((*ierr = ex_get_ss_param_global(*idne, ss_ids_glob, ss_n_cnt_glob, ss_df_cnt_glob)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read global side set parameters from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read global side set parameters from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -348,7 +360,8 @@ void F2C(nepsspg)(int *idne, void_int *global_ids, void_int *global_el_cnts, { if ((*ierr = ex_put_ss_param_global(*idne, global_ids, global_el_cnts, global_df_cnts)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store global side set parameters in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to store global side set parameters in file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -360,7 +373,8 @@ void F2C(negebig)(int *idne, void_int *el_blk_ids, void_int *el_blk_cnts, int *i { if ((*ierr = ex_get_eb_info_global(*idne, el_blk_ids, el_blk_cnts)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read global element block info from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read global element block info from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -372,7 +386,8 @@ void F2C(nepebig)(int *idne, void_int *el_blk_ids, void_int *el_blk_cnts, int *i { if ((*ierr = ex_put_eb_info_global(*idne, el_blk_ids, el_blk_cnts)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to store global element block info in file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to store global element block info in file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -395,7 +410,8 @@ void F2C(negnss)(int *idne, entity_id *ss_id, void_int *start, void_int *count, if ((*ierr = ex_get_n_side_set(*idne, *ss_id, st, cnt, ss_elem_list, ss_side_list)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read side set element list from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read side set element list from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -418,7 +434,8 @@ void F2C(nepnss)(int *idne, entity_id *ss_id, void_int *start, void_int *count, if ((*ierr = ex_put_n_side_set(*idne, *ss_id, st, cnt, ss_elem_list, ss_side_list)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write side set element list to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write side set element list to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -441,7 +458,8 @@ void F2C(negnssd)(int *idne, entity_id *ss_id, void_int *start, void_int *count, if ((*ierr = ex_get_n_side_set_df(*idne, *ss_id, st, cnt, ss_df)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read side set dist factor from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read side set dist factor from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -464,7 +482,8 @@ void F2C(nepnssd)(int *idne, entity_id *ss_id, void_int *start, void_int *count, if ((*ierr = ex_put_n_side_set_df(*idne, *ss_id, st, cnt, ss_df)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write side set dist factor to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write side set dist factor to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -487,7 +506,8 @@ void F2C(negnns)(int *idne, entity_id *ns_id, void_int *start, void_int *count, if ((*ierr = ex_get_n_node_set(*idne, *ns_id, st, cnt, ns_node_list)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read node set node list from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read node set node list from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -510,7 +530,8 @@ void F2C(nepnns)(int *idne, entity_id *ns_id, void_int *start, void_int *count, if ((*ierr = ex_put_n_node_set(*idne, *ns_id, st, cnt, ns_node_list)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write node set node list to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write node set node list to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -533,7 +554,8 @@ void F2C(negnnsd)(int *idne, entity_id *ns_id, void_int *start, void_int *count, if ((*ierr = ex_get_n_node_set_df(*idne, *ns_id, st, cnt, ns_df)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read node set dist factor from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read node set dist factor from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -556,7 +578,8 @@ void F2C(nepnnsd)(int *idne, entity_id *ns_id, void_int *start, void_int *count, if ((*ierr = ex_put_n_node_set_df(*idne, *ns_id, st, cnt, ns_df)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write node set dist factor to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write node set dist factor to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -579,7 +602,8 @@ void F2C(negcor)(int *idne, void_int *start, void_int *count, real *x_coor, real if ((*ierr = ex_get_n_coord(*idne, st, cnt, x_coor, y_coor, z_coor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read node coordinates from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read node coordinates from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -602,7 +626,8 @@ void F2C(nepcor)(int *idne, void_int *start, void_int *count, real *x_coor, real if ((*ierr = ex_put_n_coord(*idne, st, cnt, x_coor, y_coor, z_coor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write node coordinates to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write node coordinates to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -625,7 +650,8 @@ void F2C(negnec)(int *idne, entity_id *elem_blk_id, void_int *start, void_int *c if ((*ierr = ex_get_n_elem_conn(*idne, *elem_blk_id, st, cnt, connect)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element block connectivity from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read element block connectivity from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -648,7 +674,8 @@ void F2C(nepnec)(int *idne, entity_id *elem_blk_id, void_int *start, void_int *c if ((*ierr = ex_put_n_elem_conn(*idne, *elem_blk_id, st, cnt, connect)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write element block connectivity to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to write element block connectivity to file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -671,7 +698,8 @@ void F2C(negneat)(int *idne, entity_id *elem_blk_id, void_int *start, void_int * if ((*ierr = ex_get_n_elem_attr(*idne, *elem_blk_id, st, cnt, attrib)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element block attribute from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read element block attribute from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -694,7 +722,8 @@ void F2C(nepneat)(int *idne, entity_id *elem_blk_id, void_int *start, void_int * if ((*ierr = ex_put_n_elem_attr(*idne, *elem_blk_id, st, cnt, attrib)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write element block attribute to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write element block attribute to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -705,7 +734,7 @@ void F2C(nepneat)(int *idne, entity_id *elem_blk_id, void_int *start, void_int * void F2C(negelt)(int *idne, entity_id *elem_blk_id, char *elem_type, int *ierr, size_t elem_typelen) { size_t slen = MAX_STR_LENGTH; - char * etype; + char *etype; /* WARNING: ftypelen SHOULD be MAX_STR_LENGTH, but may not be depending on how the Fortran programmer passed it. It is best at @@ -713,8 +742,8 @@ void F2C(negelt)(int *idne, entity_id *elem_blk_id, char *elem_type, int *ierr, if (elem_typelen != MAX_STR_LENGTH) { #if defined(EXODUS_STRING_LENGTH_WARNING) char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Warning: element type string length is %lu in file id %d\n", elem_typelen, - *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Warning: element type string length is %lu in file id %d\n", + elem_typelen, *idne); ex_err(__func__, errmsg, EX_MSG); #endif slen = elem_typelen; @@ -724,7 +753,8 @@ void F2C(negelt)(int *idne, entity_id *elem_blk_id, char *elem_type, int *ierr, if ((*ierr = ex_get_elem_type(*idne, *elem_blk_id, etype)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element block type from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read element block type from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } @@ -756,7 +786,8 @@ void F2C(negnev)(int *idne, int *time_step, int *elem_var_index, entity_id *elem if ((*ierr = ex_get_n_elem_var(*idne, *time_step, *elem_var_index, *elem_blk_id, ne, st, cnt, elem_var_vals)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element block variable from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read element block variable from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -780,7 +811,8 @@ void F2C(nepevs)(int *idne, int *time_step, int *elem_var_index, entity_id *elem if ((*ierr = ex_put_elem_var_slab(*idne, *time_step, *elem_var_index, *elem_blk_id, st, cnt, elem_var_vals)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write elem block variable slab to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to write elem block variable slab to file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -803,7 +835,7 @@ void F2C(negnnv)(int *idne, int *time_step, int *nodal_var_index, void_int *star if ((*ierr = ex_get_n_nodal_var(*idne, *time_step, *nodal_var_index, st, cnt, nodal_vars)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read nodal variable from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read nodal variable from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -827,7 +859,8 @@ void F2C(nepnvs)(int *idne, int *time_step, int *nodal_var_index, void_int *star if ((*ierr = ex_put_nodal_var_slab(*idne, *time_step, *nodal_var_index, st, cnt, nodal_var_vals)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write nodal variable slab to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write nodal variable slab to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -849,7 +882,8 @@ void F2C(negnenm)(int *idne, void_int *starte, void_int *num_ent, void_int *elem if ((*ierr = ex_get_n_elem_num_map(*idne, st, cnt, elem_map)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read element numbering map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read element numbering map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -871,7 +905,8 @@ void F2C(nepnenm)(int *idne, void_int *starte, void_int *num_ent, void_int *elem if ((*ierr = ex_put_n_elem_num_map(*idne, st, cnt, elem_map)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write element numbering map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write element numbering map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -893,7 +928,8 @@ void F2C(negnnnm)(int *idne, void_int *startn, void_int *num_ent, void_int *node if ((*ierr = ex_get_n_node_num_map(*idne, st, cnt, node_map)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read node numbering map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read node numbering map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -915,7 +951,8 @@ void F2C(nepnnnm)(int *idne, void_int *startn, void_int *num_ent, void_int *node if ((*ierr = ex_put_n_node_num_map(*idne, st, cnt, node_map)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write node numbering map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write node numbering map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -929,7 +966,8 @@ void F2C(negnm)(int *idne, void_int *node_mapi, void_int *node_mapb, void_int *n if ((*ierr = ex_get_processor_node_maps(*idne, node_mapi, node_mapb, node_mape, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read processor node map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read processor node map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -943,7 +981,8 @@ void F2C(nepnm)(int *idne, void_int *node_mapi, void_int *node_mapb, void_int *n if ((*ierr = ex_put_processor_node_maps(*idne, node_mapi, node_mapb, node_mape, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write processor node map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write processor node map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -955,7 +994,8 @@ void F2C(negem)(int *idne, void_int *elem_mapi, void_int *elem_mapb, int *proces { if ((*ierr = ex_get_processor_elem_maps(*idne, elem_mapi, elem_mapb, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read processor element map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read processor element map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -967,7 +1007,8 @@ void F2C(nepem)(int *idne, void_int *elem_mapi, void_int *elem_mapb, int *proces { if ((*ierr = ex_put_processor_elem_maps(*idne, elem_mapi, elem_mapb, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write processor element map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write processor element map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -981,7 +1022,8 @@ void F2C(negcmp)(int *idne, void_int *ncmap_ids, void_int *ncmap_node_cnts, void if ((*ierr = ex_get_cmap_params(*idne, ncmap_ids, ncmap_node_cnts, ecmap_ids, ecmap_elem_cnts, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read comm map parameters from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read comm map parameters from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -995,7 +1037,8 @@ void F2C(nepcmp)(int *idne, void_int *nmap_ids, void_int *nmap_node_cnts, void_i if ((*ierr = ex_put_cmap_params(*idne, nmap_ids, nmap_node_cnts, emap_ids, emap_elem_cnts, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write comm map parameters to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write comm map parameters to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -1009,7 +1052,8 @@ void F2C(nepcmpc)(int *idne, void_int *nmap_ids, void_int *nmap_node_cnts, void_ if ((*ierr = ex_put_cmap_params_cc(*idne, nmap_ids, nmap_node_cnts, nproc_ptrs, emap_ids, emap_elem_cnts, eproc_ptrs)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write comm map parameters to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write comm map parameters to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -1022,7 +1066,8 @@ void F2C(negncm)(int *idne, entity_id *map_id, void_int *node_ids, void_int *pro { if ((*ierr = ex_get_node_cmap(*idne, *map_id, node_ids, proc_ids, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read nodal communications map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to read nodal communications map from file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -1035,7 +1080,8 @@ void F2C(nepncm)(int *idne, entity_id *map_id, void_int *node_ids, void_int *pro { if ((*ierr = ex_put_node_cmap(*idne, *map_id, node_ids, proc_ids, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write nodal communications map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, + "Error: failed to write nodal communications map to file id %d", *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -1048,7 +1094,8 @@ void F2C(negecm)(int *idne, entity_id *map_id, void_int *elem_ids, void_int *sid { if ((*ierr = ex_get_elem_cmap(*idne, *map_id, elem_ids, side_ids, proc_ids, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to read elemental comm map from file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to read elemental comm map from file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } @@ -1061,7 +1108,8 @@ void F2C(nepecm)(int *idne, entity_id *map_id, void_int *elem_ids, void_int *sid { if ((*ierr = ex_put_elem_cmap(*idne, *map_id, elem_ids, side_ids, proc_ids, *processor)) != 0) { char errmsg[MAX_ERR_LENGTH]; - sprintf(errmsg, "Error: failed to write elemental comm map to file id %d", *idne); + snprintf(errmsg, MAX_ERR_LENGTH, "Error: failed to write elemental comm map to file id %d", + *idne); ex_err(__func__, errmsg, EX_MSG); } } diff --git a/packages/seacas/libraries/supes/ext_lib/exname.c b/packages/seacas/libraries/supes/ext_lib/exname.c index 4fc10dbabb99..79dca12edc73 100644 --- a/packages/seacas/libraries/supes/ext_lib/exname.c +++ b/packages/seacas/libraries/supes/ext_lib/exname.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -41,7 +41,7 @@ #include /* getenv */ #include /* strlen */ -#define TRUE 1 +#define TRUE 1 #define FALSE 0 #define INSYMBOL "FOR0" @@ -71,18 +71,18 @@ void exname(FTNINT *iunit, char *name, FTNINT *ln, long int nlen) if (*iunit > -100 && *iunit < 100) { #if Build64 - sprintf(string, "%02ld", labs(*iunit)); + snprintf(string, 3, "%02ld", labs(*iunit)); #else - sprintf(string, "%02d", abs(*iunit)); + snprintf(string, 3, "%02d", abs(*iunit)); #endif if (*iunit > 0) { ExtSymbol = FALSE; - sprintf(symbol, "%s%s", INSYMBOL, string); + snprintf(symbol, 7, "%s%s", INSYMBOL, string); } else { ExtSymbol = TRUE; - sprintf(symbol, "%s%s", EXSYMBOL, string); + snprintf(symbol, 7, "%s%s", EXSYMBOL, string); } if ((darg = (char *)getenv(symbol)) != (char *)NULL) { @@ -95,9 +95,9 @@ void exname(FTNINT *iunit, char *name, FTNINT *ln, long int nlen) } else if (!ExtSymbol) { #if Build64 - sprintf(name, "fort.%ld", labs(*iunit)); + snprintf(name, nlen, "fort.%ld", labs(*iunit)); #else - sprintf(name, "fort.%d", abs(*iunit)); + snprintf(name, nlen, "fort.%d", abs(*iunit)); #endif *ln = strlen(name); } diff --git a/packages/seacas/libraries/supes/ext_lib/exparm.c b/packages/seacas/libraries/supes/ext_lib/exparm.c index fcded4a93604..2402554fc5f7 100644 --- a/packages/seacas/libraries/supes/ext_lib/exparm.c +++ b/packages/seacas/libraries/supes/ext_lib/exparm.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -50,9 +50,9 @@ #define isatty _isatty #else #include -#include /* isatty */ +#include #endif -#include /* sprintf */ +#include static char *copy_string(char *dest, char const *source, long int elements) { @@ -87,8 +87,8 @@ void exparm(char *hard, char *soft, FTNINT *mode, FTNINT *kcsu, FTNINT *knsu, FT uname(&SysInfo); - sprintf(hardname, "SGI-%.4s", SysInfo.machine); - sprintf(softname, "%.8s", SysInfo.release); + snprintf(hardname, SUPES_MAXCHAR, "SGI-%.4s", SysInfo.machine); + snprintf(softname, SUPES_MAXCHAR, "%.8s", SysInfo.release); copy_string(hard, hardname, WORDLEN); copy_string(soft, softname, WORDLEN); @@ -107,8 +107,8 @@ void exparm(char *hard, char *soft, FTNINT *mode, FTNINT *kcsu, FTNINT *knsu, FT uname(&SysInfo); - sprintf(hardname, "IBM %.4s", SysInfo.machine); - sprintf(softname, "%03s %.4s", SysInfo.sysname, SysInfo.release); + snprintf(hardname, SUPES_MAXCHAR, "IBM %.4s", SysInfo.machine); + snprintf(softname, SUPES_MAXCHAR, "%03s %.4s", SysInfo.sysname, SysInfo.release); copy_string(hard, hardname, WORDLEN); copy_string(soft, softname, WORDLEN); @@ -127,8 +127,8 @@ void exparm(char *hard, char *soft, FTNINT *mode, FTNINT *kcsu, FTNINT *knsu, FT uname(&SysInfo); - sprintf(hardname, "HP %.4s", SysInfo.machine); - sprintf(softname, "HP-UX%.3s", SysInfo.release); + snprintf(hardname, SUPES_MAXCHAR, "HP %.4s", SysInfo.machine); + snprintf(softname, SUPES_MAXCHAR, "HP-UX%.3s", SysInfo.release); copy_string(hard, hardname, WORDLEN); copy_string(soft, softname, WORDLEN); @@ -147,8 +147,8 @@ void exparm(char *hard, char *soft, FTNINT *mode, FTNINT *kcsu, FTNINT *knsu, FT uname(&SysInfo); - sprintf(hardname, "%.8s", SysInfo.machine); - sprintf(softname, "%.4s%.4s", SysInfo.sysname, SysInfo.release); + snprintf(hardname, SUPES_MAXCHAR, "%.8s", SysInfo.machine); + snprintf(softname, SUPES_MAXCHAR, "%.4s%.4s", SysInfo.sysname, SysInfo.release); copy_string(hard, hardname, WORDLEN); copy_string(soft, softname, WORDLEN); @@ -168,18 +168,24 @@ void exparm(char *hard, char *soft, FTNINT *mode, FTNINT *kcsu, FTNINT *knsu, FT GetSystemInfo(&SysInfo); - sprintf(hardname, "%-8d", SysInfo.dwProcessorType); + snprintf(hardname, SUPES_MAXCHAR, "%-8d", SysInfo.dwProcessorType); OSInfo.dwOSVersionInfoSize = sizeof(OSInfo); if (GetVersionEx(&OSInfo) > 0) { switch (OSInfo.dwPlatformId) { - case 1: sprintf(softname, "Win98%d.%d", OSInfo.dwMajorVersion, OSInfo.dwMinorVersion); break; - case 2: sprintf(softname, "WinNT%d.%d", OSInfo.dwMajorVersion, OSInfo.dwMinorVersion); break; - default: sprintf(softname, "WinOS%d.%d", OSInfo.dwMajorVersion, OSInfo.dwMinorVersion); break; + case 1: + snprintf(softname, SUPES_MAXCHAR, "Win98%d.%d", OSInfo.dwMajorVersion, OSInfo.dwMinorVersion); + break; + case 2: + snprintf(softname, SUPES_MAXCHAR, "WinNT%d.%d", OSInfo.dwMajorVersion, OSInfo.dwMinorVersion); + break; + default: + snprintf(softname, SUPES_MAXCHAR, "WinOS%d.%d", OSInfo.dwMajorVersion, OSInfo.dwMinorVersion); + break; } } else { - sprintf(softname, "Unknown OS"); + snprintf(softname, SUPES_MAXCHAR, "Unknown OS"); } copy_string(hard, hardname, WORDLEN); copy_string(soft, softname, WORDLEN); @@ -197,8 +203,8 @@ void exparm(char *hard, char *soft, FTNINT *mode, FTNINT *kcsu, FTNINT *knsu, FT uname(&SysInfo); - sprintf(hardname, "%.8s", SysInfo.machine); - sprintf(softname, "CW%.6s", SysInfo.release); + snprintf(hardname, SUPES_MAXCHAR, "%.8s", SysInfo.machine); + snprintf(softname, SUPES_MAXCHAR, "CW%.6s", SysInfo.release); copy_string(hard, hardname, WORDLEN); copy_string(soft, softname, WORDLEN); @@ -216,8 +222,8 @@ void exparm(char *hard, char *soft, FTNINT *mode, FTNINT *kcsu, FTNINT *knsu, FT uname(&SysInfo); - sprintf(hardname, "%.8s", SysInfo.machine); - sprintf(softname, "OSX%.5s", SysInfo.release); + snprintf(hardname, SUPES_MAXCHAR, "%.8s", SysInfo.machine); + snprintf(softname, SUPES_MAXCHAR, "OSX%.5s", SysInfo.release); copy_string(hard, hardname, WORDLEN); copy_string(soft, softname, WORDLEN); @@ -236,8 +242,8 @@ void exparm(char *hard, char *soft, FTNINT *mode, FTNINT *kcsu, FTNINT *knsu, FT uname(&SysInfo); - sprintf(hardname, "%.8s", SysInfo.machine); - sprintf(softname, "Lx%.6s", SysInfo.release); + snprintf(hardname, SUPES_MAXCHAR, "%.8s", SysInfo.machine); + snprintf(softname, SUPES_MAXCHAR, "Lx%.6s", SysInfo.release); copy_string(hard, hardname, WORDLEN); copy_string(soft, softname, WORDLEN); diff --git a/packages/seacas/libraries/supes/ext_lib/getline_int.c b/packages/seacas/libraries/supes/ext_lib/getline_int.c index ef50f743051e..52708c9d97ba 100644 --- a/packages/seacas/libraries/supes/ext_lib/getline_int.c +++ b/packages/seacas/libraries/supes/ext_lib/getline_int.c @@ -414,15 +414,20 @@ static void gl_addchar(int c) /* adds the character c to the input buffer at current location */ { - if (gl_cnt >= GL_BUF_SIZE - 1) - gl_error("\n*** Error: getline(): input buffer overflow\n"); if (gl_overwrite == 0 || gl_pos == gl_cnt) { - for (int i = gl_cnt; i >= gl_pos; i--) + if (gl_cnt > GL_BUF_SIZE - 2) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } + for (int i = gl_cnt; i >= gl_pos; i--) { gl_buf[i + 1] = gl_buf[i]; + } gl_buf[gl_pos] = (char)c; gl_fixup(gl_prompt, gl_pos, gl_pos + 1); } else { + if (gl_pos > GL_BUF_SIZE - 1) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } gl_buf[gl_pos] = (char)c; gl_extent = 1; gl_fixup(gl_prompt, gl_pos, gl_pos + 1); @@ -435,22 +440,27 @@ static void gl_yank(void) int len = strlen(gl_killbuf); if (len > 0) { if (gl_overwrite == 0) { - if (gl_cnt + len >= GL_BUF_SIZE - 1) + if (gl_cnt + len >= GL_BUF_SIZE) { gl_error("\n*** Error: getline(): input buffer overflow\n"); - for (int i = gl_cnt; i >= gl_pos; i--) + } + for (int i = gl_cnt; i >= gl_pos; i--) { gl_buf[i + len] = gl_buf[i]; - for (int i = 0; i < len; i++) + } + for (int i = 0; i < len; i++) { gl_buf[gl_pos + i] = gl_killbuf[i]; + } gl_fixup(gl_prompt, gl_pos, gl_pos + len); } else { + if (gl_pos + len >= GL_BUF_SIZE) { + gl_error("\n*** Error: getline(): input buffer overflow\n"); + } if (gl_pos + len > gl_cnt) { - if (gl_pos + len >= GL_BUF_SIZE - 1) - gl_error("\n*** Error: getline(): input buffer overflow\n"); - gl_buf[gl_pos + len] = 0; + gl_buf[gl_pos + len] = '\0'; } - for (int i = 0; i < len; i++) + for (int i = 0; i < len; i++) { gl_buf[gl_pos + i] = gl_killbuf[i]; + } gl_extent = len; gl_fixup(gl_prompt, gl_pos, gl_pos + len); } @@ -462,15 +472,16 @@ static void gl_yank(void) static void gl_transpose(void) /* switch character under cursor and to left of cursor */ { - if (gl_pos > 0 && gl_cnt > gl_pos) { + if (gl_pos > 0 && gl_cnt > gl_pos && gl_pos < GL_BUF_SIZE) { int c = gl_buf[gl_pos - 1]; gl_buf[gl_pos - 1] = gl_buf[gl_pos]; gl_buf[gl_pos] = (char)c; gl_extent = 2; gl_fixup(gl_prompt, gl_pos - 1, gl_pos); } - else + else { gl_beep(); + } } static void gl_newline(void) @@ -483,10 +494,12 @@ static void gl_newline(void) int len = gl_cnt; int loc = gl_width - 5; /* shifts line back to start position */ - if (gl_cnt >= GL_BUF_SIZE - 1) + if (gl_cnt >= GL_BUF_SIZE - 1) { gl_error("\n*** Error: getline(): input buffer overflow\n"); - if (loc > len) + } + if (loc > len) { loc = len; + } gl_fixup(gl_prompt, change, loc); /* must do this before appending \n */ gl_buf[len] = '\n'; gl_buf[len + 1] = '\0'; @@ -558,42 +571,39 @@ static void gl_fixup(const char *prompt, int change, int cursor) static int off_left; /* true if more text left of screen */ static char last_prompt[80] = ""; int left = 0, right = -1; /* bounds for redraw */ - int pad; /* how much to erase at end of line */ - int backup; /* how far to backup before fixing */ - int new_shift; /* value of shift based on cursor */ - int i; - int new_right = -1; /* alternate right bound, using gl_extent */ - int l1, l2; + int new_right = -1; /* alternate right bound, using gl_extent */ if (change == -2) { /* reset */ gl_pos = gl_cnt = gl_shift = off_right = off_left = 0; gl_putc('\r'); gl_puts(prompt); - copy_string(last_prompt, prompt, 80 - 1); + copy_string(last_prompt, prompt, 80); change = 0; gl_width = gl_termw - strlen(prompt); } else if (strcmp(prompt, last_prompt) != 0) { - l1 = strlen(last_prompt); - l2 = strlen(prompt); + int l1 = strlen(last_prompt); + int l2 = strlen(prompt); gl_cnt = gl_cnt + l1 - l2; - copy_string(last_prompt, prompt, 80 - 1); + copy_string(last_prompt, prompt, 80); gl_putc('\r'); gl_puts(prompt); gl_pos = gl_shift; gl_width = gl_termw - l2; change = 0; } - pad = (off_right) ? gl_width - 1 : gl_cnt - gl_shift; /* old length */ - backup = gl_pos - gl_shift; + /* how much to erase at end of line */ + int pad = (off_right) ? gl_width - 1 : gl_cnt - gl_shift; /* old length */ + int backup = gl_pos - gl_shift; /* how far to backup before fixing */ if (change >= 0) { gl_cnt = strlen(gl_buf); - if (change > gl_cnt) + if (change > gl_cnt) { change = gl_cnt; + } } if (cursor > gl_cnt) { if (cursor != GL_BUF_SIZE) { /* GL_BUF_SIZE means end of line */ - if (gl_ellipses_during_completion == 0) { + if (gl_ellipses_during_completion) { gl_beep(); } } @@ -607,13 +617,14 @@ static void gl_fixup(const char *prompt, int change, int cursor) if (off_right || (off_left && cursor < gl_shift + gl_width - gl_scroll / 2)) { extra = 2; /* shift the scrolling boundary */ } - new_shift = cursor + extra + gl_scroll - gl_width; + int new_shift = cursor + extra + gl_scroll - gl_width; if (new_shift > 0) { new_shift /= gl_scroll; new_shift *= gl_scroll; } - else + else { new_shift = 0; + } if (new_shift != gl_shift) { /* scroll occurs */ gl_shift = new_shift; off_left = (gl_shift) ? 1 : 0; @@ -636,33 +647,43 @@ static void gl_fixup(const char *prompt, int change, int cursor) pad -= (off_right) ? gl_width - 1 : gl_cnt - gl_shift; pad = (pad < 0) ? 0 : pad; if (left <= right) { /* clean up screen */ - for (i = 0; i < backup; i++) + for (int i = 0; i < backup; i++) { gl_putc('\b'); + } if (left == gl_shift && off_left) { gl_putc('$'); left++; } - for (i = left; i < new_right; i++) + for (int i = left; i < new_right; i++) { gl_putc(gl_buf[i]); + } gl_pos = new_right; if (off_right && new_right == right) { gl_putc('$'); gl_pos++; } else { - for (i = 0; i < pad; i++) /* erase remains of prev line */ + for (int i = 0; i < pad; i++) { /* erase remains of prev line */ gl_putc(' '); + } gl_pos += pad; } } - i = gl_pos - cursor; /* move to final cursor location */ + int i = gl_pos - cursor; /* move to final cursor location */ if (i > 0) { - while (i--) + while (i--) { gl_putc('\b'); + } } else { - for (i = gl_pos; i < cursor; i++) - gl_putc(gl_buf[i]); + if (cursor < GL_BUF_SIZE) { + for (int ii = gl_pos; ii < cursor; ii++) { + gl_putc(gl_buf[ii]); + } + } + else { + gl_error("\n*** Error: getline(): logic error in gl_fixup().\n"); + } } gl_pos = cursor; } diff --git a/packages/seacas/libraries/svdi/cdr/cdrsrc.c b/packages/seacas/libraries/svdi/cdr/cdrsrc.c index 96d60203231d..49c8a45c8579 100644 --- a/packages/seacas/libraries/svdi/cdr/cdrsrc.c +++ b/packages/seacas/libraries/svdi/cdr/cdrsrc.c @@ -841,13 +841,13 @@ void cdrofs_(int *ifilcd) symbol[i] = '\0'; } else { - sprintf(symbol, "file%d", *ifilcd); + snprintf(symbol, 1024, "file%d", *ifilcd); } /* check the environment to see if a file name has been assigned */ char *env = getenv(symbol); if (env != NULL && strlen(env) < 1024) { - sprintf(symbol, "%s", env); + snprintf(symbol, 1024, "%s", env); } /* open the file - if it doesn't exist, create it with mode 664 */ @@ -856,7 +856,7 @@ void cdrofs_(int *ifilcd) int errnum = 722; int errsev = 10; char err[50]; - sprintf(err, "SVDI ERROR NUMBER %d SEVERITY CODE %d", errnum, errsev); + snprintf(err, 50, "SVDI ERROR NUMBER %d SEVERITY CODE %d", errnum, errsev); perror(err); } else { @@ -883,7 +883,7 @@ void cdroab_(int *ifilcd, int *frame) len = 4; cdri2c_(frame, &len, ic); ic[len] = '\0'; - sprintf(cdrcm2_.KGNAME, "%s.RGB", ic); + snprintf(cdrcm2_.KGNAME, 80, "%s.RGB", ic); cdrofs_(ifilcd); } @@ -1046,8 +1046,8 @@ void cdrtim_(float *tim) {} void cdrtod_(void) { - sprintf((char *)vcjob_.KJTIME, "%02d:%02d:%02d\\", 11, 11, 11); - sprintf((char *)vcjob_.KJDATE, "%02d-%02d-%02d\\", 5, 5, 5); + snprintf((char *)vcjob_.KJTIME, sizeof(vcjob_.KJTIME), "%02d:%02d:%02d\\", 11, 11, 11); + snprintf((char *)vcjob_.KJDATE, sizeof(vcjob_.KJDATE), "%02d-%02d-%02d\\", 5, 5, 5); } /* *** CDRUPR *** diff --git a/packages/seacas/libraries/svdi/cgi/met_metxlate.c b/packages/seacas/libraries/svdi/cgi/met_metxlate.c index 60bf6125a13f..c0fb11ff7ae5 100644 --- a/packages/seacas/libraries/svdi/cgi/met_metxlate.c +++ b/packages/seacas/libraries/svdi/cgi/met_metxlate.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -2372,13 +2372,6 @@ static void xcca(anything **params, int num_surfaces, anything **surf_list) /* set the raster space */ vdstrs(&nx1, &ny1); - /* set mapping to virtual and freeform */ - /* - sprintf(map,"%s","VIRTUAL"); - vdstmp(map,7L); - sprintf(map,"%s","FREEFORM"); - vdstmp(map,8L); - */ imap = 3; vbstmp(&imap); imap = 5; @@ -5288,7 +5281,6 @@ void cdrofs(int *ifilcd) { int errnum, errsev; char symbol[1024]; - char err[50]; int qdc_index; float value; char *devid; @@ -5302,10 +5294,10 @@ void cdrofs(int *ifilcd) vdiqdc(&qdc_index, &value); devid = get_devid_char(value); if (devid != NULL) { - sprintf(cur_state->filename, "cgi%s%d", devid, file_cnt++); + snprintf(cur_state->filename, 100, "cgi%s%d", devid, file_cnt++); } else { - sprintf(cur_state->filename, "cgiout%d", file_cnt++); + snprintf(cur_state->filename, 100, "cgiout%d", file_cnt++); } } @@ -5315,7 +5307,7 @@ void cdrofs(int *ifilcd) /* check the environment to see if a file name has been assigned */ env = getenv(symbol); if (env != 0 && strlen(env) < 1024) { - sprintf(symbol, "%s", env); + snprintf(symbol, 1024, "%s", env); } /* open the file - if it doesn't exist, create it with mode 664 */ @@ -5324,7 +5316,8 @@ void cdrofs(int *ifilcd) if ((cur_state->file_d = open(symbol, (O_CREAT | O_TRUNC | O_RDWR), 0664)) == -1) { errnum = 722; errsev = 10; - sprintf(err, "SVDI ERROR NUMBER %d SEVERITY CODE %d", errnum, errsev); + char err[50]; + snprintf(err, 50, "SVDI ERROR NUMBER %d SEVERITY CODE %d", errnum, errsev); perror(err); } } @@ -5383,13 +5376,13 @@ void cdrcfs(int *ifilcd, int *eof) { int istat; char buf[4]; - char err[50]; /* if eof = 1 then write eof on file */ if (*eof == 1) { *buf = EOF; if ((istat = write(cur_state->file_d, buf, 4)) == -1) { - sprintf(err, "%s", "CDRCFS error"); + char err[50]; + snprintf(err, 50, "%s", "CDRCFS error"); perror(err); } } @@ -5413,7 +5406,7 @@ void cdroab(int *ifilcd, int *frame) ic[4] = '\0'; /* set the file name in the state list */ - sprintf(cur_state->filename, "%s.RGB", ic); + snprintf(cur_state->filename, 100, "%s.RGB", ic); cdrofs(ifilcd); } @@ -5429,9 +5422,8 @@ void nmtbuf(int *numwds, unsigned outary[]) static unsigned mask1 = ~(~0u << 8) << 8; /* mask off higher 8 bits */ static unsigned mask2 = ~(~0u << 8); /* mask off lower 8 bits */ - int i; /* loop variable */ - int istat; /* error reporting */ - char err[50]; /* for error reporting */ + int i; /* loop variable */ + int istat; /* error reporting */ /* cur_state is global and points to the current state */ @@ -5440,7 +5432,8 @@ void nmtbuf(int *numwds, unsigned outary[]) /* write out the data as a byte stream. */ if ((istat = write(cur_state->file_d, cur_state->buffer, cur_state->buff_ptr)) == -1) { - sprintf(err, "%s", "NMTBUF: write error"); + char err[50]; /* for error reporting */ + snprintf(err, 50, "%s", "NMTBUF: write error"); perror(err); } /* end write buffer */ @@ -5459,7 +5452,8 @@ void nmtbuf(int *numwds, unsigned outary[]) /* write out the data as a byte stream. */ if ((istat = write(cur_state->file_d, cur_state->buffer, cur_state->buff_ptr)) == -1) { - sprintf(err, "%s", "NMTBUF: write error"); + char err[50]; /* for error reporting */ + snprintf(err, 50, "%s", "NMTBUF: write error"); perror(err); } /* end write buffer */ diff --git a/packages/seacas/libraries/svdi/cgi/pst_pstxlate.c b/packages/seacas/libraries/svdi/cgi/pst_pstxlate.c index 8279284bf901..577e2498211b 100644 --- a/packages/seacas/libraries/svdi/cgi/pst_pstxlate.c +++ b/packages/seacas/libraries/svdi/cgi/pst_pstxlate.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -2379,13 +2379,6 @@ static void xcca(anything **params, int num_surfaces, anything **surf_list) /* set the raster space */ vdstrs(&nx1, &ny1); - /* set mapping to virtual and freeform */ - /* - sprintf(map,"%s","VIRTUAL"); - vdstmp(map,7L); - sprintf(map,"%s","FREEFORM"); - vdstmp(map,8L); - */ imap = 3; vbstmp(&imap); imap = 5; @@ -2765,13 +2758,6 @@ static void xcpxa(anything **params, int num_surfaces, anything **surf_list) /* set the raster viewport */ vdstrv(&xmin, &xmax, &ymin, &ymax); - /* set mapping to replicate and freeform */ - /* - sprintf(map,"%s","REPLICATE"); - vdstmp(map,8L); - sprintf(map,"%s","FREEFORM"); - vdstmp(map,9L); - */ imap = 2; vbstmp(&imap); imap = 5; @@ -5305,7 +5291,6 @@ void cdrofs(ifilcd) int *ifilcd; /* FORTRAN unit number ignored, provide for com { int errnum, errsev; char symbol[1024]; - char err[50]; int qdc_index; float value; char *devid; @@ -5319,10 +5304,10 @@ void cdrofs(ifilcd) int *ifilcd; /* FORTRAN unit number ignored, provide for com vdiqdc(&qdc_index, &value); devid = get_devid_char(value); if (devid != NULL) { - sprintf(cur_state->filename, "cgi%s%d", devid, file_cnt++); + snprintf(cur_state->filename, 100, "cgi%s%d", devid, file_cnt++); } else { - sprintf(cur_state->filename, "cgiout%d", file_cnt++); + snprintf(cur_state->filename, 100, "cgiout%d", file_cnt++); } } @@ -5332,7 +5317,7 @@ void cdrofs(ifilcd) int *ifilcd; /* FORTRAN unit number ignored, provide for com /* check the environment to see if a file name has been assigned */ env = getenv(symbol); if (env != 0 && strlen(env) < 1024) { - sprintf(symbol, "%s", env); + snprintf(symbol, 1024, "%s", env); } /* open the file - if it doesn't exist, create it with mode 664 */ @@ -5341,7 +5326,8 @@ void cdrofs(ifilcd) int *ifilcd; /* FORTRAN unit number ignored, provide for com if ((cur_state->file_d = open(symbol, (O_CREAT | O_TRUNC | O_RDWR), 0664)) == -1) { errnum = 722; errsev = 10; - sprintf(err, "SVDI ERROR NUMBER %d SEVERITY CODE %d", errnum, errsev); + char err[50]; + snprintf(err, 50, "SVDI ERROR NUMBER %d SEVERITY CODE %d", errnum, errsev); perror(err); } } @@ -5426,7 +5412,7 @@ int *frame; ic[4] = '\0'; /* set the file name in the state list */ - sprintf(cur_state->filename, "%s.RGB", ic); + snprintf(cur_state->filename, 100, "%s.RGB", ic); cdrofs(ifilcd); } diff --git a/packages/seacas/libraries/svdi/cgi/sdcgi.c b/packages/seacas/libraries/svdi/cgi/sdcgi.c index 314585ee9a69..ace531b59893 100644 --- a/packages/seacas/libraries/svdi/cgi/sdcgi.c +++ b/packages/seacas/libraries/svdi/cgi/sdcgi.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -40,134 +40,134 @@ #if defined(ADDC_) #endif #if !defined(CRA) && !defined(ADDC_) && !defined(COUGAR) -#define ci_ ci -#define ct_ ct +#define ci_ ci +#define ct_ ct #define cxdfac_ cxdfac -#define cpds_ cpds +#define cpds_ cpds #define cendpg_ cendpg -#define cbc_ cbc -#define cvdcx_ cvdcx -#define cv_ cv -#define ccl_ ccl +#define cbc_ cbc +#define cvdcx_ cvdcx +#define cv_ cv +#define ccl_ ccl #define cdqerr_ cdqerr #define cerhct_ cerhct -#define ccixp_ ccixp -#define cesc1_ cesc1 -#define cesc2_ cesc2 -#define cqid_ cqid -#define cqd_ cqd -#define clf_ clf -#define clpr_ clpr -#define cqsp_ cqsp -#define clesc_ clesc -#define cqp_ cqp -#define cpl_ cpl -#define cdjpl_ cdjpl -#define cdscl_ cdscl -#define cqcl_ cqcl -#define cpm_ cpm -#define ctx1_ ctx1 -#define ctx2_ ctx2 -#define cpg_ cpg -#define cca_ cca -#define clnt_ clnt -#define clnw_ clnw -#define clnc_ clnc -#define cmkt_ cmkt -#define cmkc_ cmkc -#define ctxp_ ctxp -#define ctxc_ ctxc -#define cchh_ cchh -#define ccho_ ccho -#define cis_ cis -#define cflc_ cflc -#define ccsm_ ccsm -#define cct_ cct +#define ccixp_ ccixp +#define cesc1_ cesc1 +#define cesc2_ cesc2 +#define cqid_ cqid +#define cqd_ cqd +#define clf_ clf +#define clpr_ clpr +#define cqsp_ cqsp +#define clesc_ clesc +#define cqp_ cqp +#define cpl_ cpl +#define cdjpl_ cdjpl +#define cdscl_ cdscl +#define cqcl_ cqcl +#define cpm_ cpm +#define ctx1_ ctx1 +#define ctx2_ ctx2 +#define cpg_ cpg +#define cca_ cca +#define clnt_ clnt +#define clnw_ clnw +#define clnc_ clnc +#define cmkt_ cmkt +#define cmkc_ cmkc +#define ctxp_ ctxp +#define ctxc_ ctxc +#define cchh_ cchh +#define ccho_ ccho +#define cis_ cis +#define cflc_ cflc +#define ccsm_ ccsm +#define cct_ cct #define cgtxx1_ cgtxx1 #define cgtxx2_ cgtxx2 -#define cqprl_ cqprl -#define cqln_ cqln -#define cqlnt_ cqlnt +#define cqprl_ cqprl +#define cqln_ cqln +#define cqlnt_ cqlnt #define cqchh1_ cqchh1 #define cqchh2_ cqchh2 -#define cqfl_ cqfl -#define cqc_ cqc -#define cqlna_ cqlna -#define cqtxa_ cqtxa -#define cqcte_ cqcte -#define cili_ cili -#define crqlc_ crqlc -#define cpxa_ cpxa +#define cqfl_ cqfl +#define cqc_ cqc +#define cqlna_ cqlna +#define cqtxa_ cqtxa +#define cqcte_ cqcte +#define cili_ cili +#define crqlc_ crqlc +#define cpxa_ cpxa #endif #if defined(CRA) -#define ci_ CI -#define ct_ CT +#define ci_ CI +#define ct_ CT #define cxdfac_ CXDFAC -#define cpds_ CPDS +#define cpds_ CPDS #define cendpg_ CENDPG -#define cbc_ CBC -#define cvdcx_ CVDCX -#define cv_ CV -#define ccl_ CCL +#define cbc_ CBC +#define cvdcx_ CVDCX +#define cv_ CV +#define ccl_ CCL #define cdqerr_ CDQERR #define cerhct_ CERHCT -#define ccixp_ CCIXP -#define cesc1_ CESC1 -#define cesc2_ CESC2 -#define cqid_ CQID -#define cqd_ CQD -#define clf_ CLF -#define clpr_ CLPR -#define cqsp_ CQSP -#define clesc_ CLESC -#define cqp_ CQP -#define cpl_ CPL -#define cdjpl_ CDJPL -#define cdscl_ CDSCL -#define cqcl_ CQCL -#define cpm_ CPM -#define ctx1_ CTX1 -#define ctx2_ CTX2 -#define cpg_ CPG -#define cca_ CCA -#define clnt_ CLNT -#define clnw_ CLNW -#define clnc_ CLNC -#define cmkt_ CMKT -#define cmkc_ CMKC -#define ctxp_ CTXP -#define ctxc_ CTXC -#define cchh_ CCHH -#define ccho_ CCHO -#define cis_ CIS -#define cflc_ CFLC -#define ccsm_ CCSM -#define cct_ CCT +#define ccixp_ CCIXP +#define cesc1_ CESC1 +#define cesc2_ CESC2 +#define cqid_ CQID +#define cqd_ CQD +#define clf_ CLF +#define clpr_ CLPR +#define cqsp_ CQSP +#define clesc_ CLESC +#define cqp_ CQP +#define cpl_ CPL +#define cdjpl_ CDJPL +#define cdscl_ CDSCL +#define cqcl_ CQCL +#define cpm_ CPM +#define ctx1_ CTX1 +#define ctx2_ CTX2 +#define cpg_ CPG +#define cca_ CCA +#define clnt_ CLNT +#define clnw_ CLNW +#define clnc_ CLNC +#define cmkt_ CMKT +#define cmkc_ CMKC +#define ctxp_ CTXP +#define ctxc_ CTXC +#define cchh_ CCHH +#define ccho_ CCHO +#define cis_ CIS +#define cflc_ CFLC +#define ccsm_ CCSM +#define cct_ CCT #define cgtxx1_ CGTXX1 #define cgtxx2_ CGTXX2 -#define cqprl_ CQPRL -#define cqln_ CQLN -#define cqlnt_ CQLNT +#define cqprl_ CQPRL +#define cqln_ CQLN +#define cqlnt_ CQLNT #define cqchh1_ CQCHH1 #define cqchh2_ CQCHH2 -#define cqfl_ CQFL -#define cqc_ CQC -#define cqlna_ CQLNA -#define cqtxa_ CQTXA -#define cqcte_ CQCTE -#define cili_ CILI -#define crqlc_ CRQLC -#define cpxa_ CPXA +#define cqfl_ CQFL +#define cqc_ CQC +#define cqlna_ CQLNA +#define cqtxa_ CQTXA +#define cqcte_ CQCTE +#define cili_ CILI +#define crqlc_ CRQLC +#define cpxa_ CPXA #endif #ifdef Build64 #if defined(ADDC_) -#define cesc1_ cesc14_ -#define ctx1_ ctx14_ +#define cesc1_ cesc14_ +#define ctx1_ ctx14_ #define cgtxx1_ cgtxx14_ #define cqchh1_ cqchh14_ #else -#define cesc1 cesc14 -#define ctx1 ctx14 +#define cesc1 cesc14 +#define ctx1 ctx14 #define cgtxx1 cgtxx14 #define cqchh1 cqchh14 #endif @@ -211,9 +211,9 @@ typedef struct FortranStr Fortran_Str; /* Make the declarations in the */ /******************************************************************************/ /* these are also used in mdcgi.c, where they are externs */ device_struct devices[MAX_DEVICES]; /* list of currently initialized */ -anything * in_params[MAX_IN_PARAMS]; /* params sent to driver */ +anything *in_params[MAX_IN_PARAMS]; /* params sent to driver */ short num_devices = 0; /* how many items in devices*/ -anything * sol_surf = NULL; /* current solicitation surface, */ +anything *sol_surf = NULL; /* current solicitation surface, */ /******************************************************************************/ /* */ @@ -222,7 +222,7 @@ anything * sol_surf = NULL; /* current solicitation surface, */ /******************************************************************************/ void ci_(f_integer *pds) { - short func_id = CI_FN; + static short func_id = CI_FN; if (num_devices == 0) { /* find the default device and initialize it */ @@ -245,7 +245,7 @@ void ci_(f_integer *pds) /******************************************************************************/ void ct_(void) { - short func_id = CT_FN; + static short func_id = CT_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -262,7 +262,7 @@ void ct_(void) /******************************************************************************/ void cxdfac_(void) { - short func_id = CXDFAC_FN; + static short func_id = CXDFAC_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -279,7 +279,7 @@ void cxdfac_(void) /******************************************************************************/ void cpds_(f_integer *clear) { - short func_id = CPDS_FN; + static short func_id = CPDS_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -297,7 +297,7 @@ void cpds_(f_integer *clear) /******************************************************************************/ void cendpg_(void) { - short func_id = CENDPG_FN; + static short func_id = CENDPG_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -314,7 +314,7 @@ void cendpg_(void) /******************************************************************************/ void cbc_(f_integer *red, f_integer *green, f_integer *blue) { - short func_id = CBC_FN; + static short func_id = CBC_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -334,7 +334,7 @@ void cbc_(f_integer *red, f_integer *green, f_integer *blue) /******************************************************************************/ void cvdcx_(f_real *x1, f_real *y1, f_real *x2, f_real *y2) { - short func_id = CVDCX_FN; + static short func_id = CVDCX_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -355,7 +355,7 @@ void cvdcx_(f_real *x1, f_real *y1, f_real *x2, f_real *y2) /******************************************************************************/ void cv_(f_real *x1, f_real *y1, f_real *x2, f_real *y2) { - short func_id = CV_FN; + static short func_id = CV_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -376,7 +376,7 @@ void cv_(f_real *x1, f_real *y1, f_real *x2, f_real *y2) /******************************************************************************/ void ccl_(f_integer *clipi) { - short func_id = CCL_FN; + static short func_id = CCL_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -394,7 +394,7 @@ void ccl_(f_integer *clipi) /******************************************************************************/ void cdscl_(f_integer *clipi) { - short func_id = CDSCL_FN; + static short func_id = CDSCL_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -413,8 +413,8 @@ void cdscl_(f_integer *clipi) void cdqerr_(f_integer *nreq, f_integer *vstat, f_integer *nrem, f_integer *nret, f_integer *errcl, f_integer *errnm, f_integer *funcid) { - short func_id = CDQERR_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CDQERR_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -452,7 +452,7 @@ void cdqerr_(f_integer *nreq, f_integer *vstat, f_integer *nrem, f_integer *nret /******************************************************************************/ void cerhct_(f_integer *n, f_integer *erclas, f_integer *hflag) { - short func_id = CERHCT_FN; + static short func_id = CERHCT_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -472,7 +472,7 @@ void cerhct_(f_integer *n, f_integer *erclas, f_integer *hflag) /******************************************************************************/ void ccixp_(f_integer *cip) { - short func_id = CCIXP_FN; + static short func_id = CCIXP_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -490,8 +490,8 @@ void ccixp_(f_integer *cip) /******************************************************************************/ void cesc1_(f_integer *funcid, f_integer *ldr, char *data, f_integer *drec_size) { - char *data1; - short func_id = CESC_FN; + char *data1; + static short func_id = CESC_FN; data1 = f2cchar(data); /* convert Fortran char ptr to C ptr */ @@ -519,8 +519,8 @@ void cesc1_(f_integer *funcid, f_integer *ldr, char *data, f_integer *drec_size) /******************************************************************************/ void cqid_(f_integer *maxchr, f_integer *vstat, f_integer *dclass, char *devid) { - short func_id = CQID_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQID_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -557,8 +557,8 @@ void cqd_(f_integer *vstat, f_integer *hscopy, f_integer *disp, f_integer *bcolo f_integer *dynvdm, f_integer *dx1, f_integer *dy1, f_integer *dx2, f_integer *dy2, f_real *width, f_real *height, f_integer *pixloc) { - short func_id = CQD_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQD_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -602,8 +602,8 @@ void cqd_(f_integer *vstat, f_integer *hscopy, f_integer *disp, f_integer *bcolo /******************************************************************************/ void clf_(f_integer *n, f_integer *funccl, f_integer *funcid, f_integer *vstat, f_integer *supprt) { - short func_id = CLF_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CLF_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -639,8 +639,8 @@ void clf_(f_integer *n, f_integer *funccl, f_integer *funcid, f_integer *vstat, /******************************************************************************/ void clpr_(f_integer *n, char *profid, f_integer *profid_size, f_integer *vstat, f_integer *supprt) { - short func_id = CLPR_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CLPR_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -679,8 +679,8 @@ void cqsp_(f_integer *vstat, f_integer *nvip, f_integer *vip, f_integer *nvrp, f f_integer *rfmt, f_integer *rexp, f_integer *rfrac, f_integer *nixp, f_integer *ixp, f_integer *ncp, f_integer *cp, f_integer *ncixp, f_integer *cixp) { - short func_id = CQSP_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQSP_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -730,8 +730,8 @@ void cqsp_(f_integer *vstat, f_integer *nvip, f_integer *vip, f_integer *nvrp, f /******************************************************************************/ void clesc_(f_integer *n, f_integer *escid, f_integer *vstat, f_integer *supprt) { - short func_id = CLESC_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CLESC_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -769,8 +769,8 @@ void cqp_(f_integer *vstat, f_integer *vip, f_integer *vrfmt, f_integer *vrexp, f_integer *ip, f_integer *rfmt, f_integer *rexp, f_integer *rfrac, f_integer *ixp, f_integer *cp, f_integer *cixp) { - short func_id = CQP_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQP_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -814,8 +814,8 @@ void cqp_(f_integer *vstat, f_integer *vip, f_integer *vrfmt, f_integer *vrexp, void cqcl_(f_integer *vstat, f_integer *clip1, f_integer *clipr, f_integer *sclip1, f_integer *sclipr) { - short func_id = CQCL_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQCL_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -851,7 +851,7 @@ void cqcl_(f_integer *vstat, f_integer *clip1, f_integer *clipr, f_integer *scli /******************************************************************************/ void cpl_(f_integer *np, f_real *px, f_real *py) { - short func_id = CPL_FN; + static short func_id = CPL_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -871,7 +871,7 @@ void cpl_(f_integer *np, f_real *px, f_real *py) /******************************************************************************/ void cdjpl_(f_integer *np, f_real *px, f_real *py) { - short func_id = CDJPL_FN; + static short func_id = CDJPL_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -891,7 +891,7 @@ void cdjpl_(f_integer *np, f_real *px, f_real *py) /******************************************************************************/ void cpm_(f_integer *np, f_real *px, f_real *py) { - short func_id = CPM_FN; + static short func_id = CPM_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -911,8 +911,8 @@ void cpm_(f_integer *np, f_real *px, f_real *py) /******************************************************************************/ void ctx1_(f_real *x, f_real *y, f_integer *flag, char *text, f_integer *text_size) { - char *text1; - short func_id = CTX_FN; + char *text1; + static short func_id = CTX_FN; text1 = f2cchar(text); /* convert Fortran char ptr to C ptr */ @@ -936,7 +936,7 @@ void ctx1_(f_real *x, f_real *y, f_integer *flag, char *text, f_integer *text_si /******************************************************************************/ void cpg_(f_integer *np, f_real *px, f_real *py) { - short func_id = CPG_FN; + static short func_id = CPG_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -957,7 +957,7 @@ void cpg_(f_integer *np, f_real *px, f_real *py) void cca_(f_real *x1, f_real *y1, f_real *x2, f_real *y2, f_real *x3, f_real *y3, f_integer *nx, f_integer *ny, f_integer *lcp, f_integer *cells) { - short func_id = CCA_FN; + static short func_id = CCA_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -984,7 +984,7 @@ void cca_(f_real *x1, f_real *y1, f_real *x2, f_real *y2, f_real *x3, f_real *y3 /******************************************************************************/ void clnt_(f_integer *lntyp) { - short func_id = CLNT_FN; + static short func_id = CLNT_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1002,7 +1002,7 @@ void clnt_(f_integer *lntyp) /******************************************************************************/ void clnw_(f_real *lnwid) { - short func_id = CLNW_FN; + static short func_id = CLNW_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1020,7 +1020,7 @@ void clnw_(f_real *lnwid) /******************************************************************************/ void clnc_(f_integer *lnclr) { - short func_id = CLNC_FN; + static short func_id = CLNC_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1038,7 +1038,7 @@ void clnc_(f_integer *lnclr) /******************************************************************************/ void cmkt_(f_integer *mktyp) { - short func_id = CMKT_FN; + static short func_id = CMKT_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1056,7 +1056,7 @@ void cmkt_(f_integer *mktyp) /******************************************************************************/ void cmkc_(f_integer *mkclr) { - short func_id = CMKC_FN; + static short func_id = CMKC_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1074,7 +1074,7 @@ void cmkc_(f_integer *mkclr) /******************************************************************************/ void ctxp_(f_integer *txp) { - short func_id = CTXP_FN; + static short func_id = CTXP_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1092,7 +1092,7 @@ void ctxp_(f_integer *txp) /******************************************************************************/ void ctxc_(f_integer *txclr) { - short func_id = CTXC_FN; + static short func_id = CTXC_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1110,7 +1110,7 @@ void ctxc_(f_integer *txclr) /******************************************************************************/ void cchh_(f_real *chhit) { - short func_id = CCHH_FN; + static short func_id = CCHH_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1128,7 +1128,7 @@ void cchh_(f_real *chhit) /******************************************************************************/ void ccho_(f_integer *xup, f_integer *yup, f_integer *xbase, f_integer *ybase) { - short func_id = CCHO_FN; + static short func_id = CCHO_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1149,7 +1149,7 @@ void ccho_(f_integer *xup, f_integer *yup, f_integer *xbase, f_integer *ybase) /******************************************************************************/ void cis_(f_integer *instyl) { - short func_id = CIS_FN; + static short func_id = CIS_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1167,7 +1167,7 @@ void cis_(f_integer *instyl) /******************************************************************************/ void cflc_(f_integer *fclr) { - short func_id = CFLC_FN; + static short func_id = CFLC_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1185,7 +1185,7 @@ void cflc_(f_integer *fclr) /******************************************************************************/ void ccsm_(f_integer *csmode) { - short func_id = CCSM_FN; + static short func_id = CCSM_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1203,7 +1203,7 @@ void ccsm_(f_integer *csmode) /******************************************************************************/ void cct_(f_integer *starti, f_integer *nclrs, f_integer *clrs) { - short func_id = CCT_FN; + static short func_id = CCT_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1225,9 +1225,9 @@ void cgtxx1_(f_real *x, f_real *y, char *string, f_integer *vstat, f_integer *vc f_real *yconc, f_real *x1, f_real *y1, f_real *x2, f_real *y2, f_real *x3, f_real *y3, f_real *x4, f_real *y4, f_integer *string_size) { - char *string1; - short func_id = CGTXX_FN; - short surf_found = 0; /* which active_surface was found */ + char *string1; + static short func_id = CGTXX_FN; + short surf_found = 0; /* which active_surface was found */ string1 = f2cchar(string); /* convert Fortran char ptr to C ptr */ @@ -1279,8 +1279,8 @@ void cqprl_(f_integer *vstat, f_integer *maxpl, f_integer *maxdpl, f_integer *ma f_integer *maxcel, f_integer *celfil, f_integer *celaln, f_integer *comptx, f_integer *clofig) { - short func_id = CQPRL_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQPRL_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1325,8 +1325,8 @@ void cqprl_(f_integer *vstat, f_integer *maxpl, f_integer *maxdpl, f_integer *ma void cqln_(f_integer *vstat, f_integer *npdefb, f_integer *nsetb, f_integer *maxbi, f_integer *dynmod, f_integer *nomwid, f_integer *minwid, f_integer *maxwid) { - short func_id = CQLN_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQLN_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1366,8 +1366,8 @@ void cqln_(f_integer *vstat, f_integer *npdefb, f_integer *nsetb, f_integer *max void cqlnt_(f_integer *nreq, f_integer *first, f_integer *vstat, f_integer *ntotal, f_integer *nlist, f_integer *lntyp) { - short func_id = CQLNT_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQLNT_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1405,9 +1405,9 @@ void cqlnt_(f_integer *nreq, f_integer *first, f_integer *vstat, f_integer *ntot void cqchh1_(char *font, f_integer *txp, f_integer *nreq, f_integer *first, f_integer *vstat, f_integer *ntotal, f_integer *nlist, f_integer *chhit, f_integer *font_size) { - char *font1; - short func_id = CQCHH_FN; - short surf_found = 0; /* which active_surface was found */ + char *font1; + static short func_id = CQCHH_FN; + short surf_found = 0; /* which active_surface was found */ font1 = f2cchar(font); /* convert Fortran char ptr to C ptr */ @@ -1452,8 +1452,8 @@ void cqfl_(f_integer *vstat, f_integer *npdefb, f_integer *nsetb, f_integer *max f_integer *nsetp, f_integer *maxpi, f_integer *pdiv, f_integer *maxpx, f_integer *maxpy, f_integer *ptrans) { - short func_id = CQFL_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQFL_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1499,8 +1499,8 @@ void cqfl_(f_integer *vstat, f_integer *npdefb, f_integer *nsetb, f_integer *max void cqc_(f_integer *vstat, f_integer *nsimul, f_integer *navail, f_integer *nint, f_integer *cmode, f_integer *dynmod, f_integer *overit, f_integer *monoc) { - short func_id = CQC_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQC_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1540,8 +1540,8 @@ void cqc_(f_integer *vstat, f_integer *nsimul, f_integer *navail, f_integer *nin void cqlna_(f_integer *vstat, f_integer *lnbi, f_integer *lntyp, f_integer *lwmode, f_integer *lnwid, f_integer *csmode, f_integer *lnclr, f_integer *lcmode) { - short func_id = CQLNA_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQLNA_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1583,8 +1583,8 @@ void cqtxa_(f_integer *vstat, f_integer *txbi, f_integer *fonti, f_integer *font f_real *orient[4], f_integer *txpath, f_integer *horal, f_real *contha, f_integer *veral, f_real *contva, f_integer *chsi, f_integer *achsi) { - short func_id = CQTXA_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQTXA_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1633,8 +1633,8 @@ void cqtxa_(f_integer *vstat, f_integer *txbi, f_integer *fonti, f_integer *font void cqcte_(f_integer *nreq, f_integer *first, f_integer *vstat, f_integer *ntotal, f_integer *nlist, f_integer *colors) { - short func_id = CQCTE_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CQCTE_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1671,8 +1671,8 @@ void cqcte_(f_integer *nreq, f_integer *first, f_integer *vstat, f_integer *ntot /******************************************************************************/ void cili_(f_integer *iclass, f_integer *idev) { - short func_id = CILI_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CILI_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1706,8 +1706,8 @@ void cili_(f_integer *iclass, f_integer *idev) void crqlc_(f_integer *idev, f_real *timeout, f_integer *vstat, f_integer *rstat, f_integer *mvalid, f_integer *triggr, f_real *x, f_real *y) { - short func_id = CRQLC_FN; - short surf_found = 0; /* which active_surface was found */ + static short func_id = CRQLC_FN; + short surf_found = 0; /* which active_surface was found */ /* set up parameter array */ in_params[0] = (anything *)&func_id; @@ -1747,7 +1747,7 @@ void crqlc_(f_integer *idev, f_real *timeout, f_integer *vstat, f_integer *rstat void cpxa_(f_real *x, f_real *y, f_integer *nx, f_integer *ny, f_integer *xscal, f_integer *yscal, f_integer *xdir, f_integer *ydir, f_integer *pxclrs) { - short func_id = CPXA_FN; + static short func_id = CPXA_FN; /* set up parameter array */ in_params[0] = (anything *)&func_id; diff --git a/packages/seacas/libraries/svdi/cgi/x11_x11xlate.c b/packages/seacas/libraries/svdi/cgi/x11_x11xlate.c index 2a12c2d923cd..e75e9474027a 100644 --- a/packages/seacas/libraries/svdi/cgi/x11_x11xlate.c +++ b/packages/seacas/libraries/svdi/cgi/x11_x11xlate.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2020, 2022 National Technology & Engineering Solutions + * Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -2375,13 +2375,6 @@ static void xcca(anything **params, int num_surfaces, anything **surf_list) /* set the raster space */ vdstrs(&nx1, &ny1); - /* set mapping to virtual and freeform */ - /* - sprintf(map,"%s","VIRTUAL"); - vdstmp(map,7L); - sprintf(map,"%s","FREEFORM"); - vdstmp(map,8L); - */ imap = 3; vbstmp(&imap); imap = 5; @@ -2761,13 +2754,6 @@ static void xcpxa(anything **params, int num_surfaces, anything **surf_list) /* set the raster viewport */ vdstrv(&xmin, &xmax, &ymin, &ymax); - /* set mapping to replicate and freeform */ - /* - sprintf(map,"%s","REPLICATE"); - vdstmp(map,8L); - sprintf(map,"%s","FREEFORM"); - vdstmp(map,9L); - */ imap = 2; vbstmp(&imap); imap = 5; @@ -5236,11 +5222,11 @@ static int inside_bnd(point *v, point *bmin, point *bmax, int bound_num) { /* this routine assumes a rectangular boundary */ switch (bound_num) { - case 0: return (v->y <= bmax->y); break; /* top */ - case 1: return (v->x <= bmax->x); break; /* right */ - case 2: return (v->y >= bmin->y); break; /* bottom */ - case 3: return (v->x >= bmin->x); break; /* left */ - default: return (FALSE); break; + case 0: return (v->y <= bmax->y); /* top */ + case 1: return (v->x <= bmax->x); /* right */ + case 2: return (v->y >= bmin->y); /* bottom */ + case 3: return (v->x >= bmin->x); /* left */ + default: return (FALSE); } /* end switch */ } /* end inside_bnd */ @@ -5297,7 +5283,6 @@ void cdrofs(ifilcd) int *ifilcd; /* FORTRAN unit number ignored, provide for com { int errnum, errsev; char symbol[1024]; - char err[50]; int qdc_index; float value; char *devid; @@ -5311,10 +5296,10 @@ void cdrofs(ifilcd) int *ifilcd; /* FORTRAN unit number ignored, provide for com vdiqdc(&qdc_index, &value); devid = get_devid_char(value); if (devid != NULL) { - sprintf(cur_state->filename, "cgi%s%d", devid, file_cnt++); + snprintf(cur_state->filename, 100, "cgi%s%d", devid, file_cnt++); } else { - sprintf(cur_state->filename, "cgiout%d", file_cnt++); + snprintf(cur_state->filename, 100, "cgiout%d", file_cnt++); } } @@ -5324,7 +5309,7 @@ void cdrofs(ifilcd) int *ifilcd; /* FORTRAN unit number ignored, provide for com /* check the environment to see if a file name has been assigned */ env = getenv(symbol); if (env != 0 && strlen(env) < 1024) { - sprintf(symbol, "%s", env); + snprintf(symbol, 1024, "%s", env); } /* open the file - if it doesn't exist, create it with mode 664 */ @@ -5333,7 +5318,8 @@ void cdrofs(ifilcd) int *ifilcd; /* FORTRAN unit number ignored, provide for com if ((cur_state->file_d = open(symbol, (O_CREAT | O_TRUNC | O_RDWR), 0664)) == -1) { errnum = 722; errsev = 10; - sprintf(err, "SVDI ERROR NUMBER %d SEVERITY CODE %d", errnum, errsev); + char err[50]; + snprintf(err, 50, "SVDI ERROR NUMBER %d SEVERITY CODE %d", errnum, errsev); perror(err); } } @@ -5406,7 +5392,7 @@ void cdrcfs(ifilcd, eof) int *ifilcd, *eof; if (*eof == 1) { *buf = EOF; if ((istat = write(cur_state->file_d, buf, 4)) == -1) { - sprintf(err, "%s", "CDRCFS error"); + snprintf(err, 50, "%s", "CDRCFS error"); perror(err); } } @@ -5431,7 +5417,7 @@ int *frame; ic[4] = '\0'; /* set the file name in the state list */ - sprintf(cur_state->filename, "%s.RGB", ic); + snprintf(cur_state->filename, 100, "%s.RGB", ic); cdrofs(ifilcd); } diff --git a/packages/seacas/scripts/exodus3.in.py b/packages/seacas/scripts/exodus3.in.py index bdb8b6ac80f5..c95784c7d04e 100644 --- a/packages/seacas/scripts/exodus3.in.py +++ b/packages/seacas/scripts/exodus3.in.py @@ -1,5 +1,5 @@ """ -exodus.py v 1.20.15 (seacas-py3) is a python wrapper of some of the exodus library +exodus.py v 1.20.21 (seacas-py3) is a python wrapper of some of the exodus library (Python 3 Version) Exodus is a common database for multiple application codes (mesh @@ -70,10 +70,10 @@ EXODUS_PY_COPYRIGHT_AND_LICENSE = __doc__ -EXODUS_PY_VERSION = "1.20.17 (seacas-py3)" +EXODUS_PY_VERSION = "1.20.21 (seacas-py3)" EXODUS_PY_COPYRIGHT = """ -You are using exodus.py v 1.20.17 (seacas-py3), a python wrapper of some of the exodus library. +You are using exodus.py v 1.20.21 (seacas-py3), a python wrapper of some of the exodus library. Copyright (c) 2013-2022 National Technology & Engineering Solutions of Sandia, LLC (NTESS). Under the terms of @@ -2202,7 +2202,28 @@ def put_reduction_variable_name(self, objType, name, index): self.__ex_put_reduction_variable_name(objType, index, name) return True - # -------------------------------------------------------------------- + def get_entity_count(self, objType, entityId): + """ + get number of nodes/elements in the specified set/block. Typically used internally + by other user-callable functions. + + Parameters + ---------- + objType : ex_entity_type + type of object being queried + entityId : int + id of the entity (block, set) *ID* (not *INDEX*) + """ + + numVals = 0 + if objType == "EX_NODAL": + numVals = self.num_nodes() + elif objType in ['EX_ELEM_BLOCK', 'EX_FACE_BLOCK', 'EX_EDGE_BLOCK']: + (_elemType, numVals, _nodesPerElem, _numAttr) = self.__ex_get_block(objType, entityId) + elif objType in ['EX_NODE_SET', 'EX_EDGE_SET', 'EX_FACE_SET', 'EX_SIDE_SET']: + (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) + + return numVals def get_variable_values(self, objType, entityId, name, step): """ @@ -2234,19 +2255,7 @@ def get_variable_values(self, objType, entityId, name, step): """ names = self.get_variable_names(objType) var_id = names.index(name) + 1 - numVals = 0 - if objType == 'EX_NODAL': - numVals = self.num_nodes() - elif objType == 'EX_ELEM_BLOCK': - numVals = self.num_elems_in_blk(entityId) - elif objType == 'EX_NODE_SET': - (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) - elif objType == 'EX_EDGE_SET': - (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) - elif objType == 'EX_FACE_SET': - (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) - elif objType == 'EX_SIDE_SET': - (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) + numVals = self.get_entity_count(objType, entityId) values = self.__ex_get_var(step, objType, var_id, entityId, numVals) if self.use_numpy: @@ -2275,19 +2284,7 @@ def put_variable_values(self, objType, entityId, name, step, values): """ names = self.get_variable_names(objType) var_id = names.index(name) + 1 - numVals = 0 - if objType == 'EX_NODAL': - numVals = self.num_nodes() - elif objType == 'EX_ELEM_BLOCK': - numVals = self.num_elems_in_blk(entityId) - elif objType == 'EX_NODE_SET': - (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) - elif objType == 'EX_EDGE_SET': - (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) - elif objType == 'EX_FACE_SET': - (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) - elif objType == 'EX_SIDE_SET': - (numVals, _numDistFactInSet) = self.__ex_get_set_param(objType, entityId) + numVals = self.get_entity_count(objType, entityId) self.__ex_put_var(step, objType, var_id, entityId, numVals, values) return True @@ -2522,7 +2519,7 @@ def elem_blk_info(self, object_id): num_elem_attrs number of attributes per element """ (elemType, numElem, nodesPerElem, numAttr) = self.__ex_get_block('EX_ELEM_BLOCK', object_id) - return elemType.value, numElem.value, nodesPerElem.value, numAttr.value + return elemType, numElem, nodesPerElem, numAttr def put_elem_blk_info(self, elem_blk_id, elem_type, num_blk_elems, num_elem_nodes, num_elem_attrs): @@ -2618,7 +2615,7 @@ def get_elem_connectivity(self, object_id): if self.use_numpy: elem_block_connectivity = ctype_to_numpy( self, elem_block_connectivity) - return elem_block_connectivity, num_elem_this_blk.value, num_nodes_per_elem.value + return elem_block_connectivity, num_elem_this_blk, num_nodes_per_elem def put_elem_connectivity(self, object_id, connectivity): """ @@ -2665,7 +2662,7 @@ def get_elem_attr(self, elem_blk_id): element, then all attributes of the second element, etc. Attributes are ordered by the ordering of the names - returned by exo.get_element_attribute_names() + returned by exo.get_attribute_names() """ elem_attrs = self.__ex_get_elem_attr(elem_blk_id) if self.use_numpy: @@ -2693,10 +2690,39 @@ def get_elem_attr_values(self, elem_blk_id, elem_attr_name): number of elements on the element block. """ # Determine index of requested attribute in attribute list - elem_attr_names = self.get_element_attribute_names(elem_blk_id) + elem_attr_names = self.get_attribute_names('EX_ELEM_BLOCK', elem_blk_id) a_ndx = elem_attr_names.index(elem_attr_name) - values = self.__ex_get_one_attr('EX_ELEM_BLOCK', elem_blk_id, a_ndx) + values = self.__ex_get_one_attr('EX_ELEM_BLOCK', elem_blk_id, a_ndx + 1) + if self.use_numpy: + values = ctype_to_numpy(self, values) + return values + + def get_attr_values(self, objType, elem_blk_id, elem_attr_name): + """ + get an attribute for each element in a block + + >>> elem_attrs = exo.get_elem_attr(elem_blk_id) + + Parameters + ---------- + elem_blk_id element block *ID* (not *INDEX*) + elem_attr_name element attribute name + + Returns + ------- + if array_type == 'ctype': > values + if array_type == 'numpy': > values + array of values for the requested + attribute. Array has dimensions of + 1 x num_elem, where num_elem is the + number of elements on the element block. + """ + # Determine index of requested attribute in attribute list + elem_attr_names = self.get_attribute_names('EX_ELEM_BLOCK', elem_blk_id) + a_ndx = elem_attr_names.index(elem_attr_name) + + values = self.__ex_get_one_attr('EX_ELEM_BLOCK', elem_blk_id, a_ndx + 1) if self.use_numpy: values = ctype_to_numpy(self, values) return values @@ -2711,14 +2737,14 @@ def put_elem_attr(self, elem_blk_id, elem_attrs): ---------- elem_blk_id : int element block *ID* (not *INDEX*) - > elem_attrs list of all attribute values for all - elements in the block; the list - cycles through all attributes of - the first element, then all attributes - of the second element, etc. Attributes - are ordered by the ordering of the - names returned by - exo.get_element_attribute_names() + > elem_attrs list of all attribute values for all + elements in the block; the list + cycles through all attributes of + the first element, then all attributes + of the second element, etc. Attributes + are ordered by the ordering of the + names returned by + exo.get_attribute_names() """ self.__ex_put_elem_attr(elem_blk_id, elem_attrs) @@ -2732,17 +2758,17 @@ def put_elem_attr_values(self, elem_blk_id, elem_attr_name, values): ---------- elem_blk_id : int element block *ID* (not *INDEX*) - elem_attr_name element attribute name - > values list of values for a single attribute - on a element block. List dimensions - should be 1 x N_elem, where N_elem is - the number of elements on the element - block. + elem_attr_name element attribute name + > values list of values for a single attribute + on a element block. List dimensions + should be 1 x N_elem, where N_elem is + the number of elements on the element + block. """ # Determine index of requested attribute in attribute list - elem_attr_names = self.get_element_attribute_names(elem_blk_id) + elem_attr_names = self.get_attribute_names('EX_ELEM_BLOCK', elem_blk_id) a_ndx = elem_attr_names.index(elem_attr_name) - self.__ex_put_one_attr('EX_ELEM_BLOCK', elem_blk_id, a_ndx, values) + self.__ex_put_one_attr('EX_ELEM_BLOCK', elem_blk_id, a_ndx + 1, values) def elem_type(self, object_id): """ @@ -2760,7 +2786,7 @@ def elem_type(self, object_id): elem_type """ (elemType, _numElem, _nodesPerElem, _numAttr) = self.__ex_get_block('EX_ELEM_BLOCK', object_id) - return elemType.value + return elemType def num_attr(self, object_id): """ @@ -2778,7 +2804,7 @@ def num_attr(self, object_id): num_elem_attrs """ (_elemType, _numElem, _nodesPerElem, numAttr) = self.__ex_get_block('EX_ELEM_BLOCK', object_id) - return numAttr.value + return numAttr def num_elems_in_blk(self, object_id): """ @@ -2795,8 +2821,8 @@ def num_elems_in_blk(self, object_id): ------- num_blk_elems """ - (_elemType, numElem, _nodesPerElem, _numAttr) = self.__ex_get_block('EX_ELEM_BLOCK', object_id) - return numElem.value + vals = self.get_entity_count('EX_ELEM_BLOCK', object_id) + return vals def num_nodes_per_elem(self, object_id): """ @@ -2814,7 +2840,7 @@ def num_nodes_per_elem(self, object_id): num_elem_nodes """ (_elemType, _numElem, nodesPerElem, _numAttr) = self.__ex_get_block('EX_ELEM_BLOCK', object_id) - return nodesPerElem.value + return nodesPerElem def get_element_variable_truth_table(self, entId=None): """ @@ -3010,6 +3036,28 @@ def put_element_variable_name(self, name, index): # -------------------------------------------------------------------- + def get_attribute_names(self, objType, blkId): + """ + get the list of attribute names for the specified block/set + + >>> attr_names = exo.get_attribute_names('EX_ELEM_BLOCK', elem_blk_id) + + Parameters + ---------- + objType: + entity type + blkId : int + block/set *ID* (not *INDEX*) + + Returns + ------- + > attr_names + """ + names = self.__ex_get_attr_names(objType, blkId) + return list(names) + + # -------------------------------------------------------------------- + def get_element_attribute_names(self, blkId): """ get the list of element attribute names for a block @@ -3018,36 +3066,59 @@ def get_element_attribute_names(self, blkId): Parameters ---------- - elem_blk_id : int - element block *ID* (not *INDEX*) + blkId : int + block/set *ID* (not *INDEX*) Returns ------- > attr_names """ - names = self.__ex_get_elem_attr_names(blkId) + names = self.__ex_get_attr_names('EX_ELEM_BLOCK', blkId) return list(names) # -------------------------------------------------------------------- + def put_attribute_names(self, objType, blkId, names): + """ + store the list of element attribute names for a block + + >>> status = exo.put_attribute_names('EX_ELEM_BLOCK', elem_blk_id, attr_names) + + Parameters + ---------- + objType: + entity type + blkId : int + block/set *ID* (not *INDEX*) + > attr_names + + Returns + ------- + status : bool + True = successful execution + """ + return self.__ex_put_attr_names(objType, blkId, names) + + # -------------------------------------------------------------------- + def put_element_attribute_names(self, blkId, names): """ store the list of element attribute names for a block - >>> status = exo.put_element_attribute_names(elem_blk_id, attr_names) + >>> status = exo.put_attribute_names(elem_blk_id, attr_names) Parameters ---------- - elem_blk_id : int - element block *ID* (not *INDEX*) - > attr_names + blkId : int + block/set *ID* (not *INDEX*) + > attr_names Returns ------- status : bool True = successful execution """ - return self.__ex_put_elem_attr_names(blkId, names) + return self.__ex_put_attr_names('EX_ELEM_BLOCK', blkId, names) # -------------------------------------------------------------------- @@ -5339,9 +5410,9 @@ def __ex_get_block_id_map(self, obj_type, id): entity_id = ctypes.c_longlong(id) _, numObjs, _, _ = self.__ex_get_block('EX_ELEM_BLOCK', id) if EXODUS_LIB.ex_int64_status(self.fileId) & EX_IDS_INT64_API: - id_map = (ctypes.c_longlong * numObjs.value)() + id_map = (ctypes.c_longlong * numObjs)() else: - id_map = (ctypes.c_int * numObjs.value)() + id_map = (ctypes.c_int * numObjs)() EXODUS_LIB.ex_get_block_id_map(self.fileId, obj_type, entity_id, id_map) if self.use_numpy: id_map = ctype_to_numpy(self, id_map) @@ -5415,7 +5486,7 @@ def __ex_get_block(self, object_type, object_id): ctypes.byref(num_edges_per_elem), ctypes.byref(num_faces_per_elem), ctypes.byref(num_attr)) - return blk_type, num_elem_this_blk, num_nodes_per_elem, num_attr + return blk_type.value, int(num_elem_this_blk.value), int(num_nodes_per_elem.value), int(num_attr.value) def __ex_put_block( self, @@ -5445,10 +5516,10 @@ def __ex_get_elem_conn(self, object_id): elem_block_id = ctypes.c_longlong(object_id) if EXODUS_LIB.ex_int64_status(self.fileId) & EX_BULK_INT64_API: elem_block_connectivity = ( - ctypes.c_longlong * (num_elem_this_blk.value * num_nodes_per_elem.value))() + ctypes.c_longlong * (num_elem_this_blk * num_nodes_per_elem))() else: elem_block_connectivity = ( - ctypes.c_int * (num_elem_this_blk.value * num_nodes_per_elem.value))() + ctypes.c_int * (num_elem_this_blk * num_nodes_per_elem))() EXODUS_LIB.ex_get_conn( self.fileId, ctypes.c_int(get_entity_type('EX_ELEM_BLOCK')), @@ -5462,13 +5533,13 @@ def __ex_put_elem_conn(self, object_id, connectivity): elem_block_id = ctypes.c_longlong(object_id) if EXODUS_LIB.ex_int64_status(self.fileId) & EX_BULK_INT64_API: elem_block_connectivity = ( - ctypes.c_longlong * (num_elem_this_blk.value * num_nodes_per_elem.value))() - for i in range(num_elem_this_blk.value * num_nodes_per_elem.value): + ctypes.c_longlong * (num_elem_this_blk * num_nodes_per_elem))() + for i in range(num_elem_this_blk * num_nodes_per_elem): elem_block_connectivity[i] = ctypes.c_longlong(connectivity[i]) else: elem_block_connectivity = ( - ctypes.c_int * (num_elem_this_blk.value * num_nodes_per_elem.value))() - for i in range(num_elem_this_blk.value * num_nodes_per_elem.value): + ctypes.c_int * (num_elem_this_blk * num_nodes_per_elem))() + for i in range(num_elem_this_blk * num_nodes_per_elem): elem_block_connectivity[i] = ctypes.c_int(connectivity[i]) EXODUS_LIB.ex_put_conn( self.fileId, @@ -5478,7 +5549,7 @@ def __ex_put_elem_conn(self, object_id, connectivity): def __ex_put_one_attr(self, objType, elemBlkID, attrIndx, Attr): elem_blk_id = ctypes.c_longlong(elemBlkID) - obj_type = ctypes.c_int(objType) + obj_type = ctypes.c_int(get_entity_type(objType)) attr_index = ctypes.c_longlong(attrIndx) attrib = (ctypes.c_double * len(Attr))() for i, attr in enumerate(Attr): @@ -5490,17 +5561,18 @@ def __ex_put_one_attr(self, objType, elemBlkID, attrIndx, Attr): attr_index, attrib) - def __ex_get_one_attr(self, objType, elemBlkID, attrIndx): - elem_blk_id = ctypes.c_longlong(elemBlkID) - obj_type = ctypes.c_int(objType) + def __ex_get_one_attr(self, objType, entityId, attrIndx): + entity_id = ctypes.c_longlong(entityId) + obj_type = ctypes.c_int(get_entity_type(objType)) attr_index = ctypes.c_longlong(attrIndx) - inqType = ex_inquiry_map(ex_obj_to_inq(objType)) - num_objs = ctypes.c_int(self.__ex_inquire_int(inqType)).value - attrib = (ctypes.c_double * num_objs)() + + numVals = self.get_entity_count(objType, entityId) + attrib = (ctypes.c_double * numVals)() + EXODUS_LIB.ex_get_one_attr( self.fileId, obj_type, - elem_blk_id, + entity_id, attr_index, ctypes.byref(attrib)) return attrib @@ -5519,7 +5591,7 @@ def __ex_put_elem_attr(self, elemBlkID, Attr): def __ex_get_elem_attr(self, elemBlkID): elem_blk_id = ctypes.c_longlong(elemBlkID) numAttrThisBlk = self.num_attr(elemBlkID) - numElemsThisBlk = self.num_elems_in_blk(elemBlkID) + numElemsThisBlk = self.get_entity_count('EX_ELEM_BLOCK', elemBlkID) totalAttr = numAttrThisBlk * numElemsThisBlk attrib = (ctypes.c_double * totalAttr)() EXODUS_LIB.ex_get_attr( @@ -5841,18 +5913,20 @@ def __ex_put_variable_name(self, varType, varId, varName): EXODUS_LIB.ex_put_variable_name(self.fileId, var_type, var_id, name) return True - def __ex_get_elem_attr_names(self, blkId): + def __ex_get_attr_names(self, objType, blkId): + obj_type = ctypes.c_int(get_entity_type(objType)) object_id = ctypes.c_longlong(blkId) num_attr = ctypes.c_int(self.num_attr(blkId)) len_name = self.__ex_inquire_int(ex_inquiry_map('EX_INQ_MAX_READ_NAME_LENGTH')) attr_name_ptrs = (ctypes.POINTER(ctypes.c_char * (len_name + 1)) * num_attr.value)() for i in range(num_attr.value): attr_name_ptrs[i] = ctypes.pointer(ctypes.create_string_buffer(len_name + 1)) - EXODUS_LIB.ex_get_elem_attr_names( - self.fileId, object_id, ctypes.byref(attr_name_ptrs)) + EXODUS_LIB.ex_get_attr_names( + self.fileId, obj_type, object_id, ctypes.byref(attr_name_ptrs)) return [cnp.contents.value.decode('utf8') for cnp in attr_name_ptrs] - def __ex_put_elem_attr_names(self, blkId, varNames): + def __ex_put_attr_names(self, objType, blkId, varNames): + obj_type = ctypes.c_int(get_entity_type(objType)) object_id = ctypes.c_int(blkId) num_attr = ctypes.c_int(self.num_attr(blkId)) len_name = self.__ex_inquire_int(ex_inquiry_map('EX_INQ_MAX_READ_NAME_LENGTH')) @@ -5862,8 +5936,8 @@ def __ex_put_elem_attr_names(self, blkId, varNames): attr_name_ptrs[i] = ctypes.pointer( ctypes.create_string_buffer( varNames[i].encode('ascii'), len_name + 1)) - EXODUS_LIB.ex_put_elem_attr_names( - self.fileId, object_id, ctypes.byref(attr_name_ptrs)) + EXODUS_LIB.ex_put_attr_names( + self.fileId, obj_type, object_id, ctypes.byref(attr_name_ptrs)) return True def __ex_get_prop_names(self, varType, inqType): @@ -6134,7 +6208,7 @@ def copy_mesh(fromFileName, toFileName, exoFromObj=None, additionalElementAttrib e_attr_vals[blk_id] = [] if numAttr > 0: e_attr_names[blk_id].extend( - exoFrom.get_element_attribute_names(blk_id)) + exoFrom.get_attribute_names('EX_ELEM_BLOCK', blk_id)) e_attr_vals[blk_id].extend(exoFrom.get_elem_attr(blk_id)) blk_num_elem[blk_id] = numElem # Collect the new element attribute names @@ -6169,7 +6243,7 @@ def copy_mesh(fromFileName, toFileName, exoFromObj=None, additionalElementAttrib (connectivity, numElem, nodesPerElem) = exoFrom.get_elem_connectivity(blkId) exo_to.put_elem_connectivity(blkId, connectivity) if numAttr > 0: - exo_to.put_element_attribute_names(blkId, e_attr_names[blkId]) + exo_to.put_attribute_names('EX_ELEM_BLOCK', blkId, e_attr_names[blkId]) exo_to.put_elem_attr(blkId, e_attr_vals[blkId]) elemProps = exoFrom.get_element_property_names() for elemProp in elemProps: diff --git a/packages/seacas/scripts/exomerge2.py b/packages/seacas/scripts/exomerge2.py index 6e9c0aef96d5..efeb568c8e7b 100755 --- a/packages/seacas/scripts/exomerge2.py +++ b/packages/seacas/scripts/exomerge2.py @@ -1,7 +1,7 @@ """ Exomerge is a lightweight Python interface for manipulating ExodusII files. -Copyright(C) 1999-2020 National Technology & Engineering Solutions +Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software. @@ -8381,52 +8381,6 @@ def get_element_edge_length_info(self, element_block_ids='all'): return [float('nan')] * 2 return [minimum, total / edge_count] - # delete any element blocks which are not of dimension 3 - new_ids = [] - for id_ in element_block_ids: - if self.get_element_block_dimension(id_) != 3: - self._warning('Unexpected element block dimension', - 'Element blocks used to determine element edge ' - 'length are expected to be of dimension 3.') - else: - new_ids.append(id_) - element_block_ids = new_ids - # create a side set with all element block faces - members = self._get_element_faces(element_block_ids) - side_set_id = self._new_side_set_id() - self.create_side_set(side_set_id, members) - # create element blocks from this side set - face_element_block_ids = self._create_element_blocks_from_side_sets( - side_set_id) - # create a side set with all element face faces - members = self._get_element_faces(face_element_block_ids) - edge_set_id = self._new_side_set_id() - self.create_side_set(edge_set_id, members) - # create element blocks from this side set - edge_element_block_ids = self._create_element_blocks_from_side_sets( - edge_set_id) - # calculate element 'volume' (i.e. edge length) on this side set - field_name = self._new_element_field_name() - self.calculate_element_volumes(field_name, edge_element_block_ids) - # find average and minimum values - total = sum(sum(self.get_element_field_values(field_name, id_)) - for id_ in edge_element_block_ids) - total_edges = sum(self.get_element_count(id_) - for id_ in edge_element_block_ids) - average = total / total_edges - minimum = min(min(self.get_element_field_values(field_name, id_)) - for id_ in edge_element_block_ids) - # delete temporary entities - self.delete_element_field(field_name, edge_element_block_ids) - self.delete_element_block(edge_element_block_ids, - delete_orphaned_nodes=False) - self.delete_side_set(edge_set_id) - self.delete_element_block(face_element_block_ids, - delete_orphaned_nodes=False) - self.delete_side_set(side_set_id) - # return the result - return [minimum, average] - def _get_closest_point_distance_brute(self, points): """Return the distance between the two closest points.""" point_count = len(points) @@ -8489,36 +8443,6 @@ def get_closest_node_distance(self): # create list of all nodes point_list = list(tuple(x) for x in self.nodes) return self._get_closest_point_distance(point_list) - # First, we sort all nodes along a vector, then sift through them. - sorting_vector = [math.pi, 2.0, 0.5 * math.sqrt(2)] - scale = math.sqrt(sum([x * x for x in sorting_vector])) - sorting_vector = [x / scale for x in sorting_vector] - # each element holds (distance, index) - sorted_nodal_distances = sorted([(self._dot(x, sorting_vector), x) - for i, x in enumerate(self.nodes)]) - node_count = len(self.nodes) - if node_count < 2: - return float('nan') - lower_index = 0 - upper_index = 1 - closest_distance = float('inf') - while lower_index < node_count: - if (upper_index >= node_count or - sorted_nodal_distances[upper_index][0] - - sorted_nodal_distances[lower_index][0] > closest_distance): - lower_index += 1 - upper_index = lower_index + 1 - continue - lower_element = sorted_nodal_distances[lower_index] - upper_element = sorted_nodal_distances[upper_index] - distance = self._distance_between(lower_element[1], - upper_element[1]) - if distance < closest_distance: - closest_distance = distance - upper_index += 1 - if closest_distance == float('inf'): - closest_distance = float('nan') - return closest_distance def _input_check_error(self, argument, format): """ diff --git a/packages/seacas/scripts/getopt.seacas.c b/packages/seacas/scripts/getopt.seacas.c index 26c4c7abe896..4fcb16753b43 100644 --- a/packages/seacas/scripts/getopt.seacas.c +++ b/packages/seacas/scripts/getopt.seacas.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2021 National Technology & Engineering Solutions + * Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -73,8 +73,8 @@ int quote = 1; /* 1 is do quote. */ int alternative = 0; /* 0 is getopt_long, 1 is getopt_long_only */ /* Function prototypes */ -void * our_malloc(size_t size); -void * our_realloc(void *ptr, size_t size); +void *our_malloc(size_t size); +void *our_realloc(void *ptr, size_t size); const char *normalize(const char *arg); int generate_output(char *argv[], int argc, const char *optstr, const struct option *longopts); int main(int argc, char *argv[]); @@ -117,8 +117,8 @@ void *our_realloc(void *ptr, size_t size) const char *normalize(const char *arg) { static char *BUFFER = NULL; - const char * argptr = arg; - char * bufptr; + const char *argptr = arg; + char *bufptr; if (BUFFER != NULL) { free(BUFFER); @@ -187,16 +187,15 @@ const char *normalize(const char *arg) */ int generate_output(char *argv[], int argc, const char *optstr, const struct option *longopts) { - int exit_code = 0; /* We assume everything will be OK */ - int opt; - int longindex; - const char *charptr; + int exit_code = 0; /* We assume everything will be OK */ + int opt = 0; if (quiet_errors) { /* No error reporting from getopt(3) */ opterr = 0; } optind = 0; /* Reset getopt(3) */ + int longindex = 0; while ((opt = (alternative ? getopt_long_only(argc, argv, optstr, longopts, &longindex) : getopt_long(argc, argv, optstr, longopts, &longindex))) != EOF) { if (opt == '?' || opt == ':') { @@ -214,7 +213,7 @@ int generate_output(char *argv[], int argc, const char *optstr, const struct opt } else { printf(" -%c", opt); - charptr = strchr(optstr, opt); + const char *charptr = strchr(optstr, opt); if (charptr != NULL && *++charptr == ':') { printf(" %s", normalize(optarg ? optarg : "")); } @@ -250,7 +249,7 @@ static struct option *long_options = NULL; static int long_options_length = 0; /* Length of array */ static int long_options_nr = 0; /* Nr of used elements in array */ #define LONG_OPTIONS_INCR 10 -#define init_longopt() add_longopt(NULL, 0) +#define init_longopt() add_longopt(NULL, 0) /* Register a long option. The contents of name is copied. */ void add_longopt(const char *name, int has_arg) diff --git a/packages/seacas/scripts/tests/test_exodus3.py b/packages/seacas/scripts/tests/test_exodus3.py index 01045fa23837..95a1df50bff7 100755 --- a/packages/seacas/scripts/tests/test_exodus3.py +++ b/packages/seacas/scripts/tests/test_exodus3.py @@ -20,7 +20,7 @@ import exodus as exo -class TestAssemblies(unittest.TestCase): +class TestExodus(unittest.TestCase): def setUp(self): input_dir = os.path.dirname(__file__) self.tempdir = tempfile.TemporaryDirectory() @@ -122,6 +122,23 @@ def test_get_assembly(self): root.entity_list = [200, 300, 400] self.assertEqual(str(root), str(assemblies[0])) + def test_get_entity_count(self): + with exo.exodus(self.temp_exo_path) as temp_exofile: + elem_ids = temp_exofile.get_ids("EX_ELEM_BLOCK") + elems = [temp_exofile.get_entity_count("EX_ELEM_BLOCK", elem) for elem in elem_ids] + self.assertListEqual([1, 1, 1, 1, 1, 1, 1], elems) + + def test_get_elem_attr_values(self): + names = ["Scale", "Units"] + temp_copy = os.path.join(self.tempdir.name, "temp_copy.exo") + with exo.copy_mesh(self.temp_exo_path, temp_copy, additionalElementAttributes=names) as temp_exofile: + for elem_id in temp_exofile.get_ids("EX_ELEM_BLOCK"): + attrs = [[3.14159], [1]] + for name, values in zip(names, attrs): + temp_exofile.put_elem_attr_values(elem_id, name, values) + self.assertEqual(3.14159, temp_exofile.get_elem_attr_values(elem_id, "Scale")[0]) + self.assertEqual(1.0, temp_exofile.get_elem_attr_values(elem_id, "Units")[0]) + def test_get_assemblies(self): with exo.exodus(self.temp_exo_path) as temp_exofile: assembly_ids = temp_exofile.get_ids("EX_ASSEMBLY")