meta, C++




60 Methoden:

/* private: */ BOOL BRCode ::   is_used
/* private: */ BOOL BRCode ::   new_section
/* private: */ BOOL BRCode ::   same_prefix
/* private: */ char BRCode ::   Be
/* private: */ int BRCode ::   pretty
/* private: */ void BRCode ::   callees
/* private: */ void BRCode ::   comma
/* private: */ void BRCode ::   no_Comment
/* private: */ void BRCode ::   param
|
/* public: */ BRCode ::   ~BRCode
/* public: */ BOOL BRCode ::   is_XMLType
/* public: */ BRCode ::   BRCode
/* public: */ void BRCode ::   alle_Getter
/* public: */ void BRCode ::   alle_Namen
/* public: */ void BRCode ::   escBr
/* public: */ void BRCode ::   force
/* public: */ void BRCode ::   keine_Leerzeilen
/* public: */ void BRCode ::   no_choice_1
/* public: */ void BRCode ::   no_choice_2
/* public: */ void BRCode ::   norm_XSD_ns_prefixes_in_dir
/* public: */ void BRCode ::   norm_base
/* public: */ void BRCode ::   nur_noch_ref
/* public: */ void BRCode ::   pretty_PHP
/* public: */ void BRCode ::   show_ALL
/* public: */ void BRCode ::   unions
/* public: */ void BRCode ::   zeige_mehrfachDef
/* public: */ void BRCode ::   catMe
/* public: */ void BRCode ::   cpp_to_htm
/* public: */ void BRCode ::   norm
/* public: */ void BRCode ::   pretty_XML



#define static #include brcode.h : cpp #undef BB #undef BBStr #undef bb #undef bbStr #define BB #define BBStr( x,y,z ) ; #define bb #define bbStr( x,y,z ) ; #ifndef procNestOn #undef BB #undef BBStr #undef bb #undef bbStr #undef LB_ #undef LE_ #undef LE_ret #undef ret #undef ret_ #undef __ #undef ___ #define BB if ( 1 < call_nr || errno ) #define bb if ( 1 < call_nr || errno ) #define BBStr( x,y,z ) { BB traceStr( x,y,z ); } #define bbStr( x,y,z ) { bb traceStr( x,y,z ); } #define __ { bb { printf( "\nLine %i", __LINE__ ); }} #define ___ #define ret_ { __ return ; } #define LE_ __ return ; } #define LE_ret( x ) __ return( x ); } #define ret( x ) { __ return( x ); } #define LB_( x ) { bb printf( "\n-> %s", x ); safe_ut.showSysCalls = 1 ; #endif /* public: */ BRCode :: BRCode ( // ----------------------------------------------------------------------------- ) LB_("BRCode.BRCode") tmp1 = "__1" ; done = false ; commz = 0 ; tmp2 = "__2" ; tmp3 = "__3" ; tmp4 = "__4" ; tmpX = "__X" ; kopf = "\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"><HTML><HEAD>" "\n<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"j2h.css\"></HEAD>" "\n<BODY text=\"#000000\"" "\n LINK=\"#FF6600\" VLINK=\"#FF6600\" ALINK=\"#0000FF\">" "\n<font face=\"Verdena,Arial\" size=2>\n" ; t1 = "\n<table" "\n id=\"Header\" border=0 cellpadding=0 cellspacing=0 width=\"100%\"" "\n <tr><td><center><font size=\"4\">" ; t2 = "\n</font></center></td></tr></table>" ; LE_ /* public: */ BRCode :: ~BRCode ( // ----------------------------------------------------------------------------- ) LB_("BRCode.~BRCode") if ( done ) { unlink( tmp1 ); ok unlink( tmp2 ); ok unlink( tmp3 ); ok unlink( tmp4 ); ok unlink( tmpX ); ok } LE_ /* private: */ BOOL BRCode :: is_used /* ----------------------------------------------------------------------------- return BOOL( "name is used in code" ) ----------------------------------------------------------------------------- */ ( char * name // of a concept , char * code // name of the code file ) LB_("BRCode.is_used") rBuffer B( code, "" ); LE_ret(( B.find( 0, name, 0 ) != 0 )) /* public: */ void BRCode :: norm /* ----------------------------------------------------------------------------- Make 'to a pretty version of 'from ----------------------------------------------------------------------------- */ ( char * from // name of input file , char * code_oc , char * code_mc ) LB_("BRCode.norm") str_set such ; BOOL comment = traceAt = 0 ; char4 xx ; *xx = ( uchar )13 ; xx[1] = 0 ; such.insert( "\t" ); such.insert( xx ); such.insert( "\n" ); such.insert( "\"" ); such.insert( "/*" ); such.insert( "*/" ); such.insert( "//" ); such.insert( "{" ); such.insert( "}" ); such.insert( "?z" ); such.insert( "if" ); such.insert( "#" ); such.insert( ":" ); __ rBuffer B( from, "\n|\n" ); B.remember( 100 ); FILE * f = create( tmp1 ); int offset = 0 ; while ( B.find( offset, such, f ) ) { if ( B.z[ B.a ] == (uchar)13 ) { char * c = B.z + B.a - 1 ; char * e = B.z + B.e ; while ( ++c < e ) if ( *c == (uchar)13 ) *c = '\n' ; if ( B.ateof && e <= c ) break ; offset = 0 ; } B.getmore( 18000, "" ); if ( B.ateof ) B.z[ B.e ] = '\n' ; char * c = B.z + B.a ; offset = 1 ; // okAt = -1000 ; if At( c, "::" ) then { offset = 2 ; continue ; } if At( c, "\n/*\n *\n * Copyright" ) then { fprintf( f, "\n----------------" "------------------------------------------------------" ); rB_( B, 10, "\n */", 0 ); c = B.z + B.a ; } if ( *c == '\n' ) then { if ( comment == 2 ) { char * x = c ; skip_space( x ); comment = ( *x == '/' ); if ( comment ) then { if At( x, "//" ) then { B.a = x + 3 - B.z ; comment = 2 ; } else B.a = x - B.z ; } else fprintf( f, "\n| " ); } if ( comment ) { offset = 0 ; fprintf( f, "\n| " ); c++ ; skip_space( c ); B.a = c - B.z ; if (0) {{{ char * e = c ; while ( *e != '\n' && not_At( e, "*/" ) ) e++ ; char m = *e ; *e = 0 ; fprintf( f, "%s", c ); *e = m ; c = e ; B.a = e - B.z ; }}} if At( c, "*/" ) then { B.a = c+2 - B.z ; fprintf( f, "\n/." ); comment = 0 ; } esif ( *c++ == '*' ) { B.a = (( *c == '\n' )? c : c+1 ) - B.z ; } } else { skip_space( c ); fprintf( f, "\n" ); offset = 0 ; B.a = c - B.z ; } } esif At( c, "_(" ) { c += 2 ; skip_space( c ) char200 xx ; s_( xx, "{ if ( testAt ) test( %i ); }", decNr( c ) ); uint n = strlen( xx ); B.a -= n ; memcpy( B.z + B.a, xx, n ); offset = 0 ; } esif ( *c == '{' || *c == '}' ) { if(0) if At( c, "{_(" ) { traceAt = true ; *c = '!' ; c++ ; while not_At( c, "; }" ) c++ ; c[2] = '~' ; offset = 0 ; continue ; } if ( c[-1] != '\'' ) { B.a += 1 ; offset = 0 ; fprintf( f, "\n%c\n", *c ); } } esif ( *c == '"' ) { if ( comment ) { *c = '~' ; continue ; } char * e = c ; skip_str( e, B.z + B.e ); char m = *e ; *e = 0 ; fprintf( f, "%s", c ); *e = m ; B.a = e - B.z ; offset = 0 ; } esif At( c, "//" ) { if ( At( c, "//-" ) || At( c, "//##" ) || At( c, "// ZU ERLEDIGEN:" ) || At( c, "//\"" ) ) { rB_( B, 3, "\n", 0 ); offset = 0 ; continue ; } if ( comment == 0 ) { comment = 2 ; fprintf( f, "\n/:" ); } c += 2 ; while ( *c == ' ' ) c++ ; // \n muss bleiben B.a = c - B.z ; offset = 0 ; uint anz = 0 ; --c ; char * m ; while ( *( ++c ) != '\n' ) { if ( *c == '"' ) then { anz++ ; m = c ; } esif ( *c == '{' ) *c = '?' ; esif ( *c == '}' ) *c = '?' ; } // if ( anz % 2 ) B.a = c - B.z ; // unbalanced strings if ( anz % 2 ) *m = ' ' ; // unbalanced strings } esif At( c, "/*" ) { if At( c, "/**/" ) { B.a += 4 ; offset = 0 ; continue ; } char * x = c+2 ; while ( *x == '*' ) x++ ; if ( *x == '/' ) c[2] = '-' ; else { // skip comment that is an old code version: while ( not_in_str( *x, "{}" ) && not_At( x, "*/" ) ) x++ ; if ( *x != '*' ) c[2] = '-' ; } if At( c, "/*-" ) { rB_( B, 3, "*/", 0 ); offset = 0 ; continue ; } while not_space( *( ++c ) ) if At( c, "*/" ) break ; if At( c, "*/" ) { comment = 0 ; B.a += 2 ; offset = 0 ; continue ; } skip_space( c ) comment = 1 ; fprintf( f, "\n/: " ); B.a = c - B.z ; offset = 0 ; continue ; // anstatt: if (0) {{{ char * e = c-1 ; while not_At( ++e, "*/" ) if ( *e == '"' ) *e = '?' ; char m = *e ; *e = 0 ; comment = 1 ; fprintf( f, "\n/: %s", c ); *e = m ; B.a = e - B.z ; offset = 0 ; }}} } esif At( c, "*/" ) { B.a += 2 ; offset = 0 ; fprintf( f, "\n/." ); comment = 0 ; } esif ( comment ) {} esif ( At( c, "if" ) && not_in_name( c[2] ) && space( c[-1] ) ) { char * e = c + 2 ; skip_space( e ) if ( *e != '(' ) continue ; c = e ; fprintf( f, "\nif " ); offset = 0 ; B.a = c - B.z ; e = c ; skip_nest_o_str( e, '(', ')', B.z + B.e ); skip_space( e ) if in_str( *e, "ifwd" ) then { if ( At( e, "if" ) && not_in_name( e[2] ) || At( e, "for" ) && not_in_name( e[3] ) || At( e, "while" ) && not_in_name( e[5] ) || At( e, "do" ) && not_in_name( e[2] ) ) { e[-1] = 0 ; fprintf( f, "\n%s", c ); B.a = e - B.z ; offset = 0 ; } } esif ( *e != '{' && *e != '/' && not_At( e, "then " ) ) { char m = *e ; *e = 0 ; fprintf( f, "%s\n{\n", c ); c = e ; *e = m ; Loop { if ( *e == '\"' ) skip_str( e, B.z + B.e ); if ( *e == '(' ) { skip_nest_o_str( e, '(', ')', B.z + B.e ); } if ( *e == ';' || *e == '\n' || At( e, " else" ) ) then break ; else e++ ; } if ( *e == ';' ) e++ ; *e++ = 0 ; fprintf( f, "%s\n}\n", c ); skip_space( e ); offset = 0 ; B.a = e - B.z ; } esif ( *e == '{' ) { *e = 0 ; fprintf( f, "%s", c ); B.a = e+1 - B.z ; fprintf( f, "\n{\n" ); } } esif ( At( c, "?z" ) && space( c[-1] ) ) { to_( c, '\n' ); B.a = c - B.z ; } esif ( *c == '?' ) { offset = 0 ; if At( c, "?? " ) { B.a += 3 ; fprintf( f, " 0 != " ); } esif At( c, "?+ " ) { B.a += 3 ; fprintf( f, " null != " ); } esif At( c, "?- " ) { B.a += 3 ; fprintf( f, " null == " ); } else offset = 1 ; } esif At( c, "::" ) { offset = 3 ; continue ; } esif ( *c == ':' && c[1] == ' ' ) { fprintf( f, ": " ); c++ ; while ( *c == ' ' ) c++ ; B.a = c - B.z ; offset = 0 ; } esif ( *c == '\t' ) *c = ' ' ; esif At( c, "#line" ) { rB_( B, 1, "\n", 0 ); offset = 0 ; } esif At( c, "#define" ) { char * e = c ; while ( *e != '\n' && not_At( e, "//" ) ) e++ ; e-- ; while ( *( ++e ) != '\n' ) if ( *e == '"' ) *e = ' ' ; *e = 0 ; fprintf( f, "%s", c ); B.a = e - B.z ; *e = '\n' ; offset = 0 ; } esif At( c, "#if" ) { to_space( c ); while ( *c == ' ' ) c++ ; if ( At( c, "0" ) || At( c, "_DEBUG" ) ) then { int k = 1 ; while ( B.find( 1, "#", 0 ) ) { c = B.z + B.a ; if At( c, "#ifdef" ) then { k++ ; } esif At( c, "#endif" ) { if ( k == 1 ) then { rB_( B, 4, "\n", 0 ) break ; } else k-- ; } } } } esif At( c, "#endif" ) { rB_( B, 4, "\n", f ); offset = 0 ; } } close( f ); no_Comment( tmp1, tmp2 ); char1000 htm ; s_( htm, "%s.htm", code_mc ); pretty( 1, tmp1, code_mc ); cpp_to_htm( htm, code_mc ); if not_At( code_mc, "alles." ) pretty( 0, tmp2, code_oc ); done = true ; LE_ /* private: */ void BRCode :: no_Comment /* ----------------------------------------------------------------------------- Delete from the code ALL comment. ----------------------------------------------------------------------------- */ ( char * from , char * to ) LB_("BRCode.no_Comment") rBuffer B( from, "" ); FILE * f = create( to ); int offset = 0 ; while ( B.find( offset, "\n", f ) ) { char * c = B.z + B.a ; skip_space( c ); B.z[ B.e ] = '\n' ; offset = 1 ; if ( At( c, "| " ) || At( c, "/:" ) || At( c, "/." ) ) { to_( c, '\n' ); B.a = c - B.z ; offset = 0 ; } } close( f ); LE_ /* private: */ char BRCode :: Be // ----------------------------------------------------------------------------- ( char * s ) LB_("BRCode.Be") while space( *( --s ) ){} LE_ret( *s ) /* private: */ int BRCode :: pretty /* ----------------------------------------------------------------------------- Make 'to a pretty version of 'from Precondition: '{' or '}' are always following immediately a '\n'. ----------------------------------------------------------------------------- */ ( BOOL mitZNr , char * from // name of input file , char * to ) LB_("BRCode.pretty") char * code = to ; int N = -1 ; char * x3 = "" ; path indent ; char *x = indent + L_path - 1 ; char * ee = x ; *x-- = 0 ; while ( indent <= x ) *x-- = ' ' ; int nest_0 = 3 ; // ----------------------------------------------------------------------------- { BOOL comment = 0 ; str_set such ; such.insert( "else" ); such.insert( "!= null" ); // such.insert( "null" ); such.insert( "\n" ); such.insert( "?z" ); such.insert( "\"" ); such.insert( "/:" ); such.insert( "/." ); such.insert( "( )" ); such.insert( "create or replace PACKAGE" ); such.insert( "EXEC SQL OPEN" ); rBuffer B( from, "" ); FILE * f = create( tmp4 ); int offset = 0 ; while ( B.find( offset, such, f ) ) { B.getmore( 10000, "" ); B.z[ B.e ] = '\n' ; offset = 0 ; char * c = B.z + B.a ; if ( *c == '"' ) then { if ( comment || c[-1] == '\'' || escaped( c ) ) { offset = 1 ; continue ; } char * e = c ; skip_str( e, B.z + B.e ); offset = e-c ; continue ; } esif ( *c == '\n' ) { while ( c[1] == '\n' ) c++ ; if ( B.z + B.e <= c ) break ; B.a = c - B.z ; offset = 1 ; comment = comment && ( c[1] == '|' ); char * x = c ; char * e = c + 120 ; char * n = 0 ; while ( ++x < e ) { if ( *x == ' ' ) n = x ; if ( *x == '"' ) skip_str( x, B.z + B.e ); if ( *x == '\n' ) { n = 0 ; break ; } } if ( n ) *n = '\n' ; } esif ( At( c, "?z" ) && space( c[-1] ) ) { to_( c, '\n' ); B.a = c - B.z ; } esif ( *c == '/' ) { comment = ( c[1] == ':' ); commz++ ; memcpy( B.z + B.a, "| ", 2 ); while ( comment ) { B.find( 1, "\n", f ); commz++ ; comment = ( B.z[ B.a+1 ] == '|' ); } } esif At( c, "( )" ) { to_( c, ')' ); B.a = c - B.z ; fprintf( f, "(" ); } esif At( c, "else" ) { if ( space( c[-1] ) && space( c[4] ) ) then { c += 5 ; skip_space( c ) if not_in_str( *c, "{ifw" ) then { char * e = c ; to_( e, ';' ) *e = 0 ; fprintf( f, "\nelse\n{\n%s;\n}\n", c ); B.a = e+1 - B.z ; } else offset = 1 ; } else offset = 1 ; } esif At( c, "!= null" ) { c += 7 ; skip_space( c ); B.a = c - B.z ; } esif At( c, "create or replace PACKAGE" ) { rB_( B, 10, "AS", 0 ); B.a += 2 ; } esif At( c, "EXEC SQL OPEN" ) { rB_( B, 1, ";", 0 ); B.a += 1 ; } else fErr } close( f ); } // ----------------------------------------------------------------------------- str_set store ; char300 Class ; *Class = 0 ; char buffer[ 4000 ]; #define zzz_ sprintf( buffer, // fErr1( tmp4 ) __ rBuffer B( tmp4, "" ); B.remember( 100 ); FILE * f = create( tmp3 ); int nest = nest_0 ; int k = 0 ; int rec = 1 ; Btree toc ; int offset = 1 ; char z1 = 0 ; int nestPlus = 0 ; BOOL extra_Line = 0 ; BOOL import = 0 ; BOOL cases = 0 ; BOOL peter = 0 ; BOOL SQL = 0 ; int nestA = 0 ; BOOL Z = false ; char c_alt = 0 ; int spac = 0 ; char x33 = 0 ; BOOL after = 0 ; char * file = tmp4 ; if substr( "testAt_code", to ) mitZNr = 0 ; if ( mitZNr ) fprintf( f, "\n%5i.%i%s", rec, k, ee - nest_0 ); BOOL LB = false ; char * c = B.z + B.a ; skip_space( c ); B.a = c - B.z ; while ( B.find( offset, "\n", f ) ) { if ( k < 0 ) fErr1( tmp3 ) B.getmore( 8000, "XX" ); int nes1 = nest ; offset = 1 ; int kk = 0 ; rec = rec + 1 - peter ; c = B.z + B.a ; skip_space( c ) if ( c[2] == '_' ) { if At( c, "LB_" ) LB = 1 ; else if At( c, "LE_" ) LB = 0 ; } if At( c, "file: " ) { char * e = c ; to_( e, '\n' ) *e = 0 ; printf( "\n%s", c ); if ( k ) { m_errMess "System: not enough closing } brackets in \n%s" m_ file, ret_error } file = store.take( c ); *e = '\n' ; } if ( k == 0 && LB == 0 ) { if ( At( c, "return" ) || At( c, "if " ) || At( c, "for " ) || At( c, "else" ) ) then { { m_errMess "System: see %s: Too many closing brackets in \n%s" m_ tmp3, file, ret_error } } } if At( c, "| *" ) // Begin of Java Doc Comment { to_( c, '\n' ); B.a = c - B.z ; skip_space( c ) } if ( nest && At( c, "------" ) && !k ) nes1 = nest = nest_0 ; if ( x33 == '}' && *c == '#' ) fprintf( f, "\n\n" ); x33 = *c ; if At( c, "extern " ) fprintf( f, "\n" ); else // if At( c, "#define" ) // if At( c, "#else" ) if At( c, "#ifdef" ) fprintf( f, "\n" ); if At( c, "#if" ) { k++ ; nes1 = nest += 3 ; } else if At( c, "#endif" ) { k-- ; nes1 = nest - 3 ; kk = 3 ; } if ( k < 0 ) fErr1( tmp3 ) if ( after ) fprintf( f, "\n" ); if At( c, "#endif" ) after = true ; else after = false ; if ( ! peter ) { if ( *c == '{' ) { k++ ; nes1 = nest += 3 ; } if ( *c == '}' ) { k-- ; nes1 = nest - 3 ; kk = 3 ; } if ( k < 0 ) fErr1( tmp3 ) } else { // peter comment /: ... :/ has a nesting of its own, though it is // not yet supported } if At( c, "EXEC SQL BEG" ) nes1 = nest + 5 ; esif At( c, "EXEC SQL END" ) nes1 = nest -= 5 ; nest = max( nest, 0 ); if ( nest < nestA || extra_Line || is( c, "typedef", 8 ) || is( c, "while" , 5 ) && z1 != '{' || is( c, "for" , 5 ) && z1 != '{' ) then fprintf( f, "\n" ); extra_Line = 0 ; if ( *c == ':' ) fprintf( f, " " ); if ( At( c, "void" ) || At( c, "int" ) ) { char * e = c ; while not_space( *e ) e++ ; skip_space( e ) while in_name ( *e ) e++ ; skip_space( e ) if ( *e == '(' ) fprintf( f, "\n\n" ); } if At( c, "WHERE" ) x3 = "" ; esif At( c, "FROM" ) x3 = "" ; esif At( c, "INTO" ) x3 = "" ; esif At( c, "ORDER BY" ) x3 = "" ; esif At( c, "END " ) x3 = "" ; esif At( c, ";" ) x3 = "" ; esif At( c, "{" ){ x3 = "" ; c[1] = '\n' ; } int u = At( c, ":r_" )? 3 : 0 ; B.a = c - B.z ; nest = nes1 ; if ( N <= rec ) { if ( c_alt != '{' ) { BOOL extra = 0 ; if At( c, "statement" ) extra = 1 ; if At( c, "public:" ) extra = 1 ; if At( c, "try " ) extra = 1 ; if At( c, "package" ) extra = 1 ; if At( c, "protected:" ) extra = 1 ; if At( c, "private:" ) extra = 1 ; if At( c, "PROCEDURE" ) extra = 1 ; if At( c, "---------" ) extra = 1 ; if ( extra ) fprintf( f, "\n" ); } if ( c_alt != '|' && c_alt != '{' && is( c, "| ", 2 ) ) fprintf( f, "\n" ); if ( At( c, "if " ) || At( c, "for " ) ) { char * x = c-1 ; while space( *x ) x-- ; if in_str( *x, "};" ) fprintf( f, "\n" ); } strcpy( B.z + B.e, "\n:\n:" ); if ( new_section( c, kk, mitZNr ) ) fprintf( f, "\n" ); { char * x = c ; to_( x, '\n' ); skip_space( x ) if At( x, "switch" ) fprintf( f, "\n" ); } if ( Z && in_name( *c ) ) then { Z = false ; fprintf( f, "\n" ); } else Z = ( nest < nestA ); if ( ee - nest - u - kk < indent ) fErr // too deep nesting if ( nest < 0 ) fErr4( nest, u, kk, tmp3 ) char * spaces = ee - nest - u - kk ; if ( spaces < indent || indent + L_path < spaces ) { fErr4( nest, u, kk, tmp3 ) } if ( mitZNr ) then { char * e = B.z + B.a ; to_( e, '\n' ) if ( peter || e[-1] == '\\' ) then { zzz_ "\n%7s%s", "", spaces ); } else zzz_ "\n%5i.%i%s%s", rec, k, x3, spaces - spac ); } else { if ( peter ) then { zzz_ "\n%7s%s", "", spaces + 3 ); } else zzz_ "\n%s%s", x3, spaces + 3 - spac ); } nestA = nest ; if At( c, "EXEC" ) SQL = 1 ; } nest += nestPlus ; char * o = c ; while not_in_str( *o, ";:\n<" ) o++ ; if At( o, "::" ) then { char * e = o ; to_( e, '\n' ) *e = 0 ; char * m = o-1 ; while space( *m ) m-- ; while not_space( *m ) m-- ; m++ ; if alpha( *m ) toc.ourIns( 'e', m, rec, int ); if At( o, "const " ) o += 6 ; if ( ! k ) { while not_space( *o ) o-- ; o++ ; if ( *o == '*' ) o++ ; toc.ourIns( 'e', o, rec, int ); } *e = '\n' ; } esif At( c, "PROCEDURE" ) { nes1 = nest += 5 ; char * e = c + 9 ; skip_space( e ); to_( e, '\n' ) *e = 0 ; toc.ourIns( 'e', c, rec, int ); *e = '\n' ; } esif At( c, "static " ) { char * e = c + 5 ; to_( e, '\n' ) *e = 0 ; char * x1 = c + 6 ; skip_space( x1 ); char * x2 = x1 ; to_space( x2 ); if ( x2 < e ) then { *x2++ = 0 ; skip_space( x2 ); if ( e < x1 ) fErr if ( e < x2 ) fErr } else x2 = e ; char800 st ; s_( st, "static %*s %s", -8, x1, x2 ); x2[-1] = ' ' ; char * x3 = in_str( '=', st ); if ( ! x3 ) x3 = in_str( '<', st ); if ( ! x3 ) x3 = in_str( '(', st ); if ( x3 ) { char m = *( ++x3 ); *x3 = 0 ; if ( 30 < strlen( x2 ) ) x2 = "" ; s_( st, "static %*s func %s", -8, x1, x2 ); *x3 = m ; } toc.ourIns( 'e', st, rec, int ); *e = '\n' ; } esif At( c, "class " ) { char * n = c + 5 ; skip_space( n ) char * e = n ; skip_name ( e ) char merke = *e ; *e = 0 ; path x ; s_( x, "Class: %s", n ); *e = merke ; toc.ourIns( 'e', x, rec, int ); } esif ( ! peter && ( k == 0 || At( c, "int " ) || At( c, "void " ) )) { char * e = c ; if alpha( *e ) { char * n = e ; while not_in_str( *n, "(\n" ) n++ ; char merke = *n ; *n = 0 ; BOOL to_toc = 1 ; if ( merke == '\n' ) { char * m = n+1 ; skip_space( m ); to_toc = ( *m == '(' ); } char * x = e ; uchar A,w ; A = 0 ; while ( *(++x) ) if ( *x != '*' && not_in_name( *x ) ) { A++ ; w = *x ; } if ( 1 < A ) to_toc = false ; if At( e, "class " ) to_toc = 1 ; if At( e, "const " ) to_toc = 0 ; if ( to_toc ) toc.ourIns( 'e', e, rec, int ); *n = merke ; } } if not_At( c, "import" ) then { if ( import ) fprintf( f, "\n" ); import = 0 ; } else import = 1 ; nestPlus = 0 ; if ( *c == 'a' ) { if At( c, "abstract public" ) memcpy( c, "public abstract" , 15 ); if At( c, "abstract protected" ) memcpy( c, "protected abstract", 18 ); if At( c, "abstract private" ) memcpy( c, "private abstract" , 16 ); } if At( c, "case " ) then { if ( Be( c ) != '{' ) fprintf( f, "\n" ); } esif At( c, "/:" ) { peter = 0 ; c[1] = ':' ; } // peter = 1 esif At( c, "/." ) { peter = 0 ; c[1] = '.' ; } esif ( At( c, "PARAMETERS" ) || At( c, "RETURNS" ) || At( c, "PROCESSING" ) || At( c, "TAG" ) || At( c, "VALUE SOURCE" ) || At( c, "NOTES" ) || At( c, "class" ) || At( c, "statement" ) ) { fprintf( f, "\n%10s", "" ); } esif At( c, "PROCEDURE" ){ x3 = " " ; param( c ); nest = nest_0 ; k = 0; } esif At( c, "SELECT" ){ x3 = " " ; comma( c, B.z + B.e ); } esif At( c, "INTO" ) x3 = " " ; esif At( c, "EXEC" ) x3 = " " ; esif At( c, "FROM" ) x3 = " " ; esif At( c, "WHERE" ) x3 = " " ; esif At( c, "ORDER BY" ){ x3 = " " ; c[8] = '\n' ; } esif ( k == 0 && At( c, "package" ) || k == 0 && At( c, "public " ) || k == 0 && At( c, "protected " ) || k == 0 && At( c, "private " ) || k == 0 && At( c, "abstract " ) || k == 0 && At( c, "FILE" ) ) { // k = {} nesting depth: char * e = c ; while not_in_str( *e, ";(\n" ) e++ ; char m = *e ; *e = 0 ; if At( c, "FILE" ) then { if ( k ) fErr } esif not_At( c, "package" ) { if At( c, "abstract" ) { c += 8 ; skip_space( c ); } char * x = c ; to_space( x ); skip_space( x ) if At( x, "final" ) { x += 6 ; skip_space( x ) } if At( x, "abstract" ) { x += 8 ; skip_space( x ) } if ( At( x, "class " ) || At( x, "interface" ) ) { char M = *x ; to_space( x ); skip_space( x ) char * e = x ; to_space( e ) char m = *e ; *e = 0 ; s_( Class, "%c,%s", M, x ); *e = m ; } } else *Class = 0 ; *e = m ; } esif ( k == 1 && At( c, "public " ) || k == 1 && At( c, "protected " ) || k == 1 && At( c, "private " ) || k == 1 && At( c, "abstract " ) ) { if ( ! *Class ) fErr char * e = c ; while not_in_str( *e, ";(\n" ) e++ ; char m = *e ; *e = 0 ; char300 x ; s_( x, "%s: %s", Class, c ); toc.ourIns( 'e', x, rec, int ); *e = m ; } if ( B.ateof && B.e <= B.a ) break ; if ( nest != nest_0 + 3 * k && ! cases && ! *x3 ) { // traceStr( "EEE", c, 100 ); fErr3( nest_0, nest, k ) } if ( k < 0 ) { // showStr( "EEE", c, 100 ); fErr3( B.a, B.e, B.ateof ) B.z[ B.e ] = B.z[ B.a + 100 ] = 0 ; fprintf( f, "\n%s", B.z + B.a ); { m_errMess "System: see %s: Too many closing brackets in \n%s" m_ tmp3, file, ret_error } } c_alt = *c ; if At( c, "| " ) { if not_space( c[2] ) { c-- ; memcpy( c, "| ", 2 ); B.a = c - B.z ; } if ( c_alt != '|' ) fprintf( f, "\n" ); } if At( c, "throws" ) { char * x = c + 7 ; while ( *x != ';' && *x != '{' ) x++ ; extra_Line = ( *x == ';' ); } z1 = *c ; B.a = c - B.z ; to_( c, '\n' ) c-- ; spac = ( *c == '(' )? 3 : 0 ; fprintf( f, buffer ); } if ( k ) then { { m_errMess "System: see %s: Not enough closing brackets in \n%s" m_ tmp3, file, ret_error } } fprintf( f, "\n\n // end of Code\n" ); codez = rec - 1 ; if ( mitZNr ) { fprintf( f, "\n\n Table of Contents:" ); path K ; strcpy( K, "xxxx" ); store_256 st ; Surr s = toc.GetFirst( st ); char m = ' ' ; while ( s ) { if ( *st.k != m ) { m = *st.k ; fprintf( f, "\n" ); } if not_At( st.k, K ) fprintf( f, "\n" ); strcpy( K, st.k ); char * x = K ; while ( *x && *x != '(' ) x++ ; *x = 0 ; x = K ; if not_is_( K, "X" ) { fprintf( f, "\n%10i _: %s", *(( int * ) st.c ), K ); } while ( *x && *x != ':' ) x++ ; x[2] = 0 ; char * ee = in_str( ' ', K ); if ( ! ee ) ee = in_str( '_', K ); if ( ee ) *ee = 0 ; s = toc.Next( st ); while ( s && in_str( '"', st.k ) ) s = toc.Next( st ); } fprintf( f, "\n\nend of toc\n" ); } close( f ); if ( ! mitZNr ) { if ( 0 && substr( "testAt_code", to ) ) then { f = create( to ); B.open_rBuffer( tmp3, "" ); while ( B.find( 0, "! _(", f ) ) { char * c = B.z + B.a ; *c = '{' ; to_( c, '~' ) *c = '}' ; } close( f ); Unlink( tmp3 ); printf( "\no k - pretty testAt_code = %s\n", to ); exit( 0 ); } else S_ "copy %s %s", tmp3, to _Do ret( 0 ) } // ----------------------------------------------------------------------------- store_256 st ; Surr s ; char m ; str_set funcs ; Btree funcVers ; Btree funcNames ; B.open_rBuffer( tmp3, "" ); f = create( tmpX ); if ( mitZNr ) { path such ; path K ; strcpy( K, "xxxx" ); fprintf( f, "\n" "\n %s" "\n Table of Contents (can also be found on the last page):" "\n" // // // // // // "\n" , code ); store_256 st ; Surr s = toc.GetFirst( st ); char m = ' ' ; while ( s ) { if ( *st.k != m ) { m = *st.k ; fprintf( f, "\n" ); } if not_At( st.k, K ) fprintf( f, "\n" ); strcpy( K, st.k ); char * x = K ; while ( *x && *x != '(' ) x++ ; *x = 0 ; x = K ; if not_is_( K, "X" ) { if ( *K && not_space( *K ) && *( eos( K ) - 1 ) != ')' ) fprintf( f, "\n%10i :_ %s", *(( int * ) st.c ), K ); } path nn ; strcpy( nn, K ); char * ee = in_str( ' ', K ); if ( ! ee ) ee = in_str( '_', K ); if ( ee ) *ee = 0 ; while ( *x && *x != ':' ) x++ ; x[2] = 0 ; char * e = nn + st.k_L - 1 ; while ( nn <= e && space( *e ) ) e-- ; e[1] = 0 ; while ( nn <= e && not_space( *e ) && *e != ':' ) e-- ; e++ ; if ( nn < e && *e && e[ strlen(e)-1 ] != ';' ) { funcVers.StrIns( 'e', nn, "" ); if ( *e == '*' ) e++ ; if alpha( *e ) { s_( such, "%i.0", *(( int * ) st.c ) ); funcs.insert( such ); funcNames.StrIns( 'e', such, e ); s_( such, "%s(", e ); funcs.insert( such ); } } s = toc.Next( st ); while ( s && in_str( '"', st.k ) ) s = toc.Next( st ); } fprintf( f, "\n\n\n" ); } if ( ! funcs.cardinality() ) funcs.insert( "-- no funcs --" ); B.find( 0, "MODULE", f ); while ( B.find( 1, "\n", f ) ) { if not_is( B.z + B.a + 6, ".0", 2 ) continue ; if is( B.z + B.a + 11, " ", 2 ) continue ; B.getmore( 4000, "" ); char * c = B.z + B.a + 10 ; while not_in_str( *c, "(\n" ) c++ ; if ( *c == '(' && c[1] != ')' ) { *c = 0 ; fprintf( f, "\n%s\n%20s(", B.z + B.a, "" ); while ( *c != ')' ) { c++ ; skip_space( c ) char * e = c ; while not_in_str( *e, ",)" ) { if ( *e == '\n' ) memcpy( e, " ", 8 ); if ( *e == '(' ) to_( e, ')' ) e++ ; } char merke = *e ; if digit( *c ) { to_( c, ' ' ); skip_space( c ); } *e = 0 ; fprintf( f, "\n%20s%s", "", c ); c = ( merke == ',' )? e+1 : e ; *e = merke ; } to_( c, '\n' ); B.a = c - B.z ; fprintf( f, "\n%20s)", "" ); } } // ------------------------------------------------- see how proc calls proc: if ( 0 ) // macht in JAVA keinen Sinn { fprintf( f, "\n" "\n How the specified Methods do call each other (in which line" " the call occurs):\n\n" ); __ B.open_rBuffer( tmp3, "" ); B.remember( 300 ); Btree calls ; path proc ; *proc = 0 ; match_rec * mr ; while ( mr = B.find( 1, funcs, 0 ) ) { char * c = B.z + B.a ; // showStr( "AAA.func", c, 30 ); char * e = c ; if in_str( *c, "123456789" ) then { store_256 st ; if ( ! funcNames.Get( mr -> str, st ) ) fErr s_( proc, "%s", st.c ); path x ; s_( x, "%s: [%s]", proc, mr -> str ); calls.StrIns( 'e', x ); } else { char * x = c ; while ( *x != '.' ) x-- ; if At( x, ".0 " ) continue ; while ( *c == '*' ) c++ ; if ( *c != '_' && not_alpha( *c ) ) { showStr( "--EEE", c, 100 ); fErr continue ; } to_( e, '(' ) e[1] = 0 ; char * z = e ; while ( *e != '.' || not_digit( e[1] ) ) e-- ; *e-- = 0 ; while digit( *e ) e-- ; char * znr = e+1 ; if ( *proc ) { c[ strlen(c) - 1 ] = 0 ; path aufruf ; s_( aufruf, "%s:%s: %s", proc, c, znr ); // calls.StrIns( 'i', aufruf ); } } } char em[ 1001 ] ; char * e = em + 1000 ; *e-- = 0 ; while ( em <= e ) *( e-- ) = ' ' ; char * spaces = em + 1000 - 7 ; store_256 st ; Surr s = calls.GetFirst( st ); while ( s ) { path caller ; strcpy( caller, st.k ); Btree schon ; char * x = caller ; to_( x, ':' ) x[1] = 0 ; if ( x[2] == '[' ) { fprintf( f, "\n .\n\n - %s %s\n", caller, x+2 ); callees( f, spaces, st.k, calls, schon ); } s = calls.Getmin_GR( st, st.k ); // } } // ----------------------------------------------------------------------------- int mL = 0 ; unlink( tmp1 ); // tmp2 muss weiter existieren unlink( tmp4 ); B.open_rBuffer( tmp3, "" ); match_rec * mr ; printf( "\nDas kann dauern ..." ); while ( mr = B.find( 1, funcs, 0 ) ) { if ( B.z[ B.a ] == '.' ) { char * c = B.z + B.a ; *c-- = 0 ; while digit( *c ) c-- ; char * func = mr -> str + 5 ; store_256 st ; Surr s = funcVers.Get( func, st ); if ( ! s ) fErr1( func ) path defs ; s_( defs, "%s, %s", st.c, c+1 ); funcVers.StrIns( 'e', func, defs ); int L = strlen( defs ); if ( mL < L ) mL = L ; } } printf( "\nMethod Version Declarations:\n" ); fprintf( f, "\nMethod Version Declarations:\n" ); s = funcVers.GetFirst( st ); m = ' ' ; while ( s ) { if ( *st.k != m ) { m = *st.k ; fprintf( f, "\n" ); } if ( *st.c ) fprintf( f, "\n %*s : %s", mL, st.c + 2, st.k ); s = funcVers.Next( st ); } // ----------------------------------------------------------------------------- close( f ); // ----------------------------------------------------------------------------- S_ "grep == %s > __const", tmp3 _Do B.open_rBuffer( tmpX, "" ); f = create( tmp4 ); while ( B.find( 1, "!!-", f ) ) { char * c = B.z + B.a ; if ( c[3] == '|' ) memcpy( c, " ||", 4 ); if ( c[3] == '&' ) memcpy( c, " &&", 4 ); } fprintf( f, "\n\n\nThe following lines contain values that should have a name:\n" ); __ B.open_rBuffer( "__const", "\n\n" ); B.remember( 200 ); while ( B.find( 1, "==", 0 ) ) { char * c = B.z + B.a ; char * n = c + 2 ; skip_space( n ) if digit( *n ) { while ( *c != '\n' ) { if At( c, "!!-|" ) memcpy( c, " ||", 4 ); if At( c, "!!-&" ) memcpy( c, " &&", 4 ); c-- ; } char * s = c ; while in_str( *s, "0123456789 .\n" ) s++ ; if ( *s == '|' ) continue ; // was comment char * e = n ; while digit( *e ) e++ ; char merke = *e ; *e = 0 ; if ( not_is_( n, "0" ) && not_is_( n, "1" ) ) { *e = merke ; to_( e, '\n' ) *e = 0 ; fprintf( f, "\n\n%s", c ); // ???? \ = \n ??? *e = '\n' ; } } } fprintf( f, "\n\nend of List of unnamed Constants.\n" ); close( f ); // ----------------------------------------------------------------------------- B.open_rBuffer( tmp4, "" ); f = create( to ); while ( B.find( 1, "p", f ) ) { char * c = B.z + B.a ; // if At( c, "public " ) { B.a += 6 ; // esif At( c, "protected " ) { B.a += 9 ; // esif At( c, "private " ) { B.a += 7 ; } close( f ); LE_ret( rec ) /* public: */ void BRCode :: cpp_to_htm /* ----------------------------------------------------------------------------- present *.cpp in form of *.htm |---------------------------------------------------------------------------- */ ( char * to , char * from ) LB_("BRCode.cpp_to_htm") printf( "\ncreate %s ...", to ); Btree hotNr ; str_set such ; such.insert( "\"" ); such.insert( ":" ); such.insert( "\n" ); such.insert( "<" ); such.insert( "| " ); such.insert( "// end of code" ); __ rBuffer B( from, "\n" ); int offset = 0 ; B.remember( 20 ); char * c = from + strlen( from ) - 5 ; *c = 0 ; while ( *c != '/' ) c-- ; FILE * f = create( to ); fprintf( f,"<a name=top></a>%s" "\n%s%s%s<pre ID=\"Classes\"><font size=2>" , kopf, t1, c+1, t2 ); char * className[20] ; className[0] = "" ; BOOL prot = 0 ; uint statics = 0 ; uint depth = 0 ; char * atClass = "" ; char * toptoc = "top" ; rB_( B, 1, "Table of", f ) rB_( B, 1, "\n" , f ) rB_( B, 1, "\n" , f ) fprintf( f, "\n <a href=#classes>classes are ...</a>\n" ); fprintf( f, "\n <a href=#statics>static are ...</a>\n" ); fprintf( f, "\n <a href=#unnamed>hard-coded are ...</a>\n" ); BOOL nnn = false ; while ( B.find( offset, such, f ) ) { B.getmore( 5000, "" ); char * c = B.z + B.a ; offset = 0 ; if ( ! c[-1] ) c[-1] = ' ' ; // traceStr( "xxx",c,100 ); if ( *c == '<' ) then { B.a += 1 ; fprintf( f, "<" ); } esif ( *c == (uchar)13 ) { char * e = B.z + B.e ; c-- ; while ( ++c < e ) if ( *c == (uchar)13 ) *c = '\n' ; } esif ( *c == '\n' ) { while At( c, "\n\n\n" ) c++ ; B.a = c - B.z ; char * s = c ; skip_space( s ) if At( s, "5000." ) nnn = true ; if At( s, "// end of Code" ) { B.find( 10, "Method Version Dec", 0 ); fprintf( f, "</pre><a href=#top>Method Version Declarations</a>" "<br><br><a name=classes></a>" "<a href=#top>Classes are:</a><br>" ); KVStore st ; Surr s = classes.GetFirst( st ); char * xx = "             . " ; while ( s ) { fprintf( f, "\n<br>%s<a href=#0%s>%s</a>", xx, st.c, st.k ); s = classes.Next( st ); } fprintf( f, "<br><a name=unnamed></a>" "<br><a href=#top>Hard-coded Constants:</a>" "<pre ID=\"Classes\"><font size=2>" ); B.a += 28 ; continue ; } char * e = s ; while digit( *e ) e++ ; if ( *e == '.' ) { *e = 0 ; if ( hotNr.contains( s ) ) { fprintf( f, "<a href=#0%s>%s</a><a name=%s></a>", s, c, s ); B.a = e - B.z ; } *e = '.' ; if ( B.ateof ) while ( B.z[ B.e-1 ] == '\n' ) B.e-- ; } offset = 1 ; } esif ( *c == '|' ) { rB_( B, 1, "\n", f ) } esif ( *c == '"' ) { if ( c[-1] == '\\' || At( c-1, "'\"'" ) ) { offset = 1 ; continue ; } char * e = ++c ; to_( e, '"' ); while ( e[-1] == '\\' && e[-2] != '\\' ){ e++ ; to_( e, '"' ); } char m = *e ; *e = 0 ; fprintf( f, "\"<font color=#FF00FF>%s</font>\"", c ); B.a = e+1 - B.z ; } esif ( *c == ':' && c[1] == '_' && not_space( c[3] ) ) { char * z = c ; to_( z, '\n' ) *z = 0 ; char * ofClass = ( c[3] == ':' )? 0 : substr( "::", c + 3 ); *z = '\n' ; if ( statics == 0 && At( c, ":_ static " ) ) { statics = 1 ; fprintf( f, "<a name=statics></a>" ); } z = c-2 ; z[1] = 0 ; while ( *z != ' ' ) z-- ; z++ ; hotNr.StrIns( 'e', z ); B.a += 2 ; fprintf( f, "<a name=0%s></a><a href=#%s>:_</a>", z, z ); if ( ofClass ) { while ( ofClass[-1] == ' ' ) ofClass-- ; char m = *ofClass ; *ofClass = 0 ; if ( ! classes.contains( c + 3 ) ) { classes.StrIns( 'e', c + 3, z ); } *ofClass = m ; } } else offset = 1 ; } // ----------------------------------------------------------------------------- int i = -1 ; char * nz = "" ; fprintf( f, "\n</pre>%s%s%s\n", t1, c+1, t2 ); fprintf( f, "\n<br><font size=1>%i neLoCode" "\n+ %i LoComm</font></body></HTML>\n", codez-commz, commz ); close( f ); LE_ /* private: */ void BRCode :: param /* ----------------------------------------------------------------------------- remove param type ----------------------------------------------------------------------------- */ ( char * c ) LB_("BRCode.param") while ( *c != '(' ) c++ ; skip_space( c ); while ( *c != ')' ) { to_space( c ); while ( *c != '\n' ) *( c++ ) = '\n' ; skip_space( c ) } LE_ /* private: */ void BRCode :: comma /* ----------------------------------------------------------------------------- replace comma by line feed ----------------------------------------------------------------------------- */ ( char * c , char * e ) LB_("BRCode.comma") while ( c < e && *( ++c ) != ';' ) { if ( *c == ',' ) *c = '\n' ; esif ( *c == '(' ){ skip_nest( c, '(', ')' ); c-- ; } } LE_ /* private: */ BOOL BRCode :: new_section // ----------------------------------------------------------------------------- ( char * c , BOOL indent , BOOL mitZNr ) LB_("BRCode.new_section") int e = 74 - indent ; int i = 1 ; while ( i < e && c[i] != '\n' ) { if ( c[i] == '\t' ) c[i] = ' ' ; i++ ; } if ( i == e ) { while not_space( c[i] ) i-- ; if ( mitZNr ) c[i] = '\n' ; // break lines too long } if (0) if ( At( c, "void" ) || At( c, "static" ) ) { char * x = c ; while not_in_str( *x, "(,;" ) { if ( *(++x) == '\n' ) *x = ' '; } } // ----------------------------------------------------------------------------- if ( indent ) ret(0) if At( c, "int " ) then { while not_in_str( *c, ";(" ) c++ ; if ( *c == '(' ) ret(1) } esif At( c, "void" ) ret(1) esif At( c, "const" ) ret(1) esif At( c, "static" ) ret(1) esif At( c, "return" ) ret(0) while not_in_str( *c, "\n:" ) c++ ; if At( c, "::" ) ret(1) LE_ret( 0 ) /* private: */ BOOL BRCode :: same_prefix /* ----------------------------------------------------------------------------- Show all methods called by the caller ----------------------------------------------------------------------------- */ ( char * s1 , char * s2 , char e ) LB_("BRCode.same_prefix") while ( *s1 == *s2 && *s1 != e && *s2 != e ) { s1++ ; s2++ ; } LE_ret( *s1 == e && *s2 == e ) /* private: */ void BRCode :: callees /* ----------------------------------------------------------------------------- Show all methods called by the caller ----------------------------------------------------------------------------- */ ( FILE * f , char * spaces , char * caller , Btree & calls , Btree & schon ) LB_("BRCode.callees") store_256 st ; Surr s = calls.Get( caller, st ); s = calls.Next( st ); if ( !s ) ret_ path ca ; strcpy( ca, st.k ); char * func = ca ; to_( func, ':' ) func++ ; path fu ; strcpy( fu, func ); char * e = fu ; to_( e, ':' ) e[1] = 0 ; // ----------------------------------------------------------------------------- BOOL schr = 1 ; if ( schon.contains( func ) ) ret_ else schon.StrIns( 'i', func ); s = calls.Getmin_GE( st, fu ); while ( s && At( st.k, fu ) ) { if ( ! same_prefix( caller, st.k, ':' ) ) { if ( schr ) fprintf( f, "\n%s%s", spaces, func ); callees( f, spaces - 4, st.k, calls, schon ); schr = false ; } s = calls.GetNext( st ); } if ( ! schr ) fprintf( f, "\n%s.", spaces ); LE_ /* public: */ void BRCode :: catMe /* ----------------------------------------------------------------------------- Make 'dest the file containing all text found in files .//*.ext ----------------------------------------------------------------------------- */ ( FILE * f , char * dir , Btree & ext , char * tmp ) LB_("BRCode.catMe") char * str = "\n\n------" "-----------------------------------------------------------------" "\nFILE " ; S_ "ufind %s > %s", dir, tmp _Do char1000 root ; s_( root, "%s/", dir ); rBuffer B( tmp, "\n" ); rBuffer U ; while ( B.find( 1, root, 0 ) ) { char * c = B.z + B.a ; char * e = c ; to_space( e ); *e = 0 ; char * x = e-1 ; while ( c < x && *x != '.' ) x-- ; x += 1 ; lower( x, x ); if ( ext.contains( x ) ) { fprintf( f, "\n%s%s\n\n", str, c ); U.open_rBuffer( c, "" ); U.copy_to( f ); } B.a = e - B.z ; } LE_ /* public: */ void BRCode :: pretty_XML // ----------------------------------------------------------------------------- ( int step , char * from , char mode ) LB_("BRCode.pretty_XML") BOOL prNo = ( mode == upper( mode ) ); if ( step <= 0 || 4 <= step ) step = 2 ; char * spaces = " " " " " "; spaces = spaces + strlen( spaces ); char * se = spaces ; __ char800 dest ; s_( dest, "%s.pr", from ); char * nam[1000] ; BOOL kaputt = 0 ; rBuffer B( from, "\n\n" ); FILE * f = create( tmp1 ); int i = 0 ; while ( i < 1000 ) nam[i++] = 0 ; i = 0 ; while ( B.find( 1, "<", 0 ) ) { char * c = B.z + B.a ; char * e = c ; to_( e, '>' ) *e = 0 ; if ( e[-1] != '/' ) { if ( c[1] == '/' ) then { i-- ; fprintf( f, "\n%3i%*s|%s", i, i, "", c+2 ); if not_is_( c+2, nam[i] ) { fprintf( f, " -- kaputtes Nesting, erwartet: /%s", nam[i] ); e[800] = 0 ; fprintf( f, "\n\n%s", e+1 ); kaputt = 1 ; break ; } } else { fprintf( f, "\n%3i%*s%s", i, i, "", c ); char * x = c+1 ; while ( *x && not_space( *x ) ) x++ ; *x = 0 ; if ( ! nam[i] ) nam[i] = ( char * ) malloc( 32 ); strcpy( nam[i], c+1 ); i++ ; } if ( i == 0 ) { kaputt = 1 ; break ; } } } close( f ); // if ( kaputt ) { S_ "pskill notepad" _Do S_ "start notepad %s", tmp1 _Do S_ "start notepad %s", from _Do fErr2( tmp1, i ) } // ----------------------------------------------------------------------------- B.open_rBuffer( from, "" ); f = create( tmp1 ); B.z[ B.e ] = 0 ; while space( B.z[ B.a ] ) B.a++ ; // if not_At( B.z + B.a, "<" ) { if ( B.z[ B.a ] == '<' ) then { char * str = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" ; if not_At( B.z + B.a, "<?xml" ) { uint L = strlen( str ); B.a -= L ; memcpy( B.z + B.a, str, L ); } } else { m_errMess "User: no XML text in: %s, we found:\n\n%s" m_ from, B.z + B.a, ret_error } } // while not_At( B.z + B.a, "< __ // while ( B.find( 0, ">" , f ) ) { B.a += 1 ; while ( B.find( 0, "><", f ) ) { B.a += 2 ; fprintf( f, ">\n<" ); } close( f ); cp_file( "x88", tmp1 ); B.open_rBuffer( tmp1, "\n" ); f = create( dest ); BOOL XML = 0 ; _1(f+0) BOOL schreibe = 0 ; while ( B.find( 0, "\n", 0 ) ) { if At( B.z + B.a, "\nEOF = {" ) break ; B.getmore( 1000 ); char * c = B.z + B.a + 1 ; skip_space( c ); int k = 0 ; char * e = c ; to_( e, '\n' ); char * ee = e ; __ if ( spaces < se && At( c, "FILE " ) ) { S_ "\ndepth error: 0 != %i\n", (se-spaces)/step _fErr } *e = 0 ; while ( c < e && space( e[-1] ) ) *( --e ) = 0 ; __ if ( XML || *c == '<' && not_in_str( c[1], "?!" ) ) { __ if ( ! XML ) spaces -= ( c[1] == '/' )? 0 : step ; char * x = e-1 ; if ( *x-- == '>' ) then { if not_in_str( *x, "/!?" ) then { int ek = 0 ; x++ ; __ while ( *( --x ) ) { if ( *x == ']' ) ek++ ; else if ( *x == '[' ) ek-- ; else if ( *x == '<' && ek <= 0 ) break ; } if in_str( x[1], "/!?" ) k = step ; } else k = step ; XML = 0 ; } else XML = 1 ; } if ( 8000 <= e-c+100 ) fErr1( e-c ) char8000 xx ; s_( xx, "%s%s", spaces, c ); char * schr = xx ; if ( ! schreibe ) while ( *schr && *schr != '<' ) schr++ ; if ( *schr ) schreibe = 1 ; if ( schreibe ) fprintf( f, "%s\n", schr ); spaces += k ; B.a = ee - B.z ; *ee = '\n' ; if ( se < spaces ) { cp_file( "xx_from", from ); _4( from, spaces-se, B.ateof, B.e - B.a ) { m_errMess "User: unbalanced XML structure: %s --> %s --> %s" m_ from, tmp1, dest, ret_error } __ } } __ close( f ); unlink( tmp1 ); // ----------------------------------------------------------------------------- B.open_rBuffer( dest, "" ); while ( B.z[ B.a ] != '<' ) B.a++ ; if ( upper( mode ) == 'C' ) norm_base( dest ); _3(mode,upper(mode),mode) if ( prNo ) then { S_ "cp %s %s", dest, from _Do printf( "\nok: see pretty in: %s\n\n", from ); } else printf( "\nok: see pretty in: %s\n\n", dest ); LE_ /* public: */ void BRCode :: norm_base ( char * xsd /* ----------------------------------------------------------------------------- Normiert ein XSD fuer Castor ----------------------------------------------------------------------------- */ ) LB_("BRCode.norm_base") uint anz1NoNs = 0 ; uint anz2NoNs = 0 ; char * tmp = "xx_normBase" ; FILE * f = create( tmp ); rBuffer B( xsd, "" ); while ( B.find( 1, "base=\"", f ) ) { if not_space( B.z[ B.a-1] ) continue ; char * c = B.z + B.a + 6 ; if At( c, "tmf854:" ) continue ; if ( c[3] == ':' ) continue ; char * e = c ; to_( e, '"' ) *e = 0 ; char * s = in_str( ':', c ); if ( !s ) anz1NoNs++ ; s = ( s )? s+1 : c ; char * ns = ( is_XMLType( s ) )? "xs:" : "ns:" ; char * ee = eos( s ) - 2 ; if ( is_( ee, "_T" ) && not_substr( "castor.xsd", xsd ) ) { ns = "tmf854:" ; } fprintf( f, "base=\"%s%s\"", ns, s ); B.a = e+1 - B.z ; } close( f ); // ----------------------------------------------------------------------------- f = create( xsd ); B.open_rBuffer( tmp, "" ); while ( B.find( 1, "type=\"", f ) ) { if not_space( B.z[ B.a-1] ) continue ; char * c = B.z + B.a + 6 ; if At( c, "tmf854:" ) continue ; if ( c[3] == ':' ) continue ; char * e = c ; to_( e, '"' ) *e = 0 ; char * s = in_str( ':', c ); if ( !s ) anz2NoNs++ ; s = ( s )? s+1 : c ; char * ns = ( is_XMLType( s ) )? "xs:" : "ns:" ; char * ee = eos( s ) - 2 ; if ( is_( ee, "_T" ) && not_substr( "castor.xsd", xsd ) ) { ns = "tmf854:" ; } fprintf( f, "type=\"%s%s\"", ns, s ); B.a = e+1 - B.z ; } close( f ); printf( "\nnow normed: %s, %i, %i\n", xsd, anz1NoNs, anz2NoNs ); unions ( xsd ); no_choice_2( xsd ); alle_Namen( xsd ); LE_ /* public: */ void BRCode :: no_choice_1 ( char * xsd /* ----------------------------------------------------------------------------- Normiert ein XSD fuer Castor -- Variante 1 Castor hat Probleme mit <xs:choice>. Wir versuchen, es durch <xs:all> zu ersetzen. Das geht aber - wie XMLSpy zeigt - nicht in allen Situationen. ----------------------------------------------------------------------------- */ ) LB_("BRCode.no_choice_1") uint anz = 0 ; char * tmp = "xx_no_choice" ; FILE * f = create( tmp ); BOOL setMin = 0 ; rBuffer B( xsd, "" ); while ( B.find( 1, "<", f ) ) { char * c = B.z + B.a ; if ( At( c, "<xs:extension" ) || At( c, "<xs:restriction" ) ) then { c -= 11 ; while ( *c != ':' ) c-- ; if ( not_At( c, ":complexContent" ) && not_At( c, ":simpleContent" ) && not_At( c, ":simpleType" ) ) fErr1( c ) } esif At( c, "<xs:choice" ) { anz++ ; B.a += 3 ; memcpy( B.z + B.a, "<xs:all", 7 ); setMin = true ; } esif At( c, "</xs:choice" ) { setMin = false ; B.a += 3 ; memcpy( B.z + B.a, "</xs:all", 8 ); } esif ( setMin && At( c, "<xs:element" ) ) { char * e = in_str( '>', c ); if ( e[-1] == '/' ) e-- ; char m = *e ; *e = 0 ; if substr( "minOccurs", c ) then { fprintf( f, "%s", c ); } else fprintf( f, "%s minOccurs=\"0\"", c ); B.a = e - B.z ; *e = m ; } } close( f ); cp_file( xsd, tmp ); printf( "\nok: %i <xs:choice> replaced by <xs:all>, also some checks done\n" , anz ); LE_ /* public: */ void BRCode :: no_choice_2 ( char * xsd /* ----------------------------------------------------------------------------- Normiert ein XSD fuer Castor -- Variante 2 Hier wird <choice> nicht durch <all> ersetzt. Stattdessen wird es in ein <group maxOccurrs="unbounded"> geklammert, und alle Elemente darin werden mit minOccurs="0" gegeben. Am <choice> selbst stehe weder minOccurs noch maxOccours. See: http://jira.codehaus.org/browse/CASTOR-1150 ----------------------------------------------------------------------------- */ ) LB_("BRCode.no_choice_2") uint anz = 0 ; char * u11 = 0 ; char * u12 = 0 ; char * tmp = "xx_no_choice" ; FILE * f = create( tmp ); BOOL setMin = 0 ; rBuffer B( xsd, "" ); while ( B.find( 1, "<", f ) ) { char * c = B.z + B.a ; if ( At( c, "<xs:extension" ) || At( c, "<xs:restriction" ) ) then { c -= 11 ; while ( *c != ':' ) c-- ; if ( not_At( c, ":complexContent" ) && not_At( c, ":simpleContent" ) && not_At( c, ":simpleType" ) ) fErr1( c ) } esif At( c, "<xs:choice" ) { anz++ ; char * u = c-1 ; while ( *u != '<' ) u-- ; u11 = "<xs:sequence>" ; u12 = "</xs:sequence>" ; if At( u, u11 ) u11 = u12 = "" ; fprintf( f, "%s<!-- gemeint ist: choice -->", u11 ); to_( c, '>' ) B.a = c+1 - B.z ; setMin = true ; } esif At( c, "</xs:choice" ) { fprintf( f, "%s", u12 ); to_( c, '>' ) B.a = c+1 - B.z ; setMin = false ; } esif ( setMin && At( c, "<xs:element" ) ) { char * e = in_str( '>', c ); if ( e[-1] == '/' ) e-- ; char m = *e ; *e = 0 ; if substr( "minOccurs", c ) then { fprintf( f, "%s", c ); } else fprintf( f, "%s minOccurs=\"0\"", c ); B.a = e - B.z ; *e = m ; } } close( f ); cp_file( xsd, tmp ); printf( "\nok: %i <xs:choice> replaced by <xs:sequence>, also some checks done\n" , anz ); LE_ /* public: */ void BRCode :: unions ( char * xsd /* ----------------------------------------------------------------------------- Normiert ein XSD fuer Castor Das Castor zu <union> keinerlei Code erzeugt, muss man ELEMENTe solchen Typs aus seiner Sich als Werte vom Typ xs:string betrachten. Daher: ----------------------------------------------------------------------------- */ ) LB_("BRCode.unions") uint anz = 0 ; Btree unions ; char * tmp = "xx_unions" ; FILE * f = create( tmp ); rBuffer B( xsd, "" ); while ( B.find( 1, "<xs:union", f ) ) { anz++ ; fprintf( f, "<xs:restriction base=\"xs:string\"/>" ); char * c = B.z + B.a ; while not_At( c, "name=" ) c-- ; to_( c, '"' ) c++ ; char * e = c ; to_( e, '"' ) *e = 0 ; unions.StrIns( c ); rB_( B, 1, "</xs:union>", 0 ) rB_( B, 1, "\n" , 0 ) } close( f ); cp_file( xsd, tmp ); printf( "\nok: %i <xs:union> maskiert als String ...\n" , anz ); LE_ /* public: */ void BRCode :: alle_Namen ( char * xsd /* ----------------------------------------------------------------------------- Zeigt alle Namen (um sie harmonisieren zu k”nnen) ----------------------------------------------------------------------------- */ ) LB_("BRCode.alle_Namen") Btree Name, types ; uint korrAnz = 0 ; rBuffer B( xsd, "" ); while ( B.find( 1, "=\"", 0 ) ) { char * c = B.z + B.a - 4 ; char * u = B.z + B.a ; *u = 0 ; char * n = B.z + B.a + 2 ; char * e = n ; to_( e, '"' ) *e++ = 0 ; char * s = in_str( ':', n ); if ( s ) strcpy( n, s+1 ); char100 xx ; strcpy( xx, n ); upper( xx ); if ( At( c, "name" ) || At( c, "type" ) ) { char100 xx ; strcpy( xx, n ); upper( xx ); s_( xx + 4, "%s", n ); Name.StrIns( 'e', xx, is_( c, "name" )? "elem" : c ); skip_space( e ); if At( e, "type=" ) { c = e+6 ; to_( c, '"' ) c[1] = 0 ; if ( substr( "BOOLEAN", e ) || substr( "STRING" , e ) || substr( "INT" , e ) || substr( "DATE" , e ) || substr( "-schema", e ) || substr( "Schema" , e ) ) korrAnz++ ; types.StrIns( 'e', xx, e ); } } } char * names = "names" ; FILE * f = create( names ); fprintf( f, "\n Alle in Flexprod XSD Files genutzten Namen" "\n ------------------------------------------" "\n " "\n Mindestens %i Korrekturen erscheinen angebracht.\n", korrAnz ); char m = 0 ; KVStore st ; Surr s = Name.GetFirst( st ); while ( s ) { if ( upper( *st.k ) != m ) { m = *st.k ; fprintf( f, "\n |" ); } char * n = "" ; KVStore zz ; if ( types.Get( st.k, zz ) ) n = zz.c ; if ( *st.c == 't' ) n = "" ; fprintf( f, "\n %s %-55s %s", st.c, st.k + 4, n ); s = Name.Next( st ); } fprintf( f, "\n |" ); close( f ); alle_Getter(); LE_ /* public: */ void BRCode :: alle_Getter ( /* ----------------------------------------------------------------------------- Zeigt alle Getter + Returntyp in ./de ----------------------------------------------------------------------------- */ ) LB_("BRCode.alle_Getter") Btree getters ; char * src = "de/alles_java" ; if not_is_file( src ) { printf( "\nno such file: %s\n", src ); ret_ } rBuffer B( src, "" ); char100 CNam ; * CNam = 0 ; while ( B.find( 1, "public ", 0 ) ) { char * c = B.z + B.a + 5 ; while ( not_in_str( *c, "(;{" ) && not_At( c, " get" ) && not_At( c, " class " ) ) c++ ; if At( c, " class" ) then { c += 7 ; skip_space( c ) char * e = c ; while in_name( *e ) e++ ; *e = 0 ; strcpy( CNam, c ); } esif At( c, " get" ) { char * n = c+1 ; char * e = n ; to_( e, '(' ) *e = 0 ; while space( c[-1] ) c-- ; *c-- = 0 ; while not_space( *c ) c-- ; c++ ; char * x = substr( ".xsd.", c ); if ( x ) c = x + 5 ; if At( c, "java.lang." ) c += 10 ; if ( 200 <= strlen( n ) + strlen( c ) ) fErr2( n, c ) char200 xx ; s_( xx, "%s~%s", n, c ); getters.StrIns( 'e', xx, CNam ); } else continue ; } char * use = "getters" ; FILE * f = create( use ); fprintf( f, "\n Alle getter und ihr Return Type" "\n -------------------------------" "\n " "\n %50s : %-50s %s\n", "method", "return", "method is part of" ); KVStore st ; Surr s = getters.GetFirst( st ); while ( s ) { char * x = in_str( '~', st.k ); *x = 0 ; fprintf( f, "\n %50s : %-50s %s", st.k, x+1, st.c ); *x = '~' ; s = getters.Next( st ); } close( f ); printf( "\nok: see getters\n" ); LE_ /* public: */ void BRCode :: nur_noch_ref ( char * xsd /* ----------------------------------------------------------------------------- Durch Castor generierter Code macht Probleme, wenn man in Typen lokal auftretende <xs:element> Zeilen nicht per ref= definiert. Castor erzeugt dann Namspace Silben, zu denen es keine Definition gibt. Daher nun auch diese Zeilen korrigieren (wo das m”glich ist - es ist nicht m”glich, wenn es Elemente gibt, die gleichen Namen aber unterschiedlichen Typ haben. Mit zum Typ in diesem Sinne rechnen Elementattribute 'default=' oder 'fixed='). ----------------------------------------------------------------------------- */ ) LB_("BRCode.nur_noch_ref") if not_is_file( xsd ) { m_errMess "User: no such file: %s" m_ xsd, ret_error } S_ "pretty X:%s", xsd _Do uint anzRefJa1 = 0 ; uint anzRefJa2 = 0 ; uint anzRefNein = 0 ; Btree makeRef; int wwAnz = 0 ; Btree defs ; char * tmp = "xx_nur_refs" ; FILE * f = create( tmp ); rBuffer B( xsd, "" ); while ( B.find( 1, "<xs:element name=", f ) ) { B.getmore( 8000 ); BOOL top = ( B.z[ B.a - 5 ] == '\n' ); if ( top ) continue ; char * c = B.z + B.a ; char * n = c + 18 ; char * x = n ; char * e = n ; to_( e, '>' ) *e = 0 ; if ( e[-1] != '/' ) { // fixed must not appear on an element reference *e = '>' ; continue ; // vorerst nicht behandelt e = substr( e+1, "</xs:element>" ); if ( e ) e[13] = 0 ; fErr1( c ) } if substr( "ref=", n ) { *e = '>' ; continue ; } *e = '>' ; char * w = substr( "/", c ); if ( w ) *w = 0 ; else fErr1( c ) char300 ww ; s_( ww, "%s :%i", c, ++wwAnz ); makeRef.StrIns( 'e', ww ); *e = 0 ; *w = '/' ; to_( x, '"' ) *x = 0 ; char100 eNam ; strcpy( eNam, n ); *x = '"' ; n = substr( "type=", x+1 ) + 6 ; x = n+1 ; to_( x, '"' ) *x = 0 ; __ char * u = x+1 ; skip_space( u ) while ( At( u, "default=" ) || At( u, "fixed=" ) ) { *x = '"' ; u = in_str( '"', u ); x = u+1 ; to_( x, '"' ) *x = 0 ; u = x+1 ; skip_space( u ) } char100 tNam ; strcpy( tNam, n ); *x = '"' ; *e = '>' ; KVStore st ; if ( defs.Get( eNam, st ) ) then { if is_( st.c, tNam ) then { anzRefJa1++ ; B.a = x - B.z ; fprintf( f, "<xs:element ref=\"%s", eNam ); } else { anzRefNein++ ; continue ; // ref= nicht eindeutig - geht nicht } } else { anzRefJa2++ ; defs.StrIns( 'i', eNam, tNam ); fprintf( f, "<xs:element ref=\"%s", eNam ); B.a = x - B.z ; } } close( f ); // ----------------------------------------------------------------------------- f = create( xsd ); B.open_rBuffer( tmp, "" ); while ( B.find( 1, "<", f ) ) { char * c = B.z + B.a ; if At( c, "</xs:schema" ) break ; if At( c, "<xs:element " ) { char * e = c ; to_( e, '>' ) *e = 0 ; char * x = substr( "ref=", c ); *e = '>' ; if ( x || e[-1] == '/' ) continue ; else e++ ; skip_space( e ) if ( At( e, "<complexType" ) || At( e, "<simpleType" ) ) { char20 ende ; s_( ende, "</xs:%s>", ( e[1] == 'c' )? "complex" : "simple" ); e = substr( e, "Type" ); if ( e[4] != '>' ) fErr2( c,e ) x = substr( "name=", c ); if ( x < c || e < x ) fErr1( c ) to_( x, '"' ) x++ ; e = in_str( '"', x+1 ); if ( e ) *e = 0 ; else fErr1( x+1 ) char100 nam ; strcpy( nam, x ); *e = '"' ; fprintf( f, "<xs:element ref=\"%s\"/>", nam ); fErr } } } // rB_( B, 1, "</xs:schema>", f ); KVStore st ; Surr s = defs.GetFirst( st ); while ( s ) { fprintf( f, "\n<xs:element name=\"%s\" type=\"%s\"/>", st.k, st.c ); s = defs.Next( st ); } B.copy_to( f ); close( f ); S_ "pretty X:%s", xsd _Do printf( "\nok: Use ref=... wherever possible: %i, %i, %i = Ja1, Ja2, Nein\n" , anzRefJa1, anzRefJa2, anzRefNein ); s = makeRef.GetFirst( st ); while ( s ) { printf( "\nE: %s", st.k ); s = makeRef.Next( st ); } show_ALL( xsd, "xs:group", "groups" ); LE_ /* public: */ void BRCode :: norm_XSD_ns_prefixes_in_dir ( char * dir /* ----------------------------------------------------------------------------- zeige, welchern Prozentsatz die Datentyp Angaben ausmachen ----------------------------------------------------------------------------- */ ) LB_("BRCode.norm_XSD_ns_prefixes_in_dir") if not_is_dir( dir ) { m_errMess "User: no such dir: %s" m_ dir, ret_error } char * tmp = "xx_nsdir" ; if is_( dir, "." ) then S_ "ls > %s", tmp _Do else S_ "wfind %s > %s", dir, tmp _Do rBuffer B( tmp, "\n" ); while ( B.find( 1, ".xsd", 0 ) ) { B.z[ B.e ] = '\n' ; char * c = B.z + B.a ; char * e = c + 4 ; while ( *c != '\n' ) c-- ; if ( *e == '\n' ) { *e = 0 ; norm_base( c+1 ); *e = '\n' ; } } Unlink( tmp ); printf( "\nok - alle ns genormt in %s/*.xsd\n", dir ); LE_ /* public: */ void BRCode :: show_ALL /* ----------------------------------------------------------------------------- zeige alle XML Elemente eines bestimmten Typs ----------------------------------------------------------------------------- */ ( char * xsd , char * elem , char * nch ) LB_("BRCode.show_ALL") if not_is_file( xsd ) { m_errMess "User: no such file: %s" m_ xsd, ret_error } if ( ! elem || ! *elem ) fErr1( elem ) uint anz = 0 ; FILE * f = create( nch ); char100 str1 ; s_( str1, "<%s", elem ); char100 str2 ; s_( str2, "</%s", elem ); rBuffer B( xsd, "\n" ); while ( B.find( 1, str1, 0 ) ) { anz++ ; fprintf( f, "\n|\n" ); char * e = B.z + B.a ; to_( e, '>' ) if ( e[-1] == '/' ) then { rB_( B, 1, "/>", f ) } else rB_( B, 1, str2, f ) rB_( B, 0, "\n", f ) } close( f ); printf( "\nok: see %s, %i %s\n", nch, anz, str1 ); LE_ /* public: */ BOOL BRCode :: is_XMLType ( char * str /* ----------------------------------------------------------------------------- Castor ist EXTREM empfindlich, wenn der Namespace fehlt oder falsch angegeben ist - man bekommt dann Fehlermeldungen, die ganz andere Fehler suggerieren, Daher: Die List der xs: Typen unten vollst„ndig machen !!!! ----------------------------------------------------------------------------- */ ) LB_("BRCode.is_XMLType") // Types in Grossbuchstaben sind Flexprod Objekte (= complexType) - man darf // sie also NICHT zu simpleType machen - der DB Services wegen: if is_( str, "event_T" ) *str = upper( *str ); // if is_( str, "STRING" ) strcpy( str, "string" ); // if is_( str, "BOOLEAN" ) strcpy( str, "boolean" ); // if is_( str, "INTEGER" ) strcpy( str, "integer" ); // if is_( str, "DATE" ) strcpy( str, "date" ); // if is_( str, "DATETIME" ) strcpy( str, "dateTime" ); if is_( str, "short" ) strcpy( str, "int" ); // // Castor hat Probleme mit short if ( *str == upper( *str ) && str[1] == upper( str[1] ) ) { char * strNotXML = str ; } if is_( str, "unsignedLong" ) strcpy( str, "int" ); if is_( str, "unsignedInt" ) strcpy( str, "int" ); if is_( str, "unsignedShort" ) strcpy( str, "short" ); if is_( str, "positiveLong" ) strcpy( str, "int" ); if is_( str, "positiveInt" ) strcpy( str, "int" ); if is_( str, "positiveShort" ) strcpy( str, "short" ); if ( is_( str, "anyURI" ) || is_( str, "boolean" ) || is_( str, "byte" ) || is_( str, "dateTime" ) || is_( str, "date" ) || is_( str, "decimal" ) || is_( str, "duration" ) || is_( str, "long" ) || is_( str, "float" ) || is_( str, "gDay" ) || is_( str, "gMonth" ) || is_( str, "gMonthDay" ) || is_( str, "gYear" ) || is_( str, "gYearMonth" ) || is_( str, "double" ) || is_( str, "int" ) || is_( str, "integer" ) || is_( str, "short" ) || is_( str, "string" ) || is_( str, "time" ) || is_( str, "positiveInteger" ) || is_( str, "nonNegativeInteger" ) || is_( str, "anyType" ) || is_( str, "QName" ) ) ret( 1 ) LE_ret( 0 ) /* public: */ void BRCode :: keine_Leerzeilen ( char * xsd /* ----------------------------------------------------------------------------- streiche alle leeren Zeilen ----------------------------------------------------------------------------- */ ) LB_("BRCode.keine_Leerzeilen") char * tmp = "xx_keine_Leerzeilen" ; FILE * f = create( tmp ); rBuffer B( xsd, "" ); while ( B.find( 0, "\n\n", f ) ) B.a++ ; close( f ); cp_file( xsd, tmp ); LE_ /* public: */ void BRCode :: force ( char * xsd /* ----------------------------------------------------------------------------- ... wenn pretty versagt ----------------------------------------------------------------------------- */ ) LB_("BRCode.force") char * tmp = "xx_force" ; FILE * f = create( tmp ); rBuffer B( xsd, "" ); while ( B.find( 0, "<", f ) ) { rB_( B, 1, ">", f ) if ( ! B.find( 0, "<", f ) ) { fprintf( f, ">" ); break ; } fprintf( f, "\n" ); } cp_file( xsd, tmp ); LE_ /* public: */ void BRCode :: zeige_mehrfachDef ( char * xsd /* ----------------------------------------------------------------------------- zeige mehrfach spezifizierte Typen ----------------------------------------------------------------------------- */ ) LB_("BRCode.zeige_mehrfachDef") Btree defs ; str_set such ; such.insert( "ns=" ); such.insert( "Type name=" ); such.insert( "<xs:element " ); uint mehrfach = 0 ; char300 ns ; *ns = 0 ; char * tmp = "xx_mehrfach" ; FILE * f = create( tmp ); rBuffer B( xsd, "" ); while ( B.find( 1, such, f ) ) { char * c = B.z + B.a ; char * n = c ; to_( n, '"' ) n++ ; char * e = n+1 ; to_( e, '"' ) *e = 0 ; if ( *c == 'T' ) then { KVStore st ; if ( defs.Get( n, st ) ) then { mehrfach++ ; printf( "\ndopp: %s -- %s", n, st.c ); printf( "\ndopp: %s -- %s", n, ns ); } else defs.StrIns( 'i', n, ns ); } esif ( *c == 'n' ) { strcpy( ns, c ); } esif ( *c == '<' ) { *e = '"' ; to_( e, '>' ) if ( e[-1] == '/' ) continue ; char m = *( ++e ); *e = 0 ; if ( ! defs.contains( c ) ) then { defs.StrIns( c ); *e = m ; continue ; } else { *e = m ; B.a = e - B.z ; } } else fErr1( c ) *e = '"' ; } close( f ); cp_file( xsd, tmp ); if ( mehrfach ) { printf( "\ndopp: Es kann sein, dass Mehrfachdefinitionen durch <xs:element>" " specs zustande kommen.\n" ); } else printf( "\nkeine Mehrfachdefinitionen\n" ); LE_ /* public: */ void BRCode :: escBr /* ----------------------------------------------------------------------------- HTM-escape { and } where in a string or comment ----------------------------------------------------------------------------- */ ( rBuffer & B , char * stop , FILE * f ) LB_("BRCode.escBr") if ( !stop || !*stop || in_str( *stop, "{}" ) ) fErr1( stop ) str_set such ; such.insert( stop ); such.insert( "{" ); such.insert( "}" ); uint offs = 1 ; while ( B.find( offs, such, f ) ) { char * c = B.z + B.a ; if At( c, stop ) break ; offs = 0 ; if in_str( *stop, "\"\'" ) then { B.a++ ; fprintf( f, "%c", *stop ); } else { switch ( *c ) { case '{' : B.a++ ; fprintf( f, "{" ); case '}' : B.a++ ; fprintf( f, "}" ); } } } LE_ /* public: */ void BRCode :: pretty_PHP /* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ ( char * aus , char * nch ) LB_("BRCode.pretty_PHP") char * tmp = "x.tmp" ; str_set such ; such.insert( "for(" ); such.insert( "if(" ); such.insert( "while" ); such.insert( "{" ); such.insert( "}" ); such.insert( "else" ); such.insert( "#" ); such.insert( "//" ); such.insert( "/*" ); such.insert( "\"" ); such.insert( "\'" ); such.insert( "\n" ); such.insert( "\t" ); cp_file( "x.aus", aus ); uint strA = 0 ; rBuffer B( aus, "" ); FILE * f = create( tmp ); while ( B.find( 1, such, f ) ) { if ( alpha( B.z[ B.a ] ) && not_space( B.z[ B.a-1 ] ) ) continue ; while ( At( B.z + B.a, "if" ) && space( B.z[ B.a+2 ] ) ) { B.a++ ; memcpy( B.z + B.a, "if", 2 ); } B.getmore( 4000 ); char * c = B.z + B.a ; // traceStr("HHH",c,100); // erst see x.tmp // ( 570 <= call_nr ) { close(f); fErr1( tmp ) } if At( c, "{" ) { c-- ; while ( *c == ' ' ) c-- ; if ( *c == ')' ) B.z[ --B.a ] = '\n' ; continue ; } if At( c, "\t" ) { while ( *c == '\t' ) *c++ = ' ' ; continue ; } if At( c, "\n" ) { if At( c, "\n\t\n" ) { c[0] = c[1] = ' ' ; continue ; } char * e = c ; skip_space( e ) while ( *e == '#' ) { to_( e, '\n' ); skip_space( e ) } e-- ; *e = 0 ; fprintf( f, "%s", c ); *e = '\n' ; B.a = e - B.z ; continue ; } if At( c, "/*" ) { escBr( B, "*/", f ); continue ; } if At( c, "// Method :" ) { rB_( B, 1, "\n", 0 ); continue ; } if At( c, "//" ) { escBr( B, "\n", f ); continue ; } if At( c, "#" ) { B.a-- ; memcpy( B.z + B.a, "//", 2 ); escBr( B, "\n", f ); continue ; } if At( c, "\"" ) { strA = ( strA )? 0:1 ; char * c1 = c ; char * x ; if ( strA ) then { // _1( c+44-44 ) x = skip_str( c, B.z + B.e ); char * z = x-1 ; while escaped( x-1 ) { to_( x, '"' ) x++ ; } char m = *x ; *x = 0 ; fprintf( f, "%s", c1 ); // _1(c1) *x = m ; strA = 0 ; } else { // _1( c-44+44 ) x = c+1 ; fprintf( f, "\"" ); } B.a = x - B.z ; continue ; if At( c, "\"0\"\" />" ) { // des Fehlers wegen in Mantis code .... c++ ; memcpy( c, "\"0", 2 ); B.a++ ; } if escaped( c ) continue ; escBr( B, "\"", f ); while escaped( B.z + B.a ) escBr( B, "\"", f ); continue ; } if At( c, "\'" ) { char * c1 = c ; char * x = skip_str1( c, B.z + B.e ); char m = *x ; *x = 0 ; fprintf( f, "%s", c1 ); B.a = x - B.z ; *x = m ; continue ; if escaped( c ) continue ; escBr( B, "\'", f ); while escaped( B.z + B.a ) escBr( B, "\'", f ); continue ; } if At( c, "}else" ) { memcpy( c-1, "}\n", 2 ); B.a-- ; continue ; } if At( c, "} else" ) { c[1] = '\n' ; continue ; } if ( *c == '}' ) { __ fprintf( f, "\n" ); continue ; } if At( c, "break;" ) { c += 6 ; skip_space( c ); if ( *c != '}' ) { B.a += 6 ; fprintf( f, "break;\n" ); } continue ; } if At( c, "else" ) { char * x = c-1 ; while space( *x ) x-- ; if ( *x == '}' ) fprintf( f, "\n" ); c += 4 ; skip_space( c ); if At( c, "if" ) continue ; if ( *c != '{' ) { char * e = c ; while ( *e != ';' ) { if in_str( *e, "\"'" ) e = skip_str( e, B.z + B.e ); else e++ ; } *e = 0 ; fprintf( f, "else\n{ %s;\n}", c ); B.a = e+1 - B.z ; } continue ; } if At( c, "while(" ) { B.a-- ; c-- ; memcpy( c, "while (", 7 ); continue ; } if At( c, "for(" ) { B.a-- ; c-- ; memcpy( c, "for (", 5 ); continue ; } if At( c, "if(" ) { B.a-- ; c-- ; memcpy( c, "if (", 4 ); continue ; } if At( c, "foreach(" ) { B.a-- ; c-- ; memcpy( c, "foreach (", 9 ); continue ; } // traceStr("ccc",c,20); char * x = c ; to_( x, '(' ) int n = 1 ; while ( n ) { x++ ; if ( *x == '\"' ) { x++ ; to_( x, '\"' ) while escaped( x ) { x++ ; to_( x, '\"' ) } } if ( *x == '\'' ) { x++ ; to_( x, '\'' ) while escaped( x ) { x++ ; to_( x, '\'' ) } } if ( *x == '(' ) n++ ; if ( *x == ')' ) n-- ; } x++ ; skip_space( x ) if ( *x != '{' ) then { char m = *x ; *x = 0 ; char * e = x+1 ; to_( e, ';' ) *e++ = 0 ; fprintf( f, "%s\n{%c%s;\n}", c, m, x+1 ); B.a = e - B.z ; } esif space( x[-1] ) x[-1] = '\n' ; } close( f ); // ----------------------------------------------------------------------------- f = create( nch ); B.open_rBuffer( tmp, "" ); int k = 0 ; int offs = 0 ; while ( B.find( offs, "\n", f ) ) { offs = 1 ; strcpy( B.z + B.e, "\n\n" ); char * c = B.z + B.a ; char * e = c + 1 ; to_( e, '\n' ) if ( B.z + B.e <= e ) break ; skip_space( c ); if ( e < c ) continue ; B.a = c - B.z ; // traceStr("UUU",c,40); if At( c, "{}" ) { fprintf( f, "%*s{\n%*s}\n", k+3, "", k+3, "" ); offs = 0 ; B.a += 1 ; B.z[ B.a ] = '\n' ; continue ; } if ( *c == '{' ) { k += 3 ; char * x = c+1 ; char * n = 0 ; char * w = B.z + B.e ; while space( *x ) { if ( *x == '\n' ) { if ( n ) *n = ' ' ; n = x ; } if ( w <= ++x ) break ; } c = x-1 ; while ( *(++c) != '\n' ) { if in_str( *c, "'\"" ) skip_str( c, B.z + B.e ); if ( *c == '}' ) { k -= 3 ; break ; } } continue ; } fprintf( f, "\n%*s", k, "" ); if ( *c == '}' ) { k -= 3 ; if ( k < 0 ) k = 0 ; if ( k < 0 ) fErr1( k ) } char * x = e-1 ; while space( *x ) x-- ; if ( *x == ';' && *c == '}' || *x == ')' && *c == '{' ) { if ( ! x[1] ) break ; *(++x) = '\n' ; while space( *(++x) ) *x = ' ' ; } if ( c < e && *e == '{' && B.z[ B.a ] != '{' ) { fErr B.find( 0, "{", f ); B.z[ --B.a ] = '\n' ; offs = 0 ; } } close( f ); if ( k ) fErr3( k, tmp, nch ) // noch k offene {... unlink( tmp ); LE_ #undef static #endif
top . C++
Include-structure of
todir / brcode.cpp

brcode.h
.   .   for_spu.h
.   .   .   for_all.h
.   .   .   .   exec_ut.h
.   .   .   .   .   exec_ut.h3
.   .   .   .   .   macros_1.h
.   .   .   .   .   traceco.h
.   .   .   .   precomp.h
.   .   .   .   .   basis.h
.   .   .   .   .   .   compiler.h
.   .   .   .   .   .   dmlerr.h
.   .   .   .   .   en.h
.   .   .   .   .   .   en_lec.h
.   .   .   .   .   limits.h
.   .   .   .   .   mt.h
.   .   .   .   .   obsolete.h
.   .   .   .   .   ot.h
.   .   .   .   .   st.h
.   .   .   .   .   trace.h
.   .   .   .   standard.h
.   .   .   .   toscreen.h
.   .   .   spu.h
.   .   .   .   help_gen.h
.   .   .   .   .   help_gen.h3
.   .   .   .   rbuffer.h
.   .   .   .   .   rbuffer.h3
.   .   .   .   .   str_set.h
.   .   .   .   .   .   str_set.h3
.   .   .   .   safe_uts.h
.   .   .   .   .   safe_uts.h3
.   .   .   .   ut_repl.h
.   .   brcode.h3
.   .   btree.h
.   .   .   btree.h3

34 include files
top . is_inc_for . C++