/// swap all the characters in reverse direction /// /// @param ibuf /// /// @return The buffer with the characters swapped. char_u* lrswap(char_u *ibuf) { if ((ibuf != NULL) && (*ibuf != '\0')) { lrswapbuf(ibuf, (int)STRLEN(ibuf)); } return ibuf; }
/* * 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; }
/* * swap all the Farsi characters in reverse direction */ char_u *lrFswap(char_u *cmdbuf, int len) { int i, cnt; if (cmdbuf == NULL) return cmdbuf; if (len == 0 && (len = (int)STRLEN(cmdbuf)) == 0) return cmdbuf; for (i = 0; i < len; i++) { for (cnt = 0; i + cnt < len && (F_isalpha(cmdbuf[i + cnt]) || F_isdigit(cmdbuf[i + cnt]) || cmdbuf[i + cnt] == ' '); ++cnt) ; lrswapbuf(cmdbuf + i, cnt); i += cnt; } return cmdbuf; }
/// 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; }
/* * swap all the characters in reverse direction */ char_u *lrswap(char_u *ibuf) { if (ibuf != NULL && *ibuf != NUL) lrswapbuf(ibuf, (int)STRLEN(ibuf)); return ibuf; }