meta,
C++
114 Methoden:
/* private: */ BOOL rBuffer :: check_a
/* private: */ void rBuffer :: allocate_z
/* private: */ void rBuffer :: exp_incs
/* private: */ char * rBuffer :: getmore
/* private: */ void rBuffer :: ers_Umlaute
/* private: */ void rBuffer :: if_ateof
|
/* public: */ BOOL rBuffer :: rm_unicode
/* public: */ BOOL rBuffer :: match
/* public: */ BOOL rBuffer :: rest
/* public: */ BOOL rBuffer :: rest_s_gr
/* public: */ BOOL rBuffer :: has_NULL
/* public: */ char * rBuffer :: string_at
/* public: */ char * rBuffer :: find
/* public: */ char * rBuffer :: getmore
/* public: */ char * rBuffer :: getmore
/* public: */ char * rBuffer :: next_ersetze
/* public: */ char * rBuffer :: next_ersetze
/* public: */ char * rBuffer :: s_to_not_Blank
/* public: */ char * rBuffer :: skip_HTM_or_XML
/* public: */ char rBuffer :: preChar
/* public: */ int rBuffer :: restTrace
/* public: */ match_rec * rBuffer :: find
/* public: */ rBuffer :: rBuffer
/* public: */ rBuffer :: rBuffer
/* public: */ rBuffer :: rBuffer
/* public: */ rBuffer :: rBuffer
/* public: */ rBuffer :: ~rBuffer
/* public: */ uint rBuffer :: remember
/* public: */ void rBuffer :: copy_to
/* public: */ void rBuffer :: copy_to_close
/* public: */ void rBuffer :: done_DEL
/* public: */ void rBuffer :: out
/* public: */ void rBuffer :: out
/* public: */ void rBuffer :: rest_to
/* public: */ void rBuffer :: select
/* public: */ void rBuffer :: to
/* public: */ void rBuffer :: close_rBuffer
/* public: */ void rBuffer :: exp_Umlaute
/* public: */ void rBuffer :: exp_Umlaute
/* public: */ void rBuffer :: exp_incs
/* public: */ void rBuffer :: noCase
/* public: */ void rBuffer :: no_komma
/* public: */ void rBuffer :: no_utf
/* public: */ void rBuffer :: open_rBuffer
/* public: */ void rBuffer :: open_rBuffer
/* public: */ void rBuffer :: reopen_rBuffer
/* public: */ void rBuffer :: reset
/* public: */ void rBuffer :: rocc
/* public: */ void rBuffer :: scan_str
/* public: */ void rBuffer :: show_rest
/* public: */ void rBuffer :: skip
/* public: */ void rBuffer :: skipComment
/* public: */ void rBuffer :: step
/* public: */ void rBuffer :: syntax_error
/* public: */ void rBuffer :: syntax_error
/* public: */ void rBuffer :: trace
/* public: */ void rBuffer :: unicode
#define static
#include rbuffer.h : cpp
#include rbuffer.c1 : 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 LB_
#undef LE_
#undef LE_ret
#undef ret
#undef ret_
#undef __
#undef ___
#define LB_( x ) {
#define LE_ }
#define ret_ return ;
#define LE_ret( x ) return( x ); }
#define ret( x ) return( x );
#define __
#define ___
#endif
#define from_a_check(s) if ( check_a( s, __LINE__ ) ) ret( 0 )
// #include "nesterTrace"
/* private: */ BOOL rBuffer :: check_a
// -----------------------------------------------------------------------------
(
char * str
, int at // __LINE__
)
LB_("rBuffer.check_a")
if ( a == e && ateof ) ret( 1 )
if ( a == from_a )
then {
if ( ++from_a_anz > 8 )
{
traceStr( "z[a..]", z+a, min( e-a, 200 ) );
{
m_errMess "System: error: Infinite loop: "
"rBuffer.cpp, line %i: ateof = %i, suche [%s] --- f = %s" m_
at, ateof, str, file, ret_error
}
;
}
}
else {
from_a_anz = 0 ;
from_a = a ;
if ( a < -PREL ) { out( at ); fErr2( a, -PREL ) }
}
LE_ret( 0 )
/* public: */ rBuffer :: rBuffer(
// -----------------------------------------------------------------------------
)
LB_("rBuffer.rBuffer")
checkMe = 0 ;
z = 0 ; f = 0 ; out_at_work = 0 ; corrPos = 0L ;
LE_
/* public: */ rBuffer :: rBuffer
// -----------------------------------------------------------------------------
(
char * src
, char * dest
, FILE * & opn_dest
, char * prefix
)
LB_("rBuffer.rBuffer")
checkMe = 0 ;
if ( ! file ) fErr
ers_unicode = false ;
ers_upper_to_lower = false ;
z = 0 ; f = 0 ; corrPos = 0L ; open_rBuffer( src, prefix );
if ( ! ateof )
then {
if is_( src, dest )
then {
FILE * tf ; path tfn ; temp_file( tf, tfn, "rm_" );
copy_to( tf ); close( tf );
open_rBuffer( tfn, 0 );
}
}
create( opn_dest, dest );
LE_
/* public: */ rBuffer :: rBuffer
// -----------------------------------------------------------------------------
(
char * file
, char * prefix // "\n" when searching for "\n..."
)
LB_("rBuffer.rBuffer")
if ( ! file ) fErr
z = 0 ; f = 0 ; corrPos = 0 ; open_rBuffer( file, prefix );
LE_
/* public: */ rBuffer :: rBuffer
// -----------------------------------------------------------------------------
(
char * str1
, char * str2
, BOOL norm
)
LB_("rBuffer.rBuffer")
checkMe = 0 ;
corrPos = 0L ;
int s1 = strlen( str1 );
int s2 = strlen( str2 );
if ( BufL < s1 + s2 ) fErr
memcpy( z , str1, s1 ); e = s1; z[ e++ ] = ' ' ;
memcpy( z+e, str2, s2 );
ateof = true ;
strcpy( this->file, "str1 str2" );
z[ e+1 ] = z[ e ] = info[ 0 ] = 0 ;
if ( norm )
{
for ( s = 0 ; s < e ; s++ )
{
if ( isspace( z[s] ) )
{
z[s] = 0 ;
}
esif ( z[s] == '\'' )
{
do s++ ; while ( s < e && z[s] != '\'' );
if ( e <= s ) fErr else z[s] = 0 ;
}
}
}
a = s = j = 0 ;
if ( strlen( z+a ) < e-a )
{
printf( "NULL in rBuffer: \n{\n%s\n}\n", z+a );
}
LE_
/* public: */ rBuffer :: ~rBuffer(
// -----------------------------------------------------------------------------
)
LB_("rBuffer.~rBuffer")
ok
printf( "\nclose B.file %s", file );
if ( f ) close( f );
*file = 0 ;
// if ( z ) rem_sto( ( pointer )( z-PREL ) );
if ( z ) free( z-PREL );
LE_
/* public: */ void rBuffer :: syntax_error
// -----------------------------------------------------------------------------
(
char * err
, char * in_text
)
LB_("rBuffer.syntax_error")
syntax_error( err, in_text, in_text );
LE_
/* public: */ BOOL rBuffer :: rm_unicode
// -----------------------------------------------------------------------------
// unicode to iso
// -----------------------------------------------------------------------------
(
char * x
, uchar c1
, uchar c2
, uchar c3
)
LB_("rBuffer.rm_unicode")
if ( (uchar) *x == c1 && (uchar) x[1] == c2 )
{
*x = c3 ;
strcpy( x+1, x+2 );
ret( --e )
}
LE_ret( 0 )
/* public: */ void rBuffer :: unicode (
// -----------------------------------------------------------------------------
)
LB_("rBuffer.unicode")
ret_ // better use safe_uts :: ersUtf_HTM
ers_unicode = true ;
char * x = z + a ;
while ( *(++x) )
{
if ( (uchar) 195 == (uchar) *x )
{
if ( rm_unicode( x, 195, 164, 228 ) ) continue ; // „
if ( rm_unicode( x, 195, 182, 246 ) ) continue ; // ”
if ( rm_unicode( x, 195, 188, 252 ) ) continue ; // ue
if ( rm_unicode( x, 195, 132, 196 ) ) continue ; // Ž
// ( rm_unicode( x, 214 ) ) continue ; //
if ( rm_unicode( x, 195, 156, 220 ) ) continue ; // š
if ( rm_unicode( x, 195, 159, 223 ) ) continue ; // á
}
// per utfTrace.exe erkennt man: 226 128 148 = —
// 226 128 156 = "
// 226 136 158 = das unendlich-Zeichen
// 207 128 = Kreiszahl pi
// 206 169 = groáes Omega
if ( (uchar) 180 == (uchar) *x ) *x = '\'' ;
if ( (uchar) 128 == (uchar) x[1] )
{
if ( (uchar) 226 == (uchar) x[0] )
{
if ( (uchar) 148 == (uchar) x[2] )
{
*x = (uchar) 196 ; s_( x+1, "%s", x+3 );
}
if ( (uchar) 147 == (uchar) x[2] ) s_( x, "-%s" , x+3 );
if ( (uchar) 152 == (uchar) x[2] ) s_( x, "'%s" , x+3 );
if ( (uchar) 153 == (uchar) x[2] ) s_( x, "'%s" , x+3 );
if ( (uchar) 156 == (uchar) x[2] ) s_( x, "\"%s", x+3 );
if ( (uchar) 157 == (uchar) x[2] ) s_( x, "\"%s", x+3 );
if ( (uchar) 158 == (uchar) x[2] ) s_( x, "\"%s", x+3 );
if ( (uchar) 166 == (uchar) x[2] ) x[0] = x[1] = x[2] = '.' ;
}
if ( ( uchar ) 132 == (uchar) x[1] )
if ( ( uchar ) 207 == (uchar) x[0] ) s_( x, "t%s", x+2 );
}
}
LE_
/* public: */ void rBuffer :: no_utf (
// -----------------------------------------------------------------------------
)
LB_("rBuffer.no_utf")
skipUtfNULL = 1 ;
char * z1 = z + a ;
char * x1 = z + a - 1 ;
char * e1 = z + e ;
while ( ++x1 < e1 ) if ( *x1 ) *z1++ = *x1 ;
*z1 = 0 ;
e = z1 - z ;
memcpy( z1, e1, 20 );
LE_
/* public: */ void rBuffer :: no_komma (
// -----------------------------------------------------------------------------
)
LB_("rBuffer.no_komma")
char * z1 = z + a ;
char * x1 = z + a ;
char * e1 = z + e ;
while ( x1 < e1 )
{
if ( *x1 != '"' )
then {
*z1++ = *x1++ ;
}
esif ( x1[1] == '"' )
{
x1 += 2 ;
char * x = x1-1 ;
while ( *(++x) != '"' )
{
if ( *x == ',' ) *z1++ = '.' ; else *z1++ = *x ;
}
x1 = x+2 ; *z1++ = ' ' ;
}
else x1 += 1 ;
}
e = z1 - z ;
LE_
/* public: */ void rBuffer :: rocc
/* -----------------------------------------------------------------------------
remove + open + close + create
-----------------------------------------------------------------------------
*/ (
char * f1 // file to remove, or 0
, char * f2 // file to open in rBuffer
, char * str
, FILE * & f // close f, then f = create( f3 )
, char * f3
)
LB_("rBuffer.rocc")
if ( ! str ) fErr
if ( ! f2 ) fErr
if ( ! f3 ) fErr
if ( f ) close ( f );
if ( f1 ) unlink( f1 );
ok open_rBuffer( f2, str ); f = create( f3 );
LE_
/* public: */ void rBuffer :: syntax_error
// -----------------------------------------------------------------------------
(
char * err
, char * in_text
, char * at
)
LB_("rBuffer.syntax_error")
int n = z+e - in_text ; if ( n <= 0 ) fErr
int m = at - in_text ; if ( m < 0 || n < m ) fErr
char cc = *at ; *at = 0 ;
S_ "\nSyntax Error( %s ):\n%s[?]", err, in_text _ste
*at = cc ;
char * ce = z+e ;
char * c1 = at ; while ( c1 < ce && *c1 != '\n' ) c1++ ;
cc = *c1 ; *c1 = 0 ; S_ "%s\n\n", at _ste
*c1 = cc ;
LE_
/* public: */ void rBuffer :: exp_Umlaute
/* -----------------------------------------------------------------------------
transform z[ a_raw .. e-1 ]
-----------------------------------------------------------------------------
*/ (
char * to_code
, int a_raw
)
LB_("rBuffer.exp_Umlaute")
exp_Umlaute( to_code, a_raw );
LE_
/* public: */ void rBuffer :: exp_Umlaute
/* -----------------------------------------------------------------------------
transform z[ a_raw .. e-1 ]
-----------------------------------------------------------------------------
*/ (
char * nur // chars aus dieser Menge
, char * to_code
, int a_raw
)
LB_("rBuffer.exp_Umlaute")
char oem_to_ansi[] = "" ;
// "ÇüéâäàåçeëèïîìÄÅÉæÆôöòûùÿÖÜ¢
// "++++-++++++++-+++++++++++++
exp_umlaute = to_code ;
if ( e <= a_raw || ! to_code ) ret_ esif ( ! to_code[0] ) ret_
if ( a < s ) fErr
if ( a < j ) fErr
// char z1[ 2*BufL ] ;
char * z1 = ( char * ) malloc( 2 * BufL );
int e1 = e - a_raw ; memcpy( z1, z + a_raw, e1 );
char c ; int s1 = 0 ; e = a_raw ;
if is_( to_code, "two_chars" )
then {
while ( s1 < e1 )
{
c = z1[ s1++ ] ;
if ( ( uchar )c <= 128 ) z[ e++ ] = c ;
esif ( ( uchar )c == 132 ) { z[ e++ ] = 'a' ; z[ e++ ] = 'e' ; }
esif ( ( uchar )c == 148 ) { z[ e++ ] = 'o' ; z[ e++ ] = 'e' ; }
esif ( ( uchar )c == 129 ) { z[ e++ ] = 'u' ; z[ e++ ] = 'e' ; }
esif ( ( uchar )c == 142 ) { z[ e++ ] = 'A' ; z[ e++ ] = 'e' ; }
esif ( ( uchar )c == 153 ) { z[ e++ ] = 'O' ; z[ e++ ] = 'e' ; }
esif ( ( uchar )c == 154 ) { z[ e++ ] = 'U' ; z[ e++ ] = 'e' ; }
esif ( ( uchar )c == 225 ) { z[ e++ ] = 's' ; z[ e++ ] = 's' ; }
else z[ e++ ] = c ;
}
}
esif is_( to_code, "schmutz" )
then {
while ( s1 < e1 )
{
c = z1[ s1++ ] ;
// Nun MS C++ Editor:
if ( ( uchar )c == 228 ) { memcpy( z+e, "\\'e4", 4 ); e += 4 ; }
esif ( ( uchar )c == 246 ) { memcpy( z+e, "\\'f6", 4 ); e += 4 ; }
esif ( ( uchar )c == 252 ) { memcpy( z+e, "\\'fc", 4 ); e += 4 ; }
esif ( ( uchar )c == 196 ) { memcpy( z+e, "\\'c4", 4 ); e += 4 ; }
esif ( ( uchar )c == 214 ) { memcpy( z+e, "\\'d6", 4 ); e += 4 ; }
esif ( ( uchar )c == 220 ) { memcpy( z+e, "\\'dc", 4 ); e += 4 ; }
esif ( ( uchar )c == 223 ) { memcpy( z+e, "\\'df", 4 ); e += 4 ; }
else z[ e++ ] = c ;
}
}
esif is_( to_code, "ohne_CR" )
then {
while ( s1 < e1 )
{
c = z1[ s1++ ] ; if (( uchar )c != 13 ) z[ e++ ] = c ;
}
}
esif is_( to_code, "rtf_chars" )
then {
while ( s1 < e1 )
{
c = z1[ s1++ ] ;
if ( ( uchar )c <= 31 )
then {
if ( ( uchar )c == 10 ) z[ e++ ] = '\n' ; // LF
esif ( ( uchar )c == 13 ) ; // CR
esif ( ( uchar )c <= 25 )
{
S_ "Error in Input: Falsch codierte Umlaute (vi ??):"
"ascii( %u )\n", ( uchar )c _sto
// z[ e++ ] = '
}
}
esif ( ( uchar )c == 92 ) // c is backslash
{
{ z[ e++ ] = '\\' ; z[ e++ ] = '\\' ; }
// N E I N : da sonst "\n ..." nicht mehr richtig
// J A : damit \ als Zeilenvorschub bei define ...
}
esif ( c == '{' ) { memcpy( z+e, "\\{" , 2 ); e += 2 ; }
esif ( c == '}' ) { memcpy( z+e, "\\}" , 2 ); e += 2 ; }
esif ( ( uchar )c <= 127 ) z[ e++ ] = c ;
esif ( ( uchar )c == 132 ) { memcpy( z+e, "\\'e4", 4 ); e += 4 ; }
esif ( ( uchar )c == 148 ) { memcpy( z+e, "\\'f6", 4 ); e += 4 ; }
esif ( ( uchar )c == 129 ) { memcpy( z+e, "\\'fc", 4 ); e += 4 ; }
esif ( ( uchar )c == 142 ) { memcpy( z+e, "\\'c4", 4 ); e += 4 ; }
esif ( ( uchar )c == 153 ) { memcpy( z+e, "\\'d6", 4 ); e += 4 ; }
esif ( ( uchar )c == 154 ) { memcpy( z+e, "\\'dc", 4 ); e += 4 ; }
esif ( ( uchar )c == 225 ) { memcpy( z+e, "\\'df", 4 ); e += 4 ; }
// Nun MS C++ Editor:
esif ( ( uchar )c == 228 ) { memcpy( z+e, "\\'e4", 4 ); e += 4 ; }
esif ( ( uchar )c == 246 ) { memcpy( z+e, "\\'f6", 4 ); e += 4 ; }
esif ( ( uchar )c == 252 ) { memcpy( z+e, "\\'fc", 4 ); e += 4 ; }
esif ( ( uchar )c == 196 ) { memcpy( z+e, "\\'c4", 4 ); e += 4 ; }
esif ( ( uchar )c == 214 ) { memcpy( z+e, "\\'d6", 4 ); e += 4 ; }
esif ( ( uchar )c == 220 ) { memcpy( z+e, "\\'dc", 4 ); e += 4 ; }
esif ( ( uchar )c == 223 ) { memcpy( z+e, "\\'df", 4 ); e += 4 ; }
//
else {
S_ "Error in Input: ascii( %u ) in rtf code nicht erlaubt\n"
, ( uchar )c _sto
// z[ e++ ] = '
}
}
}
esif is_( to_code, "mae_to_rtf" ) // noch n i c h t richtig !!!
then {
while ( s1 < e1 )
{
c = z1[ s1++ ] ;
// if ( 128 <= ( uchar )c ) c = oem_to_ansi[ ( uchar )c - 128 ] ;
if ( ( uchar )c <= 31 )
then {
if ( ( uchar )c == 10 ) z[ e++ ] = '\n' ; // LF
esif ( ( uchar )c == 13 ) ; // CR
esif ( ( uchar )c <= 25 )
{
S_ "Error in Input: Falsch codierte Umlaute (vi ??):"
"ascii( %u )\n", ( uchar )c _sto
// z[ e++ ] = '
}
}
esif ( ( uchar )c == 92 ) // c is backslash
{
{ z[ e++ ] = '\\' ; z[ e++ ] = '\\' ; }
// N E I N : da sonst "\n ..." nicht mehr richtig
// J A : damit \ als Zeilenvorschub bei define ...
}
esif ( c == '{' ) { memcpy( z+e, "\\{" , 2 ); e += 2 ; }
esif ( c == '}' ) { memcpy( z+e, "\\}" , 2 ); e += 2 ; }
esif ( ( uchar )c <= 127 ) z[ e++ ] = c ;
esif ( ( uchar )c == 132 ) { memcpy( z+e, "\\'e4", 4 ); e += 4 ; }
esif ( ( uchar )c == 148 ) { memcpy( z+e, "\\'f6", 4 ); e += 4 ; }
esif ( ( uchar )c == 129 ) { memcpy( z+e, "\\'fc", 4 ); e += 4 ; }
esif ( ( uchar )c == 142 ) { memcpy( z+e, "\\'c4", 4 ); e += 4 ; }
esif ( ( uchar )c == 153 ) { memcpy( z+e, "\\'d6", 4 ); e += 4 ; }
esif ( ( uchar )c == 154 ) { memcpy( z+e, "\\'dc", 4 ); e += 4 ; }
esif ( ( uchar )c == 225 ) { memcpy( z+e, "\\'df", 4 ); e += 4 ; }
esif ( ( uchar )c == 196 ) { memcpy( z+e, "\\'ad", 4 ); e += 4 ; }
esif ( ( uchar )c == 179 ) { memcpy( z+e, "\\'7c", 4 ); e += 4 ; }
esif ( ( uchar )c == 205 ) { memcpy( z+e, "\\'2d", 4 ); e += 4 ; }
esif ( ( uchar )c == 186 ) { memcpy( z+e, "\\'7c", 4 ); e += 4 ; }
else z[ e++ ] = '+' ;
}
}
esif is_( to_code, "mae_nach_win" ) // = oem_to_ansi
then {
while ( s1 < e1 )
{
c = z1[ s1++ ] ;
if ( ( uchar )c <= 127 ) z[ e++ ] = c ;
esif ( ( uchar )c == 132 ) z[ e++ ] = 228 ;
esif ( ( uchar )c == 148 ) z[ e++ ] = 246 ;
esif ( ( uchar )c == 129 ) z[ e++ ] = 252 ;
esif ( ( uchar )c == 142 ) z[ e++ ] = 196 ;
esif ( ( uchar )c == 153 ) z[ e++ ] = 214 ;
esif ( ( uchar )c == 154 ) z[ e++ ] = 220 ;
esif ( ( uchar )c == 225 ) z[ e++ ] = 223 ;
else z[ e++ ] = c ;
// else fErr1( c ) //z[ e++ ] = oem_to_ansi[ ( uchar )c - 128 ] ;
}
}
esif is_( to_code, "mae_to_msHtm" )
then {
while ( s1 < e1 )
{
c = z1[ s1++ ] ;
switch ( ( uchar ) c )
{
Case ( uchar )160 : // tabulator
Case ( uchar )225 : z[ e++ ] = ( uchar )223 ; // á
Case ( uchar )228 : z[ e++ ] = ( uchar )132 ; // „
Case ( uchar )148 : z[ e++ ] = ( uchar )246 ; // ”
Case ( uchar )129 : z[ e++ ] = ( uchar )252 ; //
Case ( uchar )142 : z[ e++ ] = ( uchar )196 ; // Ž
Case ( uchar )153 : z[ e++ ] = ( uchar )214 ; //
Case ( uchar )154 : z[ e++ ] = ( uchar )220 ; // š
Else : z[ e++ ] = c ;
}
}
}
esif is_( to_code, "win_nach_mae" )
then {
while ( s1 < e1 )
{
c = z1[ s1++ ] ;
if ( ( uchar )c <= 31 )
then {
if ( ( uchar )c == 10 ) z[ e++ ] = '\n' ; // LF
esif ( ( uchar )c == 13 ) ; // CR
esif ( ( uchar )c <= 25 )
{
S_ "Error in Input: Falsch codierte Umlaute (vi ??):"
"ascii( %u )\n", ( uchar )c _sto
// z[ e++ ] = '
}
}
esif ( ( uchar )c == 92 ) // c is backslash
{
{ z[ e++ ] = '\\' ; z[ e++ ] = '\\' ; }
// N E I N : da sonst "\n ..." nicht mehr richtig
// J A : damit \ als Zeilenvorschub bei define ...
}
esif ( c == '{' ) { memcpy( z+e, "\\{" , 2 ); e += 2 ; }
esif ( c == '}' ) { memcpy( z+e, "\\}" , 2 ); e += 2 ; }
esif ( ( uchar )c <= 127 ) z[ e++ ] = c ;
esif ( ( uchar )c == 228 ) z[ e++ ] = 132 ;
esif ( ( uchar )c == 246 ) z[ e++ ] = 148 ;
esif ( ( uchar )c == 252 ) z[ e++ ] = 129 ;
esif ( ( uchar )c == 196 ) z[ e++ ] = 142 ;
esif ( ( uchar )c == 214 ) z[ e++ ] = 153 ;
esif ( ( uchar )c == 220 ) z[ e++ ] = 154 ;
esif ( ( uchar )c == 223 ) z[ e++ ] = 225 ;
else {
sprintf( z+e, "\\%u", ( uchar )c ); e += 4 ;
}
}
}
esif is_( to_code, "exp_tabs" )
then {
char * blanks = " " ;
while ( s1 < e1 )
{
c = z1[ s1++ ] ;
if ( c == '\n' ) { z[ e++ ] = c ; tab_L = 4 ; }
esif ( c == '\t' ) { memcpy( z+e, blanks, tab_L ); e += tab_L ;
tab_L = 4 ; }
else { z[ e++ ] = c ;
if ( --tab_L == 0 ) tab_L = 4 ; }
}
}
else
{
m_errMess "System: to_code = %s is not supported" m_
to_code, ret_error
}
free( z1 ); if ( z != z_merke ) fErr
LE_
/* public: */ void rBuffer :: scan_str
// -----------------------------------------------------------------------------
(
char * from
, int anz_chars
, char * prefix
)
LB_("rBuffer.scan_str")
strcpy( this -> file, "no file - we want to scan a string" );
exp_umlaute = 0 ;
anf_rem = 0 ;
errors = 0 ;
if ( f > 0 ) { close( f ); } esif ( ! z ) allocate_z() ; // {} muss sein
if ( prefix )
then {
e = strlen( prefix ); memcpy( z, prefix, e );
}
else e = 0 ;
if ( max_e < e + anz_chars )
then {
S_ "anz_chars = %i too large \n", anz_chars _fErr
}
memcpy( z+e, from, anz_chars ); e += anz_chars ;
ateof = true ; *( this->file ) = 0 ;
a = s = j = from_a_anz = 0 ;
LE_
/* private: */ void rBuffer :: allocate_z(
// -----------------------------------------------------------------------------
)
LB_("rBuffer.allocate_z")
fNr = 0 ;
int L = BufL + RS ; // ( 16000 < L ) fErr
z = ( char * )malloc( 2 * L + 300 ); z += PREL ;
// new_sto( z, char[ 2 * L + 200 ] ); z += PREL ;
z_merke = z ;
max_e = 2 * L + 200 - PREL - 32 ;
LE_
/* public: */ void rBuffer :: open_rBuffer
/* -----------------------------------------------------------------------------
Use this open_rBuffer() for reading text appended to a *.exe file.
-----------------------------------------------------------------------------
*/ (
long offset // wenn negativ, von hinten
, char * fn
, char * prefix // or NULL
)
LB_("rBuffer.open_rBuffer")
fErr
corrPos = offset ; open_rBuffer( fn, prefix );
LE_
/* public: */ int rBuffer :: restTrace
// -----------------------------------------------------------------------------
(
char * str
, char * nam
)
LB_("rBuffer.restTrace")
_1(str)
int L = z + e - str ;
traceStr( nam, str, ( 500 < L )? 500 : L );
LE_ret( L )
/* public: */ void rBuffer :: close_rBuffer(
// -----------------------------------------------------------------------------
)
LB_("rBuffer.close_rBuffer")
if ( ! ateof ) { ateof = true ; close( f ); }
LE_
/* public: */ void rBuffer :: reopen_rBuffer
// -----------------------------------------------------------------------------
(
char * fn
, char * prefix // or NULL
)
LB_("rBuffer.reopen_rBuffer")
close_rBuffer(); open_rBuffer( fn, prefix );
LE_
/* public: */ void rBuffer :: open_rBuffer
// -----------------------------------------------------------------------------
(
char * fn
, char * prefix // or NULL
)
LB_("rBuffer.open_rBuffer")
*file = 0 ;
checkMe = 0 ;
if ( safe_ut.neuNam )
{
if substr( safe_ut.neuNam, fn )
printf( "\n neuNr %i: open rBuffer %s", neuNr, fn );
}
showProgress
SCTr printf( "\nopen rB %s", fn );
ii = 0 ; eofMarker = " \n EOF = {[(.)]}/\\-_' \" " ;
// Roter Teil wird von gewissen Anwendungen erwartet - nicht ab„ndern!
// Es wird ohnehin stets z[e] = 0 gesetzt.
if ( tr_rBuffer ) printf( "\ntr_: open rBuffer %s\n", fn );
strcpy( this -> file, "is not yet open" );
out_at_work = 0 ;
ers_umlaute = 0 ;
exp_umlaute = 0 ; tab_L = 4 ;
anf_rem = 0 ;
errors = 0 ;
if ( f > 0 ) { close( f ); } esif ( ! z ) allocate_z() ; // {} muss sein
if ( prefix )
then {
e = strlen( prefix ); memcp( z, prefix, e );
}
else e = 0 ;
if ( ! fn ) fErr
expansion( file, fn ); // declares file as a path variable
if ( no_file( file ) && not_is_( file, "stdin" ) )
then {
{
m_errMess "System: No such file for open_rBuffer: %s" m_
file, ret_error
}
printf( "\nError: not a file: %s\n", file ); exit( 1 );
}
if is_( file, "stdin" )
then {
f = 0 ;
}
esif (( f = open( file, 'R', 't' ) ) == -1 )
{
a = e = s = j = 0 ;
int w = strlen( file );
int wz = 0 ;
while ( w )
{
if ( file[ --w ] == '\\' ) wz = 0 ; else
if ( file[ w ] == '.' )
{
if ( 3 < wz ) fErr1( file )
wz = 0 ;
}
else wz++ ;
if ( 8 < wz ) fErr3( fn, wz, w )
}
S_ "error: cannot open %s\n", file _fErr
}
else from_a = INT_MIN ;
// Beachte: Der Umlaut Ue wird durch den vi in ein Byte verwandelt,
// welches read als Ende der Datei interpretiert (das sie 'cooked'
// ge”ffnet wird).
if ( corrPos )
{
_x( corrPos )
if ( corrPos < 0 )
then lseek( f, -corrPos, SEEK_END );
else lseek( f, corrPos, SEEK_SET );
if ( errno ) fErr2( corrPos, errno )
corrPos = 0L ;
}
int r = BufL - e ; int gel = get_more( f, z+e, r );
// int fLen = file_len( f );
//
if ( gel < 0 ) fErr5( gel, e, a, fn, file_len( f ) )
a = s = j = 0 ; e += gel ; if_ateof();
// if ( ateof && e-a < fLen ) fErr2( fLen, e-a ) // NEIN !!!!
strcpy( this -> file, file );
z[ e+1 ] = z[ e ] = info[ 0 ] = 0 ;
// char * fende = z + e - 100 ; if ( ateof && z < fende ) _2( fende, file )
from_a_anz = 0 ;
from_a = 0 ;
remember( PREL );
z[e] = 0 ;
skipUtfNULL = 0 ;
if ( (uchar)( z[a] ) == (uchar)255 ) // wenn Utf coded
{
path zz ; s_( zz, "char %s 1 8", fn ); dos_me( zz );
// system_do( zz );
no_utf();
a += 2 ;
}
strcpy( file, fn );
printf( "\ncall_nr %u, rB.file = %s", call_nr, file );
LE_
/* private: */ void rBuffer :: if_ateof(
// -----------------------------------------------------------------------------
)
LB_("rBuffer.if_ateof")
// Beachte: Wollte man N bytes lesen, so kann gel < N sein auch dann, wenn
// das Ende der Datei noch n i c h t erreicht ist.
ateof = _eof( f ); // ( gel == 0 ); // GNU does not support eof()
if ( ateof )
then {
// show_rest();
if ( f ) close( f );
if is( file, "rm_", 3 ) unlink( file ); ok
if ( z[ e-1 ] != '\n' ) z[ e++ ] = '\n' ;
}
LE_
/* public: */ void rBuffer :: show_rest(
/* -----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/ )
LB_("rBuffer.show_rest")
# define GR 50
int sh = GR ; if ( e < GR ) sh = e ;
char str[ GR+3 ] ; memcpy( str, z+e-sh, sh ); memcpy( str+sh, "]\n", 3 );
trace_( str );
int k = 0 ; while ( str[ k ] ) k++ ;
for ( ; k < sh ; k++ ) L1_( z[k] )
# undef GR
LE_
/* public: */ uint rBuffer :: remember ( uint anz_rem
/* -----------------------------------------------------------------------------
remember anz_rem positions preceeding z[a]
-----------------------------------------------------------------------------
*/ )
LB_("rBuffer.remember")
if ( PREL < anz_rem ) fErr1( PREL ) else anz_rem = PREL ; // robust
anf_rem = - anz_rem ;
LE_ret( anz_rem )
/* public: */ char * rBuffer :: getmore
/* -----------------------------------------------------------------------------
Shift the buffer (as a window into the file) to contain more data
not yet processed, then mark the end of the buffer by 'ende.
-----------------------------------------------------------------------------
*/ (
char * & c // pointer into buffer B.[a..e[
, int notw
, char * ende
)
LB_("rBuffer.getmore")
if ( ateof || notw < e-a ) ret( z+a )
int n = c - ( z+a ); getmore( notw, ende );
c = z + a + n ;
LE_ret( z+a )
/* public: */ char * rBuffer :: getmore
/* -----------------------------------------------------------------------------
Shift the buffer (as a window into the file) to contain more data
not yet processed.
-----------------------------------------------------------------------------
*/ (
int notw
, char * ende
)
LB_("rBuffer.getmore")
if ( ateof ) { ret( z+a ) }
// if ( ateof ) { if ( ende ) strcpy( z+e, ende ); ret( z+a ) }
//
if ( notw == -1 ) notw = sBufL - e + a ;
if ( ateof || notw < e-a ) ret( z+a )
notw = sBufL - e + a ; // the maximal possible shift
//
if ( a < -100 || e < a ) S_ "a,s,e,f = %i, %i, %i, %s", a, s, e, file _fErr
int a_raw = e - a ;
if ( a <= 0 )
then {
if ( ateof ) ret( z+a )
if ( BufL <= e ) { out(__LINE__); fErr } // cannot shift
}
__
if ( 0 < a )
then {
int k = anf_rem ; // see remember(), default = 0
while ( k < e-a ) { z[k] = z[k+a] ; k++ ; } // memmove not GNU-
// supported
s -= a ; if ( s < 0 ) s = 0 ;
j -= a ; if ( j < 0 ) j = 0 ;
e -= a ;
a = 0 ;
}
if ( BufL - e <= 0 ) { L3_( a, e, ateof ) fErr }
int gel = get_more( f, z+e, BufL - e ); if ( gel < 0 ) fErr
e += gel ; from_a = INT_MIN ; if_ateof();
if ( ers_umlaute ) ers_Umlaute( /* MAE to WIN */ );
if ( exp_umlaute ) exp_Umlaute( exp_umlaute, a + a_raw );
if ( e < 0 || e < a ) fErr3( a, s, e )
if (1)
{
if ( e <= a && ! ateof ) fErr1( file )
}
if ( skipUtfNULL ) no_utf();
strcpy( z+e, eofMarker ); if ( z != z_merke ) fErr
z[e] = 0 ;
if ( ers_upper_to_lower ) noCase();
if ( ers_unicode ) unicode();
if (0)
{
// char * x = eos( z+a ); if ( x < z+e ) { _1( x-7 ) fErr1( file ) }
char * x = eos( z+a ); if ( x < z+e ) *x = ' ' ;
}
LE_ret( z+a )
/* public: */ void rBuffer :: noCase (
/* -----------------------------------------------------------------------------
nur aktivieren, wenn man alles to_lower sehen m”chte
-----------------------------------------------------------------------------
*/ )
LB_("rBuffer.noCase")
ret_
ers_upper_to_lower = true ;
z[e] = 0 ; lower( z+a );
LE_
/* public: */ BOOL rBuffer :: has_NULL (
/* -----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/ )
LB_("rBuffer.has_NULL")
char * x = z + a - 1 ;
char * u = z + e ;
while ( ++x < u ) if ( ! *x )
{
printf( "\n\nNULL following [%s]\n", z + a );
traceStr( "has_NULL", x, 100 );
ret( x - ( z + a ) )
}
LE_ret( 0 )
/* private: */ void rBuffer :: ers_Umlaute (
/* -----------------------------------------------------------------------------
Maestro nach MS Windows
-----------------------------------------------------------------------------
*/ )
LB_("rBuffer.ers_Umlaute")
char * c = z + a ; char * x = c-1 ;
char * m = z + e ;
while ( ++x < m )
{
switch ( ( uchar )( *x ) )
{
Case 132 : *x = ( uchar ) 228 ; // „
Case 148 : *x = ( uchar ) 246 ; // ”
Case 129 : *x = ( uchar ) 252 ; //
Case 142 : *x = ( uchar ) 196 ; // Ž
Case 153 : *x = ( uchar ) 214 ; //
Case 154 : *x = ( uchar ) 220 ; // š
}
}
LE_
/* public: */ char rBuffer :: preChar( char * str
// -----------------------------------------------------------------------------
)
LB_("rBuffer.preChar(")
char * x = z + a - 1 ;
while ( z < x && in_str( *x, str ) ) x-- ;
LE_ret( *x )
/* private: */ char * rBuffer :: getmore
/* -----------------------------------------------------------------------------
Shift the buffer (as a window into the file) to contain more data
not yet processed.
Wird z.B. in find() genau so ben”tigt !!!!
-----------------------------------------------------------------------------
*/ (
FILE * wto
)
LB_("rBuffer.getmore")
if ( s < a ) fErr
if ( wto && a < s ) put( wto, z+a, s-a );
a = s ; if ( ! ateof ) getmore( sBufL, "" );
LE_ret( z+a )
/* public: */ BOOL rBuffer :: rest_s_gr
/* -----------------------------------------------------------------------------
return(" still more than n chars after z[s] ")
-----------------------------------------------------------------------------
*/ (
int n // ret BOOL( "more than n bytes left" )
)
LB_("rBuffer.rest_s_gr")
if ( !ateof && e < s+n ) getmore( sBufL, 0 );
LE_ret( n < e-s )
/* public: */ BOOL rBuffer :: rest(
// -----------------------------------------------------------------------------
)
LB_("rBuffer.rest")
// if ( s < a ) fErr ///
if ( e <= s && ! ateof ) getmore( sBufL, 0 );
LE_ret( a < e )
/* public: */ void rBuffer :: trace
// -----------------------------------------------------------------------------
(
char * name // Objekt
, FILE * f // soll geschrieben werden nach
)
LB_("rBuffer.trace")
fprintf( f, "\n%s - Instanz der Klasse 'rBuffer': \n\n", name );
out( 0 );
LE_
/* public: */ void rBuffer :: out
// -----------------------------------------------------------------------------
(
int at // __LINE__
)
LB_("rBuffer.out")
int L = s-a ; if ( L <= 0 ) L = 80 ; else L += 20 ;
out( at, 'a', L );
if ( a < s && s < e ) out( at, 's', 10 );
LE_
/* public: */ void rBuffer :: out
// -----------------------------------------------------------------------------
(
int at //
, char c // 'a' or 's'
, int anz //
)
LB_("rBuffer.out")
if ( out_at_work ) ret_ else out_at_work = true ;
S_ "\n\nrB at %d: a,s,e,eof = ( %d, %d, %d, %d ) of file( %s )\n%c:("
, at, a, s, e, ateof, this->file, c _TR
char * from ;
if ( c == 'a' ) from = z+a ;
esif ( c == 's' ) from = z+s ; else { L1_( c ) fErr }
if ( from < z )
then {
printf( "\nrBuffer.cpp, Line %i: from < z", __LINE__ );
fErr4( from-z, a,e,s )
}
if ( from < z+e )
then {
show_str( "rB_from-4", from-4, z+e - from + 4 );
/*
char sss[ L_sss ] ;
if ( z+e - from < anz ) anz = z+e - from ;
if ( L_sss - 6 < anz ) anz = L_sss - 6 ;
memcpy( sss, from, anz ); sss[ anz ] = 0 ;
int k = 0 ; while ( sss[k] == 0 && k < anz ) sss[ k++ ] = 'N' ;
S_ "%s", sss _TR
*/
}
else ;
trace_( ")\n" ); L1_( anz )
out_at_work = false ;
LE_
/* public: */ void rBuffer :: to ( FILE * f
/* -----------------------------------------------------------------------------
append rest of buffered file to a stream fs ,
return number of bytes written to fs
-----------------------------------------------------------------------------
*/ )
LB_("rBuffer.to")
copy_to( f );
LE_
/* public: */ void rBuffer :: copy_to_close ( FILE * f
// -----------------------------------------------------------------------------
)
LB_("rBuffer.copy_to_close")
copy_to( f ); close( f );
LE_
/* public: */ void rBuffer :: copy_to ( FILE * fs
/* -----------------------------------------------------------------------------
append rest of buffered file to a stream fs ,
return number of bytes written to fs
-----------------------------------------------------------------------------
*/ )
LB_("rBuffer.copy_to")
// if ( ! ateof ) { find( 0, "$
long m = 0 ;
while ( a < e || ! ateof )
{
// z[e] = 0 ;
put( fs, z+a, e-a ); // da es bin„re Fles geben kann
m += ( e-a ); a = s = e ; getmore( sBufL, 0 );
}
// LE_ret( m );
LE_
/* public: */ void rBuffer :: rest_to
/* -----------------------------------------------------------------------------
append str and then rest of buffered file to open file f
-----------------------------------------------------------------------------
*/ (
char * str
, char * c
, FILE * f
)
LB_("rBuffer.rest_to")
a = c - z ; fprintf( f, "%s", str );
copy_to( f );
LE_
/* public: */ void rBuffer :: done_DEL
// -----------------------------------------------------------------------------
(
FILE * f
, char * neu
, char * tm1
)
LB_("rBuffer.done_DEL")
copy_to( f ); close( f ); cp_file( neu, tm1 );
if ( tm1 ) Unlink( tm1 )
LE_
/* public: */ char * rBuffer :: next_ersetze
/* -----------------------------------------------------------------------------
*/ (
FILE * f
, char * str1
, char * str2
)
LB_("rBuffer.next_ersetze")
LE_ret( next_ersetze( 0, f, str1, str2 ) )
/* public: */ char * rBuffer :: next_ersetze
/* -----------------------------------------------------------------------------
*/ (
int offs
, FILE * f
, char * str1
, char * str2
)
LB_("rBuffer.next_ersetze")
if ( ! f || ! str1 || ! *str1 || ! str2 ) fErr3( f, str1, str2 )
if ( ! find( offs, str1, f ) ) fErr
a += strlen( str1 );
fprintf( f, "%s", str2 );
LE_ret( z+a )
/* public: */ void rBuffer :: select
/* -----------------------------------------------------------------------------
select a section to f
-----------------------------------------------------------------------------
*/ (
FILE * f
, char * str1
, char * str2
, char * str3
)
LB_("rBuffer.select")
if ( ! f ) fErr
rB_( *this, 0, str1, 0 )
rB_( *this, 1, str2, 0 )
rB_( *this, 1, str3, f )
LE_
/* public: */ char * rBuffer :: string_at
/* -----------------------------------------------------------------------------
Pre-condition:
This is an rBuffer( str1, str2, true ) seen as a keystring.
Note: If str1 as well as str2 are itself keystrings, and if
some keys present in str2 are also present in str1 , the str1
is information superseding str2 .
The string returned is
- either the default_2 (if at is not present as a key),
- or the default_1 (if at is present as a key but has no value
assigned to it at its first occurrance),
- the value assigned to the key at otherwise (again the first
occurrance considered).
-----------------------------------------------------------------------------
*/ (
char * at
, char * default_1
, char * default_2
)
LB_("rBuffer.string_at")
a = 0 ; find( 0, at, ( FILE * )0 );
while ( rest() )
{
s += strlen( at );
if ( isspace( z[s] ) ) ret( default_1 )
if ( z[ s ] != '=' )
if ( z[ s+1 ] == '\'' ) ret( z+s+1 ) else ret( z+s );
}
LE_ret( default_2 )
/* public: */ void rBuffer :: reset(
/* -----------------------------------------------------------------------------
Show file( 0.. ) in z and reset a = s = 0 .
-----------------------------------------------------------------------------
*/ )
LB_("rBuffer.reset")
if ( strcmp( file, "str1 str2" ) )
then {
if ( ! ateof ) close(f) ;
f = open( file, 'r', 't' );
e = get_more( f, z, BufL ) ; ateof = ( e < BufL );
if ( ateof ) close( f );
z[ e+1 ] = z[ e ] = info[ 0 ] = 0 ;
}
else ;
a = s = 0 ;
from_a = INT_MIN ;
LE_
/* public: */ BOOL rBuffer :: match
/* -----------------------------------------------------------------------------
return BOOL( c ist element of set[ 0 .. n [ )
-----------------------------------------------------------------------------
*/ (
char c // search it in the set
, char * set // a set of characters
, int n // the first n characters in this set
)
LB_("rBuffer.match")
fErr // rename it to 'c_in_set'
while ( 0 <= --n ) if ( c == set[n] ) ret( true )
LE_ret( false )
/* public: */ char * rBuffer :: find
/* -----------------------------------------------------------------------------
Is to search for a string str , and is to set s = position of string
so that then z[ s.. ] = str .
In case of wto != 0 , everything in front of it is written to the
file wto , and a ist set to s .
ret( 0 ) means "string not found"
-----------------------------------------------------------------------------
*/ (
int p // offset
, char * str // string to search for
, FILE * wto // file open for writing
)
LB_("rBuffer.find")
// has_NULL();
fNr++ ;
call_nr++ ;
if (0)
{
if ( traceMe ) showStr( "B.a-1 ...", z+a-1, 10 );
if ( traceMe ) printf( "\nsuche[ %s ]", str );
if ( a == e && ateof ) printf( "\nsuche[ %s ]", str );
}
from_a_check( str ); ++ii ;
int n = strlen( str );
int repeat ;
__
if ( e <= a )
{
if ( ateof )
{
a = e ; // da ( e < a ) erlaubt sein muss (s. help_gen)
ret( 0 )
}
if ( ateof ) printf( "\nWARN: e-a = %i, ateof = %i", e-a, ateof );
}
__
s = a + p ;
// if ( traceMe ) traceStr( "sss", z+s, 100 );
LOOP ( repeat, 1 )
{
__
if ( e <= s+n )
{
__ if ( ateof ) {
if ( wto ) put( wto, z+a, e-a );
ret( 0 )
}
__
__ getmore( wto ); if ( e <= s+n )
{
// Dieser Fehler tritt auf, wenn rBuffer eine
// noch im Entstehen begriffene Datei ge”ffnet
// hat - ein Programmierfehler !!!
if ( ! ateof ) fErr5( file, a,e,s,n )
}
}
__
char x = z[ e ] = *str ; // sentinel
__
while ( z[ s ] != x ) s++ ;
if ( n <= e-s && At( z+s, str ) ) break ;
__
if ( s < e )
then {
__ __ if ( e <= s+n )
{
getmore( wto ); if ( e <= s+n )
{
if ( wto ) put( wto, z+a, e-a );
a = s = e ; ret(0)
}
}
repeat = memcmp( z+s, str, n );
if ( repeat ) s++ ;
}
else {
__ s = e ; getmore( wto );
}
}
__
if ( wto && a < s ) put( wto, z+a, s-a );
__
a = s ;
if ( ! ateof && e < a + 8000 ) getmore( 8000 );
if ( ateof && e == a ) ret( 0 )
__
if ( e < a ) fErr
// if not_At( z+a, str ) fErr1( str )
__
LE_ret( z+a )
/* public: */ match_rec * rBuffer :: find
/* -----------------------------------------------------------------------------
Is to search for the next character 'c' such that func[c] = true.
return 0 if not found
-----------------------------------------------------------------------------
*/ (
int p // offset
, str_set & strset //
, FILE * wto // file open for writing
)
LB_("rBuffer.find")
// has_NULL();
fNr++ ;
// fflush( stdout ); fflush( stderr );
call_nr++ ;
uint1 sent = 255 ; ++ii ;
char * xxx = z ; // Value does not matter
while ( sent && ! strset.strings[ sent ] ) sent-- ;
if ( ! strset.strings[ sent ] )
then {
{
m_errMess "User: Strset for find() must not be empty." m_
ret_error
}
}
else z[e] = sent ; // for sentinel
match_rec * a_match ;
if ( e < a ) a = e ; // Es darf eingangs e < a sein !!
getmore( p + 10, 0 ); s = a + p ;
if ( e <= s )
{
if ( ! ateof ) fErr ;
if ( wto ) put( wto, z+a, e-a );
a = e ; ret( 0 )
}
while ( e )
{
from_a_check( "out of str_set" )
if ( e <= s )
then {
if ( ateof && e-a <= 1 ) ret( 0 )
if ( wto ) put( wto, z+a, e-a );
a = e ; getmore( sBufL, 0 );
}
while ( ! strset.strings[ ( uchar )z[s] ] && s < e )
{
char * c = z+s-1 ;
char * ce = z+e ; if ( ce <= c ) fErr
while ( ! strset.strings[ ( uchar )( *(++c) ) ] )
{
if ( ce <= c ) break;
}
s = c-z ;
if ( s == e )
then {
if ( wto ) put( wto, z+a, s-a ); a = s ;
getmore( sBufL, 0 );
}
}
if ( e < s ) s = e ;
if ( wto && a < s ) put( wto, z+a, s-a ); a = s ;
if ( ateof && e <= s ) goto Le ; // es kann hier auch e < s sein
getmore( strset.maxlen, 0 );
a_match = strset.match( z+s, 0 );
if ( a_match )
then {
if ( ! ateof && e < a + 8000 ) getmore( 8000 );
atStr = a_match -> str ;
ret( a_match )
}
else s++ ;
__ }
Le: if ( a != e || ! ateof ) fErr3( a, e, s ) else s = e ;
LE_ret( 0 )
/* public: */ char * rBuffer :: s_to_not_Blank
/* -----------------------------------------------------------------------------
Is to search for the next non-empty character and is to identify
the smallest "oms_string" starting with this character.
We search until eos (in case of eos = '\n' empty lines will be
skipped however).
return( 0 ) means: "string not found"
-----------------------------------------------------------------------------
*/ (
int p // offset
, FILE * wto // file open for writing
, char eos // end of search space
)
LB_("rBuffer.s_to_not_Blank")
from_a_check( "rBuffer.s_to_not_Blank" )
if ( eos == ' ' ) fErr
int repeat = 0 ; if ( wto == 0 ) getmore( sBufL, 0 );
if ( e < a ) a = e ; // Es darf eingangs e < a sein (kein Fehler!)
s = a + p ; if ( e < s ) ret(0)
do {
if ( a + rest() <= s )
{
if ( wto ) put( wto, z+a, s-a ); a = s ; ret(0)
}
while ( z[s] == ' ' && s < e ) s++ ;
getmore( wto );
}
while ( repeat && s < e+1 );
if ( wto && a < s ) put( wto, z+a, s-a );
char fc = z[s] ; // e.g. a string quote character
a = s ;
if ( e == s ) ret(0)
esif ( fc == eos && eos == '\n' ) ret( s_to_not_Blank( 1, wto, eos ))
else ;
getmore( 100, 0 ); int s1 = s ;
char cc[2] ; cc[0] = eos ; cc[1] = 0
; strcpy( cc, "\n" ); find( 0, cc, 0 ); a = s ;
while ( z[s] != fc && z[s] != ' ' ) s-- ;
LE_ret( z + s1 );
/* private: */ void rBuffer :: exp_incs
/* -----------------------------------------------------------------------------
auxiliary - to be called from exp_incs only
-----------------------------------------------------------------------------
*/ (
char * esc // escape string to search for
, FILE * wto // file open for writing
, array_c & arr // pathes to file already included
, char * at_file // file that called the include
)
LB_("rBuffer.exp_incs")
rBuffer * inc ;
int j ;
fprintf( wto, "\n- f %s\n\n", at_file );
exp_Umlaute( exp_umlaute, a ); find( 0, esc, wto );
while ( rest() )
{
s += strlen( esc );
while ( z[ s ] != ' ' ) s-- ;
a = ++s ; while not_space( z[s] ) s++ ; j = z[s] = 0 ;
path in ; expansion( in, z+a );
while ( j < arr.nxt )
{
if is_( in, arr.c + arr.pos[ j ] ) j = arr.nxt + 1 ; else j++ ;
}
if ( j == arr.nxt ) // bislang noch nicht includiert
then {
j = arr.pos[ arr.nxt ] ;
if ( arr.no_pos <= ++ arr.nxt ) fErr
arr.pos[ arr.nxt ] = j + strlen( in ) + 1 ;
if ( arr.no_c <= arr.pos[ arr.nxt ] ) fErr
new_sto( inc, rBuffer( in, "" ) );
strcpy( arr.c + j, in );
inc->exp_incs( esc, wto, arr, in );
fprintf( wto, "\n- f %s\n\n", at_file );
rem_sto( inc );
}
else ;
a = s ; find( 0, "\n", 0 ); find( 0, esc, wto );
}
LE_
/* public: */ void rBuffer :: exp_incs
/* -----------------------------------------------------------------------------
expand recursively all includes escaped by the given esc symbol
-----------------------------------------------------------------------------
*/ (
char * esc // escape string to search for
, char * to // the expanded file
, char * umlaute // 0, two_chars, rtf_chars, ...
)
LB_("rBuffer.exp_incs")
exp_umlaute = umlaute ;
FILE * wto ; create( wto, to );
new_sto( arr.pos, int[ arr.no_pos = 200 ] )
new_sto( arr.c , char[ arr.no_c = 8000 ] )
strcpy( arr.c, this->file );
arr.pos[ 0 ] = 0 ;
arr.pos[ 1 ] = 1 + strlen( arr.c ) ;
arr.nxt = 1 ;
exp_incs( esc, wto, arr, this->file );
rem_sto( arr.c );
rem_sto( arr.pos );
close( wto );
LE_
/* public: */ void rBuffer :: step
// -----------------------------------------------------------------------------
(
char * x
, FILE * f
)
LB_("rBuffer.step")
if ( f )
{
char merke = *x ; *x = 0 ; fprintf( f, "%s", z+a ); *x = merke ;
}
a = x - z ;
LE_
/* public: */ void rBuffer :: skip
// -----------------------------------------------------------------------------
(
int offset
, char * str
)
LB_("rBuffer.skip")
a += offset ; while in_str( z[a], str ) a += 1 ;
LE_
/* public: */ char * rBuffer :: skip_HTM_or_XML
/* -----------------------------------------------------------------------------
<str ... </str> // end of nest
| |
c (ein) c (aus)
-----------------------------------------------------------------------------
*/ (
BOOL trace
, int offset
, char * c // muss im ersten <str ...> stehen: aber nur irgendwo dort
, char * str
)
LB_("rBuffer.skip_HTM_or_XML")
if ( !str || ! *str ) fErr
int n = strlen( str ) ;
int L = n + 1 ;
int k = 1 ;
char * x = substr( str, c + offset );
while ( x )
{
while ( x && not_in_str( x[n], "> \n" ) && not_in_str( x[-1], "</" ) )
{
x = substr( str, x+n );
}
if ( x[-1] == '<' ) k++ ;
esif ( x[-1] == '/' ) k-- ;
if ( k == 0 ) ret( x + L ) else x = substr( str, x + L );
}
fErr1( k )
LE_ret( 0 )
/* public: */ void rBuffer :: skipComment
/* -----------------------------------------------------------------------------
Der Aufrufer sagt:
z[ a.. ] = "/... " oder "/..." - skip this comment if z[ a+1 ] is
either * or / , otherwise there is no comment to skip.
In case of "/. ... " we assume that the next "./" means the end of
this comment - i.e. we do not test whether the comment contains this
as a substring (which m i g h t be the case)!
Die Funktion garantiert: ok || fErr
-----------------------------------------------------------------------------
*/ (
FILE * f
)
LB_("rBuffer.skipComment")
if ( z[ a+1 ] == '*' )
then {
if ( ! find( 2, "*/", f ) ) fErr1( ateof )
if ( f ) fprintf( f, "*/" );
a += 2 ;
}
esif ( z[ a+1 ] == '/' )
{
while is( z + a+1, "//", 2 ) find( 1, "\n", f );
}
LE_
#undef static
#endif