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
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ CMake-based build system requires `cmake` version 3 or later. Use the following
mkdir build
cd build
cmake <PATH TO CMakeLists.txt>
gmake
make
```
The `-DGNUREADLINE=OFF` option to `cmake` will disable the use of the [GNU Readline library](https://en.wikipedia.org/wiki/GNU_Readline) for bash-style commandline editing and command history capabilities. The `-DENABLE_TESTING=ON` option also builds the application for unit testing, which can be executed by the following commands

```
make test

or

ctest
```
The `-DGNUREADLINE=OFF` option to `cmake` will disable the use of the [GNU Readline library](https://en.wikipedia.org/wiki/GNU_Readline) for bash-style commandline editing and command history capabilities. The `-DENABLE_TESTING=ON` option will enable unit testing.


While the hand-written `makefiles` have been tested with `make` version 3 only, they do not depend on a specific version of `make`. These `makefiles` are in the `code/nocmake_makefiles` directory. Using the command `cd code; make -f nocmake_makefiles/makefile` should build the _parafeed_ project.
Expand Down
5 changes: 3 additions & 2 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ target_include_directories(parafeed PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# install target
set(header_list
parafeed.h
clbool.h
clconvert.h
clError.h
Expand Down Expand Up @@ -176,11 +177,11 @@ set(shccl_sources
ParseCmdLine.cc
clparseVal.cc
InstallSymb.cc
# clgetSVal.cc
clgetSVal.cc
# clgetNSVal.cc
clgetFullVal.cc

# clgetValp.cc
clgetValp.cc
clStartInteractive.cc
clRestartShell.cc
clfInteractive.cc
Expand Down
6 changes: 4 additions & 2 deletions code/ErrorObj.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ErrorObj: public std::exception{
// Id.resize(0);Msg.resize(0);Src.resize(0);Message.resize(0);};

ErrorObj(const char *m, const char *i, int l=0):
Id(i), Msg(m), Src(), Message(),Level(l)
Id(i), Msg(m), Src(), Message(),Level(l)
{};

ErrorObj(const string &m, const string &i, int l):
Expand All @@ -43,10 +43,12 @@ class ErrorObj: public std::exception{
ErrorObj(const ErrorObj& that);
~ErrorObj()
{};

void SetSource(const char *m=0);
void SetMsg(const string& m) {Msg=m;}
const char *Source() {return Src.c_str();}
int Severity() {return Level;}
string GetMsg() {return Msg;};
const char *what();

ostream &operator<<(const std::string& m) {return cerr << m;}
Expand Down
4 changes: 2 additions & 2 deletions code/ParseCmdLine.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2012, 2013 S. Bhatnagar (bhatnagar dot sanjay at gmail dot com)
* Copyright (c) 2026 S. Bhatnagar (bhatnagar dot sanjay at gmail dot com)
*
* 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
Expand Down Expand Up @@ -383,7 +383,7 @@ int startShell()
{
if (!cl_defaultsLoaded) /* Load the defaults */
{
loadDefaults(1); cl_defaultsLoaded=1;
loadDefaults(0); cl_defaultsLoaded=1;
}
if (doInp && !cl_NoPrompt)
{
Expand Down
15 changes: 10 additions & 5 deletions code/SetVar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int UnsetVar(Symbol *S, int setFactoryDefaults)
if(pos==0) return -2;
// if (pos->Exposed!=1)
// {
// string msg="Attempted modification of a hidden variable (named \'" + string(pos->Name) + "\').";
// string msg="Attempted modification of a hidden variable (named \'" + string(pos->Name) + "\').";
// //clThrowUp(msg.c_str(),"###Error",CL_INFORMATIONAL);
// clError x(msg.c_str(),"###Error",CL_INFORMATIONAL);
// throw(x);
Expand All @@ -97,12 +97,12 @@ int UnsetVar(Symbol *S, int setFactoryDefaults)
if (!Force)
if (pos->Class == CL_USERCLASS)
{
string msg="Attempted modification of a shell-constant (named \'" + string(pos->Name) + "\'). Ignored.";
string msg="Attempted modification of a shell-constant (named \'" + string(pos->Name) + "\'). Ignored.";
clThrowUp(msg.c_str(),"###Error",CL_INFORMATIONAL);
return -2;
}

if ((val==NULL) || (strlen(val) == 0))
if ((val==NULL) || (strlen(val) == 0))
{
ret= UnsetVar(pos,1);
}
Expand Down Expand Up @@ -176,7 +176,7 @@ std::function<void(const Symbol&)> noMatchExceptionLambda_ptr=noMatchException;
newval=v;
// if (S->Exposed!=1)
// {
// string msg="Attempted modification of a hidden variable (named \'" + string(S->Name) + "\').";
// string msg="Attempted modification of a hidden variable (named \'" + string(S->Name) + "\').";
// //clThrowUp(msg.c_str(),"###Error",CL_INFORMATIONAL);
// clError x(msg.c_str(),"###Error",CL_INFORMATIONAL);
// throw(x);
Expand Down Expand Up @@ -242,7 +242,12 @@ void SetVal(const char *v, Symbol *S, int i)
{
// Same as cerr << x.what(), except that the output
// stream is centrally specified in clError.
x << x << " at position " << i << endl;
std::stringstream msg;

msg << x.GetMsg();
if (i > 0) msg << " at position " << i;
//x << msg.str().c_str() << endl;
x.SetMsg(msg.str());
throw(x);
}

Expand Down
93 changes: 56 additions & 37 deletions code/callbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ int dosavefd(FILE *fd, const std::vector<std::string>& opts)

ifs.open(defFile.c_str());

std::stringstream errorMessages;
if (!ifs.good())
{
clThrowUp(std::string("Error in opening file \"")+defFile+std::string("\""), "###Error", CL_FATAL);
Expand All @@ -495,54 +496,72 @@ int dosavefd(FILE *fd, const std::vector<std::string>& opts)
else
{
Symbol *pos;

uint lineNo=0;
while(!ifs.eof())
{
string line;
if (getline(ifs,line))
try
{
stripwhitep(line);
if ((line.size() > 0) && (line[0] != '#'))
if (getline(ifs,line))
{
// Separate the line into name and value strings
// separated by the first '=' char. Strip the
// white spaces.
std::string Name_str, Val_str;
BreakStrp(line,Name_str,Val_str);
stripwhitep(Name_str);
stripwhitep(Val_str);

// Seperate the Name string into scope and Name
// string seperated by ':'
std::string Scope_str;
BreakStrp(Name_str, Scope_str, Name_str,"::");
stripwhitep(Name_str);
stripwhitep(Scope_str);
if (Name_str == Scope_str) Scope_str="";

pos = NULL;
if ((Scope_str == "") || (Scope_str == ProgName()))
lineNo++;
stripwhitep(line);
if ((line.size() > 0) && (line[0] != '#'))
{
if (Complement)
{
pos=SearchVSymbFullMatch(Name_str.c_str(),
cl_SymbTab);
if ((pos == (Symbol *)NULL))
pos=AddVar(Name_str.c_str(),&cl_SymbTab,
&cl_TabTail);
if ((pos->NVals == 0))
pos = (Symbol *)NULL;
}
if (pos==NULL)
// Separate the line into name and value strings
// separated by the first '=' char. Strip the
// white spaces.
std::string Name_str, Val_str;
BreakStrp(line,Name_str,Val_str);
stripwhitep(Name_str);
stripwhitep(Val_str);

// Seperate the Name string into scope and Name
// string seperated by ':'
std::string Scope_str;
BreakStrp(Name_str, Scope_str, Name_str,"::");
stripwhitep(Name_str);
stripwhitep(Scope_str);
if (Name_str == Scope_str) Scope_str="";

pos = NULL;
if ((Scope_str == "") || (Scope_str == ProgName()))
{
if (doregister)
pos=AddVar(Name_str.c_str(),&cl_SymbTab,&cl_TabTail);
SetVar((char*)Name_str.c_str(),(char *)Val_str.c_str(),
cl_SymbTab,0,1,cl_do_doinp);
if (Complement)
{
pos=SearchVSymbFullMatch(Name_str.c_str(),
cl_SymbTab);
if ((pos == (Symbol *)NULL))
pos=AddVar(Name_str.c_str(),&cl_SymbTab,
&cl_TabTail);
if ((pos->NVals == 0))
pos = (Symbol *)NULL;
}
if (pos==NULL)
{
if (doregister)
pos=AddVar(Name_str.c_str(),&cl_SymbTab,&cl_TabTail);
SetVar((char*)Name_str.c_str(),(char *)Val_str.c_str(),
cl_SymbTab,0,1,cl_do_doinp);
}
}
}
}
}
catch(clError& x)
{
errorMessages
<< "In " << defFile << ":" << lineNo << endl
<< x
<< endl << "-----------------------" << endl;
}
}
if (!errorMessages.str().empty())
{
clExit x("","###Error",CL_INFORMATIONAL);
x.SetMsg(errorMessages.str());
x << x << endl;
throw(x);
}
// Set all symbols loaded in the table to USERCLASS. The ones
// that get queried (via clget*Val() functions) are converted
Expand Down
16 changes: 9 additions & 7 deletions code/cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{ \
throw; \
}


#else
#define HANDLE_EXCEPTIONS(str) str
Expand All @@ -73,9 +73,9 @@ extern "C" {
#define CL_SEVERE -20
#define CL_FATAL -10
#define CL_WARNING -5
/*
/*
Define readline stuff as readline.h is
NOT ANSI C
NOT ANSI C
*/
#ifdef __cplusplus
/*
Expand Down Expand Up @@ -127,7 +127,7 @@ extern int add_history(char *);
Symbol *IntallSymb(char *, char *, Symbol *);
Symbol *SearchQSymb(const std::string& Name, const std::string& Type);
Symbol *SearchVSymb(const char *Name, Symbol *Tab);
Symbol *AddQKey(const char *Name, const char *Type,
Symbol *AddQKey(const char *Name, const char *Type,
Symbol **Head, Symbol **Tail);
int ParseCmdLine(int, char **);
std::vector<std::string> clMakeArgvFromFile(const std::string& Name);
Expand All @@ -151,8 +151,6 @@ int clgetIVal(char *Name, int *Val, int *N);
int dbgclgetIVal(char *Name, int *Val, int *N);
int clgetFVal(char *Name, float *Val, int *N);
int dbgclgetFVal(char *Name, float *Val, int *N);
int clgetSVal(const char *Name, char *Val, int *N);
int dbgclgetSVal(const char *Name, char *Val, int *N);
int clgetNIVal(char *Key, int *Val, int *m);
int dbgclgetNIVal(char *Key, int *Val, int *m);
int clgetNFVal(char *Name, float *Val, int *N);
Expand All @@ -164,6 +162,9 @@ int dbgclgetBVal(char *Name, bool *Val, int *N);
int clgetNBVal(char *Name, bool *Val, int *N);
int dbgclgetNBVal(char *Name, bool *Val, int *N);

int clgetSVal(const char *Name, char *Val, int *N,SMap smap=SMap(),bool dbg=false);
inline int dbgclgetSVal(const char *Name, char *Val, int *N, SMap smap=SMap()) {return clgetSVal(Name,Val,N,smap,true);};

#ifdef __cplusplus
int clTgetOptp(const std::string& Name, std::string& Type);
int clgetOptp(const std::string& Name);
Expand Down Expand Up @@ -196,7 +197,7 @@ std::string stripwhitep (std::string& str);
int redirect(char *, char *);
void yyerror(char *);
int clgetConfigFile(char *, char *);
int AddCmd(const char *Name, char *Doc, int (*func)(char *),
int AddCmd(const char *Name, char *Doc, int (*func)(char *),
CmdSymbol **Head, CmdSymbol **Tail);
int BreakStr(char *, char **, char **);
int BreakStrp(const std::string& str, std::string& Name, std::string& Val,
Expand Down Expand Up @@ -277,6 +278,7 @@ int clgetBaseCore(const std::string& Name, int& Val, int& N, SMap &smap);
int clgetFullValp(const std::string& Name, std::string& Val);
int dbgclgetFullValp(const std::string& Name, std::string& Val);
int clgetFullp(const std::string& Arg, int &N);
int clgetSValp(const std::string& Name, std::string& Val, int& N, SMap &smap,bool dbg);
//
//------------------------------------------------------------------------------------------------
// Wrappers for clgetValp(...,T& val,...) and clgetValp(...,vector<T>&,...)
Expand Down
10 changes: 4 additions & 6 deletions code/clgetBaseCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Symbol* clgetBaseCode(const string& Name, T& val, int& n, SMap &smap=SMap(), boo
else
S=SearchQSymb((char *)Name.c_str(),type_str);

if (S!=NULL)
if (S!=NULL)
{
// Use templated function that works for all values of T
setAutoDefaults(S,val);
Expand All @@ -74,7 +74,7 @@ Symbol* clgetBaseCode(const string& Name, T& val, int& n, SMap &smap=SMap(), boo
};

//
// Templated functions for NVal calls.
// Templated functions for NVal calls.
//
template <class T>
Symbol *clgetNValBaseCode(const string& Name, vector<T>& val, int& m, const SMap &smap=SMap(), bool dbg=false)
Expand All @@ -91,7 +91,7 @@ Symbol *clgetNValBaseCode(const string& Name, vector<T>& val, int& m, const SMap
HANDLE_EXCEPTIONS(
S = SearchQSymb((char *)Name.c_str(), os.str());

if (S!=NULL)
if (S!=NULL)
{
// Use templated function that works for all values of T
setAutoDefaults(S,val);
Expand All @@ -109,8 +109,6 @@ Symbol *clgetNValBaseCode(const string& Name, vector<T>& val, int& m, const SMap
}
//
//----------------------------------------------------------------------
// This has the API-level templated functions that use the BaseCode
// functions above.
//#include <clgetValp.h>
//

#endif
7 changes: 2 additions & 5 deletions code/clgetFullVal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
*
*/
/* $Id: clgetFullVal.c,v 2.0 1998/11/11 07:13:01 sanjay Exp $ */
#include <cllib.h>
#include <support.h>
#include <setAutoDefaults.h>
#include <clparseVal.h>
#include <clgetValp.h>
#include <cl.h>
#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -94,7 +91,7 @@ Symbol* clgetFullValpBase(const string& Name, string& val, bool dbg)
// Do not modify val if S->Val is empty. The
// in-comming val may have a default value
// that is not yet tranferred to S-Val.
if (S->NVals > 0)
if (S->NVals > 0)
val = vecStr2Str(S->Val);
}
);
Expand Down
Loading
Loading