From 393778ffabecc8fabadc72b9f0bce5340863406d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 7 Sep 2021 13:39:11 -0700 Subject: [PATCH] Shortening \033[0m -> \033[m --- bp.c | 4 ++-- explain.c | 12 ++++++------ files.c | 6 +++--- print.c | 4 ++-- tutorial.sh | 14 +++++++------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bp.c b/bp.c index 5e77a17..b55b236 100644 --- a/bp.c +++ b/bp.c @@ -94,7 +94,7 @@ static file_t *backup_file; static inline void fprint_filename(FILE *out, const char *filename) { if (!filename[0]) return; - if (options.format == FORMAT_FANCY) fprintf(out, "\033[0;1;4;33m%s\033[0m\n", filename); + if (options.format == FORMAT_FANCY) fprintf(out, "\033[0;1;4;33m%s\033[m\n", filename); else fprintf(out, "%s:\n", filename); } @@ -317,7 +317,7 @@ static int process_file(def_t *defs, const char *filename, pat_t *pattern) cache_destroy(f); if (recycle_all_matches() != 0) - fprintf(stderr, "\033[33;1mMemory leak: there should no longer be any matches in use at this point.\033[0m\n"); + fprintf(stderr, "\033[33;1mMemory leak: there should no longer be any matches in use at this point.\033[m\n"); destroy_file(&f); (void)fflush(stdout); return matches; diff --git a/explain.c b/explain.c index 79ef8c7..58ddcc1 100644 --- a/explain.c +++ b/explain.c @@ -74,7 +74,7 @@ static void _explain_matches(match_node_t *firstmatch, int depth, const char *te if (viz_type >= text && viz_type <= &text[textlen]) printf("\033[0;2m\""); - printf("\033[0m"); + printf("\033[m"); match_node_t *children = NULL; match_node_t **nextchild = &children; @@ -102,7 +102,7 @@ static void _explain_matches(match_node_t *firstmatch, int depth, const char *te else printf("%c", *c); } - printf("\033[0;2m%s\033[0m", V); + printf("\033[0;2m%s\033[m", V); } else { *nextchild = new(match_node_t); (*nextchild)->m = m->m; @@ -112,7 +112,7 @@ static void _explain_matches(match_node_t *firstmatch, int depth, const char *te printf(" "); if (m->m->end > m->m->start) printf("\033[0;2m%s", V); - printf("\033[0m"); + printf("\033[m"); } } @@ -120,9 +120,9 @@ static void _explain_matches(match_node_t *firstmatch, int depth, const char *te for (match_node_t *m = firstmatch; m; m = m->next) { if (m->m->end > m->m->start) continue; if (RIGHT_TYPE(m)) { - printf("\033[%ldG\033[7;%sm▒\033[0m", 1+2*(m->m->start - text), color); + printf("\033[%ldG\033[7;%sm▒\033[m", 1+2*(m->m->start - text), color); } else { - printf("\033[%ldG\033[0;2m%s\033[0m", 1+2*(m->m->start - text), V); + printf("\033[%ldG\033[0;2m%s\033[m", 1+2*(m->m->start - text), V); } } @@ -143,7 +143,7 @@ static void _explain_matches(match_node_t *firstmatch, int depth, const char *te const char *h = RIGHT_TYPE(m) ? H : " "; for (ssize_t n = (ssize_t)(2*(m->m->end - m->m->start) - 1); n > 0; n--) printf("%s", h); - printf("%s\033[0m", r); + printf("%s\033[m", r); } } #undef RIGHT_TYPE diff --git a/files.c b/files.c index 7e55d27..774f830 100644 --- a/files.c +++ b/files.c @@ -233,7 +233,7 @@ void fprint_line(FILE *dest, file_t *f, const char *start, const char *end, cons if (end > f->end) end = f->end; size_t linenum = get_line_number(f, start); const char *line = get_line(f, linenum); - fprintf(dest, "\033[1m%s:%lu:\033[0m ", f->filename[0] ? f->filename : "stdin", linenum); + fprintf(dest, "\033[1m%s:%lu:\033[m ", f->filename[0] ? f->filename : "stdin", linenum); va_list args; va_start(args, fmt); @@ -243,7 +243,7 @@ void fprint_line(FILE *dest, file_t *f, const char *start, const char *end, cons const char *eol = linenum == f->nlines ? strchr(line, '\0') : strchr(line, '\n'); if (end == NULL || end > eol) end = eol; - fprintf(dest, "\033[2m%5lu\033(0\x78\033(B\033[0m%.*s\033[41;30m%.*s\033[0m%.*s\n", + fprintf(dest, "\033[2m%5lu\033(0\x78\033(B\033[m%.*s\033[41;30m%.*s\033[m%.*s\n", linenum, (int)(start - line), line, (int)(end - start), start, @@ -258,7 +258,7 @@ void fprint_line(FILE *dest, file_t *f, const char *start, const char *end, cons fprintf(dest, "^^^^^^^^\033[8D\033[I\033[K"); else (void)fputc('^', dest); - fprintf(dest, "\033[0m\n"); + fprintf(dest, "\033[m\n"); } // diff --git a/print.c b/print.c index cbfe92e..cb2ea34 100644 --- a/print.c +++ b/print.c @@ -15,7 +15,7 @@ static const char *color_match = "\033[0;31;1m"; static const char *color_replace = "\033[0;34;1m"; -static const char *color_normal = "\033[0m"; +static const char *color_normal = "\033[m"; static const char *current_color = NULL; // @@ -267,7 +267,7 @@ int print_errors(file_t *f, match_t *m) fprintf(stderr, "\033[31;1m"); printer_t tmp = {.file = f, .context_before=NO_CONTEXT, .context_after=NO_CONTEXT}; // No bells and whistles print_match(stderr, &tmp, m); // Error message - fprintf(stderr, "\033[0m\n"); + fprintf(stderr, "\033[m\n"); fprint_line(stderr, f, m->start, m->end, " "); return 1; } diff --git a/tutorial.sh b/tutorial.sh index e598612..6c47a3f 100755 --- a/tutorial.sh +++ b/tutorial.sh @@ -8,17 +8,17 @@ for t in $([ $# -gt 0 ] && echo "$@" || ls -v tests/*.sh); do echo printf "\033[1m" sed -n 's/^# //p' "$t" - printf "\033[0m" - printf "\033[33;1mGiven these lines: Give this output:\033[0m\n" + printf "\033[m" + printf "\033[33;1mGiven these lines: Give this output:\033[m\n" diff -y -W60 --color=always "${t/.sh/.in}" "${t/.sh/.out}" while true; do - printf "\n\033[1mbp pattern: \033[0m" + printf "\n\033[1mbp pattern: \033[m" read -r pat - printf "\033[0;2mRunning: \033[32m%s\033[0m\n\n" "bp -p '$pat'" - printf "\033[33;1mExpected output: Your pattern's output:\033[0m\n" + printf "\033[0;2mRunning: \033[32m%s\033[m\n\n" "bp -p '$pat'" + printf "\033[33;1mExpected output: Your pattern's output:\033[m\n" bp -p "$pat" < "${t/.sh/.in}" 2>"$tmpfile" | diff -y -W60 --color=always "${t/.sh/.out}" - && break cat "$tmpfile" - printf "\n\033[0;1;31mSorry, try again!\033[0m\n" + printf "\n\033[0;1;31mSorry, try again!\033[m\n" done - printf "\n\033[0;1;32mCorrect!\033[0m\n" + printf "\n\033[0;1;32mCorrect!\033[m\n" done