Beispiel #1
0
/*
 * Reverse the characters in the search path and substitute section
 * accordingly.
 * TODO: handle different separator characters.  Use skip_regexp().
 */
char_u *lrF_sub(char_u *ibuf)
{
  char_u      *p, *ep;
  int i, cnt;

  p = ibuf;

  /* Find the boundary of the search path */
  while (((p = vim_strchr(p + 1, '/')) != NULL) && p[-1] == '\\')
    ;

  if (p == NULL)
    return ibuf;

  /* Reverse the Farsi characters in the search path. */
  lrFswap(ibuf, (int)(p-ibuf));

  /* Now find the boundary of the substitute section */
  if ((ep = (char_u *)strrchr((char *)++p, '/')) != NULL)
    cnt = (int)(ep - p);
  else
    cnt = (int)STRLEN(p);

  /* Reverse the characters in the substitute section and take care of '\' */
  for (i = 0; i < cnt-1; i++)
    if (p[i] == '\\') {
      p[i] = p[i+1];
      p[++i] = '\\';
    }

  lrswapbuf(p, cnt);

  return ibuf;
}
Beispiel #2
0
/// Reverse the characters in the search path and substitute section
/// accordingly.
/// TODO: handle different separator characters.  Use skip_regexp().
///
/// @param ibuf
///
/// @return The buffer with the characters in the search path and substitute
///         section reversed.
char_u* lrF_sub(char_u *ibuf)
{
  char_u *p, *ep;
  int i, cnt;

  p = ibuf;

  // Find the boundary of the search path
  while (((p = vim_strchr(p + 1, '/')) != NULL) && p[-1] == '\\') {
    // empty
  }

  if (p == NULL) {
    return ibuf;
  }

  // Reverse the Farsi characters in the search path.
  lrFswap(ibuf, (int)(p - ibuf));

  // Now find the boundary of the substitute section
  if ((ep = (char_u *)strrchr((char *)++p, '/')) != NULL) {
    cnt = (int)(ep - p);
  } else {
    cnt = (int)STRLEN(p);
  }

  // Reverse the characters in the substitute section and take care of '\'
  for (i = 0; i < cnt - 1; i++) {
    if (p[i] == '\\') {
      p[i] = p[i + 1];
      p[++i] = '\\';
    }
  }

  lrswapbuf(p, cnt);
  return ibuf;
}