264 lines
5.1 KiB
C
264 lines
5.1 KiB
C
|
|
#if (defined(DEBUG_BUILD) || defined(TEST_BUILD))
|
|
|
|
#include <inttypes.h>
|
|
#include <stdint.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <limits.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <stddef.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <assert.h>
|
|
#include <wchar.h>
|
|
#include <math.h>
|
|
#include <getopt.h>
|
|
#include <sys/param.h>
|
|
#include <time.h>
|
|
#include <sys/types.h>
|
|
#include <sys/wait.h>
|
|
|
|
#include <valgrind/memcheck.h>
|
|
|
|
struct cmdln_flags;
|
|
struct gc;
|
|
struct istream;
|
|
struct tokenizer;
|
|
struct value;
|
|
struct stringtree;
|
|
struct gc_flags;
|
|
struct linked_list;
|
|
struct link;
|
|
struct string;
|
|
struct istream_inheritance;
|
|
struct istream;
|
|
struct environment_value;
|
|
struct value_inheritance;
|
|
|
|
#include <defines/argv0.h>
|
|
/*#include <defines/RES.h>*/
|
|
|
|
/*#include <macros/N.h>*/
|
|
|
|
/*#include <memory/smalloc.h>*/
|
|
/*#include <memory/srealloc.h>*/
|
|
|
|
/*#include <string/struct.h>*/
|
|
/*#include <string/new.h>*/
|
|
/*#include <string/inc.h>*/
|
|
/*#include <string/free.h>*/
|
|
|
|
/*#include <string/new.h>*/
|
|
/*#include <string/write.h>*/
|
|
/*#include <string/free.h>*/
|
|
|
|
/*#include <structs/charset.h>*/
|
|
/*#include <structs/value.h>*/
|
|
|
|
/*#include <enums/syntax_type.h>*/
|
|
|
|
/*#include <misc/ptrcmp.h>*/
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG_BUILD
|
|
|
|
extern int debug_depth;
|
|
|
|
#define HERE \
|
|
printf("%*s" "HERE at %s:%i\n", debug_depth, "", __PRETTY_FUNCTION__, __LINE__);
|
|
|
|
#define ENTER \
|
|
printf("%*s" "%s\n", debug_depth++, "", __PRETTY_FUNCTION__);
|
|
|
|
#define EXIT \
|
|
assert(debug_depth), printf("%*s" "return; // from %s\n", debug_depth--, "", __FUNCTION__);
|
|
|
|
#define TODO \
|
|
{ \
|
|
printf("TODO hit at %s:%i!\n", __FILE__, __LINE__); \
|
|
\
|
|
pid_t child = fork(); \
|
|
\
|
|
if (child < 0) \
|
|
{\
|
|
perror("fork");\
|
|
}\
|
|
else if (child)\
|
|
{\
|
|
int wstatus = 0;\
|
|
\
|
|
if (waitpid(child, &wstatus, 0) < 0)\
|
|
perror("waitpid");\
|
|
else if (wstatus)\
|
|
fprintf(stderr, "child failed!");\
|
|
}\
|
|
else\
|
|
{\
|
|
char buffer[100]; \
|
|
snprintf(buffer, 100, "+%u", __LINE__); \
|
|
execlp("gedit", "gedit", __FILE__, buffer, NULL); \
|
|
}\
|
|
\
|
|
exit(1); \
|
|
}
|
|
|
|
#define CHECK \
|
|
{ \
|
|
printf("CHECK hit at %s:%i!\n", __FILE__, __LINE__); \
|
|
\
|
|
pid_t child = fork(); \
|
|
\
|
|
if (child < 0) \
|
|
{\
|
|
perror("fork");\
|
|
}\
|
|
else if (child)\
|
|
{\
|
|
int wstatus = 0;\
|
|
\
|
|
if (waitpid(child, &wstatus, 0) < 0)\
|
|
perror("waitpid");\
|
|
else if (wstatus)\
|
|
fprintf(stderr, "child failed!");\
|
|
}\
|
|
else\
|
|
{\
|
|
char buffer[100]; \
|
|
snprintf(buffer, 100, "+%u", __LINE__); \
|
|
execlp("gedit", "gedit", __FILE__, buffer, NULL); \
|
|
}\
|
|
\
|
|
exit(1); \
|
|
}
|
|
|
|
#define NOPE \
|
|
{ \
|
|
printf("NOPE hit at %s:%i!\n", __FILE__, __LINE__); \
|
|
\
|
|
pid_t child = fork(); \
|
|
\
|
|
if (child < 0) \
|
|
{\
|
|
perror("fork");\
|
|
}\
|
|
else if (child)\
|
|
{\
|
|
int wstatus = 0;\
|
|
\
|
|
if (waitpid(child, &wstatus, 0) < 0)\
|
|
perror("waitpid");\
|
|
else if (wstatus)\
|
|
fprintf(stderr, "child failed!");\
|
|
}\
|
|
else\
|
|
{\
|
|
char buffer[100]; \
|
|
snprintf(buffer, 100, "+%u", __LINE__); \
|
|
execlp("gedit", "gedit", __FILE__, buffer, NULL); \
|
|
}\
|
|
\
|
|
exit(1); \
|
|
}
|
|
|
|
extern void dpvs_implementation(
|
|
const char*,
|
|
char quote,
|
|
const unsigned char*,
|
|
size_t);
|
|
|
|
#define dpvs(str) \
|
|
dpvs_implementation(#str, '\"', (const unsigned char*) str, (size_t) -1);
|
|
|
|
#define dpvsn(str, len) \
|
|
dpvs_implementation(#str, '\"', (const unsigned char*) str, (size_t) (len));
|
|
|
|
#define dpvss(str) \
|
|
dpvs_implementation(#str, str->data, str->len);
|
|
|
|
#define dpvb(b) \
|
|
printf("%*s" "%s = %s\n", debug_depth, "", #b, (b) ? "true" : "false");
|
|
|
|
#define dputs(s) \
|
|
printf("%*s" "%s\n", debug_depth, "", s);
|
|
|
|
#define dpvc(c) \
|
|
dpvs_implementation(#c, '\'', (const unsigned char[1]) {c}, (size_t) 1);
|
|
|
|
#define dpvp(p) \
|
|
printf("%*s" "%s = %p\n", debug_depth, "", #p, p);
|
|
|
|
#define dpvf(f) \
|
|
printf("%*s" "%s = %f\n", debug_depth, "", #f, f);
|
|
|
|
#define dpvi(x) \
|
|
printf("%*s" "%s = %i\n", debug_depth, "", #x, (x));
|
|
|
|
#define dpvhhu(x) \
|
|
printf("%*s" "%s = %hhu\n", debug_depth, "", #x, (x));
|
|
|
|
#define dpvu(x) \
|
|
printf("%*s" "%s = %u\n", debug_depth, "", #x, (x));
|
|
|
|
#define dpvlu(x) \
|
|
printf("%*s" "%s = %lu\n", debug_depth, "", #x, (x));
|
|
|
|
#else
|
|
|
|
#define ENTER ;
|
|
|
|
#define EXIT ;
|
|
|
|
#define HERE ;
|
|
|
|
#define TODO assert(!"TODO");
|
|
|
|
#define CHECK assert(!"CHECK");
|
|
|
|
#define NOPE assert(!"NOPE");
|
|
|
|
#define dpvp(_) ;
|
|
|
|
#define dpvs(_) ;
|
|
|
|
#define dpvss(_) ;
|
|
|
|
#define dpvsn(str, len) ;
|
|
|
|
#define dpvb(_) ;
|
|
|
|
#define dputs(_) ;
|
|
|
|
#define dpvc(_) ;
|
|
|
|
#define dpvi(_) ;
|
|
|
|
#define dpvf(_) ;
|
|
|
|
#define dpvhhu(_) ;
|
|
|
|
#define dpvlu(_) ;
|
|
|
|
#define dpvu(_) ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|