comparison src/tests.c @ 5156:6bff4f219697

fix crash etc. in tests.c/c-tests.el -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-18 Ben Wing <ben@xemacs.org> * tests.c: * tests.c (Ftest_data_format_conversion): Need to GCPRO newly created objects or we'll eventually get a crash due to occurrence of call2(). tests/ChangeLog addition: 2010-03-18 Ben Wing <ben@xemacs.org> * automated/c-tests.el: * automated/c-tests.el (when): Use `with-temp-buffer' so results don't get written into source file.
author Ben Wing <ben@xemacs.org>
date Thu, 18 Mar 2010 10:19:08 -0500
parents e70a73f9243d
children 71ee43b8a74d
comparison
equal deleted inserted replaced
5155:c97dc3b6de63 5156:6bff4f219697
47 REASON is nil or a string describing the failure (not required). 47 REASON is nil or a string describing the failure (not required).
48 */ 48 */
49 ()) 49 ())
50 { 50 {
51 void *ptr; Bytecount len; 51 void *ptr; Bytecount len;
52 Lisp_Object string, opaque, conversion_result = Qnil; 52 Lisp_Object string = Qnil, opaque = Qnil, conversion_result = Qnil;
53 53
54 Ibyte int_foo[] = "\n\nfoo\nbar"; 54 Ibyte int_foo[] = "\n\nfoo\nbar";
55 Extbyte ext_unix[]= "\n\nfoo\nbar"; 55 Extbyte ext_unix[]= "\n\nfoo\nbar";
56 56
57 Extbyte ext_dos[] = "\r\n\r\nfoo\r\nbar"; 57 Extbyte ext_dos[] = "\r\n\r\nfoo\r\nbar";
70 Lisp_Object opaque_latin = make_opaque (ext_latin, sizeof (ext_latin) - 1); 70 Lisp_Object opaque_latin = make_opaque (ext_latin, sizeof (ext_latin) - 1);
71 Lisp_Object opaque0_latin = make_opaque (ext_latin, sizeof (ext_latin)); 71 Lisp_Object opaque0_latin = make_opaque (ext_latin, sizeof (ext_latin));
72 Lisp_Object string_latin1 = make_string (int_latin1, sizeof (int_latin1) - 1); 72 Lisp_Object string_latin1 = make_string (int_latin1, sizeof (int_latin1) - 1);
73 int autodetect_eol_p = 73 int autodetect_eol_p =
74 !NILP (Fsymbol_value (intern ("eol-detection-enabled-p"))); 74 !NILP (Fsymbol_value (intern ("eol-detection-enabled-p")));
75 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
76 struct gcpro ngcpro1, ngcpro2, ngcpro3;
77 #ifdef MULE
78 struct gcpro ngcpro4;
79 #endif
80
81 /* DFC conversion inhibits GC, but we have a call2() below which calls
82 Lisp, which can trigger GC, so we need to GC-protect everything here. */
83 GCPRO5 (string, opaque, conversion_result, opaque_dos, string_foo);
84 #ifdef MULE
85 NGCPRO4 (string_latin2, opaque_latin, opaque0_latin, string_latin1);
86 #else
87 NGCPRO3 (opaque_latin, opaque0_latin, string_latin1);
88 #endif
75 89
76 /* Check for expected strings before and after conversion. 90 /* Check for expected strings before and after conversion.
77 Conversions depend on whether MULE is defined. */ 91 Conversions depend on whether MULE is defined. */
78 92
79 /* #### Any code below that uses iso-latin-2-with-esc is ill-conceived. */ 93 /* #### Any code below that uses iso-latin-2-with-esc is ill-conceived. */
539 TO_EXTERNAL_FORMAT (LISP_OPAQUE, opaque_dos, 553 TO_EXTERNAL_FORMAT (LISP_OPAQUE, opaque_dos,
540 ALLOCA, (ptr, len), 554 ALLOCA, (ptr, len),
541 Qbinary); 555 Qbinary);
542 DFC_CHECK_DATA (ptr, len, ext_dos, "DOS Lisp opaque, ALLOCA, binary"); 556 DFC_CHECK_DATA (ptr, len, ext_dos, "DOS Lisp opaque, ALLOCA, binary");
543 557
558 NUNGCPRO;
559 UNGCPRO;
544 return conversion_result; 560 return conversion_result;
545 } 561 }
546 562
547 563
548 /* Hash Table testing */ 564 /* Hash Table testing */