Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/parafeed_CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
inputs:
reason:
description: 'Reason for manual run'

jobs:
build-and-test:
Expand Down
6 changes: 3 additions & 3 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ set(shccl_sources
ParseCmdLine.cc
clparseVal.cc
InstallSymb.cc
clgetSVal.cc
clgetNSVal.cc
# clgetSVal.cc
# clgetNSVal.cc
clgetFullVal.cc

clgetValp.cc
# clgetValp.cc
clStartInteractive.cc
clRestartShell.cc
clfInteractive.cc
Expand Down
20 changes: 10 additions & 10 deletions code/ParseCmdLine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <support.h>
#include <sstream>
#include <clstring.h>
//#include <clgetValp.h>
#include <clgetValp.h>
/*#include <signal.h>*/
#ifdef __cplusplus
#ifdef _GNU_SOURCE
Expand Down Expand Up @@ -385,7 +385,7 @@ int startShell()
{
loadDefaults(1); cl_defaultsLoaded=1;
}
if (doInp)
if (doInp && !cl_NoPrompt)
{
//
// Why is this required? This gets called anyway via
Expand Down Expand Up @@ -454,8 +454,9 @@ int EndCL()

cl_RegistrationMode=0;
// i = clgetSVal("help",val,&i);
i = clgetSValp("help",strVal,i);
DeleteVar("help",&cl_SymbTab,&cl_TabTail);
string help("help");
i = clgetSValp(help,strVal,i);
DeleteVar((char *)help.c_str(),&cl_SymbTab,&cl_TabTail);

// if (!cl_NoPrompt) loadDefaults(0);
// if (!strcmp(val,"doc"))
Expand All @@ -476,6 +477,7 @@ int EndCL()
if (!cl_defaultsLoaded) {loadDefaults(1);cl_defaultsLoaded=1;}
}
// DeleteVar("help",&cl_SymbTab,&cl_TabTail);
cl_NoPrompt=1;
if (strVal=="doc") doprintdoc(strVal.c_str());
else doprintparams(strVal.c_str());
}
Expand All @@ -495,7 +497,7 @@ int EndCL()
if (arg[strlen(arg)-1]==')') arg[strlen(arg)-1] = '\0';
doexplain(arg);
free(val_t);
exit(0);
throw(clExit("Exiting due to explain mode", "###Informational", CL_INFORMATIONAL));
}
else if (strVal=="def")
{
Expand All @@ -511,8 +513,7 @@ int EndCL()
if (cl_DOCLEANUP) clCleanUp();
if (cl_DryRun==1)
{
clThrowUp("Exiting in EndCL() due to dryrun mode", "###Informational", CL_INFORMATIONAL);
exit(0);
throw(clExit("Exiting in EndCL() due to dryrun mode", "###Informational", CL_INFORMATIONAL));
}
return i;
}
Expand All @@ -529,9 +530,8 @@ int EndCL()
save_hist(var,(char *)CL_HIST_DEFAULT);
#endif
if (cl_DryRun==1)
{
exit(0);
}
throw(clExit("Exiting in EndCL() due to dryrun mode", "###Informational", CL_INFORMATIONAL));

return 1;
}
/*------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions code/callbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#ifdef GNUREADLINE
#include <readline/history.h>
#endif
extern unsigned short cl_NoPrompt;

#ifdef __cplusplus
using namespace std;
Expand Down Expand Up @@ -108,6 +109,7 @@ END{ \
/*----------------------------------------------------------------------*/
int doinp(char *arg)
{
if (cl_NoPrompt) return 0;
auto printer = [](FILE *fd, Symbol *t)
{
PrintKey(stderr, t);
Expand Down Expand Up @@ -702,7 +704,7 @@ int dosavefd(FILE *fd, const std::vector<std::string>& opts)
if (S->Class==CL_DBGCLASS)
cout << "\t***This keyword is exposed with a command-line argument of \"help=dbg\"***" << endl;
}
exit(0);
// exit(0);
return 1;
}
/*----------------------------------------------------------------------*/
Expand All @@ -729,7 +731,7 @@ int dosavefd(FILE *fd, const std::vector<std::string>& opts)
cout << endl;
}
}
exit(0);
// exit(0);
return 1;
}
/*----------------------------------------------------------------------*/
Expand Down
2 changes: 2 additions & 0 deletions code/clCleanUp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ void clCleanUp()
cl_RegistrationMode=1;
cl_Pass = 0;
cl_SymbLoaded= 0;
cl_InteractiveShell=0;
cl_NoPrompt=0;
}

#ifdef __cplusplus
Expand Down
10 changes: 10 additions & 0 deletions code/clError.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ class clNumParsingError: public clError
clNumParsingError(const clNumParsingError& that) : clError(that) {};
~clNumParsingError() {};
};

class clExit: public clError
{
public:
clExit():clError() {};
clExit(const char *m, const char *i, int l=0): clError(m,i,l) {};
clExit(const string& m, const string& i, int l=0): clError(m,i,l) {};
clExit(const clExit& that) : clError(that) {};
~clExit() {};
};
/*---------------------------------------------------------------------
In the entire library, the following routine is used always when an
exception is to be thrown.
Expand Down
16 changes: 9 additions & 7 deletions code/clgetFullVal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <support.h>
#include <setAutoDefaults.h>
#include <clparseVal.h>
#include <clgetValp.h>
#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -30,27 +31,28 @@ extern "C" {
int clgetFullVal(char *Name, char **val)
{
int n,i,len=0;
char tmp[FILENAME_MAX];
// char tmp[FILENAME_MAX];
std::string tmp;

if (!*val) free(*val); *val=NULL;
if ((n=clgetNVals(Name))>0)
{
for (i=1;i<=n;i++)
{
clgetSVal(Name,tmp,&i);
len += strlen(tmp)+1;
clgetSValp(string(Name),tmp,i);
len += strlen(tmp.c_str())+1;
}

*val = (char *)getmem(len,"clgetFullVal");
for (i=0;i<len;i++) (*val)[i]=' ';
i=1; clgetSVal(Name,tmp,&i);
strcpy(*val,tmp);
i=1; clgetSValp(string(Name),tmp,i);
strcpy(*val,tmp.c_str());

for (i=2;i<=n;i++)
{
strcat(*val,",");
clgetSVal(Name,tmp,&i);
strcat(*val,tmp);
clgetSValp(string(Name),tmp,i);
strcat(*val,tmp.c_str());
}
*(*val+strlen(*val))='\0';
}
Expand Down
20 changes: 10 additions & 10 deletions code/clgetSVal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ extern "C" {
/*------------------------------------------------------------------------
Return the Nth value of Name as a string
------------------------------------------------------------------------*/
int clgetSVal(const char *Name, char *val, int *n)
{
HANDLE_EXCEPTIONS(
string valp;
int r;
if ((r = clgetSValp(std::string(Name), valp, *n))!= CL_FAIL)
strncpy(val,valp.c_str(),valp.size()+1);
return r;
);
}
// int clgetSVal(const char *Name, char *val, int *n)
// {
// HANDLE_EXCEPTIONS(
// string valp;
// int r;
// if ((r = clgetSValp(std::string(Name), valp, *n))!= CL_FAIL)
// strncpy(val,valp.c_str(),valp.size()+1);
// return r;
// );
// }
#ifdef __cplusplus
}
#endif
Expand Down
78 changes: 38 additions & 40 deletions code/clgetValp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@
// dbgclgetValp() and dbgclgetNValp(). These use the templated
// clgetBaseCode() and clparseVal().
//
// Templates for std::string type is deleted and overloaded since
// val = (T)d cannot work the same way for string as it works
// for float,int, bool types.
//
// For directly using clget?Valp() interface, nothing else is required
// other than these templates. This usage is recommended. For
// backward compatibility, the clget[SIBF][N]Valp() functions are
// backward compatibility, the [dbg]clget[SIBF][N]Valp() functions are
// implemented which are wrappers around clgetValp() functions. These
// functions are still in use in other parts of the library -- so
// these are required even internally for now. Similar functions may
// also be possible for pure-C interface.
//
#ifndef CLGETVALP_CPP
#define CLGETVALP_CPP
#include <clgetValp.h>
#include <clgetBaseCode.h>
//#include <clgetValp.h>
//
//
//----------------------------------------------------------------------
Expand Down Expand Up @@ -145,46 +142,47 @@ int dbgclgetValp(const std::string& Name, std::vector<T>& val, int& n, SMap smap
//

template<class T>
int cldbggetValp(const std::string& Name, T& val, int& n) {return dbgclgetValp(Name,val,n);}
inline int cldbggetValp(const std::string& Name, T& val, int& n) {return dbgclgetValp(Name,val,n);}

int clgetFValp(const std::string& Name, float &val, int &n) {return clgetValp(Name,val,n);}
int clgetFValp(const std::string& Name, float& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
int clgetNFValp(const std::string& Name, std::vector<float>& val, int& n) {return clgetValp(Name,val,n);}
int clgetNFValp(const std::string& Name, std::vector<float>& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
inline int clgetFValp(const std::string& Name, float& val, int& n) {return clgetValp(Name,val,n);}
inline int clgetFValp(const std::string& Name, float& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
inline int clgetNFValp(const std::string& Name, std::vector<float>& val, int& n) {return clgetValp(Name,val,n);}
inline int clgetNFValp(const std::string& Name, std::vector<float>& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}

int clgetIValp(const std::string& Name, int &val, int &n) {return clgetValp(Name,val,n);}
int clgetIValp(const std::string& Name, int& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
int clgetNIValp(const std::string& Name, std::vector<int>& val, int& n) {return clgetValp(Name,val,n);}
int clgetNIValp(const std::string& Name, std::vector<int>& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
inline int clgetIValp(const std::string& Name, int &val, int &n) {return clgetValp(Name,val,n);}
inline int clgetIValp(const std::string& Name, int& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
inline int clgetNIValp(const std::string& Name, std::vector<int>& val, int& n) {return clgetValp(Name,val,n);}
inline int clgetNIValp(const std::string& Name, std::vector<int>& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}

int clgetBValp(const std::string& Name, bool& val, int &n) {return clgetValp(Name,val,n);}
int clgetBValp(const std::string& Name, bool& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
int clgetNBValp(const std::string& Name, std::vector<bool>& val, int& n) {return clgetValp(Name,val,n);}
int clgetNBValp(const std::string& Name, std::vector<bool>& val, int& n, SMap &smap){return clgetValp(Name,val,n,smap);}
inline int clgetBValp(const std::string& Name, bool& val, int &n) {return clgetValp(Name,val,n);}
inline int clgetBValp(const std::string& Name, bool& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
inline int clgetNBValp(const std::string& Name, std::vector<bool>& val, int& n) {return clgetValp(Name,val,n);}
inline int clgetNBValp(const std::string& Name, std::vector<bool>& val, int& n, SMap &smap){return clgetValp(Name,val,n,smap);}

int clgetSValp(const std::string& Name, std::string& val, int &n) {return clgetValp(Name,val,n);}
int clgetSValp(const std::string& Name, std::string& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
int clgetNSValp(const std::string& Name, std::vector<std::string>& val, int& n) {return clgetValp(Name,val,n);}
int clgetNSValp(const std::string& Name, std::vector<std::string>& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
int clgetNSValp(const std::string& Name, std::vector<std::string>& val, int& n, const SMap smap) {return clgetValp(Name,val,n,smap);}
//inline int clgetSVal(const char *Name, char *val, int *n) {return clgetValp(std::string(Name), *val, *n);}
inline int clgetSValp(const std::string& Name, std::string& val, int &n) {return clgetValp(Name,val,n);}
inline int clgetSValp(const std::string& Name, std::string& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
inline int clgetNSValp(const std::string& Name, std::vector<std::string>& val, int& n) {return clgetValp(Name,val,n);}
inline int clgetNSValp(const std::string& Name, std::vector<std::string>& val, int& n, SMap &smap) {return clgetValp(Name,val,n,smap);}
inline int clgetNSValp(const std::string& Name, std::vector<std::string>& val, int& n, const SMap smap) {return clgetValp(Name,val,n,smap);}

int cldbggetIValp(const std::string& Name, int& val, int& n) {return dbgclgetValp(Name,val,n);}
int cldbggetFValp(const std::string& Name, float& val, int& n) {return dbgclgetValp(Name,val,n);}
int cldbggetBValp(const std::string& Name, bool& val, int& n) {return dbgclgetValp(Name,val,n);}
int cldbggetSValp(const std::string& Name, std::string& val, int& n) {return dbgclgetValp(Name,val,n);}
inline int cldbggetIValp(const std::string& Name, int& val, int& n) {return dbgclgetValp(Name,val,n);}
inline int cldbggetFValp(const std::string& Name, float& val, int& n) {return dbgclgetValp(Name,val,n);}
inline int cldbggetBValp(const std::string& Name, bool& val, int& n) {return dbgclgetValp(Name,val,n);}
inline int cldbggetSValp(const std::string& Name, std::string& val, int& n) {return dbgclgetValp(Name,val,n);}

int cldbggetIValp(const std::string& Name, int& val, int& n, SMap& smap) {return dbgclgetValp(Name,val,n,smap);}
int cldbggetFValp(const std::string& Name, float& val, int& n, SMap& smap) {return dbgclgetValp(Name,val,n,smap);}
int cldbggetBValp(const std::string& Name, bool& val, int& n, SMap& smap) {return dbgclgetValp(Name,val,n, smap);}
int cldbggetSValp(const std::string& Name, std::string& val, int& n, SMap& smap) {return dbgclgetValp(Name,val,n,smap);}
inline int cldbggetIValp(const std::string& Name, int& val, int& n, SMap& smap) {return dbgclgetValp(Name,val,n,smap);}
inline int cldbggetFValp(const std::string& Name, float& val, int& n, SMap& smap) {return dbgclgetValp(Name,val,n,smap);}
inline int cldbggetBValp(const std::string& Name, bool& val, int& n, SMap& smap) {return dbgclgetValp(Name,val,n, smap);}
inline int cldbggetSValp(const std::string& Name, std::string& val, int& n, SMap& smap) {return dbgclgetValp(Name,val,n,smap);}

int cldbggetNIValp(const std::string& Key, std::vector<int>& val, int& m) {return dbgclgetValp(Key, val, m);}
int cldbggetNFValp(const std::string& Key, std::vector<float>& val, int& m) {return dbgclgetValp(Key, val, m);}
int cldbggetNBValp(const std::string& Key, std::vector<bool>& val, int& m) {return dbgclgetValp(Key, val, m);}
int cldbggetNSValp(const std::string& Key, std::vector<std::string>& val, int& m) {return dbgclgetValp(Key, val, m);}
inline int cldbggetNIValp(const std::string& Key, std::vector<int>& val, int& m) {return dbgclgetValp(Key, val, m);}
inline int cldbggetNFValp(const std::string& Key, std::vector<float>& val, int& m) {return dbgclgetValp(Key, val, m);}
inline int cldbggetNBValp(const std::string& Key, std::vector<bool>& val, int& m) {return dbgclgetValp(Key, val, m);}
inline int cldbggetNSValp(const std::string& Key, std::vector<std::string>& val, int& m) {return dbgclgetValp(Key, val, m);}

int cldbggetNIValp(const std::string& Key, std::vector<int>& val, int& m, SMap& smap) {return dbgclgetValp(Key, val, m,smap);}
int cldbggetNFValp(const std::string& Key, std::vector<float>& val, int& m, SMap& smap) {return dbgclgetValp(Key, val, m,smap);}
int cldbggetNBValp(const std::string& Key, std::vector<bool>& val, int& m, SMap& smap) {return dbgclgetValp(Key, val, m,smap);}
int cldbggetNSValp(const std::string& Key, std::vector<std::string>& val, int& m, SMap& smap){return dbgclgetValp(Key, val, m,smap);}
inline int cldbggetNIValp(const std::string& Key, std::vector<int>& val, int& m, SMap& smap) {return dbgclgetValp(Key, val, m,smap);}
inline int cldbggetNFValp(const std::string& Key, std::vector<float>& val, int& m, SMap& smap) {return dbgclgetValp(Key, val, m,smap);}
inline int cldbggetNBValp(const std::string& Key, std::vector<bool>& val, int& m, SMap& smap) {return dbgclgetValp(Key, val, m,smap);}
inline int cldbggetNSValp(const std::string& Key, std::vector<std::string>& val, int& m, SMap& smap){return dbgclgetValp(Key, val, m,smap);}
#endif
17 changes: 7 additions & 10 deletions code/clgetValp.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@
*
*/
//
// Generic baseclass type functions that are called in clget?Valp()
// functions.
//
// The code is separated into clgetBaseCode() and clgetGenericValp()
// functions since the code to return the value from the Symbol is
// differen, at least for T=string. clgetGenericValp() function has
// this code for T=int,float,bool and is therefore usable for
// realizing clget{I,F,B}Valp() functions. clgetSValp() calls
// clgetBaseCode() directly.
// API level include file to use clgetValp() style, or
// clget[N][IFBS]Val() style function.
//
#ifndef CLGETVALP_H
#define CLGETVALP_H
#include <cllib.h>
#include <clhashdefines.h>
#include <support.h>
#include <type_traits>
#include <clgetBaseCode.h>
//
//----------------------------------------------------------------------
// Templated code and wrapper functions
//
#include <clgetValp.cc>
#endif
5 changes: 0 additions & 5 deletions code/support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,6 @@ extern "C" {
if ((fd1=creat(err,0644))<0)
{
perror(out);
/*
if (clThrowUp("In STDERR redirection.","###Error",
CL_SEVERE)==CL_SEVERE)
exit(-1);
*/
clThrowUp("In STDERR redirection.","###Error",
CL_SEVERE);
}
Expand Down
Loading
Loading