Problem with CINT and strtok

Dear Rooters

On the weekend I downloaded from cvs the newest root version and compiled
it for Mac OS X 10.4.4.

Sorrowly CINT is no longer able to handle the following function:

TString Path2Name(const char *name, const char *sep, const char *exten)
{
   // Extract name from full path
   // sep is path separator and exten is name extension

   TString outname = TString(name);
   char   *tmpname = new char[strlen(name) + 1];
   char   *delname = tmpname;

   tmpname = strtok(strcpy(tmpname,name),sep);
   while(tmpname) {
      outname = tmpname;
      tmpname = strtok(NULL,sep);
   }//while
      
   if (strcmp(exten,"") != 0) {
      Int_t i = outname.Index(exten);
      if (i > 0) {outname = outname.Remove(i);}
   }//if

   delete [] delname;

   return outname;
}//Path2Name

I get the error:
root [1] Path2Name(“xxx/aaa.ddd”,"/",".")
Error: strtok param[0] type mismatch macros4DirTest3.C:2157:
*** Interpreter error recovered ***

Best regards
Christian

Hi. NULL should work, but it doesnt. Use 0 instead of NULL.

[quote]

TString Path2Name(const char *name, const char *sep, const char *exten)
{
   // Extract name from full path
   // sep is path separator and exten is name extension

   TString outname = TString(name);
   char   *tmpname = new char[strlen(name) + 1];
   char   *delname = tmpname;

   tmpname = strtok(strcpy(tmpname,name),sep);
   while(tmpname) {
      outname = tmpname;
      tmpname = strtok(0, sep);
   }//while
      
   if (strcmp(exten,"") != 0) {
      Int_t i = outname.Index(exten);
      if (i > 0) {outname = outname.Remove(i);}
   }//if

   delete [] delname;

   return outname;
}//Path2Name

Christian[/quote]

Hi

Thank you, this works.

However, I hope that the CINT developers correct this bug. Since at least
six years CINT was able to recognize NULL, this is the first version of CINT
which does not. It will break quite some code.

Best regards
Christian

Hi, Christian.

[quote]

However, I hope that the CINT developers correct this bug. Since at least
six years CINT was able to recognize NULL, this is the first version of CINT
which does not. It will break quite some code.

Best regards
Christian[/quote]

Yes, you are right. CINT must understand, that 0l is a valid null-pointer constant.

I can not reproduce this problem (I tried on windows and on MacOS 10.3.9 [I do not have access to higher version).
Are you sure you build the cintdlls?

Cheers,
Philippe

Dear Philippe

During more that 6 years of using ROOT I never needed to build cintdll.
However, now I did: make cintdll and make install.

The result remains the same, as another more primitive example shows:

root [0] NULL
(long)0
root [1] char *p = strtok(NULL,"., ")
Error: strtok param[0] type mismatch (tmpfile):1:
*** Interpreter error recovered ***
root [2] char *p = strtok(0,"., ")
root [3]

It seems that CINT does not understand strtok(NULL,…).

P.S.: Recently, you have written: "The compiler in 10.3.x is deficient and can not handle
the template in the matrix package. I strongly recommend that you upgrade to a
newer version of the operating system (or at least a newer version of the compiler)."
So I am wondering that you still use 10.3.9, you should test it on 10.4.x.

Best regards
Christian

[quote]So I am wondering that you still use 10.3.9, you should test it on 10.4.x. [/quote]Yes I am still using 10.3.9 and I do not have access to a 10.4.x machine (maybe you can help by giving me access to one of your macs?).

Thanks,
Philippe

Dear Philippe

Meanwhile I have compiled the new root 5.13/01 on my Laptop with FC4 (Fedora Core 4).
The problem is the same, so this problem is not Mac-specific.

Best regards
Christian

Ok. I now understand the problem. One does need to generate the cintdlls in order for strtok to properly work BUT the makefile where broken (possibly as early as June 21 until July 20). So in order to fix the problem you need to get the lastest version of $ROOTSYS/cint/Module.mk) and regenerate the cintdlls.

Cheers,
Philippe.

Dear Philippe

Thank you, I will download the new version soon.

However, it is not quite clear to me why I need to compile the cintdlls in order
to get strtok to work. For ALL earlier versions of root including version 5.11/03
there was no need to compile cintdll.

Best regards
Christian

Hi Christian,

I am not sure either :frowning: (neither about why it stop working, nor why it works without the cintdlls :slight_smile: ). Anyway, we will investigate.

Cheers,
Philippe