Commit 571cc7bc authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added option operators_no_output.

parent d6b0101b
......@@ -1051,6 +1051,7 @@ int parse_options_long(int argc, char *argv[])
int lgridsearchradius;
int lremap_genweights;
int lpercentile;
int lprintoperatorsno = 0;
int lprintoperators = 0;
int lenableexcept;
int ltimestat_date;
......@@ -1071,6 +1072,7 @@ int parse_options_long(int argc, char *argv[])
{ "reduce_dim", no_argument, &CDO_Reduce_Dim, 1 },
{ "float", no_argument, &CDO_Memtype, MEMTYPE_FLOAT },
{ "rusage", no_argument, &CDO_Rusage, 1 },
{ "operators_no_output", no_argument, &lprintoperatorsno, 1 },
{ "operators", no_argument, &lprintoperators, 1 },
{ "no_warnings", no_argument, &_Verbose, 0 },
{ "color", no_argument, NULL, 'C' },
......@@ -1307,15 +1309,16 @@ int parse_options_long(int argc, char *argv[])
}
}
if ( lprintoperators )
if ( lprintoperators || lprintoperatorsno )
{
set_text_color(stderr, RESET, GREEN);
operatorPrintList();
bool print_no_output = lprintoperatorsno > 0;
operatorPrintList(print_no_output);
//operatorPrintAll();
reset_text_color(stderr);
return 1;
}
return 0;
}
......@@ -1350,7 +1353,6 @@ int main(int argc, char *argv[])
int lstop = FALSE;
int noff = 0;
int status = 0;
char *operatorName = NULL;
char *operatorArg = NULL;
argument_t *argument = NULL;
......@@ -1465,7 +1467,7 @@ int main(int argc, char *argv[])
if ( cdoDefaultTableID != CDI_UNDEFID ) cdiDefTableID(cdoDefaultTableID);
operatorName = getOperatorName(operatorArg);
const char *operatorName = getOperatorName(operatorArg);
if ( Help )
{
......
......@@ -914,7 +914,7 @@ int similar(const char *a, const char *b, int alen, int blen)
}
const char *operatorAlias(char *operatorName)
const char *operatorAlias(const char *operatorName)
{
int i;
......@@ -1015,31 +1015,31 @@ int operatorInqModID(const char *operatorName)
return modID;
}
void *(*operatorModule(char *operatorName))(void *)
void *(*operatorModule(const char *operatorName))(void *)
{
int modID = operatorInqModID(operatorName);
return Modules[modID].func;
}
const char **operatorHelp(char *operatorName)
const char **operatorHelp(const char *operatorName)
{
int modID = operatorInqModID(operatorName);
return Modules[modID].help;
}
int operatorStreamInCnt(char *operatorName)
int operatorStreamInCnt(const char *operatorName)
{
int modID = operatorInqModID(operatorAlias(operatorName));
return Modules[modID].streamInCnt;
}
int operatorStreamOutCnt(char *operatorName)
int operatorStreamOutCnt(const char *operatorName)
{
int modID = operatorInqModID(operatorAlias(operatorName));
return Modules[modID].streamOutCnt;
}
int operatorStreamNumber(char *operatorName)
int operatorStreamNumber(const char *operatorName)
{
int modID = operatorInqModID(operatorAlias(operatorName));
return Modules[modID].number;
......@@ -1091,7 +1091,7 @@ void operatorPrintAll(void)
}
void operatorPrintList(void)
void operatorPrintList(bool print_no_output)
{
int i, j, nbyte, nop = 0;
const char *opernames[4096];
......@@ -1108,10 +1108,7 @@ void operatorPrintList(void)
}
// Add operator aliases
for ( i = 0; i < nopalias; i++ )
{
opernames[nop++] = opalias[i][0];
}
for ( i = 0; i < nopalias; i++ ) opernames[nop++] = opalias[i][0];
qsort(opernames, nop, sizeof(char *), cmpname);
......@@ -1191,10 +1188,13 @@ void operatorPrintList(void)
}
}
nbyte = fprintf(pout, "%s ", opernames[i]);
for ( int i = nbyte; i <= 16; ++i ) fprintf(pout, " ");
if ( pdes ) fprintf(pout, "%s", pdes);
else if ( ialias >= 0 ) fprintf(pout, "--> %s", opalias[ialias][1]);
fprintf(pout, "\n");
if ( !print_no_output || operatorStreamOutCnt(opernames[i]) == 0 )
{
nbyte = fprintf(pout, "%s ", opernames[i]);
for ( int i = nbyte; i <= 16; ++i ) fprintf(pout, " ");
if ( pdes ) fprintf(pout, "%s", pdes);
else if ( ialias >= 0 ) fprintf(pout, "--> %s", opalias[ialias][1]);
fprintf(pout, "\n");
}
}
}
......@@ -18,15 +18,17 @@
#ifndef _MODULES_H
#define _MODULES_H
void *(*operatorModule(char *operatorName))(void *);
#include <stdbool.h>
const char **operatorHelp(char *operatorName);
void *(*operatorModule(const char *operatorName))(void *);
int operatorStreamInCnt(char *operatorName);
int operatorStreamOutCnt(char *operatorName);
int operatorStreamNumber(char *operatorName);
const char **operatorHelp(const char *operatorName);
int operatorStreamInCnt(const char *operatorName);
int operatorStreamOutCnt(const char *operatorName);
int operatorStreamNumber(const char *operatorName);
void operatorPrintAll(void);
void operatorPrintList(void);
void operatorPrintList(bool print_no_output);
#endif /* _MODULES_H */
......@@ -77,7 +77,7 @@ typedef struct {
short streamCnt;
argument_t *streamNames;
char *xoperator;
char *operatorName;
const char *operatorName;
char *operatorArg;
int oargc;
char *oargv[MAX_OARGC];
......@@ -304,7 +304,7 @@ const char *processInqOpername(void)
}
void processDefPrompt(char *opername)
void processDefPrompt(const char *opername)
{
int processID = processSelf();
......
......@@ -301,7 +301,7 @@ void pstreamOpenReadPipe(const argument_t *argument, pstream_t *pstreamptr)
memcpy(newargument->argv, argument->argv, argument->argc*sizeof(char *));
char *operatorArg = argument->argv[0];
char *operatorName = getOperatorName(operatorArg);
const char *operatorName = getOperatorName(operatorArg);
size_t len = strlen(argument->args);
char *newarg = (char*) Malloc(len+pnlen);
......
......@@ -213,9 +213,9 @@ char *getOperator(const char *argument)
return operatorArg;
}
char *operatorAlias(char *operatorName);
const char *operatorAlias(const char *operatorName);
char *getOperatorName(const char *operatorArg)
const char *getOperatorName(const char *operatorArg)
{
char *commapos;
char *operatorName = NULL;
......@@ -239,8 +239,7 @@ char *getOperatorName(const char *operatorArg)
}
/* return operatorName; */
char * alias = operatorAlias(operatorName);
return alias;
return operatorAlias(operatorName);
}
......
......@@ -121,7 +121,7 @@ void argument_fill(argument_t *argument, int argc, char *argv[]);
char *getProgname(char *string);
char *getOperator(const char *argument);
char *getOperatorName(const char *xoperator);
const char *getOperatorName(const char *xoperator);
const char *cdoComment(void);
argument_t makeArgument(int argc, char *argv[]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment