Replace non-portable "\e" escape in string literals with "\033"

This commit is contained in:
Craig Barnes 2020-08-02 23:54:04 +01:00
parent 91da76656c
commit 11a1d99da7
4 changed files with 10 additions and 10 deletions

View file

@ -360,7 +360,7 @@ parse_section_main(const char *key, const char *value, struct config *conf,
else if (strcmp(key, "scrollback") == 0) {
LOG_WARN("deprecated: [default]: scrollback: use 'scrollback.lines' instead'");
const char *fmt = "%s:%d: \e[1mdefault.scrollback\e[21m, use \e[1mscrollback.lines\e[21m instead";
const char *fmt = "%s:%d: \033[1mdefault.scrollback\033[21m, use \033[1mscrollback.lines\033[21m instead";
int len = snprintf(NULL, 0, fmt, path, lineno);
char *text = malloc(len + 1);
snprintf(text, len + 1, fmt, path, lineno);

8
log.c
View file

@ -60,14 +60,14 @@ _log(enum log_class log_class, const char *module, const char *file, int lineno,
}
char clr[16];
snprintf(clr, sizeof(clr), "\e[%dm", class_clr);
fprintf(stderr, "%s%s%s: ", colorize ? clr : "", class, colorize ? "\e[0m" : "");
snprintf(clr, sizeof(clr), "\033[%dm", class_clr);
fprintf(stderr, "%s%s%s: ", colorize ? clr : "", class, colorize ? "\033[0m" : "");
if (colorize)
fprintf(stderr, "\e[2m");
fprintf(stderr, "\033[2m");
fprintf(stderr, "%s:%d: ", file, lineno);
if (colorize)
fprintf(stderr, "\e[0m");
fprintf(stderr, "\033[0m");
vfprintf(stderr, fmt, va);

2
osc.c
View file

@ -575,7 +575,7 @@ osc_dispatch(struct terminal *term)
/*
* Reply in XParseColor format
* E.g. for color 0xdcdccc we reply "\e]10;rgb:dc/dc/cc\e\\"
* E.g. for color 0xdcdccc we reply "\033]10;rgb:dc/dc/cc\033\\"
*/
char reply[32];
snprintf(

View file

@ -73,19 +73,19 @@ static enum user_notification_ret_t
emit_one_notification(int fd, const struct user_notification *notif)
{
const char *prefix = NULL;
const char *postfix = "\e[m\n";
const char *postfix = "\033[m\n";
switch (notif->kind) {
case USER_NOTIFICATION_DEPRECATED:
prefix = "\e[33;1mdeprecated\e[39;21m: ";
prefix = "\033[33;1mdeprecated\033[39;21m: ";
break;
case USER_NOTIFICATION_WARNING:
prefix = "\e[33;1mwarning\e[39;21m: ";
prefix = "\033[33;1mwarning\033[39;21m: ";
break;
case USER_NOTIFICATION_ERROR:
prefix = "\e[31;1merror\e[39;21m: ";
prefix = "\033[31;1merror\033[39;21m: ";
break;
}