RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: [EMAIL PROTECTED] Module: syck Date: 17-Oct-2008 22:03:40 Branch: HEAD Handle: 2008101720033801 Modified files: syck Makefile.am syck/ext/php make_module.sh syck/ext/python setup.py syck/lib Makefile.am bytecode.c emitter.c implicit.c token.c token.re syck/tests CuTest.c CuTest.h Log: - jbj: incorporate changes from what linux is calling syck-0.61-2.fc7.src.rpm. Summary: Revision Changes Path 1.3 +1 -1 syck/Makefile.am 1.2 +2 -1 syck/ext/php/make_module.sh 1.2 +1 -1 syck/ext/python/setup.py 1.2 +7 -2 syck/lib/Makefile.am 1.2 +117 -122 syck/lib/bytecode.c 1.2 +103 -56 syck/lib/emitter.c 1.2 +79 -79 syck/lib/implicit.c 1.2 +517 -497 syck/lib/token.c 1.2 +52 -33 syck/lib/token.re 1.2 +294 -294 syck/tests/CuTest.c 1.2 +84 -84 syck/tests/CuTest.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: syck/Makefile.am ============================================================================ $ cvs diff -u -r1.2 -r1.3 Makefile.am --- syck/Makefile.am 17 Oct 2008 19:37:35 -0000 1.2 +++ syck/Makefile.am 17 Oct 2008 20:03:38 -0000 1.3 @@ -1,5 +1,5 @@ # # I feel like saying, "The magic happens here!" But it doesn't. # -SUBDIRS = lib # tests +SUBDIRS = lib tests @@ . patch -p0 <<'@@ .' Index: syck/ext/php/make_module.sh ============================================================================ $ cvs diff -u -r1.1.1.1 -r1.2 make_module.sh --- syck/ext/php/make_module.sh 17 Oct 2008 18:53:27 -0000 1.1.1.1 +++ syck/ext/php/make_module.sh 17 Oct 2008 20:03:38 -0000 1.2 @@ -1,5 +1,6 @@ #!/bin/sh phpize -./configure --with-syck +CFLAGS='-L../../lib/.libs -I../../lib' ./configure --with-syck=../../lib/.libs +#./configure --with-syck make make install @@ . patch -p0 <<'@@ .' Index: syck/ext/python/setup.py ============================================================================ $ cvs diff -u -r1.1.1.1 -r1.2 setup.py --- syck/ext/python/setup.py 17 Oct 2008 18:53:34 -0000 1.1.1.1 +++ syck/ext/python/setup.py 17 Oct 2008 20:03:39 -0000 1.2 @@ -3,7 +3,7 @@ syck = Extension('syck', include_dirs = ['/usr/local/include','../../lib'], libraries = ['syck'], - library_dirs = ['/usr/local/lib','../../lib'], + library_dirs = ['/usr/local/lib','../../lib/.libs'], sources = ['pyext.c']) setup (name = 'Syck', @@ . patch -p0 <<'@@ .' Index: syck/lib/Makefile.am ============================================================================ $ cvs diff -u -r1.1.1.1 -r1.2 Makefile.am --- syck/lib/Makefile.am 17 Oct 2008 18:53:41 -0000 1.1.1.1 +++ syck/lib/Makefile.am 17 Oct 2008 20:03:39 -0000 1.2 @@ -4,10 +4,10 @@ AM_YFLAGS = -d -t -v -p syck -lib_LIBRARIES = libsyck.a +lib_LTLIBRARIES = libsyck.la include_HEADERS = syck.h syck_st.h -libsyck_a_SOURCES = \ +libsyck_la_SOURCES = \ emitter.c \ handler.c \ node.c \ @@ -19,6 +19,11 @@ token.re \ implicit.re +# CURRENT:REVISION:AGE +# Bump REVISION if there's no API or ABI changes. +# Bump AGE and CURRENT and reset REVISION if there's no ABI changes. +# Bump CURRENT and reset AGE and REVISION if there's ABI changes. +libsyck_la_LDFLAGS = -version-info 0:55:0 # libsyck_a_LIBADD = $(LEXLIB) REC = re2c @@ . patch -p0 <<'@@ .' Index: syck/lib/bytecode.c ============================================================================ $ cvs diff -u -r1.1.1.2 -r1.2 bytecode.c --- syck/lib/bytecode.c 17 Oct 2008 19:01:17 -0000 1.1.1.2 +++ syck/lib/bytecode.c 17 Oct 2008 20:03:39 -0000 1.2 @@ -1,10 +1,10 @@ -/* Generated by re2c 0.9.10 on Mon Sep 19 23:21:26 2005 */ +/* Generated by re2c 0.9.12 on Tue Mar 14 00:14:53 2006 */ #line 1 "bytecode.re" /* * bytecode.re * * $Author: why $ - * $Date: 2005/09/20 05:21:06 $ + * $Date: 2005-09-20 08:21:06 +0300 (Tue, 20 Sep 2005) $ * * Copyright (C) 2003 why the lucky stiff */ @@ -164,7 +164,7 @@ #line 165 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy0; ++YYCURSOR; yy0: @@ -542,7 +542,7 @@ #line 543 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy45; ++YYCURSOR; yy45: @@ . patch -p0 <<'@@ .' Index: syck/lib/emitter.c ============================================================================ $ cvs diff -u -r1.1.1.2 -r1.2 emitter.c --- syck/lib/emitter.c 17 Oct 2008 19:01:13 -0000 1.1.1.2 +++ syck/lib/emitter.c 17 Oct 2008 20:03:39 -0000 1.2 @@ -2,7 +2,7 @@ * emitter.c * * $Author: why $ - * $Date: 2005/09/20 06:20:40 $ + * $Date: 2005-09-20 09:20:40 +0300 (Tue, 20 Sep 2005) $ * * Copyright (C) 2003 why the lucky stiff * @@ -359,6 +359,7 @@ char *anchor_name = NULL; int indent = 0; long x = 0; + SyckLevel *parent; SyckLevel *lvl = syck_emitter_current_level( e ); /* @@ -386,6 +387,7 @@ indent = lvl->spaces + e->indent; } syck_emitter_add_level( e, indent, syck_lvl_open ); + parent = lvl; lvl = syck_emitter_current_level( e ); /* Look for anchor */ @@ -402,6 +404,13 @@ { char *an = S_ALLOC_N( char, strlen( anchor_name ) + 3 ); sprintf( an, "&%s ", anchor_name ); + + /* Complex key */ + if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1) { + syck_emitter_write( e, "? ", 2 ); + parent->status = syck_lvl_mapx; + } + syck_emitter_write( e, an, strlen( anchor_name ) + 2 ); free( an ); @@ -996,6 +1005,17 @@ { SyckLevel *parent = syck_emitter_parent_level( e ); SyckLevel *lvl = syck_emitter_current_level( e ); + + /* complex key + * There should also be the check "&& style == seq_none", + * but unfortunately syck cannot parse flow collections as simple keys + * now, so we will make a complex key. + * Add the check when syck is able to parse "[]: foo" */ + if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) { + syck_emitter_write( e, "? ", 2 ); + parent->status = syck_lvl_mapx; + } + syck_emit_tag( e, tag, "tag:yaml.org,2002:seq" ); if ( style == seq_inline || ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) ) { syck_emitter_write( e, "[", 1 ); @@ -1012,6 +1032,17 @@ { SyckLevel *parent = syck_emitter_parent_level( e ); SyckLevel *lvl = syck_emitter_current_level( e ); + + /* complex key + * There should also be the check "&& style == map_none", + * but unfortunately syck cannot parse flow collections as simple keys + * now, so we will make a complex key. + * Add the check when syck is able to parse "{}: foo". */ + if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) { + syck_emitter_write( e, "? ", 2 ); + parent->status = syck_lvl_mapx; + } + syck_emit_tag( e, tag, "tag:yaml.org,2002:map" ); if ( style == map_inline || ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) ) { syck_emitter_write( e, "{", 1 ); @@ -1035,15 +1066,11 @@ SyckLevel *parent = syck_emitter_parent_level( e ); /* seq-in-map shortcut */ - if ( parent->status == syck_lvl_map && lvl->ncount == 0 ) { - /* complex key */ - if ( parent->ncount % 2 == 1 ) { - syck_emitter_write( e, "?", 1 ); - parent->status = syck_lvl_mapx; + if ( parent->status == syck_lvl_mapx && lvl->ncount == 0 ) { /* shortcut -- the lvl->anctag check should be unneccesary but * there is a nasty shift/reduce in the parser on this point and * i'm not ready to tickle it. */ - } else if ( lvl->anctag == 0 ) { + if ( parent->ncount % 2 == 0 && lvl->anctag == 0 ) { lvl->spaces = parent->spaces; } } @@ -1078,15 +1105,6 @@ { SyckLevel *parent = syck_emitter_parent_level( e ); - /* map-in-map */ - if ( parent->status == syck_lvl_map && lvl->ncount == 0 ) { - /* complex key */ - if ( parent->ncount % 2 == 1 ) { - syck_emitter_write( e, "?", 1 ); - parent->status = syck_lvl_mapx; - } - } - /* map-in-seq shortcut */ if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) { int spcs = ( lvl->spaces - parent->spaces ) - 2; @@ -1164,21 +1182,27 @@ break; case syck_lvl_iseq: - syck_emitter_write( e, "]\n", 1 ); + syck_emitter_write( e, "]", 1 ); + if ( parent->status == syck_lvl_mapx ) { + syck_emitter_write( e, "\n", 1 ); + } break; case syck_lvl_map: if ( lvl->ncount == 0 ) { syck_emitter_write( e, "{}\n", 3 ); } else if ( lvl->ncount % 2 == 1 ) { - syck_emitter_write( e, ":\n", 1 ); + syck_emitter_write( e, ":", 1 ); } else if ( parent->status == syck_lvl_mapx ) { syck_emitter_write( e, "\n", 1 ); } break; case syck_lvl_imap: - syck_emitter_write( e, "}\n", 1 ); + syck_emitter_write( e, "}", 1 ); + if ( parent->status == syck_lvl_mapx ) { + syck_emitter_write( e, "\n", 1 ); + } break; default: break; @@ . patch -p0 <<'@@ .' Index: syck/lib/implicit.c ============================================================================ $ cvs diff -u -r1.1.1.2 -r1.2 implicit.c --- syck/lib/implicit.c 17 Oct 2008 19:01:12 -0000 1.1.1.2 +++ syck/lib/implicit.c 17 Oct 2008 20:03:39 -0000 1.2 @@ -1,10 +1,10 @@ -/* Generated by re2c 0.9.10 on Sun Nov 13 16:09:51 2005 */ +/* Generated by re2c 0.9.12 on Tue Mar 14 00:14:53 2006 */ #line 1 "implicit.re" /* * implicit.re * * $Author: why $ - * $Date: 2005/11/13 23:43:56 $ + * $Date: 2005-11-14 01:43:56 +0200 (Mon, 14 Nov 2005) $ * * Copyright (C) 2003 why the lucky stiff */ @@ -54,7 +54,7 @@ #line 55 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy0; ++YYCURSOR; yy0: @@ -1619,11 +1619,11 @@ #line 1620 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy202; ++YYCURSOR; yy202: - if((YYLIMIT - YYCURSOR) < 11) YYFILL(11); + if((YYLIMIT - YYCURSOR) < 21) YYFILL(21); yych = *YYCURSOR; switch(yych){ case 0x00: goto yy204; @@ -1979,7 +1979,7 @@ default: goto yy204; } yy214: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + if((YYLIMIT - YYCURSOR) < 12) YYFILL(12); yych = *YYCURSOR; goto yy215; yy215: switch(yych){ @@ -2506,7 +2506,7 @@ default: goto yy250; } yy249: ++YYCURSOR; - if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + if((YYLIMIT - YYCURSOR) < 12) YYFILL(12); yych = *YYCURSOR; goto yy250; yy250: switch(yych){ @@ . patch -p0 <<'@@ .' Index: syck/lib/token.c ============================================================================ $ cvs diff -u -r1.1.1.2 -r1.2 token.c --- syck/lib/token.c 17 Oct 2008 19:01:17 -0000 1.1.1.2 +++ syck/lib/token.c 17 Oct 2008 20:03:39 -0000 1.2 @@ -1,10 +1,10 @@ -/* Generated by re2c 0.9.10 on Tue Sep 20 17:46:17 2005 */ +/* Generated by re2c 0.9.12 on Tue Mar 14 00:14:53 2006 */ #line 1 "token.re" /* * token.re * * $Author: why $ - * $Date: 2005/09/20 23:42:51 $ + * $Date: 2005-09-21 02:42:51 +0300 (Wed, 21 Sep 2005) $ * * Copyright (C) 2003 why the lucky stiff */ @@ -306,7 +306,7 @@ #line 307 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy0; ++YYCURSOR; yy0: @@ -517,7 +517,7 @@ #line 518 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy35; ++YYCURSOR; yy35: @@ -581,7 +581,7 @@ default: goto yy40; } yy40: -#line 497 "token.re" +#line 500 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto Plain; } @@ -761,20 +761,20 @@ yy51: ++YYCURSOR; goto yy52; yy52: -#line 471 "token.re" +#line 474 "token.re" { goto TransferMethod; } #line 767 "<stdout>" yy53: ++YYCURSOR; goto yy54; yy54: -#line 473 "token.re" +#line 476 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto SingleQuote; } #line 774 "<stdout>" yy55: ++YYCURSOR; goto yy56; yy56: -#line 476 "token.re" +#line 479 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); goto DoubleQuote; } #line 781 "<stdout>" @@ -799,7 +799,7 @@ yy58: ++YYCURSOR; goto yy59; yy59: -#line 486 "token.re" +#line 489 "token.re" { eat_comments( parser ); goto Document; } @@ -808,13 +808,13 @@ yych = *YYCURSOR; goto yy66; yy61: -#line 490 "token.re" +#line 493 "token.re" { goto Document; } #line 814 "<stdout>" yy62: ++YYCURSOR; goto yy63; yy63: -#line 492 "token.re" +#line 495 "token.re" { ENSURE_YAML_IEND(lvl, -1); YYPOS(0); return 0; @@ -858,7 +858,7 @@ yy70: ++YYCURSOR; goto yy71; yy71: -#line 479 "token.re" +#line 482 "token.re" { if ( is_newline( YYCURSOR - 1 ) ) { YYCURSOR--; @@ -947,7 +947,7 @@ default: goto yy77; } yy77: -#line 466 "token.re" +#line 469 "token.re" { ENSURE_YAML_IOPEN(lvl, doc_level, 1); sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); return YAML_ALIAS; @@ -1021,7 +1021,7 @@ default: goto yy80; } yy80: -#line 455 "token.re" +#line 458 "token.re" { sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); /* @@ -1036,7 +1036,7 @@ yy81: ++YYCURSOR; goto yy82; yy82: -#line 441 "token.re" +#line 444 "token.re" { ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1); FORCE_NEXT_TOKEN(YAML_IOPEN); if ( *YYCURSOR == '#' || is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) ) @@ -1068,11 +1068,14 @@ goto yy87; yy87: #line 436 "token.re" -{ if ( *YYTOKEN == ':' && lvl->status != syck_lvl_imap ) lvl->status = syck_lvl_map; +{ if ( *YYTOKEN == ':' && lvl->status != syck_lvl_imap && lvl->status != syck_lvl_iseq ) + { + lvl->status = syck_lvl_map; + } YYPOS(1); return YYTOKEN[0]; } -#line 1076 "<stdout>" +#line 1079 "<stdout>" yy88: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -1104,7 +1107,7 @@ default: goto yy69; } } -#line 501 "token.re" +#line 504 "token.re" } @@ -1113,10 +1116,10 @@ YYTOKTMP = YYCURSOR; -#line 1117 "<stdout>" +#line 1120 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy94; ++YYCURSOR; yy94: @@ -1213,18 +1216,18 @@ default: goto yy98; } yy98: -#line 514 "token.re" +#line 517 "token.re" { YYCURSOR = YYTOKTMP; return YAML_DOCSEP; } -#line 1221 "<stdout>" +#line 1224 "<stdout>" yy99: ++YYCURSOR; yych = *YYCURSOR; goto yy103; yy100: -#line 512 "token.re" +#line 515 "token.re" { goto Directive; } -#line 1228 "<stdout>" +#line 1231 "<stdout>" yy101: yych = *++YYCURSOR; goto yy98; yy102: ++YYCURSOR; @@ -1478,11 +1481,11 @@ default: goto yy109; } yy109: -#line 510 "token.re" +#line 513 "token.re" { goto Directive; } -#line 1484 "<stdout>" +#line 1487 "<stdout>" } -#line 517 "token.re" +#line 520 "token.re" } @@ -1505,10 +1508,10 @@ Plain3: -#line 1509 "<stdout>" +#line 1512 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy110; ++YYCURSOR; yy110: @@ -1530,7 +1533,7 @@ yych = *(YYMARKER = ++YYCURSOR); goto yy142; yy113: -#line 540 "token.re" +#line 543 "token.re" { int indt_len, nl_count = 0; SyckLevel *lvl; char *tok = YYTOKEN; @@ -1566,18 +1569,18 @@ goto Plain2; } -#line 1570 "<stdout>" +#line 1573 "<stdout>" yy114: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy141; default: goto yy115; } yy115: -#line 627 "token.re" +#line 630 "token.re" { QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN); goto Plain2; } -#line 1581 "<stdout>" +#line 1584 "<stdout>" yy116: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ @@ -1597,7 +1600,7 @@ yy118: ++YYCURSOR; goto yy119; yy119: -#line 589 "token.re" +#line 592 "token.re" { if ( plvl->status != syck_lvl_imap ) { PLAIN_NOT_INL(); @@ -1608,11 +1611,11 @@ } RETURN_IMPLICIT(); } -#line 1612 "<stdout>" +#line 1615 "<stdout>" yy120: ++YYCURSOR; goto yy121; yy121: -#line 600 "token.re" +#line 603 "token.re" { if ( plvl->status != syck_lvl_iseq ) { PLAIN_NOT_INL(); @@ -1623,14 +1626,14 @@ } RETURN_IMPLICIT(); } -#line 1627 "<stdout>" +#line 1630 "<stdout>" yy122: ++YYCURSOR; switch((yych = *YYCURSOR)) { case '#': goto yy128; default: goto yy123; } yy123: -#line 617 "token.re" +#line 620 "token.re" { if ( qidx == 0 ) { goto Plain2; @@ -1640,13 +1643,13 @@ goto Plain3; } } -#line 1644 "<stdout>" +#line 1647 "<stdout>" yy124: ++YYCURSOR; goto yy125; yy125: -#line 615 "token.re" +#line 618 "token.re" { RETURN_IMPLICIT(); } -#line 1650 "<stdout>" +#line 1653 "<stdout>" yy126: yych = *++YYCURSOR; goto yy123; yy127: yych = *++YYCURSOR; @@ -1654,15 +1657,15 @@ yy128: ++YYCURSOR; goto yy129; yy129: -#line 611 "token.re" +#line 614 "token.re" { eat_comments( parser ); RETURN_IMPLICIT(); } -#line 1662 "<stdout>" +#line 1665 "<stdout>" yy130: ++YYCURSOR; goto yy131; yy131: -#line 578 "token.re" +#line 581 "token.re" { if ( plvl->status != syck_lvl_iseq && plvl->status != syck_lvl_imap ) { PLAIN_NOT_INL(); @@ -1673,7 +1676,7 @@ } RETURN_IMPLICIT(); } -#line 1677 "<stdout>" +#line 1680 "<stdout>" yy132: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -1695,9 +1698,9 @@ yy136: ++YYCURSOR; goto yy137; yy137: -#line 576 "token.re" +#line 579 "token.re" { RETURN_IMPLICIT(); } -#line 1701 "<stdout>" +#line 1704 "<stdout>" yy138: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -1729,7 +1732,7 @@ default: goto yy135; } } -#line 631 "token.re" +#line 634 "token.re" } @@ -1743,10 +1746,10 @@ YYTOKEN = YYCURSOR; -#line 1747 "<stdout>" +#line 1750 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy144; ++YYCURSOR; yy144: @@ -1763,7 +1766,7 @@ yych = *(YYMARKER = ++YYCURSOR); goto yy157; yy147: -#line 645 "token.re" +#line 648 "token.re" { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1803,25 +1806,25 @@ goto SingleQuote2; } -#line 1807 "<stdout>" +#line 1810 "<stdout>" yy148: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy156; default: goto yy149; } yy149: -#line 712 "token.re" +#line 715 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto SingleQuote2; } -#line 1818 "<stdout>" +#line 1821 "<stdout>" yy150: ++YYCURSOR; switch((yych = *YYCURSOR)) { case '\'': goto yy154; default: goto yy151; } yy151: -#line 689 "token.re" +#line 692 "token.re" { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -1844,7 +1847,7 @@ sycklval->nodeData = n; return YAML_PLAIN; } -#line 1848 "<stdout>" +#line 1851 "<stdout>" yy152: yych = *++YYCURSOR; goto yy151; yy153: yych = *++YYCURSOR; @@ -1852,11 +1855,11 @@ yy154: ++YYCURSOR; goto yy155; yy155: -#line 685 "token.re" +#line 688 "token.re" { QUOTECAT(qstr, qcapa, qidx, '\''); goto SingleQuote2; } -#line 1860 "<stdout>" +#line 1863 "<stdout>" yy156: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -1879,7 +1882,7 @@ case 0: goto yy147; } } -#line 716 "token.re" +#line 719 "token.re" } @@ -1897,10 +1900,10 @@ -#line 1901 "<stdout>" +#line 1904 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy160; ++YYCURSOR; yy160: @@ -1918,7 +1921,7 @@ yych = *(YYMARKER = ++YYCURSOR); goto yy184; yy163: -#line 734 "token.re" +#line 737 "token.re" { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1962,18 +1965,18 @@ keep_nl = 1; goto DoubleQuote2; } -#line 1966 "<stdout>" +#line 1969 "<stdout>" yy164: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy183; default: goto yy165; } yy165: -#line 820 "token.re" +#line 823 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto DoubleQuote2; } -#line 1977 "<stdout>" +#line 1980 "<stdout>" yy166: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ @@ -1989,7 +1992,7 @@ yy167: ++YYCURSOR; goto yy168; yy168: -#line 797 "token.re" +#line 800 "token.re" { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -2012,7 +2015,7 @@ sycklval->nodeData = n; return YAML_PLAIN; } -#line 2016 "<stdout>" +#line 2019 "<stdout>" yy169: yych = *++YYCURSOR; goto yy168; yy170: yych = *++YYCURSOR; @@ -2035,12 +2038,12 @@ yy174: ++YYCURSOR; goto yy175; yy175: -#line 792 "token.re" +#line 795 "token.re" { keep_nl = 0; YYCURSOR--; goto DoubleQuote2; } -#line 2044 "<stdout>" +#line 2047 "<stdout>" yy176: yych = *++YYCURSOR; switch(yych){ case 0x0A: goto yy174; @@ -2073,12 +2076,12 @@ yy178: ++YYCURSOR; goto yy179; yy179: -#line 778 "token.re" +#line 781 "token.re" { char ch = *( YYCURSOR - 1 ); QUOTECAT(qstr, qcapa, qidx, escape_seq( ch )); goto DoubleQuote2; } -#line 2082 "<stdout>" +#line 2085 "<stdout>" yy180: yych = *++YYCURSOR; switch(yych){ case '0': @@ -2106,7 +2109,7 @@ yy181: ++YYCURSOR; goto yy182; yy182: -#line 783 "token.re" +#line 786 "token.re" { long ch; char *chr_text = syck_strndup( YYTOKEN, 4 ); chr_text[0] = '0'; @@ -2115,7 +2118,7 @@ QUOTECAT(qstr, qcapa, qidx, ch); goto DoubleQuote2; } -#line 2119 "<stdout>" +#line 2122 "<stdout>" yy183: yyaccept = 0; YYMARKER = ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -2134,7 +2137,7 @@ default: goto yy173; } } -#line 824 "token.re" +#line 827 "token.re" } @@ -2148,10 +2151,10 @@ YYTOKTMP = YYCURSOR; -#line 2152 "<stdout>" +#line 2155 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy186; ++YYCURSOR; yy186: @@ -2168,7 +2171,7 @@ yy188: ++YYCURSOR; goto yy189; yy189: -#line 838 "token.re" +#line 841 "token.re" { SyckLevel *lvl; YYCURSOR = YYTOKTMP; if ( YYCURSOR == YYTOKEN + 1 ) @@ -2218,7 +2221,7 @@ return YAML_TRANSFER; } -#line 2222 "<stdout>" +#line 2225 "<stdout>" yy190: yych = *++YYCURSOR; goto yy189; yy191: yych = *++YYCURSOR; @@ -2229,11 +2232,11 @@ default: goto yy193; } yy193: -#line 905 "token.re" +#line 908 "token.re" { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto TransferMethod2; } -#line 2237 "<stdout>" +#line 2240 "<stdout>" yy194: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ @@ -2276,12 +2279,12 @@ yy198: ++YYCURSOR; goto yy199; yy199: -#line 891 "token.re" +#line 894 "token.re" { char ch = *( YYCURSOR - 1 ); QUOTECAT(qstr, qcapa, qidx, escape_seq( ch )); goto TransferMethod2; } -#line 2285 "<stdout>" +#line 2288 "<stdout>" yy200: yych = *++YYCURSOR; switch(yych){ case '0': @@ -2309,7 +2312,7 @@ yy201: ++YYCURSOR; goto yy202; yy202: -#line 896 "token.re" +#line 899 "token.re" { long ch; char *chr_text = syck_strndup( YYTOKTMP, 4 ); chr_text[0] = '0'; @@ -2318,7 +2321,7 @@ QUOTECAT(qstr, qcapa, qidx, ch); goto TransferMethod2; } -#line 2322 "<stdout>" +#line 2325 "<stdout>" yy203: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -2328,7 +2331,7 @@ default: goto yy189; } } -#line 910 "token.re" +#line 913 "token.re" } @@ -2374,10 +2377,10 @@ YYTOKEN = YYCURSOR; -#line 2378 "<stdout>" +#line 2381 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy205; ++YYCURSOR; yy205: @@ -2395,7 +2398,7 @@ yych = *(YYMARKER = ++YYCURSOR); goto yy226; yy208: -#line 956 "token.re" +#line 959 "token.re" { char *pacer; char *tok = YYTOKEN; int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0; @@ -2470,22 +2473,22 @@ } goto ScalarBlock2; } -#line 2474 "<stdout>" +#line 2477 "<stdout>" yy209: ++YYCURSOR; switch((yych = *YYCURSOR)) { case 0x0A: goto yy225; default: goto yy210; } yy210: -#line 1070 "token.re" +#line 1073 "token.re" { QUOTECAT(qstr, qcapa, qidx, *YYTOKEN); goto ScalarBlock2; } -#line 2485 "<stdout>" +#line 2488 "<stdout>" yy211: ++YYCURSOR; goto yy212; yy212: -#line 1032 "token.re" +#line 1035 "token.re" { lvl = CURRENT_LEVEL(); if ( lvl->status != syck_lvl_block ) { @@ -2498,16 +2501,16 @@ } goto ScalarBlock2; } -#line 2502 "<stdout>" +#line 2505 "<stdout>" yy213: ++YYCURSOR; goto yy214; yy214: -#line 1046 "token.re" +#line 1049 "token.re" { YYCURSOR--; POP_LEVEL(); RETURN_YAML_BLOCK(); } -#line 2511 "<stdout>" +#line 2514 "<stdout>" yy215: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch(yych){ @@ -2536,7 +2539,7 @@ yy220: ++YYCURSOR; goto yy221; yy221: -#line 1051 "token.re" +#line 1054 "token.re" { if ( YYTOKEN == YYLINEPTR ) { if ( blockType == BLOCK_FOLD && qidx > 0 ) @@ -2555,7 +2558,7 @@ goto ScalarBlock2; } } -#line 2559 "<stdout>" +#line 2562 "<stdout>" yy222: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; @@ -2587,7 +2590,7 @@ default: goto yy218; } } -#line 1075 "token.re" +#line 1078 "token.re" } @@ -2603,10 +2606,10 @@ YYTOKEN = YYCURSOR; -#line 2607 "<stdout>" +#line 2610 "<stdout>" { YYCTYPE yych; - unsigned int yyaccept; + unsigned int yyaccept = 0; goto yy228; ++YYCURSOR; yy228: @@ -2621,11 +2624,11 @@ yy230: ++YYCURSOR; goto yy231; yy231: -#line 1091 "token.re" +#line 1094 "token.re" { YYCURSOR = YYTOKEN; return; } -#line 2629 "<stdout>" +#line 2632 "<stdout>" yy232: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); goto yy237; @@ -2635,10 +2638,10 @@ default: goto yy234; } yy234: -#line 1095 "token.re" +#line 1098 "token.re" { goto Comment; } -#line 2642 "<stdout>" +#line 2645 "<stdout>" yy235: yych = *++YYCURSOR; goto yy234; yy236: yyaccept = 0; @@ -2663,7 +2666,7 @@ case 0: goto yy231; } } -#line 1098 "token.re" +#line 1101 "token.re" } @@ . patch -p0 <<'@@ .' Index: syck/lib/token.re ============================================================================ $ cvs diff -u -r1.1.1.2 -r1.2 token.re --- syck/lib/token.re 17 Oct 2008 19:01:15 -0000 1.1.1.2 +++ syck/lib/token.re 17 Oct 2008 20:03:39 -0000 1.2 @@ -2,7 +2,7 @@ * token.re * * $Author: why $ - * $Date: 2005/09/20 23:42:51 $ + * $Date: 2005-09-21 02:42:51 +0300 (Wed, 21 Sep 2005) $ * * Copyright (C) 2003 why the lucky stiff */ @@ -433,7 +433,10 @@ return YYTOKEN[0]; } -[:,] ENDSPC { if ( *YYTOKEN == ':' && lvl->status != syck_lvl_imap ) lvl->status = syck_lvl_map; +[:,] ENDSPC { if ( *YYTOKEN == ':' && lvl->status != syck_lvl_imap && lvl->status != syck_lvl_iseq ) + { + lvl->status = syck_lvl_map; + } YYPOS(1); return YYTOKEN[0]; } @@ . patch -p0 <<'@@ .' Index: syck/tests/CuTest.c ============================================================================ $ cvs diff -u -r1.1.1.1 -r1.2 CuTest.c --- syck/tests/CuTest.c 17 Oct 2008 18:53:48 -0000 1.1.1.1 +++ syck/tests/CuTest.c 17 Oct 2008 20:03:39 -0000 1.2 @@ -1,294 +1,294 @@ -#include <assert.h> -#include <setjmp.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include "CuTest.h" - -/*-------------------------------------------------------------------------* - * CuStr - *-------------------------------------------------------------------------*/ - -char* CuStrAlloc(int size) -{ - char* new = (char*) malloc( sizeof(char) * (size) ); - return new; -} - -char* CuStrCopy(char* old) -{ - int len = strlen(old); - char* new = CuStrAlloc(len + 1); - strcpy(new, old); - return new; -} - -/*-------------------------------------------------------------------------* - * CuString - *-------------------------------------------------------------------------*/ - -void CuStringInit(CuString* str) -{ - str->length = 0; - str->size = STRING_MAX; - str->buffer = (char*) malloc(sizeof(char) * str->size); - str->buffer[0] = '\0'; -} - -CuString* CuStringNew(void) -{ - CuString* str = (CuString*) malloc(sizeof(CuString)); - str->length = 0; - str->size = STRING_MAX; - str->buffer = (char*) malloc(sizeof(char) * str->size); - str->buffer[0] = '\0'; - return str; -} - -void CuStringResize(CuString* str, int newSize) -{ - str->buffer = (char*) realloc(str->buffer, sizeof(char) * newSize); - str->size = newSize; -} - -void CuStringAppend(CuString* str, char* text) -{ - int length = strlen(text); - CuStringAppendLen(str, text, length); -} - -void CuStringAppendLen(CuString* str, char* text, long length) -{ - if (str->length + length + 1 >= str->size) - CuStringResize(str, str->length + length + 1 + STRING_INC); - str->length += length; - strcat(str->buffer, text); -} - -void CuStringAppendChar(CuString* str, char ch) -{ - char text[2]; - text[0] = ch; - text[1] = '\0'; - CuStringAppend(str, text); -} - -void CuStringAppendFormat(CuString* str, char* format, ...) -{ - va_list argp; - char buf[HUGE_STRING_LEN]; - va_start(argp, format); - vsprintf(buf, format, argp); - va_end(argp); - CuStringAppend(str, buf); -} - -void CuStringFree(CuString* str) -{ - if ( str != NULL ) - { - free( str->buffer ); - free( str ); - } -} - -/*-------------------------------------------------------------------------* - * CuTest - *-------------------------------------------------------------------------*/ - -void CuTestInit(CuTest* t, char* name, TestFunction function) -{ - t->name = CuStrCopy(name); - t->failed = 0; - t->ran = 0; - t->message = NULL; - t->function = function; - t->jumpBuf = NULL; -} - -CuTest* CuTestNew(char* name, TestFunction function) -{ - CuTest* tc = CU_ALLOC(CuTest); - CuTestInit(tc, name, function); - return tc; -} - -void CuTestFree(CuTest* t) -{ - if ( t != NULL ) - { - free( t->name ); - free( t ); - } -} - -void CuFail(CuTest* tc, char* message) -{ - tc->failed = 1; - tc->message = CuStrCopy(message); - if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0); -} - -void CuAssert(CuTest* tc, char* message, int condition) -{ - if (condition) return; - CuFail(tc, message); -} - -void CuAssertTrue(CuTest* tc, int condition) -{ - if (condition) return; - CuFail(tc, "assert failed"); -} - -void CuAssertStrEquals(CuTest* tc, char* expected, char* actual) -{ - CuString* message; - if (strcmp(expected, actual) == 0) return; - message = CuStringNew(); - CuStringAppend(message, "expected <"); - CuStringAppend(message, expected); - CuStringAppend(message, "> but was <"); - CuStringAppend(message, actual); - CuStringAppend(message, ">"); - CuFail(tc, message->buffer); -} - -void CuAssertIntEquals(CuTest* tc, int expected, int actual) -{ - char buf[STRING_MAX]; - if (expected == actual) return; - sprintf(buf, "expected <%d> but was <%d>", expected, actual); - CuFail(tc, buf); -} - -void CuAssertPtrEquals(CuTest* tc, void* expected, void* actual) -{ - char buf[STRING_MAX]; - if (expected == actual) return; - sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual); - CuFail(tc, buf); -} - -void CuAssertPtrNotNull(CuTest* tc, void* pointer) -{ - char buf[STRING_MAX]; - if (pointer != NULL ) return; - sprintf(buf, "null pointer unexpected"); - CuFail(tc, buf); -} - -void CuTestRun(CuTest* tc) -{ - jmp_buf buf; - tc->jumpBuf = &buf; - if (setjmp(buf) == 0) - { - tc->ran = 1; - (tc->function)(tc); - } - tc->jumpBuf = 0; -} - -/*-------------------------------------------------------------------------* - * CuSuite - *-------------------------------------------------------------------------*/ - -void CuSuiteInit(CuSuite* testSuite) -{ - testSuite->count = 0; - testSuite->failCount = 0; -} - -CuSuite* CuSuiteNew() -{ - CuSuite* testSuite = CU_ALLOC(CuSuite); - CuSuiteInit(testSuite); - return testSuite; -} - -void CuSuiteFree(CuSuite* testSuite) -{ - int i; - for (i = 0 ; i < testSuite->count ; ++i) - { - CuTestFree( testSuite->list[i] ); - } - free( testSuite ); -} - -void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase) -{ - assert(testSuite->count < MAX_TEST_CASES); - testSuite->list[testSuite->count] = testCase; - testSuite->count++; -} - -void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2) -{ - int i; - for (i = 0 ; i < testSuite2->count ; ++i) - { - CuTest* testCase = testSuite2->list[i]; - CuSuiteAdd(testSuite, testCase); - } -} - -void CuSuiteRun(CuSuite* testSuite) -{ - int i; - for (i = 0 ; i < testSuite->count ; ++i) - { - CuTest* testCase = testSuite->list[i]; - CuTestRun(testCase); - if (testCase->failed) { testSuite->failCount += 1; } - } -} - -void CuSuiteSummary(CuSuite* testSuite, CuString* summary) -{ - int i; - for (i = 0 ; i < testSuite->count ; ++i) - { - CuTest* testCase = testSuite->list[i]; - CuStringAppend(summary, testCase->failed ? "F" : "."); - } - CuStringAppend(summary, "\n\n"); -} - -void CuSuiteDetails(CuSuite* testSuite, CuString* details) -{ - int i; - int failCount = 0; - - if (testSuite->failCount == 0) - { - int passCount = testSuite->count - testSuite->failCount; - char* testWord = passCount == 1 ? "test" : "tests"; - CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord); - } - else - { - if (testSuite->failCount == 1) - CuStringAppend(details, "There was 1 failure:\n"); - else - CuStringAppendFormat(details, "There were %d failures:\n", testSuite->failCount); - - for (i = 0 ; i < testSuite->count ; ++i) - { - CuTest* testCase = testSuite->list[i]; - if (testCase->failed) - { - failCount++; - CuStringAppendFormat(details, "%d) %s: %s\n", - failCount, testCase->name, testCase->message); - } - } - CuStringAppend(details, "\n!!!FAILURES!!!\n"); - - CuStringAppendFormat(details, "Runs: %d ", testSuite->count); - CuStringAppendFormat(details, "Passes: %d ", testSuite->count - testSuite->failCount); - CuStringAppendFormat(details, "Fails: %d\n", testSuite->failCount); - } -} +#include <assert.h> +#include <setjmp.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "CuTest.h" + +/*-------------------------------------------------------------------------* + * CuStr + *-------------------------------------------------------------------------*/ + +char* CuStrAlloc(int size) +{ + char* new = (char*) malloc( sizeof(char) * (size) ); + return new; +} + +char* CuStrCopy(char* old) +{ + int len = strlen(old); + char* new = CuStrAlloc(len + 1); + strcpy(new, old); + return new; +} + +/*-------------------------------------------------------------------------* + * CuString + *-------------------------------------------------------------------------*/ + +void CuStringInit(CuString* str) +{ + str->length = 0; + str->size = STRING_MAX; + str->buffer = (char*) malloc(sizeof(char) * str->size); + str->buffer[0] = '\0'; +} + +CuString* CuStringNew(void) +{ + CuString* str = (CuString*) malloc(sizeof(CuString)); + str->length = 0; + str->size = STRING_MAX; + str->buffer = (char*) malloc(sizeof(char) * str->size); + str->buffer[0] = '\0'; + return str; +} + +void CuStringResize(CuString* str, int newSize) +{ + str->buffer = (char*) realloc(str->buffer, sizeof(char) * newSize); + str->size = newSize; +} + +void CuStringAppend(CuString* str, char* text) +{ + int length = strlen(text); + CuStringAppendLen(str, text, length); +} + +void CuStringAppendLen(CuString* str, char* text, long length) +{ + if (str->length + length + 1 >= str->size) + CuStringResize(str, str->length + length + 1 + STRING_INC); + str->length += length; + strcat(str->buffer, text); +} + +void CuStringAppendChar(CuString* str, char ch) +{ + char text[2]; + text[0] = ch; + text[1] = '\0'; + CuStringAppend(str, text); +} + +void CuStringAppendFormat(CuString* str, char* format, ...) +{ + va_list argp; + char buf[HUGE_STRING_LEN]; + va_start(argp, format); + vsprintf(buf, format, argp); + va_end(argp); + CuStringAppend(str, buf); +} + +void CuStringFree(CuString* str) +{ + if ( str != NULL ) + { + free( str->buffer ); + free( str ); + } +} + +/*-------------------------------------------------------------------------* + * CuTest + *-------------------------------------------------------------------------*/ + +void CuTestInit(CuTest* t, char* name, TestFunction function) +{ + t->name = CuStrCopy(name); + t->failed = 0; + t->ran = 0; + t->message = NULL; + t->function = function; + t->jumpBuf = NULL; +} + +CuTest* CuTestNew(char* name, TestFunction function) +{ + CuTest* tc = CU_ALLOC(CuTest); + CuTestInit(tc, name, function); + return tc; +} + +void CuTestFree(CuTest* t) +{ + if ( t != NULL ) + { + free( t->name ); + free( t ); + } +} + +void CuFail(CuTest* tc, char* message) +{ + tc->failed = 1; + tc->message = CuStrCopy(message); + if (tc->jumpBuf != 0) longjmp(*(tc->jumpBuf), 0); +} + +void CuAssert(CuTest* tc, char* message, int condition) +{ + if (condition) return; + CuFail(tc, message); +} + +void CuAssertTrue(CuTest* tc, int condition) +{ + if (condition) return; + CuFail(tc, "assert failed"); +} + +void CuAssertStrEquals(CuTest* tc, char* expected, char* actual) +{ + CuString* message; + if (strcmp(expected, actual) == 0) return; + message = CuStringNew(); + CuStringAppend(message, "expected <"); + CuStringAppend(message, expected); + CuStringAppend(message, "> but was <"); + CuStringAppend(message, actual); + CuStringAppend(message, ">"); + CuFail(tc, message->buffer); +} + +void CuAssertIntEquals(CuTest* tc, int expected, int actual) +{ + char buf[STRING_MAX]; + if (expected == actual) return; + sprintf(buf, "expected <%d> but was <%d>", expected, actual); + CuFail(tc, buf); +} + +void CuAssertPtrEquals(CuTest* tc, void* expected, void* actual) +{ + char buf[STRING_MAX]; + if (expected == actual) return; + sprintf(buf, "expected pointer <0x%p> but was <0x%p>", expected, actual); + CuFail(tc, buf); +} + +void CuAssertPtrNotNull(CuTest* tc, void* pointer) +{ + char buf[STRING_MAX]; + if (pointer != NULL ) return; + sprintf(buf, "null pointer unexpected"); + CuFail(tc, buf); +} + +void CuTestRun(CuTest* tc) +{ + jmp_buf buf; + tc->jumpBuf = &buf; + if (setjmp(buf) == 0) + { + tc->ran = 1; + (tc->function)(tc); + } + tc->jumpBuf = 0; +} + +/*-------------------------------------------------------------------------* + * CuSuite + *-------------------------------------------------------------------------*/ + +void CuSuiteInit(CuSuite* testSuite) +{ + testSuite->count = 0; + testSuite->failCount = 0; +} + +CuSuite* CuSuiteNew() +{ + CuSuite* testSuite = CU_ALLOC(CuSuite); + CuSuiteInit(testSuite); + return testSuite; +} + +void CuSuiteFree(CuSuite* testSuite) +{ + int i; + for (i = 0 ; i < testSuite->count ; ++i) + { + CuTestFree( testSuite->list[i] ); + } + free( testSuite ); +} + +void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase) +{ + assert(testSuite->count < MAX_TEST_CASES); + testSuite->list[testSuite->count] = testCase; + testSuite->count++; +} + +void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2) +{ + int i; + for (i = 0 ; i < testSuite2->count ; ++i) + { + CuTest* testCase = testSuite2->list[i]; + CuSuiteAdd(testSuite, testCase); + } +} + +void CuSuiteRun(CuSuite* testSuite) +{ + int i; + for (i = 0 ; i < testSuite->count ; ++i) + { + CuTest* testCase = testSuite->list[i]; + CuTestRun(testCase); + if (testCase->failed) { testSuite->failCount += 1; } + } +} + +void CuSuiteSummary(CuSuite* testSuite, CuString* summary) +{ + int i; + for (i = 0 ; i < testSuite->count ; ++i) + { + CuTest* testCase = testSuite->list[i]; + CuStringAppend(summary, testCase->failed ? "F" : "."); + } + CuStringAppend(summary, "\n\n"); +} + +void CuSuiteDetails(CuSuite* testSuite, CuString* details) +{ + int i; + int failCount = 0; + + if (testSuite->failCount == 0) + { + int passCount = testSuite->count - testSuite->failCount; + char* testWord = passCount == 1 ? "test" : "tests"; + CuStringAppendFormat(details, "OK (%d %s)\n", passCount, testWord); + } + else + { + if (testSuite->failCount == 1) + CuStringAppend(details, "There was 1 failure:\n"); + else + CuStringAppendFormat(details, "There were %d failures:\n", testSuite->failCount); + + for (i = 0 ; i < testSuite->count ; ++i) + { + CuTest* testCase = testSuite->list[i]; + if (testCase->failed) + { + failCount++; + CuStringAppendFormat(details, "%d) %s: %s\n", + failCount, testCase->name, testCase->message); + } + } + CuStringAppend(details, "\n!!!FAILURES!!!\n"); + + CuStringAppendFormat(details, "Runs: %d ", testSuite->count); + CuStringAppendFormat(details, "Passes: %d ", testSuite->count - testSuite->failCount); + CuStringAppendFormat(details, "Fails: %d\n", testSuite->failCount); + } +} @@ . patch -p0 <<'@@ .' Index: syck/tests/CuTest.h ============================================================================ $ cvs diff -u -r1.1.1.1 -r1.2 CuTest.h --- syck/tests/CuTest.h 17 Oct 2008 18:53:48 -0000 1.1.1.1 +++ syck/tests/CuTest.h 17 Oct 2008 20:03:39 -0000 1.2 @@ -1,84 +1,84 @@ -#ifndef CU_TEST_H -#define CU_TEST_H - -#include <setjmp.h> -#include <stdarg.h> - -/* CuString */ - -char* CuStrAlloc(int size); -char* CuStrCopy(char* old); - -#define CU_ALLOC(TYPE) ((TYPE*) malloc(sizeof(TYPE))) - -#define HUGE_STRING_LEN 8192 -#define STRING_MAX 256 -#define STRING_INC 256 - -typedef struct -{ - int length; - int size; - char* buffer; -} CuString; - -void CuStringInit(CuString* str); -CuString* CuStringNew(void); -void CuStringRead(CuString* str, char* path); -void CuStringAppend(CuString* str, char* text); -void CuStringAppendLen(CuString* str, char* text, long length); -void CuStringAppendChar(CuString* str, char ch); -void CuStringAppendFormat(CuString* str, char* format, ...); -void CuStringResize(CuString* str, int newSize); - -/* CuTest */ - -typedef struct CuTest CuTest; - -typedef void (*TestFunction)(CuTest *); - -struct CuTest -{ - char* name; - TestFunction function; - int failed; - int ran; - char* message; - jmp_buf *jumpBuf; -}; - -void CuTestInit(CuTest* t, char* name, TestFunction function); -CuTest* CuTestNew(char* name, TestFunction function); -void CuFail(CuTest* tc, char* message); -void CuAssert(CuTest* tc, char* message, int condition); -void CuAssertTrue(CuTest* tc, int condition); -void CuAssertStrEquals(CuTest* tc, char* expected, char* actual); -void CuAssertIntEquals(CuTest* tc, int expected, int actual); -void CuAssertPtrEquals(CuTest* tc, void* expected, void* actual); -void CuAssertPtrNotNull(CuTest* tc, void* pointer); -void CuTestRun(CuTest* tc); - -/* CuSuite */ - -#define MAX_TEST_CASES 1024 - -#define SUITE_ADD_TEST(SUITE,TEST) CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST)) - -typedef struct -{ - int count; - CuTest* list[MAX_TEST_CASES]; - int failCount; - -} CuSuite; - - -void CuSuiteInit(CuSuite* testSuite); -CuSuite* CuSuiteNew(); -void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase); -void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2); -void CuSuiteRun(CuSuite* testSuite); -void CuSuiteSummary(CuSuite* testSuite, CuString* summary); -void CuSuiteDetails(CuSuite* testSuite, CuString* details); - -#endif /* CU_TEST_H */ +#ifndef CU_TEST_H +#define CU_TEST_H + +#include <setjmp.h> +#include <stdarg.h> + +/* CuString */ + +char* CuStrAlloc(int size); +char* CuStrCopy(char* old); + +#define CU_ALLOC(TYPE) ((TYPE*) malloc(sizeof(TYPE))) + +#define HUGE_STRING_LEN 8192 +#define STRING_MAX 256 +#define STRING_INC 256 + +typedef struct +{ + int length; + int size; + char* buffer; +} CuString; + +void CuStringInit(CuString* str); +CuString* CuStringNew(void); +void CuStringRead(CuString* str, char* path); +void CuStringAppend(CuString* str, char* text); +void CuStringAppendLen(CuString* str, char* text, long length); +void CuStringAppendChar(CuString* str, char ch); +void CuStringAppendFormat(CuString* str, char* format, ...); +void CuStringResize(CuString* str, int newSize); + +/* CuTest */ + +typedef struct CuTest CuTest; + +typedef void (*TestFunction)(CuTest *); + +struct CuTest +{ + char* name; + TestFunction function; + int failed; + int ran; + char* message; + jmp_buf *jumpBuf; +}; + +void CuTestInit(CuTest* t, char* name, TestFunction function); +CuTest* CuTestNew(char* name, TestFunction function); +void CuFail(CuTest* tc, char* message); +void CuAssert(CuTest* tc, char* message, int condition); +void CuAssertTrue(CuTest* tc, int condition); +void CuAssertStrEquals(CuTest* tc, char* expected, char* actual); +void CuAssertIntEquals(CuTest* tc, int expected, int actual); +void CuAssertPtrEquals(CuTest* tc, void* expected, void* actual); +void CuAssertPtrNotNull(CuTest* tc, void* pointer); +void CuTestRun(CuTest* tc); + +/* CuSuite */ + +#define MAX_TEST_CASES 1024 + +#define SUITE_ADD_TEST(SUITE,TEST) CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST)) + +typedef struct +{ + int count; + CuTest* list[MAX_TEST_CASES]; + int failCount; + +} CuSuite; + + +void CuSuiteInit(CuSuite* testSuite); +CuSuite* CuSuiteNew(); +void CuSuiteAdd(CuSuite* testSuite, CuTest *testCase); +void CuSuiteAddSuite(CuSuite* testSuite, CuSuite* testSuite2); +void CuSuiteRun(CuSuite* testSuite); +void CuSuiteSummary(CuSuite* testSuite, CuString* summary); +void CuSuiteDetails(CuSuite* testSuite, CuString* details); + +#endif /* CU_TEST_H */ @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org