RE: How to define the expression to check if a big char st ring contai ns small char string

From: Borse, Ganesh <ganesh.borse_at_credit-suisse.com>
Date: Thu, 29 Nov 2007 18:00:23 +0800

This error message printed from the file "root/hist/src/TFormula.cxx" & the method "Int_t TFormula::Compile(const char *expression)":

   //*-* replace 'normal' == or != by ==(string) or !=(string) if needed.    Int_t is_it_string,last_string=0,before_last_string=0;    if (!fOper) fNoper = 0;
   enum { kIsCharacter = BIT(12) };
   for (i=0; i<fNoper; i++,

      before_last_string = last_string,
      last_string = is_it_string) {
      is_it_string = IsString(i);
      if (is_it_string) continue;
      if (GetAction(i) == kstrstr) {
         if (! (before_last_string && last_string) ) {
            Error("Compile", "strstr requires 2 string arguments");
            return -1;
         }

The function IsString() is also defined in this same file. Which is like this: Bool_t TFormula::IsString(Int_t oper) const {

   // return true if the expression at the index 'oper' is to be treated as string    return GetAction(oper) == kStringConst; }

How to define a string of "kStringConst" type, so that this expression is true & we don't get above error?

-----Original Message-----
From: Borse, Ganesh
Sent: 29 November 2007 17:39
To: 'Philippe Canal'; Borse, Ganesh; roottalk_at_lxbuild091.cern.ch Subject: RE: [ROOT] How to define the expression to check if a big char st ring contai ns small char string

A quick grep through the ROOT libraries installed on my machine, shows that this error message is emitted by the root library libHist.so. # gborse ~/pxm/root>strings ./lib/libHist.so|grep -i strstr strstr strstr requires two arguments strstr requires 2 string arguments <---------- strstr( strstr kstrstr=23

-----Original Message-----
From: Philippe Canal [mailto:pcanal_at_fnal.gov] Sent: 29 November 2007 16:47
To: 'Borse, Ganesh'; roottalk_at_lxbuild091.cern.ch Subject: RE: [ROOT] How to define the expression to check if a big char st ring contai ns small char string

Hi Ganesh,

According to your code you use something that look like wrappers around ROOT's TCut/TFormula/TTreeFormula (aka THaCut etc.). I am not familiar which this extension and do not have their source code and thus can not reproduce your problem. You may want to check with the authors of this extension.

Cheers,
Philippe.

-----Original Message-----
From: Borse, Ganesh [mailto:ganesh.borse_at_credit-suisse.com] Sent: Thursday, November 29, 2007 2:42 AM To: 'Philippe Canal'; roottalk_at_lxbuild091.cern.ch Subject: RE: [ROOT] How to define the expression to check if a big char st ring contai ns small char string

Hi,

It could be possible that the Compile function is resolving this to the Tformula version of strstr. But I want to use the normal C++ version - which is declared in <string.h>

Yes, I making it aware to the formula about these 'variables'. If you see my code below, before calling the Define function, I cam doing "gHaVars->Define("listClients",listClients);" & "gHaVars->Define("ordClient",ordClient);"

This defines these variables.

I think this is the problem of ambiguity between the OS strstr & Tformula strstr. How do we rsolve it? Should I define one cut for strstr & add it here? I just now emailed my test program. May be some more information could be found from it.

Thanks,
Ganesh

-----Original Message-----
From: Philippe Canal [mailto:pcanal_at_fnal.gov] Sent: 29 November 2007 16:34
To: 'Borse, Ganesh'; roottalk_at_lxbuild091.cern.ch Subject: RE: [ROOT] How to define the expression to check if a big char string contai ns small char string

> For this, I am using strstr() library function in C++.
 

Are you sure it is the C++ version (as opposed to the TFormula version)?  

> Error in <THaCut::Compile>: strstr requires 2 string arguments

This sounds like the type of error message TFormula (or TTreeFormula) would issue.

If it is from TFormula/TTreeFormula, you need to make sure that the formula knows the 'variables' (listClients,ordClient) and that the formula knows that they are strings.

Cheers,
Philippe.


From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Borse, Ganesh Sent: Wednesday, November 28, 2007 10:05 PM To: 'roottalk_at_lxbuild091.cern.ch'
Subject: [ROOT] How to define the expression to check if a big char string contai ns small char string

Hi,

I am trying to "Define" an expression to check whether a long char string contains another small char string. For this, I am using strstr() library function in C++.

Expression is like this:

    THaVarList * gHaVars = new THaVarList();     THaCutList * gHaCuts = new THaCutList(gHaVars);     const char* listClients="ABCD,EFGH,HIJK,NEWONE,JUNK,DONE";     const char* ordClient = "DONE";

    gHaVars->Define("listClients",listClients); 
    gHaVars->Define("ordClient",ordClient); 
    gHaCuts->Define("Expr","((size < 1000) && (vol < (0.001 * ADV)) && (prod == value) && strstr(listClients,ordClient) )");

Program compiles fine, but when I run this program, the Define() function call fails with an error message: Error in <THaCut::Compile>: strstr requires 2 string arguments Error in <THaCutList::Define>: expression error, cut not created: Expr ((size < 1000) && (vol < (0.001 * ADV)) && (prod == value) && strstr((listClients),(ordClient)) ) block: Default

I have given the correct number & type of input parameters to strstr, but then why is the "::Compile" still failing? How can we achieve this type of checks?

Please help.

Thanks and Regards,
Ganesh



==
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html



==

==
Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html



==

Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html


Received on Thu Nov 29 2007 - 11:02:26 CET

This archive was generated by hypermail 2.2.0 : Thu Nov 29 2007 - 11:50:02 CET