Loading...
Searching...
No Matches
reporter.h File Reference
`#include <stdio.h>`
`#include <string.h>`
`#include "misc/auxiliary.h"`
`#include "resources/feFopen.h"`

Go to the source code of this file.

## Macros

#define | TRACE_SHOW_PROC 1
#define | TRACE_SHOW_LINENO 2
#define | TRACE_SHOW_LINE 4
#define | TRACE_SHOW_RINGS 8
#define | TRACE_SHOW_LINE1 16
#define | TRACE_BREAKPOINT 32
#define | TRACE_TMP_BREAKPOINT 64
#define | TRACE_CALL 128
#define | TRACE_ASSIGN 256
#define | TRACE_CONV 512
#define | TRACE_PROFILING 1024
#define | SI_PROT_I 1
#define | SI_PROT_O 2
#define | SI_PROT_IO 3
#define | mflush()
#define | dReportBug(s)
#define | assume_violation(s, f, l)
#define | assume(x)
#define | r_assume(x)
#define | _assume(x, f, l)
#define | _r_assume(x, f, l)

## Functions

void | Werror (const char *fmt,...) __attribute__((format(printf
void void | WerrorS_batch (const char *s)
void | WarnS (const char *s)
void | Print (const char *fmt,...) __attribute__((format(printf
void void | PrintNSpaces (const int n)
void | PrintLn ()
void | PrintS (const char *s)
void | StringAppend (const char *fmt,...)
void | StringAppendS (const char *s)
void | StringSetS (const char *s)
char * | StringEndS ()
void | Warn (const char *fmt,...)
const char * | eati (const char *s, int *i)
void | feStringAppendResources (int warn=-1)
void | SPrintStart ()
char * | SPrintEnd ()
int | dReportError (const char *fmt,...)
void | dErrorBreak ()

## Variables

EXTERN_VAR char * | feErrors
EXTERN_VAR int | feErrorsLen
EXTERN_VAR FILE * | feProtFile
EXTERN_VAR int | pagelength
EXTERN_VAR int | colmax
EXTERN_VAR int | yy_blocklineno
EXTERN_VAR int | yy_noeof
const char | feNotImplemented []
EXTERN_VAR int | feProt
EXTERN_VAR BOOLEAN | feWarn
EXTERN_VAR BOOLEAN | feOut
EXTERN_VAR int | traceit
EXTERN_VAR int | traceit_stop
EXTERN_VAR void(* | WarnS_callback )(const char *s)

## Macro Definition Documentation

## _assume

#define _assume | ( |  | x,
|  |  | f,
|  |  | l )

Value:
do \
{ \
if (! (x)) \
{ \
assume_violation(#x, f, l); \
} \
} \
while (0)
l
int l
Definition cfEzgcd.cc:100
x
Variable x
Definition cfModGcd.cc:4090
f
FILE * f
Definition checklibs.c:9

Definition at line 135 of file reporter.h.

#define _assume(x, f, l) \
do \
{ \
if (! (x)) \
{ \
assume_violation(#x, f, l); \
} \
} \
while (0)

## _r_assume

#define _r_assume | ( |  | x,
|  |  | f,
|  |  | l )

Value:
do \
{ \
if (! (x)) \
{ \
assume_violation(#x, f, l); \
return 0; \
} \
} \
while (0)

Definition at line 145 of file reporter.h.

#define _r_assume(x, f, l) \
do \
{ \
if (! (x)) \
{ \
assume_violation(#x, f, l); \
return 0; \
} \
} \
while (0)

## assume

#define assume | ( |  | x | ) |

Value:
_assume(x, __FILE__, __LINE__)
_assume
#define _assume(x, f, l)
Definition mod2.h:392

Definition at line 132 of file reporter.h.

## assume_violation

#define assume_violation | ( |  | s,
|  |  | f,
|  |  | l )

Value:
dReportError("assume violation at %s:%d condition: %s", f,l,s)
s
const CanonicalForm int s
Definition facAbsFact.cc:51
dReportError
int dReportError(const char *fmt,...)
Definition dError.cc:44

Definition at line 129 of file reporter.h.

#define assume_violation(s,f,l) \
dReportError("assume violation at %s:%d condition: %s", f,l,s)

## dReportBug

#define dReportBug | ( |  | s | ) |

Value:
dReportError("Bug reported: %s\n occurred at %s,%d\n", s, __FILE__, __LINE__)

Definition at line 113 of file reporter.h.

#define dReportBug(s) \
dReportError("Bug reported: %s\n occurred at %s,%d\n", s, __FILE__, __LINE__)

## mflush

#define mflush | ( |  | ) |

Value:
fflush(stdout)

Definition at line 58 of file reporter.h.

## r_assume

#define r_assume | ( |  | x | ) |

Value:
_r_assume(x, __FILE__, __LINE__)
_r_assume
#define _r_assume(x, f, l)
Definition mod2.h:402

Definition at line 133 of file reporter.h.

## SI_PROT_I

#define SI_PROT_I 1

Definition at line 53 of file reporter.h.

## SI_PROT_IO

#define SI_PROT_IO 3

Definition at line 55 of file reporter.h.

## SI_PROT_O

#define SI_PROT_O 2

Definition at line 54 of file reporter.h.

## TRACE_ASSIGN

#define TRACE_ASSIGN 256

Definition at line 46 of file reporter.h.

## TRACE_BREAKPOINT

#define TRACE_BREAKPOINT 32

Definition at line 40 of file reporter.h.

## TRACE_CALL

#define TRACE_CALL 128

Definition at line 44 of file reporter.h.

## TRACE_CONV

#define TRACE_CONV 512

Definition at line 48 of file reporter.h.

## TRACE_PROFILING

#define TRACE_PROFILING 1024

Definition at line 50 of file reporter.h.

## TRACE_SHOW_LINE

#define TRACE_SHOW_LINE 4

Definition at line 33 of file reporter.h.

## TRACE_SHOW_LINE1

#define TRACE_SHOW_LINE1 16

Definition at line 38 of file reporter.h.

## TRACE_SHOW_LINENO

#define TRACE_SHOW_LINENO 2

Definition at line 31 of file reporter.h.

## TRACE_SHOW_PROC

#define TRACE_SHOW_PROC 1

Definition at line 29 of file reporter.h.

## TRACE_SHOW_RINGS

#define TRACE_SHOW_RINGS 8

Definition at line 36 of file reporter.h.

## TRACE_TMP_BREAKPOINT

#define TRACE_TMP_BREAKPOINT 64

Definition at line 42 of file reporter.h.

## Function Documentation

## dErrorBreak()

void dErrorBreak | ( |  | ) |

extern

Definition at line 140 of file dError.cc.

{}

## dReportError()

int dReportError | ( | const char * | fmt,
|  |  | ... )

extern

Definition at line 44 of file dError.cc.

{
#if 0
#ifdef HAVE_EXECINFO_H
#define SIZE 50
void *buffer[SIZE+1]; int ret;
#endif
#endif
va_list ap;
va_start(ap, fmt);
#ifndef MAKE_DISTRIBUTION
fprintf(stderr, "\n// ***dError: ");
vfprintf(stderr, fmt, ap);
#if !defined(OM_NDEBUG)
#ifdef omPrintCurrentBackTraceMax
fprintf(stderr, " occurred at: \n");
omPrintCurrentBackTraceMax(stderr, 8);
#endif
#endif
#if 0
#ifdef HAVE_EXECINFO_H
ret = backtrace( buffer, SIZE ); // execinfo.h
fprintf(stderr, "\nExecinfo backtrace (with %zd stack frames): \n", ret);
#ifndef HAVE_GCC_ABI_DEMANGLE
backtrace_symbols_fd(buffer, ret, STDERR_FILENO); // execinfo.h
#else
char **ptr = backtrace_symbols( buffer, ret ); // execinfo.h
int status;
char *demangledName;
char *s;
char *ss;
for (int i = 0; i < ret; i++)
{
status = -1;
s = ptr[i];
// fprintf (stderr, " #%02d: %s\n", i, s);
ss = index(s, '(');
ss[0] = 0;
fprintf (stderr, " #%02d: '%s': ", i, s);
ss[0] = '('; s = ss + 1;
ss = index(s, '+');
if ( ss != NULL )
{
ss[0] = 0;
demangledName = abi::__cxa_demangle( s, NULL, NULL, &status ); // cxxabi.h!
if( status == 0 && demangledName != NULL )
fprintf (stderr, " '%s'", (demangledName[0] != 0)? demangledName: s);
else
fprintf (stderr, " '%s'", s);
malloc_free( demangledName );
ss[0] = '+';
s = ss + 1;
}
ss = index(s, ')');
if( s != ss)
{
ss[0] = 0;
fprintf (stderr, " + %s", s);
ss[0] = ')';
}
fprintf (stderr, " %s\n", ss + 2);
}
malloc_free (ptr);
#endif
#endif
#undef SIZE
#endif
dErrorBreak();
#else
fprintf(stderr, "\n// !!! YOU HAVE FOUND A BUG IN SINGULAR.");
fprintf(stderr, "// !!! Please, email the input\n// and the following error message to singular@mathematik.uni-kl.de");
vfprintf(stderr, fmt, ap);
#endif
return 0;
}
i
int i
Definition cfEzgcd.cc:132
malloc_free
static void malloc_free(void *ptr)
Definition dError.cc:23
dErrorBreak
void dErrorBreak()
Definition dError.cc:140
ap
Definition ap.h:40
NULL
#define NULL
Definition omList.c:12
index
static int index(p_Length length, p_Ord ord)
Definition p_Procs_Impl.h:592
status
int * status
Definition si_signals.h:61
omPrintCurrentBackTraceMax
#define omPrintCurrentBackTraceMax(A, B)
Definition xalloc.h:265

## eati()

const char * eati | ( | const char * | s,
|  | int * | i )

Definition at line 377 of file reporter.cc.

{
int l=0;
if (*s >= '0' && *s <= '9')
{
*i = 0;
while (*s >= '0' && *s <= '9')
{
*i *= 10;
*i += *s++ - '0';
l++;
if ((l>=MAX_INT_LEN)||((*i) <0))
{
s-=l;
Werror("`%s` greater than %d(max. integer representation)",
s,MAX_INT_VAL);
return s;
}
}
}
else *i = 1;
return s;
}
MAX_INT_VAL
const int MAX_INT_VAL
Definition mylimits.h:12
MAX_INT_LEN
const int MAX_INT_LEN
Definition mylimits.h:13
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189

## feStringAppendResources()

void feStringAppendResources | ( | int | warn = -1 | ) |

Definition at line 402 of file reporter.cc.

{
int i = 0;
char* r;
StringAppend("%-10s:\t%s\n", "argv[0]", feArgv0);
while (feResourceConfigs[i].key != NULL)
{
r = feResource(feResourceConfigs[i].key, warn);
StringAppend("%-10s:\t%s\n", feResourceConfigs[i].key,
(r != NULL ? r : ""));
i++;
}
}
StringAppend
#define StringAppend
Definition emacs.cc:79
feArgv0
VAR char * feArgv0
Definition feResource.cc:19
feResourceConfigs
VAR feResourceConfig_s feResourceConfigs[]
Definition feResource.cc:41
feResource
static char * feResource(feResourceConfig config, int warn)
Definition feResource.cc:233

## Print()

void Print | ( | const char * | fmt,
|  |  | ... )

## PrintLn()

void PrintLn | ( |  | ) |

Definition at line 314 of file reporter.cc.

{
PrintS("\n");
}
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## PrintNSpaces()

void void PrintNSpaces | ( | const int | n | ) |

Definition at line 368 of file reporter.cc.

{
int l=n-1;
while(l>=0) { PrintS(" "); l--; }
}

## PrintS()

void PrintS | ( | const char * | s | ) |

Definition at line 288 of file reporter.cc.

{
if (sprint != NULL)
{
SPrintS(s);
return;
}
else if (feOut) /* do not print when option --no-out was given */
{
if (PrintS_callback!=NULL)
{
PrintS_callback(s);
}
else
{
fwrite(s,1,strlen(s),stdout);
fflush(stdout);
if (feProt&SI_PROT_O)
{
fwrite(s,1,strlen(s),feProtFile);
}
}
}
}
PrintS_callback
VAR void(* PrintS_callback)(const char *s)
Definition feFopen.cc:22
feProt
VAR int feProt
Definition reporter.cc:56
SPrintS
static void SPrintS(const char *s)
Definition reporter.cc:260
sprint
STATIC_VAR char * sprint
Definition reporter.cc:248
feProtFile
VAR FILE * feProtFile
Definition reporter.cc:57
feOut
VAR BOOLEAN feOut
Definition reporter.cc:50
SI_PROT_O
#define SI_PROT_O
Definition reporter.h:54

## SPrintEnd()

char * SPrintEnd | ( |  | ) |

Definition at line 277 of file reporter.cc.

{
char* ns = sprint;
sprint = sprint_backup;
sprint_backup=NULL;
omCheckAddr(ns);
return ns;
}
omCheckAddr
#define omCheckAddr(addr)
Definition omAllocDecl.h:328
sprint_backup
STATIC_VAR char * sprint_backup
Definition reporter.cc:249

## SPrintStart()

void SPrintStart | ( |  | ) |

Definition at line 250 of file reporter.cc.

{
if (sprint!=NULL)
{
if (sprint_backup!=NULL) WerrorS("internal error: SPrintStart");
else sprint_backup=sprint;
}
sprint = omStrDup("");
}
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263

## StringAppend()

void StringAppend | ( | const char * | fmt,
|  |  | ... )

Definition at line 61 of file reporter.cc.

{
va_list ap;
char *s = feBufferStart; /*feBuffer + strlen(feBuffer);*/
int vs;
long more;
va_start(ap, fmt);
if ((more=feBufferStart-feBuffer+strlen(fmt)+100)>feBufferLength)
{
more = ((more + (8*1024-1))/(8*1024))*(8*1024);
int l=s-feBuffer;
feBuffer=(char *)omReallocSize((void *)feBuffer,feBufferLength,
more);
#if (!defined(SING_NDEBUG)) && (!defined(OM_NDEBUG))
omMarkAsStaticAddr(feBuffer);
#endif
feBufferLength=more;
s=feBuffer+l;
#ifndef BSD_SPRINTF
feBufferStart=s;
#endif
}
//#ifdef BSD_SPRINTF
// vsprintf(s, fmt, ap);
// while (*s!='\0') s++;
// feBufferStart =s;
//#else
#ifdef HAVE_VSNPRINTF
vs = vsnprintf(s, feBufferLength - (feBufferStart - feBuffer), fmt, ap);
if (vs == -1)
{
assume(0);
feBufferStart = feBuffer + feBufferLength -1;
}
else
{
feBufferStart += vs;
}
#else
feBufferStart += vsprintf(s, fmt, ap);
#endif
//#endif
omCheckAddrSize(feBuffer, feBufferLength);
va_end(ap);
}
assume
#define assume(x)
Definition mod2.h:389
omReallocSize
#define omReallocSize(addr, o_size, size)
Definition omAllocDecl.h:220
omCheckAddrSize
#define omCheckAddrSize(addr, size)
Definition omAllocDecl.h:327
feBuffer
STATIC_VAR char * feBuffer
Definition reporter.cc:40
feBufferStart
STATIC_VAR char * feBufferStart
Definition reporter.cc:59
feBufferLength
STATIC_VAR long feBufferLength
Definition reporter.cc:39
omMarkAsStaticAddr
#define omMarkAsStaticAddr(A)
Definition xalloc.h:245

## StringAppendS()

void StringAppendS | ( | const char * | s | ) |

Definition at line 107 of file reporter.cc.

{
if (*st!='\0')
{
/* feBufferStart is feBuffer + strlen(feBuffer);*/
int l=strlen(st);
long more;
int ll=feBufferStart-feBuffer;
if ((more=ll+2+l)>feBufferLength)
{
more = ((more + (8*1024-1))/(8*1024))*(8*1024);
feBuffer=(char *)omreallocSize((void *)feBuffer,feBufferLength,
more);
feBufferLength=more;
feBufferStart=feBuffer+ll;
}
strncat(feBufferStart, st,l);
feBufferStart +=l;
}
}
omreallocSize
#define omreallocSize(addr, o_size, size)
Definition omAllocDecl.h:231

## StringEndS()

char * StringEndS | ( |  | ) |

Definition at line 151 of file reporter.cc.

{
char *r=feBuffer;
feBuffer_cnt--;
assume(feBuffer_cnt >=0);
feBuffer=feBuffer_save[feBuffer_cnt];
feBufferLength=feBufferLength_save[feBuffer_cnt];
feBufferStart=feBufferStart_save[feBuffer_cnt];
if (strlen(r)<1024)
{
// if the used buffer is a "small block",
// substitute the "large" initial block by a small one
char *s=omStrDup(r); omFree(r); r=s;
}
return r;
}
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
feBufferStart_save
STATIC_VAR char * feBufferStart_save[8]
Definition reporter.cc:44
feBuffer_save
STATIC_VAR char * feBuffer_save[8]
Definition reporter.cc:42
feBufferLength_save
STATIC_VAR long feBufferLength_save[8]
Definition reporter.cc:41
feBuffer_cnt
STATIC_VAR int feBuffer_cnt
Definition reporter.cc:43

## StringSetS()

void StringSetS | ( | const char * | s | ) |

Definition at line 128 of file reporter.cc.

{
feBuffer_save[feBuffer_cnt]=feBuffer;
feBuffer=(char*)omAlloc0(INITIAL_PRINT_BUFFER);
feBufferLength_save[feBuffer_cnt]=feBufferLength;
feBufferLength=INITIAL_PRINT_BUFFER;
feBufferStart_save[feBuffer_cnt]=feBufferStart;
feBufferStart=feBuffer;
feBuffer_cnt++;
assume(feBuffer_cnt<8);
int l=strlen(st);
long more;
if (l>feBufferLength)
{
more = ((l + (4*1024-1))/(4*1024))*(4*1024);
feBuffer=(char *)omReallocSize((ADDRESS)feBuffer,feBufferLength,
more);
feBufferLength=more;
}
strcpy(feBuffer,st);
feBufferStart=feBuffer+l;
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
INITIAL_PRINT_BUFFER
#define INITIAL_PRINT_BUFFER
Definition reporter.cc:34

## Warn()

void Warn | ( | const char * | fmt,
|  |  | ... )

Definition at line 231 of file reporter.cc.

{
va_list ap;
va_start(ap, fmt);
char *s=(char *)omAlloc(256);
#ifdef HAVE_VSNPRINTF
vsnprintf(s, 256, fmt, ap);
#else
vsprintf(s, fmt, ap);
#endif
WarnS(s);
omFreeSize(s,256);
va_end(ap);
}
WarnS
#define WarnS
Definition emacs.cc:78
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210

## WarnS()

void WarnS | ( | const char * | s | ) |

Definition at line 206 of file reporter.cc.

{
#define warn_str "// ** "
if (feWarn) /* ignore warnings if option --no-warn was given */
{
if (WarnS_callback==NULL)
{
fwrite(warn_str,1,6,stdout);
fwrite(s,1,strlen(s),stdout);
fwrite("\n",1,1,stdout);
fflush(stdout);
if (feProt&SI_PROT_O)
{
fwrite(warn_str,1,6,feProtFile);
fwrite(s,1,strlen(s),feProtFile);
fwrite("\n",1,1,feProtFile);
}
}
else
{
WarnS_callback(s);
}
}
}
WarnS_callback
VAR void(* WarnS_callback)(const char *s)
Definition reporter.cc:204
feWarn
VAR BOOLEAN feWarn
Definition reporter.cc:49
warn_str
#define warn_str

## Werror()

void Werror | ( | const char * | fmt,
|  |  | ... )

## WerrorS_batch()

void void WerrorS_batch | ( | const char * | s | ) |

Definition at line 168 of file reporter.cc.

{
if (feErrors==NULL)
{
feErrors=(char *)omAlloc(256);
feErrorsLen=256;
*feErrors = '\0';
}
else
{
if (((int)(strlen((char *)s)+ 20 +strlen(feErrors)))>=feErrorsLen)
{
feErrors=(char *)omReallocSize(feErrors,feErrorsLen,feErrorsLen+256);
feErrorsLen+=256;
}
}
strcat(feErrors, "Singular error: ");
strcat(feErrors, (char *)s);
errorreported = TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
errorreported
VAR short errorreported
Definition feFopen.cc:23
feErrorsLen
VAR int feErrorsLen
Definition reporter.cc:48
feErrors
VAR char * feErrors
Definition reporter.cc:47

## Variable Documentation

## colmax

EXTERN_VAR int colmax

Definition at line 17 of file reporter.h.

## feErrors

EXTERN_VAR char* feErrors

Definition at line 14 of file reporter.h.

## feErrorsLen

EXTERN_VAR int feErrorsLen

Definition at line 15 of file reporter.h.

## feNotImplemented

const char feNotImplemented[]

extern

Definition at line 54 of file reporter.cc.

## feOut

EXTERN_VAR BOOLEAN feOut

Definition at line 23 of file reporter.h.

## feProt

EXTERN_VAR int feProt

Definition at line 21 of file reporter.h.

## feProtFile

EXTERN_VAR FILE* feProtFile

Definition at line 16 of file reporter.h.

## feWarn

EXTERN_VAR BOOLEAN feWarn

Definition at line 22 of file reporter.h.

## pagelength

EXTERN_VAR int pagelength

Definition at line 17 of file reporter.h.

## traceit

EXTERN_VAR int traceit

Definition at line 24 of file reporter.h.

## traceit_stop

EXTERN_VAR int traceit_stop

Definition at line 25 of file reporter.h.

## WarnS_callback

EXTERN_VAR void(* WarnS_callback) (const char *s) | ( | const char * | s | ) |

Definition at line 26 of file reporter.h.

## yy_blocklineno

EXTERN_VAR int yy_blocklineno

Definition at line 18 of file reporter.h.

## yy_noeof

EXTERN_VAR int yy_noeof

Definition at line 19 of file reporter.h.