/*
--------------------------------------------------------------------------
lstrrchr

Function to parse a filename string, which searches backward for the next
proper ansi value.

Inputs:
  str - string to look at
  ch  - character to search for

Outputs
  lstrrchr - modified string
--------------------------------------------------------------------------
*/
LPSTR lstrrchr(LPSTR str, char ch)
{
  LPSTR strl = str + lstrlen(str);   /* Add length of str to end of str	*/

  do
  {
    if (ch == *strl)   /* end of string */
      return strl;
    strl = AnsiPrev(str, strl);  /* load previous character */
  } /* do */
  while(strl > str);

  return NULL;
} /* lstrchr */
예제 #2
0
char *lstrrchr (char* str, char ch)
	{
  char* strl = str + lstrlen (str) ;

  do
		{
   	if (ch == *strl)
    	return strl ;
		strl = AnsiPrev (str, strl) ;
    }
  while (strl > str) ;

  return NULL ;
	}
예제 #3
0
void FAR PASCAL PathUp (LPSTR lpDest,LPCSTR lpSource)
{
    if (lpDest)
        if (!lpSource || !(*lpSource))
        {
            *lpDest = 0;
        }
        else
        {
            LPCSTR lpLastSlash = lpSource;
            LPCSTR c           = lpSource+lstrlen (lpSource);

            /************************************************************
             *  Always truncate at least one character from end.
             *  This guarantees that a directory will be removed if
             *  the last character of the path name is a "\" or ":".
             ************************************************************/
            c = AnsiPrev (lpSource,c);
            while (c > lpSource)
            {
                c = AnsiPrev (lpSource,c);
                if ((*c=='\\') || (*c==':'))
                {
                    lpLastSlash = c;
                    break;
                }
            }

            /************************************************************
             *  Truncate the path.
             ************************************************************/
            if (lpDest != lpSource)
                _fstrncpy (lpDest,lpSource,lpLastSlash-lpSource);
            lpDest[lpLastSlash-lpSource] = 0; // cuz lpLastSlash is const
        }
}