Changeset 84af815 in tol


Ignore:
Timestamp:
Mar 9, 2012, 3:54:00 PM (15 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
0fd52fc
Parents:
bfa6580
Message:

refs #1460, #1476, se implementa TextMatch en C (tomado de la implementación interna de tcl), ya no se recurre a Tcl_Eval, el argumento pattern se pasa por referencia evitando una copia temporal, se eliminan algunos warnings de compilación

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@4326 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • tol/bbasic/tol_btext.h

    rbfa6580 r84af815  
    386386
    387387  //! Checks if a given pattern matchs with the actual text
    388   BBool Match (const BText pattern, BBool caseSensitive=BFALSE) const;
     388  BBool Match (const BText &pattern, BBool caseSensitive=BFALSE) const;
    389389
    390390  //! Returns the wrapped text \a txt compacted
  • tol/bbasic/txtalgeb.cpp

    rbfa6580 r84af815  
    717717  {
    718718    const BChar* beginText;
    719     if(beginText = strstr(String() + from, txt.String()))
     719    if( (beginText = strstr(String() + from, txt.String())) )
    720720    {
    721721      indexText = (beginText - String());
    … …  
    849849  number = 0;
    850850  BChar* pos=Buffer();
    851   while(pos=strchr(pos, oldChar))
     851  while( (pos=strchr(pos, oldChar)) )
    852852  {
    853853    *pos = newChar;
    … …  
    907907        txt.ReallocateBuffer(2*txt.Size());
    908908      }
    909       if(pos=strstr(Buffer()+oldPos, oldText.String()))
     909      if( (pos=strstr(Buffer()+oldPos, oldText.String())) )
    910910      {
    911911        number++;
    … …  
    10621062
    10631063
    1064 //--------------------------------------------------------------------
    1065 BBool BText::Match(const BText pattern, BBool caseSensitive) const
     1064#include "StringMatch.cpp"
     1065
     1066//--------------------------------------------------------------------
     1067BBool BText::Match(const BText &pattern, BBool caseSensitive) const
    10661068
    10671069/*! Returns true if the pattern \a pattern makes match with the
    … …  
    10811083{
    10821084  assert(IsAllOk());
     1085  return Tol_StringCaseMatch( String(), pattern.String(), !caseSensitive );
     1086#if 0
    10831087  BBool Ok=BFALSE;
    10841088  if(!HasName() || !pattern.HasName()) { Ok=BFALSE; }
    … …  
    11201124  }
    11211125  return(Ok);
     1126#endif
    11221127}
    11231128
    … …  
    11391144  BText txt;
    11401145  BInt len;
    1141   if(len=strftime(buf, maxSize, fmt, localtime(&t)))
     1146  if( (len=strftime(buf, maxSize, fmt, localtime(&t))) )
    11421147  {
    11431148    txt.Copy(buf,len-1);
    … …  
    12251230  for(n=0; (n<maxItems) && pos && oldPos[0]; n++)
    12261231  {
    1227     if(pos = strchr(oldPos, sep))
     1232    if( (pos = strchr(oldPos, sep)) )
    12281233    {
    12291234      txt[n].Copy(oldPos, 0, pos-oldPos-1);
  • tol/btol/real_type/datgrav.cpp

    rbfa6580 r84af815  
    21152115  BInt mode = 0;
    21162116  if(Arg(3)) { mode = (BInt)Real(Arg(3)); }
    2117   if(TolTclIsEnabled())
    2118   {
    2119     if ( tclTextMatch || ( tclTextMatch = (BUserFunction*)GraReal()->FindOperator( "TextMatch_Tcl" ) ) ) {
    2120       BList *args = Cons( Arg(1), NCons( Arg(2) ) );
    2121 
    2122       if ( Arg(3) ) {
    2123         LstAppend( args, Arg(3) );
    2124       } else {
    2125         BUserDat *uMode = BContensDat::New( "", BDat(mode), "" );
    2126         uMode->PutName( "case" );
    2127         LstAppend( args, uMode );
    2128       }
    2129       BSyntaxObject *evalResult = tclTextMatch->Evaluator( args );
    2130       if ( evalResult ) {
    2131         contens_ = Dat( evalResult );
    2132       }
    2133       // DUDA: debo destruir args?
    2134       DESTROY( evalResult );
    2135       return;
    2136     }
    2137   }
    2138   Warning("Using internal version of TextMatch could cause invalid results. "
    2139           "Please use a TCL version of TOL like tolsh or tolbase.");
     2117 
    21402118  contens_ = (BReal)(string.Match(pattern, mode));
    21412119}
Note: See TracChangeset for help on using the changeset viewer.