Exemple #1
0
static void do_cite(WIN *w, int start, int end)
{
  wchar_t tmp_line[MAXCOLS];
  ELM *tmp_e;
  int x, y;

  for (y=start; y<=end; y++) {
    vt_send('>');
    vt_send(' ');
    tmp_e = mc_getline(w, y);
    mc_wdrawelm_var(w, tmp_e, tmp_line);
    tmp_line[w->xs] = 0;
    for (x = w->xs-1; x >= 0; x--) {
      if (tmp_line[x] <= ' ')
        tmp_line[x]=0;
      else
        break;
    }
    for (x = 0; tmp_line[x]; x++) {
      char buf[MB_LEN_MAX];
      size_t i, len;

      len = one_wctomb(buf, tmp_line[x]);
      for (i = 0; i < len; i++)
	vt_send(buf[i]);
    }
    vt_send(13);
  }
}
Exemple #2
0
unsigned char *
unparsestring(const CStr *str, const Char *sep)
{
    unsigned char *buf, *b;
    Char   p;
    int l;

    /* Worst-case is "\uuu" or result of wctomb() for each char from str */
    buf = xmalloc((str->len + 1) * max(4, MB_LEN_MAX));
    b = buf;
    if (sep[0])
#ifndef WINNT_NATIVE
	*b++ = sep[0];
#else /* WINNT_NATIVE */
	*b++ = CHAR & sep[0];
#endif /* !WINNT_NATIVE */

    for (l = 0; l < str->len; l++) {
	p = str->buf[l];
	if (Iscntrl(p)) {
	    *b++ = '^';
	    if (p == CTL_ESC('\177'))
		*b++ = '?';
	    else
#ifdef IS_ASCII
		*b++ = (unsigned char) (p | 0100);
#else
		*b++ = _toebcdic[_toascii[p]|0100];
#endif
	}
	else if (p == '^' || p == '\\') {
	    *b++ = '\\';
	    *b++ = (unsigned char) p;
	}
	else if (p == ' ' || (Isprint(p) && !Isspace(p)))
	    b += one_wctomb((char *)b, p & CHAR);
	else {
	    *b++ = '\\';
	    *b++ = ((p >> 6) & 7) + '0';
	    *b++ = ((p >> 3) & 7) + '0';
	    *b++ = (p & 7) + '0';
	}
    }
    if (sep[0] && sep[1])
#ifndef WINNT_NATIVE
	*b++ = sep[1];
#else /* WINNT_NATIVE */
	*b++ = CHAR & sep[1];
#endif /* !WINNT_NATIVE */
    *b++ = 0;
    return buf;			/* should check for overflow */
}
Exemple #3
0
/* getstring():
 */
static	int
getstring(char **dp, const Char **sp, Str *pd, int f)
{
    const Char *s = *sp;
    char *d = *dp;
    eChar sc;

    while (*s && (*s & CHAR) != (Char)f && (*s & CHAR) != ':') {
	if ((*s & CHAR) == '\\' || (*s & CHAR) == '^') {
	    if ((sc = parseescape(&s)) == CHAR_ERR)
		return 0;
	}
	else
	    sc = *s++ & CHAR;
	d += one_wctomb(d, sc);
    }

    pd->s = *dp;
    pd->len = d - *dp;
    *sp = s;
    *dp = d;
    return *s == (Char)f;
}