/* Puts string into buffer, replacing each occurrence of character from @esc with usual octal escape. Returns 0 in case of success, -1 - in case of overflow.  */
int seq_escape(struct seq_file *m, const char *s, const char *esc)
/* Puts string into buffer, replacing each occurrence of character from @esc with usual octal escape. Returns 0 in case of success, -1 - in case of overflow.  */
int seq_escape(struct seq_file *m, const char *s, const char *esc)
{
	char *end = m->buf + m->size;
        char *p;
	char c;
        for (p = m->buf + m->count; (c = *s) != '\0' && p < end; s++) {
		if (!strchr(esc, c)) {
			*p++ = c;
			continue;
		}
		if (p + 3 < end) {
			*p++ = '\\';
			*p++ = '0' + ((c & 0300) >> 6);
			*p++ = '0' + ((c & 070) >> 3);
			*p++ = '0' + (c & 07);
			continue;
		}
		m->count = m->size;
		return -1;
        }
	m->count = p - m->buf;
        return 0;
}