[eggheads-patches] PATCH: assert2.patch

Peter 'Rattacresh' Backes rtc at rhrk.uni-kl.de
Wed Oct 6 16:06:43 CST 1999


You might have noticed that addbtab.patch+assert.patch didn't work. 
use this one, it now allows expressions with operators.


-- Peter 'Rattacresh' Backes, rtc at rhrk.uni-kl.de

-------------- next part --------------
diff -urN eggdrop1.3.29/doc/UPDATES1.3 eggdrop1.3.29+assert2/doc/UPDATES1.3
--- eggdrop1.3.29/doc/UPDATES1.3	Wed Oct  6 22:39:30 1999
+++ eggdrop1.3.29+assert2/doc/UPDATES1.3	Wed Oct  6 22:41:44 1999
@@ -4,6 +4,8 @@
 
 1.3.29
 Foundby   Fixedby   What....
+          rtc       added assert debugging feature
+          rtc       contextnote had wrong function index in modules.h
 Ben       Fabian    eggdrop.conf.dist now talks positively about allow-resync
           rtc       fixed .console to not allow channels starting with '*'.
 SuperS	  Fabian    if run with '-n', eggdrop now only prints every line once
diff -urN eggdrop1.3.29/src/eggdrop.h eggdrop1.3.29+assert2/src/eggdrop.h
--- eggdrop1.3.29/src/eggdrop.h	Wed Oct  6 22:39:30 1999
+++ eggdrop1.3.29+assert2/src/eggdrop.h	Wed Oct  6 22:40:51 1999
@@ -130,6 +130,8 @@
                               cx_line[cx_ptr]=__LINE__; \
                               strncpy(cx_note[cx_ptr],string,255); \
                               cx_note[cx_ptr][255] = 0; }
+#define ASSERT(expr) { if (!(expr)) assert_failed (NULL, __FILE__, __LINE__); }
+
 /* move these here, makes more sense to me :) */
 extern int cx_line[16];
 extern char cx_file[16][30];
diff -urN eggdrop1.3.29/src/main.c eggdrop1.3.29+assert2/src/main.c
--- eggdrop1.3.29/src/main.c	Wed Oct  6 22:39:30 1999
+++ eggdrop1.3.29+assert2/src/main.c	Wed Oct  6 22:39:41 1999
@@ -242,6 +242,18 @@
   }
 }
 
+void assert_failed (const char *module, const char *file, const int line)
+{
+  write_debug();
+  if (!module) {
+    putlog (LOG_MISC, "*", "* In file %s, line %u", file, line);
+  } else {
+    putlog (LOG_MISC, "*", "* In file %s:%s, line %u", module, file, line);
+  }
+  fatal ("ASSERT FAILED -- CRASHING!", 1);
+  exit (1);
+}
+
 static void got_bus(int z)
 {
   write_debug();
diff -urN eggdrop1.3.29/src/mod/module.h eggdrop1.3.29+assert2/src/mod/module.h
--- eggdrop1.3.29/src/mod/module.h	Wed Oct  6 22:39:30 1999
+++ eggdrop1.3.29+assert2/src/mod/module.h	Wed Oct  6 22:41:08 1999
@@ -24,6 +24,7 @@
 #undef context
 #undef contextnote
 #undef feof
+#undef ASSERT
 
 /* redefine for module-relevance */
 /* 0 - 3 */
@@ -318,9 +319,12 @@
 #define user_realloc(x,y) ((void *(*)(void *,int,char *,int))global[229])((x),(y),__FILE__,__LINE__)
 #define nrealloc(x,y) ((void *)(global[230]((x),(y),MODULE_NAME,__FILE__,__LINE__)))
 #define xtra_set ((int(*)(struct userrec *,struct user_entry *, void *))global[231])
-
+/* 232 - 235 */
 /* time to let modules use contextnote <cybah> */
-#define contextnote(note) (global[230](MODULE_NAME, __FILE__, __LINE__, note))
+#define contextnote(note) (global[232](MODULE_NAME, __FILE__, __LINE__, note))
+#define assert_failed (global[233])
+
+#define ASSERT(expr) { if (!(expr)) assert_failed (MODULE_NAME, __FILE__, __LINE__); }
 
 /* this is for blowfish module, couldnt be bothereed making a whole new .h
  * file for it ;) */
diff -urN eggdrop1.3.29/src/modules.c eggdrop1.3.29+assert2/src/modules.c
--- eggdrop1.3.29/src/modules.c	Wed Oct  6 22:39:30 1999
+++ eggdrop1.3.29+assert2/src/modules.c	Wed Oct  6 22:39:41 1999
@@ -461,6 +461,7 @@
   (Function) xtra_set,
   /* 232 - 235 */
   (Function) mod_contextnote,
+  (Function) assert_failed,
 };
 
 void init_modules(void)
diff -urN eggdrop1.3.29/src/proto.h eggdrop1.3.29+assert2/src/proto.h
--- eggdrop1.3.29/src/proto.h	Wed Oct  6 22:39:30 1999
+++ eggdrop1.3.29+assert2/src/proto.h	Wed Oct  6 22:39:41 1999
@@ -145,6 +145,7 @@
 void fatal(char *, int);
 int expected_memory();
 void backup_userfile();
+void assert_failed(const char *, const char *, const int);
 
 /* match.c */
 int _wild_match(register unsigned char *, register unsigned char *);


More information about the Patches mailing list