1 #include "sbcomp.hxx" 2 #include "scanner.hxx" 3 #include "token.hxx" 4 5 // Override of SbModule::SetSource32() - compiled into the test binary so 6 // the linker picks our version instead of libsb.so's buggy one (which has 7 // the TokenLabelInfo buffer overflow bug causing heap corruption). 8 SetSource32(const::rtl::OUString & r)9void SbModule::SetSource32( const ::rtl::OUString& r ) 10 { 11 aOUSource = r; 12 StartDefinitions(); 13 SbiTokenizer aTok( r ); 14 while( !aTok.IsEof() ) 15 { 16 SbiToken eEndTok = NIL; 17 18 // Suchen nach SUB oder FUNCTION 19 SbiToken eLastTok = NIL; 20 while( !aTok.IsEof() ) 21 { 22 SbiToken eCurTok = aTok.Next(); 23 if( eLastTok != DECLARE ) 24 { 25 if( eCurTok == SUB ) 26 { 27 eEndTok = ENDSUB; break; 28 } 29 if( eCurTok == FUNCTION ) 30 { 31 eEndTok = ENDFUNC; break; 32 } 33 if( eCurTok == PROPERTY ) 34 { 35 eEndTok = ENDPROPERTY; break; 36 } 37 if( eCurTok == OPTION ) 38 { 39 eCurTok = aTok.Next(); 40 if( eCurTok == COMPATIBLE ) 41 aTok.SetCompatible( true ); 42 else if ( ( eCurTok == VBASUPPORT ) && ( aTok.Next() == NUMBER ) ) 43 { 44 sal_Bool bIsVBA = ( aTok.GetDbl()== 1 ); 45 SetVBACompat( bIsVBA ); 46 aTok.SetCompatible( bIsVBA ); 47 } 48 } 49 } 50 eLastTok = eCurTok; 51 } 52 // Definition der Methode 53 SbMethod* pMeth = NULL; 54 if( eEndTok != NIL ) 55 { 56 sal_uInt16 nLine1 = aTok.GetLine(); 57 if( aTok.Next() == SYMBOL ) 58 { 59 String aName_( aTok.GetSym() ); 60 SbxDataType t = aTok.GetType(); 61 if( t == SbxVARIANT && eEndTok == ENDSUB ) 62 t = SbxVOID; 63 pMeth = GetMethod( aName_, t ); 64 pMeth->nLine1 = pMeth->nLine2 = nLine1; 65 // Die Methode ist erst mal GUELTIG 66 pMeth->bInvalid = sal_False; 67 } 68 else 69 eEndTok = NIL; 70 } 71 // Skip bis END SUB/END FUNCTION 72 if( eEndTok != NIL ) 73 { 74 while( !aTok.IsEof() ) 75 { 76 if( aTok.Next() == eEndTok ) 77 { 78 pMeth->nLine2 = aTok.GetLine(); 79 break; 80 } 81 } 82 if( aTok.IsEof() ) 83 pMeth->nLine2 = aTok.GetLine(); 84 } 85 } 86 EndDefinitions( sal_True ); 87 } 88