Back to index

tetex-bin  3.0
Functions
make-suffix.c File Reference
#include <kpathsea/config.h>
#include <kpathsea/c-pathch.h>

Go to the source code of this file.

Functions

string make_suffix P2C (const_string, s, const_string, suffix)

Function Documentation

string make_suffix P2C ( const_string  ,
s  ,
const_string  ,
suffix   
)

Definition at line 26 of file make-suffix.c.

{
  string new_s;
  const_string dot_pos = strrchr (s, '.');
  const_string slash_pos;
  
  for (slash_pos = s + strlen (s) - 1; slash_pos > dot_pos && slash_pos > s;
       slash_pos--) {
    if (IS_DIR_SEP (*slash_pos))
      break;
  }

  if (dot_pos == NULL || slash_pos > dot_pos )
    new_s = concat3 (s, ".", suffix);
  else
    {
      unsigned past_dot_index = dot_pos + 1 - s;
      
      new_s = (string)xmalloc (past_dot_index + strlen (suffix) + 1);
      strncpy (new_s, s, dot_pos + 1 - s);
      strcpy (new_s + past_dot_index, suffix);
    }

  return new_s;
}

Here is the call graph for this function: