Escape macro bodies when displaying in help.
This commit is contained in:
parent
34712e643c
commit
0bf6dd5766
3 changed files with 50 additions and 5 deletions
|
|
@ -527,10 +527,12 @@ binding_t *bi;
|
||||||
else
|
else
|
||||||
swprintf(t, wsizeof(t), L"%lc", bi->bi_code);
|
swprintf(t, wsizeof(t), L"%lc", bi->bi_code);
|
||||||
|
|
||||||
if (bi->bi_macro)
|
if (bi->bi_macro) {
|
||||||
|
wchar_t *esc = escstr(bi->bi_macro);
|
||||||
swprintf(s, wsizeof(s), L"%-10ls execute macro: %ls",
|
swprintf(s, wsizeof(s), L"%-10ls execute macro: %ls",
|
||||||
t, bi->bi_macro);
|
t, esc);
|
||||||
else
|
free(esc);
|
||||||
|
} else
|
||||||
swprintf(s, wsizeof(s), L"%-10ls %ls (%ls)",
|
swprintf(s, wsizeof(s), L"%-10ls %ls (%ls)",
|
||||||
t, bi->bi_func->fn_desc, bi->bi_func->fn_name);
|
t, bi->bi_func->fn_desc, bi->bi_func->fn_name);
|
||||||
|
|
||||||
|
|
|
||||||
44
str.c
44
str.c
|
|
@ -135,7 +135,7 @@ wchar_t **p;
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
parsetime(tm)
|
parsetime(tm)
|
||||||
wchar_t *tm;
|
const wchar_t *tm;
|
||||||
{
|
{
|
||||||
int h = 0, m = 0, s = 0;
|
int h = 0, m = 0, s = 0;
|
||||||
time_t i = 0, r = 0;
|
time_t i = 0, r = 0;
|
||||||
|
|
@ -211,3 +211,45 @@ wchar_t t[16];
|
||||||
|
|
||||||
return wcsdup(res);
|
return wcsdup(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wchar_t *
|
||||||
|
escstr(s)
|
||||||
|
const wchar_t *s;
|
||||||
|
{
|
||||||
|
wchar_t *ret, *p;
|
||||||
|
|
||||||
|
if ((ret = calloc(sizeof(wchar_t), wcslen(s) * 2 + 1)) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (p = ret; *s; s++) {
|
||||||
|
switch (*s) {
|
||||||
|
case '\\':
|
||||||
|
*p++ = L'\\';
|
||||||
|
*p++ = L'\\';
|
||||||
|
continue;
|
||||||
|
case '\n':
|
||||||
|
*p++ = L'\\';
|
||||||
|
*p++ = L'n';
|
||||||
|
continue;
|
||||||
|
case '\t':
|
||||||
|
*p++ = L'\\';
|
||||||
|
*p++ = L't';
|
||||||
|
continue;
|
||||||
|
case '\v':
|
||||||
|
*p++ = L'\\';
|
||||||
|
*p++ = L'v';
|
||||||
|
continue;
|
||||||
|
case '\r':
|
||||||
|
*p++ = L'\\';
|
||||||
|
*p++ = L'r';
|
||||||
|
continue;
|
||||||
|
case '"':
|
||||||
|
*p++ = L'\\';
|
||||||
|
*p++ = L'"';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
*p++ = *s;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
||||||
3
str.h
3
str.h
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
size_t tokenise (const wchar_t *, wchar_t ***result);
|
size_t tokenise (const wchar_t *, wchar_t ***result);
|
||||||
void tokfree (wchar_t ***);
|
void tokfree (wchar_t ***);
|
||||||
time_t parsetime (wchar_t *);
|
time_t parsetime (const wchar_t *);
|
||||||
wchar_t *maketime (time_t);
|
wchar_t *maketime (time_t);
|
||||||
|
wchar_t *escstr (const wchar_t *);
|
||||||
|
|
||||||
#endif /* !TTS_STR_H */
|
#endif /* !TTS_STR_H */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue