Author Topic: _bufname2ext thinks .h files are .c files  (Read 2814 times)

cappy2112

  • Community Member
  • Posts: 91
  • Hero Points: 0
_bufname2ext thinks .h files are .c files
« on: June 20, 2007, 11:25:06 pm »

When for_each_buffer() iterates over .h files, .c is displayed for the extension (in the code below).
I guess this is normal- that is, Slick treats .h files as .c files, but since I've had so many problems with Slick macros today, I don't want to assume anything. So, I'm trying to verify this with the experts..

_command int My_SelectiveDisplay_Callback() name_info(',')
{

_str fileExt;

   fileExt = _bufname2ext(p_buf_name);
   message("Buffer name is ->" p_buf_name);
   _message_box("File Ext  = " fileExt, "EXTENSION", MB_OK | MB_ICONEXCLAMATION)

   if (stricmp(fileExt, "h") == 0)
   {
      message("Preprocessing " strip_filename(p_buf_name,"PD"));   
   }
   else
   {
      _message_box("Not a valid file type -> " strip_filename(p_buf_name,"PD"), "My Source Preprocessor", MB_OK | MB_ICONEXCLAMATION); 
     
   }

   return 0;
}

//******************************************************************************************

_command void MyPreprocess() name_info(',')
{
int rc;

   rc = for_each_buffer('My_SelectiveDisplay_Callback');
   if (rc !=0) {
      _message_box("RC from for_each_buffer = " rc, "FOR_EACH_BUFFER ERROR", MB_OK | MB_ICONEXCLAMATION)

   }
}

hs2

  • Senior Community Member
  • Posts: 2733
  • Hero Points: 285
Re: _bufname2ext thinks .h files are .c files
« Reply #1 on: June 20, 2007, 11:42:56 pm »
That's right. I assume in your file ext. setup 'h'-files refer to 'c'.
As already mentioned _bufname2ext returns the the referred extension if the curr. file extension is configured like that.
If you don't want that use get_extension() instead (help is available).

HS2