* [PATCH 3/3] Document my gcc 8 changes for the website
2018-03-16 21:33 [PATCH 0/3] wwwdocs: Updates for gcc 8 changes David Malcolm
@ 2018-03-16 21:33 ` David Malcolm
2018-03-18 23:20 ` Gerald Pfeifer
2018-03-16 21:33 ` [PATCH 2/3] Add htdocs/ansi2html.css David Malcolm
` (2 subsequent siblings)
3 siblings, 1 reply; 17+ messages in thread
From: David Malcolm @ 2018-03-16 21:33 UTC (permalink / raw)
To: gcc-patches; +Cc: David Malcolm
This patch documents various improvements in GCC 8 for our website.
There are lots of examples of colorized output from GCC (generated
using ansi2html); the patch uses the ansi2html.css from the previous
patch for styling them.
Caveat: I don't have the toolchain working for building the site, so
I was only able to test the CSS by manually hacking the <head> during
testing. The patch adds the CSS there. I hope this works.
Successfully checked as XHTML 1.0 Transitional.
---
htdocs/gcc-8/changes.html | 264 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 263 insertions(+), 1 deletion(-)
diff --git a/htdocs/gcc-8/changes.html b/htdocs/gcc-8/changes.html
index 7b76e34..122d02d 100644
--- a/htdocs/gcc-8/changes.html
+++ b/htdocs/gcc-8/changes.html
@@ -1,6 +1,7 @@
<html>
<head>
+ <link rel="stylesheet" type="text/css" href="../ansi2html.css" />
<title>GCC 8 Release Series — Changes, New Features, and Fixes</title>
</head>
@@ -120,11 +121,243 @@ a work-in-progress.</h2>
default at all optimization levels. Using
<code>-fsanitize=signed-integer-overflow</code> is now the preferred
way to audit code, <code>-Wstrict-overflow</code> is deprecated.</li>
+ <li>When reporting mismatching argument types at a function call, the
+ C and C++ compilers now underline both the argument and the pertinent
+ parameter in the declaration.
+<pre class="f9 b9">
+$ gcc arg-type-mismatch.cc
+<span class="bold">arg-type-mismatch.cc:</span> In function '<span class="bold">int caller(int, int, float)</span>':
+<span class="bold">arg-type-mismatch.cc:5:24:</span> <span class="bold"><span class="f1">error: </span></span>invalid conversion from '<span class="bold">int</span>' to '<span class="bold">const char*</span>' [<span class="bold"><span class="f1">-fpermissive</span></span>]
+ return callee(first, <span class="bold"><span class="f1">second</span></span>, third);
+ <span class="bold"><span class="f1">^~~~~~</span></span>
+<span class="bold">arg-type-mismatch.cc:1:40:</span> <span class="bold"><span class="f6">note: </span></span> initializing argument 2 of '<span class="bold">int callee(int, const char*, float)</span>'
+ extern int callee(int one, <span class="bold"><span class="f6">const char *two</span></span>, float three);
+ <span class="bold"><span class="f6">~~~~~~~~~~~~^~~</span></span>
+</pre>
+
+ </li>
+ <li>When reporting on unrecognized identifiers, the C and C++ compilers
+ will now emit fix-it hints suggesting <code>#include</code> directives
+ for various headers in the C and C++ standard libraries.
+<pre class="f9 b9">
+$ gcc incomplete.c
+<span class="bold">incomplete.c:</span> In function '<span class="bold">test</span>':
+<span class="bold">incomplete.c:3:10:</span> <span class="bold"><span class="f1">error: </span></span>'<span class="bold">NULL</span>' undeclared (first use in this function)
+ return <span class="bold"><span class="f1">NULL</span></span>;
+ <span class="bold"><span class="f1">^~~~</span></span>
+<span class="bold">incomplete.c:3:10:</span> <span class="bold"><span class="f6">note: </span></span>'<span class="bold">NULL</span>' is defined in header '<span class="bold"><stddef.h></span>'; did you forget to '<span class="bold">#include <stddef.h></span>'?
+<span class="bold">incomplete.c:1:1:</span>
++<span class="f2">#include <stddef.h></span>
+ const char *test(void)
+<span class="bold">incomplete.c:3:10:</span>
+ return <span class="bold"><span class="f6">NULL</span></span>;
+ <span class="bold"><span class="f6">^~~~</span></span>
+<span class="bold">incomplete.c:3:10:</span> <span class="bold"><span class="f6">note: </span></span>each undeclared identifier is reported only once for each function it appears in
+</pre>
+
+<pre class="f9 b9">
+$ gcc incomplete.cc
+<span class="bold">incomplete.cc:1:6:</span> <span class="bold"><span class="f1">error: </span></span>'<span class="bold">string</span>' in namespace '<span class="bold">std</span>' does not name a type
+ std::<span class="bold"><span class="f1">string</span></span> s("hello world");
+ <span class="bold"><span class="f1">^~~~~~</span></span>
+<span class="bold">incomplete.cc:1:1:</span> <span class="bold"><span class="f6">note: </span></span>'<span class="bold">std::string</span>' is defined in header '<span class="bold"><string></span>'; did you forget to '<span class="bold">#include <string></span>'?
++<span class="f2">#include <string></span>
+ <span class="bold"><span class="f6">std</span></span>::string s("hello world");
+ <span class="bold"><span class="f6">^~~</span></span>
+</pre>
+
+ </li>
+ <li>The C and C++ compilers now use more intuitive locations when
+ reporting on missing semicolons, and offer fix-it hints:
+<pre class="f9 b9">
+$ gcc t.c
+<span class="bold">t.c:</span> In function '<span class="bold">test</span>':
+<span class="bold">t.c:3:12:</span> <span class="bold"><span class="f1">error: </span></span>expected '<span class="bold">;</span>' before '<span class="bold">}</span>' token
+ return 42
+ <span class="bold"><span class="f1">^</span></span>
+ <span class="f2">;</span>
+ <span class="f2">}</span>
+ <span class="f2">~</span>
+</pre>
+
+ </li>
+ <li>When reporting on missing '}' and ')' tokens, the C and C++
+ compilers will now highlight the corresponding '{' and '(' token,
+ issuing a 'note' if it's on a separate line:
+<pre class="f9 b9">
+$ gcc unclosed.c
+<span class="bold">unclosed.c:</span> In function '<span class="bold">log_when_out_of_range</span>':
+<span class="bold">unclosed.c:12:50:</span> <span class="bold"><span class="f1">error: </span></span>expected '<span class="bold">)</span>' before '<span class="bold">{</span>' token
+ && (temperature < MIN || temperature > MAX)<span class="bold"><span class="f1"> </span></span><span class="f2">{</span>
+ <span class="bold"><span class="f1">^</span></span><span class="f2">~</span>
+ <span class="f2">)</span>
+<span class="bold">unclosed.c:11:6:</span> <span class="bold"><span class="f6">note: </span></span>to match this '<span class="bold">(</span>'
+ if <span class="bold"><span class="f6">(</span></span>logging_enabled && check_range ()
+ <span class="bold"><span class="f6">^</span></span>
+</pre>
+ or highlighting it directly if it's on the same line:
+<pre class="f9 b9">
+$ gcc unclosed-2.c
+<span class="bold">unclosed-2.c:</span> In function '<span class="bold">test</span>':
+<span class="bold">unclosed-2.c:8:45:</span> <span class="bold"><span class="f1">error: </span></span>expected '<span class="bold">)</span>' before '<span class="bold">{</span>' token
+ if <span class="f4">(</span>temperature < MIN || temperature > MAX<span class="bold"><span class="f1"> </span></span><span class="f2">{</span>
+ <span class="f4">~</span> <span class="bold"><span class="f1">^</span></span><span class="f2">~</span>
+ <span class="f2">)</span>
+</pre>
+ They will also emit fix-it hints.
+ </li>
</ul>
<h3 id="cxx">C++</h3>
<ul>
- <li></li>
+ <li>When reporting on attempts to access private fields of a class or
+ struct, the C++ compiler will now offer fix-it hints showing how to
+ use an accessor function to get at the field in question, if one exists.
+<pre class="f9 b9">
+$ gcc accessor.cc
+<span class="bold">accessor.cc:</span> In function '<span class="bold">void test(foo*)</span>':
+<span class="bold">accessor.cc:12:12:</span> <span class="bold"><span class="f1">error: </span></span>'<span class="bold">double foo::m_ratio</span>' is private within this context
+ if (ptr-><span class="bold"><span class="f1">m_ratio</span></span> >= 0.5)
+ <span class="bold"><span class="f1">^~~~~~~</span></span>
+<span class="bold">accessor.cc:7:10:</span> <span class="bold"><span class="f6">note: </span></span>declared private here
+ double <span class="bold"><span class="f6">m_ratio</span></span>;
+ <span class="bold"><span class="f6">^~~~~~~</span></span>
+<span class="bold">accessor.cc:12:12:</span> <span class="bold"><span class="f6">note: </span></span>field '<span class="bold">double foo::m_ratio</span>' can be accessed via '<span class="bold">double foo::get_ratio() const</span>'
+ if (ptr-><span class="bold"><span class="f6">m_ratio</span></span> >= 0.5)
+ <span class="bold"><span class="f6">^~~~~~~</span></span>
+ <span class="f2">get_ratio()</span>
+</pre>
+
+ </li>
+ <li>The C++ compiler can now give you a hint if you use a macro before it
+ was defined (e.g. if you mess up the order of your <code>#include</code>
+ directives):
+<pre class="f9 b9">
+$ gcc ordering.cc
+<span class="bold">ordering.cc:2:24:</span> <span class="bold"><span class="f1">error: </span></span>expected '<span class="bold">;</span>' at end of member declaration
+ virtual void clone() <span class="bold"><span class="f1">const</span></span> OVERRIDE { }
+ <span class="bold"><span class="f1">^~~~~</span></span>
+ <span class="f2">;</span>
+<span class="bold">ordering.cc:2:30:</span> <span class="bold"><span class="f1">error: </span></span>'<span class="bold">OVERRIDE</span>' does not name a type
+ virtual void clone() const <span class="bold"><span class="f1">OVERRIDE</span></span> { }
+ <span class="bold"><span class="f1">^~~~~~~~</span></span>
+<span class="bold">ordering.cc:2:30:</span> <span class="bold"><span class="f6">note: </span></span>the macro '<span class="bold">OVERRIDE</span>' had not yet been defined
+In file included from <span class="bold">ordering.cc:5</span>:
+<span class="bold">c++11-compat.h:2:</span> <span class="bold"><span class="f6">note: </span></span>it was later defined here
+ #define OVERRIDE override
+
+</pre>
+
+ </li>
+ <li>The <code>-Wold-style-cast</code> diagnostic can now emit fix-it hints
+ telling you when you can use a <code>static_cast</code>,
+ <code>const_cast</code>, or <code>reinterpret_cast</code>.
+<pre class="f9 b9">
+$ gcc -c old-style-cast-fixits.cc -Wold-style-cast
+<span class="bold">old-style-cast-fixits.cc:</span> In function '<span class="bold">void test(void*)</span>':
+<span class="bold">old-style-cast-fixits.cc:5:19:</span> <span class="bold"><span class="f5">warning: </span></span>use of old-style cast to '<span class="bold">struct foo*</span>' [<span class="bold"><span class="f5">-Wold-style-cast</span></span>]
+ foo *f = (foo *)<span class="bold"><span class="f5">ptr</span></span>;
+ <span class="bold"><span class="f5">^~~</span></span>
+ <span class="f1">----------</span>
+ <span class="f2">static_cast<foo *> (ptr)</span>
+</pre>
+
+ </li>
+ <li>When reporting on problems within <code>extern "C"</code> linkage
+ specifications, the C++ compiler will now display the location of the
+ start of the <code>extern "C"</code>.
+<pre class="f9 b9">
+$ gcc -c extern-c.cc
+<span class="bold">extern-c.cc:3:1:</span> <span class="bold"><span class="f1">error: </span></span>template with C linkage
+ <span class="bold"><span class="f1">template</span></span> <typename T> void test (void);
+ <span class="bold"><span class="f1">^~~~~~~~</span></span>
+In file included from <span class="bold">extern-c.cc:1</span>:
+<span class="bold">unclosed.h:1:1:</span> <span class="bold"><span class="f6">note: </span></span>'<span class="bold">extern "C"</span>' linkage started here
+ <span class="bold"><span class="f6">extern "C"</span></span> {
+ <span class="bold"><span class="f6">^~~~~~~~~~</span></span>
+<span class="bold">extern-c.cc:3:39:</span> <span class="bold"><span class="f1">error: </span></span>expected '<span class="bold">}</span>' at end of input
+ template <typename T> void test (void)<span class="bold"><span class="f1">;</span></span>
+ <span class="bold"><span class="f1">^</span></span>
+In file included from <span class="bold">extern-c.cc:1</span>:
+<span class="bold">unclosed.h:1:12:</span> <span class="bold"><span class="f6">note: </span></span>to match this '<span class="bold">{</span>'
+ extern "C" <span class="bold"><span class="f6">{</span></span>
+ <span class="bold"><span class="f6">^</span></span>
+</pre>
+
+ </li>
+ <li>When reporting on mismatching template types, the C++ compiler will
+ now use color to highlight the mismatching parts of the template, and will
+ elide the parameters that are common between two mismatching templates,
+ printing <code>[...]</code> instead:
+<pre class="f9 b9">
+$ gcc templates.cc
+<span class="bold">templates.cc:</span> In function '<span class="bold">void test()</span>':
+<span class="bold">templates.cc:9:8:</span> <span class="bold"><span class="f1">error: </span></span>could not convert '<span class="bold">vector<double>()</span>' from '<span class="bold">vector<<span class="bold"><span class="f2">double</span></span></span>>' to '<span class="bold">vector<<span class="bold"><span class="f2">int</span></span></span>>'
+ fn_1(<span class="bold"><span class="f1">vector<double> ()</span></span>);
+ <span class="bold"><span class="f1">^~~~~~~~~~~~~~~~~</span></span>
+<span class="bold">templates.cc:10:8:</span> <span class="bold"><span class="f1">error: </span></span>could not convert '<span class="bold">map<int, double>()</span>' from '<span class="bold">map<[...],<span class="bold"><span class="f2">double</span></span></span>>' to '<span class="bold">map<[...],<span class="bold"><span class="f2">int</span></span></span>>'
+ fn_2(<span class="bold"><span class="f1">map<int, double>()</span></span>);
+ <span class="bold"><span class="f1">^~~~~~~~~~~~~~~~~~</span></span>
+</pre>
+
+ Those <code>[...]</code> elided parameters can be seen using
+ <code>-fno-elide-type</code>:
+<pre class="f9 b9">
+$ gcc templates.cc -fno-elide-type
+<span class="bold">templates.cc:</span> In function '<span class="bold">void test()</span>':
+<span class="bold">templates.cc:9:8:</span> <span class="bold"><span class="f1">error: </span></span>could not convert '<span class="bold">vector<double>()</span>' from '<span class="bold">vector<<span class="bold"><span class="f2">double</span></span></span>>' to '<span class="bold">vector<<span class="bold"><span class="f2">int</span></span></span>>'
+ fn_1(<span class="bold"><span class="f1">vector<double> ()</span></span>);
+ <span class="bold"><span class="f1">^~~~~~~~~~~~~~~~~</span></span>
+<span class="bold">templates.cc:10:8:</span> <span class="bold"><span class="f1">error: </span></span>could not convert '<span class="bold">map<int, double>()</span>' from '<span class="bold">map<int,<span class="bold"><span class="f2">double</span></span></span>>' to '<span class="bold">map<int,<span class="bold"><span class="f2">int</span></span></span>>'
+ fn_2(<span class="bold"><span class="f1">map<int, double>()</span></span>);
+ <span class="bold"><span class="f1">^~~~~~~~~~~~~~~~~~</span></span>
+</pre>
+
+ The C++ compiler has also gained an option
+ <code>-fdiagnostics-show-template-tree</code> which visualizes such
+ mismatching templates in a hierarchical form:
+<pre class="f9 b9">
+$ gcc templates-2.cc -fdiagnostics-show-template-tree
+<span class="bold">templates-2.cc:</span> In function '<span class="bold">void test()</span>':
+<span class="bold">templates-2.cc:9:8:</span> <span class="bold"><span class="f1">error: </span></span>could not convert '<span class="bold">vector<double>()</span>' from '<span class="bold">vector<<span class="bold"><span class="f2">double</span></span></span>>' to '<span class="bold">vector<<span class="bold"><span class="f2">int</span></span></span>>'
+ vector<
+ [<span class="bold"><span class="f2">double</span></span> != <span class="bold"><span class="f2">int</span></span>]>
+ fn_1(<span class="bold"><span class="f1">vector<double> ()</span></span>);
+ <span class="bold"><span class="f1">^~~~~~~~~~~~~~~~~</span></span>
+<span class="bold">templates-2.cc:10:8:</span> <span class="bold"><span class="f1">error: </span></span>could not convert '<span class="bold">map<map<int, vector<double> >, vector<double> >()</span>' from '<span class="bold">map<map<[...],vector<<span class="bold"><span class="f2">double</span></span></span>>>,vector<<span class="bold"><span class="f2">double</span></span>>>' to '<span class="bold">map<map<[...],vector<<span class="bold"><span class="f2">float</span></span></span>>>,vector<<span class="bold"><span class="f2">float</span></span>>>'
+ map<
+ map<
+ [...],
+ vector<
+ [<span class="bold"><span class="f2">double</span></span> != <span class="bold"><span class="f2">float</span></span>]>>,
+ vector<
+ [<span class="bold"><span class="f2">double</span></span> != <span class="bold"><span class="f2">float</span></span>]>>
+ fn_2(<span class="bold"><span class="f1">map<map<int, vector<double>>, vector<double>> ()</span></span>);
+ <span class="bold"><span class="f1">^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span></span>
+</pre>
+
+ which again works with <code>-fno-elide-type</code>:
+<pre class="f9 b9">
+$ gcc templates-2.cc -fdiagnostics-show-template-tree -fno-elide-type
+<span class="bold">templates-2.cc:</span> In function '<span class="bold">void test()</span>':
+<span class="bold">templates-2.cc:9:8:</span> <span class="bold"><span class="f1">error: </span></span>could not convert '<span class="bold">vector<double>()</span>' from '<span class="bold">vector<<span class="bold"><span class="f2">double</span></span></span>>' to '<span class="bold">vector<<span class="bold"><span class="f2">int</span></span></span>>'
+ vector<
+ [<span class="bold"><span class="f2">double</span></span> != <span class="bold"><span class="f2">int</span></span>]>
+ fn_1(<span class="bold"><span class="f1">vector<double> ()</span></span>);
+ <span class="bold"><span class="f1">^~~~~~~~~~~~~~~~~</span></span>
+<span class="bold">templates-2.cc:10:8:</span> <span class="bold"><span class="f1">error: </span></span>could not convert '<span class="bold">map<map<int, vector<double> >, vector<double> >()</span>' from '<span class="bold">map<map<int,vector<<span class="bold"><span class="f2">double</span></span></span>>>,vector<<span class="bold"><span class="f2">double</span></span>>>' to '<span class="bold">map<map<int,vector<<span class="bold"><span class="f2">float</span></span></span>>>,vector<<span class="bold"><span class="f2">float</span></span>>>'
+ map<
+ map<
+ int,
+ vector<
+ [<span class="bold"><span class="f2">double</span></span> != <span class="bold"><span class="f2">float</span></span>]>>,
+ vector<
+ [<span class="bold"><span class="f2">double</span></span> != <span class="bold"><span class="f2">float</span></span>]>>
+ fn_2(<span class="bold"><span class="f1">map<map<int, vector<double>>, vector<double>> ()</span></span>);
+ <span class="bold"><span class="f1">^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span></span>
+</pre>
+
+ </li>
</ul>
<h3 id="fortran">Fortran</h3>
@@ -207,6 +440,19 @@ a work-in-progress.</h2>
<!-- .................................................................. -->
<h2 id="jit">libgccjit</h2>
+<p>The libgccjit API gained four new entrypoints:</p>
+<ul>
+ <li><a href="https://gcc.gnu.org/onlinedocs/jit/topics/types.html#gcc_jit_type_get_vector">gcc_jit_type_get_vector</a>
+ and
+ </li>
+ <li><a href="https://gcc.gnu.org/onlinedocs/jit/topics/expressions.html#gcc_jit_context_new_rvalue_from_vector">gcc_jit_context_new_rvalue_from_vector</a> for working with vectors,
+ </li>
+ <li><a href="https://gcc.gnu.org/onlinedocs/jit/topics/types.html#gcc_jit_type_get_aligned">gcc_jit_type_get_aligned</a></li>
+ <li><a href="https://gcc.gnu.org/onlinedocs/jit/topics/function-pointers.html#gcc_jit_function_get_address">gcc_jit_function_get_address</a></li>
+</ul>
+<p>The C code generated by
+<a href="https://gcc.gnu.org/onlinedocs/jit/topics/contexts.html#gcc_jit_context_dump_reproducer_to_file">gcc_jit_context_dump_reproducer_to_file</a>
+is now easier-to-read.</p>
<!-- .................................................................. -->
<h2 id="targets">New Targets and Target Specific Improvements</h2>
@@ -569,6 +815,22 @@ a work-in-progress.</h2>
<!-- .................................................................. -->
+<h2 id="plugins">Improvements for plugin authors</h2>
+<ul>
+ <li>Plugins can now register a callback hook for when comments are
+ encountered by the C and C++ compiler, allowing e.g. for plugins
+ to handle documentation markup in code comments.
+ </li>
+ <li>The gdbinit support script for debugging gcc now has a
+ <code>break-on-diagnostic</code> command, providing an easy way
+ to trigger a breakpoint whenever a diagnostic is emitted.
+ </li>
+ <li>The API for creating fix-it hints now supports newlines, and for
+ emitting mutually-incompatible fix-it hints for one diagnostic.
+ </li>
+</ul>
+
+<!-- .................................................................. -->
<h2>Other significant improvements</h2>
<ul>
<li></li>
--
1.8.5.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 2/3] Add htdocs/ansi2html.css
2018-03-16 21:33 [PATCH 0/3] wwwdocs: Updates for gcc 8 changes David Malcolm
2018-03-16 21:33 ` [PATCH 3/3] Document my gcc 8 changes for the website David Malcolm
@ 2018-03-16 21:33 ` David Malcolm
2018-03-18 23:06 ` Gerald Pfeifer
2018-03-16 21:38 ` [PATCH 1/3] bin: add ansi2html.sh David Malcolm
2018-03-18 23:03 ` [PATCH 0/3] wwwdocs: Updates for gcc 8 changes Gerald Pfeifer
3 siblings, 1 reply; 17+ messages in thread
From: David Malcolm @ 2018-03-16 21:33 UTC (permalink / raw)
To: gcc-patches; +Cc: David Malcolm
Generated by:
ansi2html.sh --css-only --bg=dark --palette=xterm
---
htdocs/ansi2html.css | 287 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 287 insertions(+)
create mode 100644 htdocs/ansi2html.css
diff --git a/htdocs/ansi2html.css b/htdocs/ansi2html.css
new file mode 100644
index 0000000..3401288
--- /dev/null
+++ b/htdocs/ansi2html.css
@@ -0,0 +1,287 @@
+.ef0,.f0 { color: #000000; } .eb0,.b0 { background-color: #000000; }
+.ef1,.f1 { color: #CD0000; } .eb1,.b1 { background-color: #CD0000; }
+.ef2,.f2 { color: #00CD00; } .eb2,.b2 { background-color: #00CD00; }
+.ef3,.f3 { color: #CDCD00; } .eb3,.b3 { background-color: #CDCD00; }
+.ef4,.f4 { color: #0000EE; } .eb4,.b4 { background-color: #0000EE; }
+.ef5,.f5 { color: #CD00CD; } .eb5,.b5 { background-color: #CD00CD; }
+.ef6,.f6 { color: #00CDCD; } .eb6,.b6 { background-color: #00CDCD; }
+.ef7,.f7 { color: #E5E5E5; } .eb7,.b7 { background-color: #E5E5E5; }
+.ef8, .f0 > .bold,.bold > .f0 { color: #7F7F7F; font-weight: normal; }
+.ef9, .f1 > .bold,.bold > .f1 { color: #FF0000; font-weight: normal; }
+.ef10,.f2 > .bold,.bold > .f2 { color: #00FF00; font-weight: normal; }
+.ef11,.f3 > .bold,.bold > .f3 { color: #FFFF00; font-weight: normal; }
+.ef12,.f4 > .bold,.bold > .f4 { color: #5C5CFF; font-weight: normal; }
+.ef13,.f5 > .bold,.bold > .f5 { color: #FF00FF; font-weight: normal; }
+.ef14,.f6 > .bold,.bold > .f6 { color: #00FFFF; font-weight: normal; }
+.ef15,.f7 > .bold,.bold > .f7 { color: #FFFFFF; font-weight: normal; }
+.eb8 { background-color: #7F7F7F; }
+.eb9 { background-color: #FF0000; }
+.eb10 { background-color: #00FF00; }
+.eb11 { background-color: #FFFF00; }
+.eb12 { background-color: #5C5CFF; }
+.eb13 { background-color: #FF00FF; }
+.eb14 { background-color: #00FFFF; }
+.eb15 { background-color: #FFFFFF; }
+.ef16 { color: #000000; } .eb16 { background-color: #000000; }
+.ef17 { color: #00005f; } .eb17 { background-color: #00005f; }
+.ef18 { color: #000087; } .eb18 { background-color: #000087; }
+.ef19 { color: #0000af; } .eb19 { background-color: #0000af; }
+.ef20 { color: #0000d7; } .eb20 { background-color: #0000d7; }
+.ef21 { color: #0000ff; } .eb21 { background-color: #0000ff; }
+.ef22 { color: #005f00; } .eb22 { background-color: #005f00; }
+.ef23 { color: #005f5f; } .eb23 { background-color: #005f5f; }
+.ef24 { color: #005f87; } .eb24 { background-color: #005f87; }
+.ef25 { color: #005faf; } .eb25 { background-color: #005faf; }
+.ef26 { color: #005fd7; } .eb26 { background-color: #005fd7; }
+.ef27 { color: #005fff; } .eb27 { background-color: #005fff; }
+.ef28 { color: #008700; } .eb28 { background-color: #008700; }
+.ef29 { color: #00875f; } .eb29 { background-color: #00875f; }
+.ef30 { color: #008787; } .eb30 { background-color: #008787; }
+.ef31 { color: #0087af; } .eb31 { background-color: #0087af; }
+.ef32 { color: #0087d7; } .eb32 { background-color: #0087d7; }
+.ef33 { color: #0087ff; } .eb33 { background-color: #0087ff; }
+.ef34 { color: #00af00; } .eb34 { background-color: #00af00; }
+.ef35 { color: #00af5f; } .eb35 { background-color: #00af5f; }
+.ef36 { color: #00af87; } .eb36 { background-color: #00af87; }
+.ef37 { color: #00afaf; } .eb37 { background-color: #00afaf; }
+.ef38 { color: #00afd7; } .eb38 { background-color: #00afd7; }
+.ef39 { color: #00afff; } .eb39 { background-color: #00afff; }
+.ef40 { color: #00d700; } .eb40 { background-color: #00d700; }
+.ef41 { color: #00d75f; } .eb41 { background-color: #00d75f; }
+.ef42 { color: #00d787; } .eb42 { background-color: #00d787; }
+.ef43 { color: #00d7af; } .eb43 { background-color: #00d7af; }
+.ef44 { color: #00d7d7; } .eb44 { background-color: #00d7d7; }
+.ef45 { color: #00d7ff; } .eb45 { background-color: #00d7ff; }
+.ef46 { color: #00ff00; } .eb46 { background-color: #00ff00; }
+.ef47 { color: #00ff5f; } .eb47 { background-color: #00ff5f; }
+.ef48 { color: #00ff87; } .eb48 { background-color: #00ff87; }
+.ef49 { color: #00ffaf; } .eb49 { background-color: #00ffaf; }
+.ef50 { color: #00ffd7; } .eb50 { background-color: #00ffd7; }
+.ef51 { color: #00ffff; } .eb51 { background-color: #00ffff; }
+.ef52 { color: #5f0000; } .eb52 { background-color: #5f0000; }
+.ef53 { color: #5f005f; } .eb53 { background-color: #5f005f; }
+.ef54 { color: #5f0087; } .eb54 { background-color: #5f0087; }
+.ef55 { color: #5f00af; } .eb55 { background-color: #5f00af; }
+.ef56 { color: #5f00d7; } .eb56 { background-color: #5f00d7; }
+.ef57 { color: #5f00ff; } .eb57 { background-color: #5f00ff; }
+.ef58 { color: #5f5f00; } .eb58 { background-color: #5f5f00; }
+.ef59 { color: #5f5f5f; } .eb59 { background-color: #5f5f5f; }
+.ef60 { color: #5f5f87; } .eb60 { background-color: #5f5f87; }
+.ef61 { color: #5f5faf; } .eb61 { background-color: #5f5faf; }
+.ef62 { color: #5f5fd7; } .eb62 { background-color: #5f5fd7; }
+.ef63 { color: #5f5fff; } .eb63 { background-color: #5f5fff; }
+.ef64 { color: #5f8700; } .eb64 { background-color: #5f8700; }
+.ef65 { color: #5f875f; } .eb65 { background-color: #5f875f; }
+.ef66 { color: #5f8787; } .eb66 { background-color: #5f8787; }
+.ef67 { color: #5f87af; } .eb67 { background-color: #5f87af; }
+.ef68 { color: #5f87d7; } .eb68 { background-color: #5f87d7; }
+.ef69 { color: #5f87ff; } .eb69 { background-color: #5f87ff; }
+.ef70 { color: #5faf00; } .eb70 { background-color: #5faf00; }
+.ef71 { color: #5faf5f; } .eb71 { background-color: #5faf5f; }
+.ef72 { color: #5faf87; } .eb72 { background-color: #5faf87; }
+.ef73 { color: #5fafaf; } .eb73 { background-color: #5fafaf; }
+.ef74 { color: #5fafd7; } .eb74 { background-color: #5fafd7; }
+.ef75 { color: #5fafff; } .eb75 { background-color: #5fafff; }
+.ef76 { color: #5fd700; } .eb76 { background-color: #5fd700; }
+.ef77 { color: #5fd75f; } .eb77 { background-color: #5fd75f; }
+.ef78 { color: #5fd787; } .eb78 { background-color: #5fd787; }
+.ef79 { color: #5fd7af; } .eb79 { background-color: #5fd7af; }
+.ef80 { color: #5fd7d7; } .eb80 { background-color: #5fd7d7; }
+.ef81 { color: #5fd7ff; } .eb81 { background-color: #5fd7ff; }
+.ef82 { color: #5fff00; } .eb82 { background-color: #5fff00; }
+.ef83 { color: #5fff5f; } .eb83 { background-color: #5fff5f; }
+.ef84 { color: #5fff87; } .eb84 { background-color: #5fff87; }
+.ef85 { color: #5fffaf; } .eb85 { background-color: #5fffaf; }
+.ef86 { color: #5fffd7; } .eb86 { background-color: #5fffd7; }
+.ef87 { color: #5fffff; } .eb87 { background-color: #5fffff; }
+.ef88 { color: #870000; } .eb88 { background-color: #870000; }
+.ef89 { color: #87005f; } .eb89 { background-color: #87005f; }
+.ef90 { color: #870087; } .eb90 { background-color: #870087; }
+.ef91 { color: #8700af; } .eb91 { background-color: #8700af; }
+.ef92 { color: #8700d7; } .eb92 { background-color: #8700d7; }
+.ef93 { color: #8700ff; } .eb93 { background-color: #8700ff; }
+.ef94 { color: #875f00; } .eb94 { background-color: #875f00; }
+.ef95 { color: #875f5f; } .eb95 { background-color: #875f5f; }
+.ef96 { color: #875f87; } .eb96 { background-color: #875f87; }
+.ef97 { color: #875faf; } .eb97 { background-color: #875faf; }
+.ef98 { color: #875fd7; } .eb98 { background-color: #875fd7; }
+.ef99 { color: #875fff; } .eb99 { background-color: #875fff; }
+.ef100 { color: #878700; } .eb100 { background-color: #878700; }
+.ef101 { color: #87875f; } .eb101 { background-color: #87875f; }
+.ef102 { color: #878787; } .eb102 { background-color: #878787; }
+.ef103 { color: #8787af; } .eb103 { background-color: #8787af; }
+.ef104 { color: #8787d7; } .eb104 { background-color: #8787d7; }
+.ef105 { color: #8787ff; } .eb105 { background-color: #8787ff; }
+.ef106 { color: #87af00; } .eb106 { background-color: #87af00; }
+.ef107 { color: #87af5f; } .eb107 { background-color: #87af5f; }
+.ef108 { color: #87af87; } .eb108 { background-color: #87af87; }
+.ef109 { color: #87afaf; } .eb109 { background-color: #87afaf; }
+.ef110 { color: #87afd7; } .eb110 { background-color: #87afd7; }
+.ef111 { color: #87afff; } .eb111 { background-color: #87afff; }
+.ef112 { color: #87d700; } .eb112 { background-color: #87d700; }
+.ef113 { color: #87d75f; } .eb113 { background-color: #87d75f; }
+.ef114 { color: #87d787; } .eb114 { background-color: #87d787; }
+.ef115 { color: #87d7af; } .eb115 { background-color: #87d7af; }
+.ef116 { color: #87d7d7; } .eb116 { background-color: #87d7d7; }
+.ef117 { color: #87d7ff; } .eb117 { background-color: #87d7ff; }
+.ef118 { color: #87ff00; } .eb118 { background-color: #87ff00; }
+.ef119 { color: #87ff5f; } .eb119 { background-color: #87ff5f; }
+.ef120 { color: #87ff87; } .eb120 { background-color: #87ff87; }
+.ef121 { color: #87ffaf; } .eb121 { background-color: #87ffaf; }
+.ef122 { color: #87ffd7; } .eb122 { background-color: #87ffd7; }
+.ef123 { color: #87ffff; } .eb123 { background-color: #87ffff; }
+.ef124 { color: #af0000; } .eb124 { background-color: #af0000; }
+.ef125 { color: #af005f; } .eb125 { background-color: #af005f; }
+.ef126 { color: #af0087; } .eb126 { background-color: #af0087; }
+.ef127 { color: #af00af; } .eb127 { background-color: #af00af; }
+.ef128 { color: #af00d7; } .eb128 { background-color: #af00d7; }
+.ef129 { color: #af00ff; } .eb129 { background-color: #af00ff; }
+.ef130 { color: #af5f00; } .eb130 { background-color: #af5f00; }
+.ef131 { color: #af5f5f; } .eb131 { background-color: #af5f5f; }
+.ef132 { color: #af5f87; } .eb132 { background-color: #af5f87; }
+.ef133 { color: #af5faf; } .eb133 { background-color: #af5faf; }
+.ef134 { color: #af5fd7; } .eb134 { background-color: #af5fd7; }
+.ef135 { color: #af5fff; } .eb135 { background-color: #af5fff; }
+.ef136 { color: #af8700; } .eb136 { background-color: #af8700; }
+.ef137 { color: #af875f; } .eb137 { background-color: #af875f; }
+.ef138 { color: #af8787; } .eb138 { background-color: #af8787; }
+.ef139 { color: #af87af; } .eb139 { background-color: #af87af; }
+.ef140 { color: #af87d7; } .eb140 { background-color: #af87d7; }
+.ef141 { color: #af87ff; } .eb141 { background-color: #af87ff; }
+.ef142 { color: #afaf00; } .eb142 { background-color: #afaf00; }
+.ef143 { color: #afaf5f; } .eb143 { background-color: #afaf5f; }
+.ef144 { color: #afaf87; } .eb144 { background-color: #afaf87; }
+.ef145 { color: #afafaf; } .eb145 { background-color: #afafaf; }
+.ef146 { color: #afafd7; } .eb146 { background-color: #afafd7; }
+.ef147 { color: #afafff; } .eb147 { background-color: #afafff; }
+.ef148 { color: #afd700; } .eb148 { background-color: #afd700; }
+.ef149 { color: #afd75f; } .eb149 { background-color: #afd75f; }
+.ef150 { color: #afd787; } .eb150 { background-color: #afd787; }
+.ef151 { color: #afd7af; } .eb151 { background-color: #afd7af; }
+.ef152 { color: #afd7d7; } .eb152 { background-color: #afd7d7; }
+.ef153 { color: #afd7ff; } .eb153 { background-color: #afd7ff; }
+.ef154 { color: #afff00; } .eb154 { background-color: #afff00; }
+.ef155 { color: #afff5f; } .eb155 { background-color: #afff5f; }
+.ef156 { color: #afff87; } .eb156 { background-color: #afff87; }
+.ef157 { color: #afffaf; } .eb157 { background-color: #afffaf; }
+.ef158 { color: #afffd7; } .eb158 { background-color: #afffd7; }
+.ef159 { color: #afffff; } .eb159 { background-color: #afffff; }
+.ef160 { color: #d70000; } .eb160 { background-color: #d70000; }
+.ef161 { color: #d7005f; } .eb161 { background-color: #d7005f; }
+.ef162 { color: #d70087; } .eb162 { background-color: #d70087; }
+.ef163 { color: #d700af; } .eb163 { background-color: #d700af; }
+.ef164 { color: #d700d7; } .eb164 { background-color: #d700d7; }
+.ef165 { color: #d700ff; } .eb165 { background-color: #d700ff; }
+.ef166 { color: #d75f00; } .eb166 { background-color: #d75f00; }
+.ef167 { color: #d75f5f; } .eb167 { background-color: #d75f5f; }
+.ef168 { color: #d75f87; } .eb168 { background-color: #d75f87; }
+.ef169 { color: #d75faf; } .eb169 { background-color: #d75faf; }
+.ef170 { color: #d75fd7; } .eb170 { background-color: #d75fd7; }
+.ef171 { color: #d75fff; } .eb171 { background-color: #d75fff; }
+.ef172 { color: #d78700; } .eb172 { background-color: #d78700; }
+.ef173 { color: #d7875f; } .eb173 { background-color: #d7875f; }
+.ef174 { color: #d78787; } .eb174 { background-color: #d78787; }
+.ef175 { color: #d787af; } .eb175 { background-color: #d787af; }
+.ef176 { color: #d787d7; } .eb176 { background-color: #d787d7; }
+.ef177 { color: #d787ff; } .eb177 { background-color: #d787ff; }
+.ef178 { color: #d7af00; } .eb178 { background-color: #d7af00; }
+.ef179 { color: #d7af5f; } .eb179 { background-color: #d7af5f; }
+.ef180 { color: #d7af87; } .eb180 { background-color: #d7af87; }
+.ef181 { color: #d7afaf; } .eb181 { background-color: #d7afaf; }
+.ef182 { color: #d7afd7; } .eb182 { background-color: #d7afd7; }
+.ef183 { color: #d7afff; } .eb183 { background-color: #d7afff; }
+.ef184 { color: #d7d700; } .eb184 { background-color: #d7d700; }
+.ef185 { color: #d7d75f; } .eb185 { background-color: #d7d75f; }
+.ef186 { color: #d7d787; } .eb186 { background-color: #d7d787; }
+.ef187 { color: #d7d7af; } .eb187 { background-color: #d7d7af; }
+.ef188 { color: #d7d7d7; } .eb188 { background-color: #d7d7d7; }
+.ef189 { color: #d7d7ff; } .eb189 { background-color: #d7d7ff; }
+.ef190 { color: #d7ff00; } .eb190 { background-color: #d7ff00; }
+.ef191 { color: #d7ff5f; } .eb191 { background-color: #d7ff5f; }
+.ef192 { color: #d7ff87; } .eb192 { background-color: #d7ff87; }
+.ef193 { color: #d7ffaf; } .eb193 { background-color: #d7ffaf; }
+.ef194 { color: #d7ffd7; } .eb194 { background-color: #d7ffd7; }
+.ef195 { color: #d7ffff; } .eb195 { background-color: #d7ffff; }
+.ef196 { color: #ff0000; } .eb196 { background-color: #ff0000; }
+.ef197 { color: #ff005f; } .eb197 { background-color: #ff005f; }
+.ef198 { color: #ff0087; } .eb198 { background-color: #ff0087; }
+.ef199 { color: #ff00af; } .eb199 { background-color: #ff00af; }
+.ef200 { color: #ff00d7; } .eb200 { background-color: #ff00d7; }
+.ef201 { color: #ff00ff; } .eb201 { background-color: #ff00ff; }
+.ef202 { color: #ff5f00; } .eb202 { background-color: #ff5f00; }
+.ef203 { color: #ff5f5f; } .eb203 { background-color: #ff5f5f; }
+.ef204 { color: #ff5f87; } .eb204 { background-color: #ff5f87; }
+.ef205 { color: #ff5faf; } .eb205 { background-color: #ff5faf; }
+.ef206 { color: #ff5fd7; } .eb206 { background-color: #ff5fd7; }
+.ef207 { color: #ff5fff; } .eb207 { background-color: #ff5fff; }
+.ef208 { color: #ff8700; } .eb208 { background-color: #ff8700; }
+.ef209 { color: #ff875f; } .eb209 { background-color: #ff875f; }
+.ef210 { color: #ff8787; } .eb210 { background-color: #ff8787; }
+.ef211 { color: #ff87af; } .eb211 { background-color: #ff87af; }
+.ef212 { color: #ff87d7; } .eb212 { background-color: #ff87d7; }
+.ef213 { color: #ff87ff; } .eb213 { background-color: #ff87ff; }
+.ef214 { color: #ffaf00; } .eb214 { background-color: #ffaf00; }
+.ef215 { color: #ffaf5f; } .eb215 { background-color: #ffaf5f; }
+.ef216 { color: #ffaf87; } .eb216 { background-color: #ffaf87; }
+.ef217 { color: #ffafaf; } .eb217 { background-color: #ffafaf; }
+.ef218 { color: #ffafd7; } .eb218 { background-color: #ffafd7; }
+.ef219 { color: #ffafff; } .eb219 { background-color: #ffafff; }
+.ef220 { color: #ffd700; } .eb220 { background-color: #ffd700; }
+.ef221 { color: #ffd75f; } .eb221 { background-color: #ffd75f; }
+.ef222 { color: #ffd787; } .eb222 { background-color: #ffd787; }
+.ef223 { color: #ffd7af; } .eb223 { background-color: #ffd7af; }
+.ef224 { color: #ffd7d7; } .eb224 { background-color: #ffd7d7; }
+.ef225 { color: #ffd7ff; } .eb225 { background-color: #ffd7ff; }
+.ef226 { color: #ffff00; } .eb226 { background-color: #ffff00; }
+.ef227 { color: #ffff5f; } .eb227 { background-color: #ffff5f; }
+.ef228 { color: #ffff87; } .eb228 { background-color: #ffff87; }
+.ef229 { color: #ffffaf; } .eb229 { background-color: #ffffaf; }
+.ef230 { color: #ffffd7; } .eb230 { background-color: #ffffd7; }
+.ef231 { color: #ffffff; } .eb231 { background-color: #ffffff; }
+.ef232 { color: #080808; } .eb232 { background-color: #080808; }
+.ef233 { color: #121212; } .eb233 { background-color: #121212; }
+.ef234 { color: #1c1c1c; } .eb234 { background-color: #1c1c1c; }
+.ef235 { color: #262626; } .eb235 { background-color: #262626; }
+.ef236 { color: #303030; } .eb236 { background-color: #303030; }
+.ef237 { color: #3a3a3a; } .eb237 { background-color: #3a3a3a; }
+.ef238 { color: #444444; } .eb238 { background-color: #444444; }
+.ef239 { color: #4e4e4e; } .eb239 { background-color: #4e4e4e; }
+.ef240 { color: #585858; } .eb240 { background-color: #585858; }
+.ef241 { color: #626262; } .eb241 { background-color: #626262; }
+.ef242 { color: #6c6c6c; } .eb242 { background-color: #6c6c6c; }
+.ef243 { color: #767676; } .eb243 { background-color: #767676; }
+.ef244 { color: #808080; } .eb244 { background-color: #808080; }
+.ef245 { color: #8a8a8a; } .eb245 { background-color: #8a8a8a; }
+.ef246 { color: #949494; } .eb246 { background-color: #949494; }
+.ef247 { color: #9e9e9e; } .eb247 { background-color: #9e9e9e; }
+.ef248 { color: #a8a8a8; } .eb248 { background-color: #a8a8a8; }
+.ef249 { color: #b2b2b2; } .eb249 { background-color: #b2b2b2; }
+.ef250 { color: #bcbcbc; } .eb250 { background-color: #bcbcbc; }
+.ef251 { color: #c6c6c6; } .eb251 { background-color: #c6c6c6; }
+.ef252 { color: #d0d0d0; } .eb252 { background-color: #d0d0d0; }
+.ef253 { color: #dadada; } .eb253 { background-color: #dadada; }
+.ef254 { color: #e4e4e4; } .eb254 { background-color: #e4e4e4; }
+.ef255 { color: #eeeeee; } .eb255 { background-color: #eeeeee; }
+
+.f9 { color: #E5E5E5; }
+.b9 { background-color: #000000; }
+.f9 > .bold,.bold > .f9, body.f9 > pre > .bold {
+ /* Bold is heavy black on white, or bright white
+ depending on the default background */
+ color: #FFFFFF;
+ font-weight: normal;
+}
+.reverse {
+ /* CSS does not support swapping fg and bg colours unfortunately,
+ so just hardcode something that will look OK on all backgrounds. */
+ color: #000000; background-color: #E5E5E5;
+}
+.underline { text-decoration: underline; }
+.line-through { text-decoration: line-through; }
+.blink { text-decoration: blink; }
+
+/* Avoid pixels between adjacent span elements.
+ Note this only works for lines less than 80 chars
+ where we close span elements on the same line.
+span { display: inline-block; }
+*/
--
1.8.5.3
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/3] bin: add ansi2html.sh
2018-03-16 21:33 [PATCH 0/3] wwwdocs: Updates for gcc 8 changes David Malcolm
2018-03-16 21:33 ` [PATCH 3/3] Document my gcc 8 changes for the website David Malcolm
2018-03-16 21:33 ` [PATCH 2/3] Add htdocs/ansi2html.css David Malcolm
@ 2018-03-16 21:38 ` David Malcolm
2018-03-18 23:03 ` [PATCH 0/3] wwwdocs: Updates for gcc 8 changes Gerald Pfeifer
3 siblings, 0 replies; 17+ messages in thread
From: David Malcolm @ 2018-03-16 21:38 UTC (permalink / raw)
To: gcc-patches; +Cc: David Malcolm
---
bin/ansi2html.sh | 520 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 520 insertions(+)
create mode 100755 bin/ansi2html.sh
diff --git a/bin/ansi2html.sh b/bin/ansi2html.sh
new file mode 100755
index 0000000..ae83a78
--- /dev/null
+++ b/bin/ansi2html.sh
@@ -0,0 +1,520 @@
+#!/bin/sh
+
+# Convert ANSI (terminal) colours and attributes to HTML
+
+# Licence: LGPLv2
+# Author:
+# http://www.pixelbeat.org/docs/terminal_colours/
+# Examples:
+# ls -l --color=always | ansi2html.sh > ls.html
+# git show --color | ansi2html.sh > last_change.html
+# Generally one can use the `script` util to capture full terminal output.
+# Changes:
+# V0.1, 24 Apr 2008, Initial release
+# V0.2, 01 Jan 2009, Phil Harnish <philharnish@gmail.com>
+# Support `git diff --color` output by
+# matching ANSI codes that specify only
+# bold or background colour.
+# P@draigBrady.com
+# Support `ls --color` output by stripping
+# redundant leading 0s from ANSI codes.
+# Support `grep --color=always` by stripping
+# unhandled ANSI codes (specifically ^[[K).
+# V0.3, 20 Mar 2009, http://eexpress.blog.ubuntu.org.cn/
+# Remove cat -v usage which mangled non ascii input.
+# Cleanup regular expressions used.
+# Support other attributes like reverse, ...
+# P@draigBrady.com
+# Correctly nest <span> tags (even across lines).
+# Add a command line option to use a dark background.
+# Strip more terminal control codes.
+# V0.4, 17 Sep 2009, P@draigBrady.com
+# Handle codes with combined attributes and color.
+# Handle isolated <bold> attributes with css.
+# Strip more terminal control codes.
+# V0.24, 14 Sep 2017
+# http://github.com/pixelb/scripts/commits/master/scripts/ansi2html.sh
+
+gawk --version >/dev/null || exit 1
+
+if [ "$1" = "--version" ]; then
+ printf '0.23\n' && exit
+fi
+
+usage()
+{
+printf '%s\n' \
+'This utility converts ANSI codes in data passed to stdin
+It has 4 optional parameters:
+--bg=dark --palette=linux|solarized|tango|xterm --css-only|--body-only
+E.g.: ls -l --color=always | ansi2html.sh --bg=dark > ls.html' >&2
+ exit
+}
+
+if [ "$1" = "--help" ]; then
+ usage
+fi
+
+processArg()
+{
+ [ "$1" = "--bg=dark" ] && { dark_bg=yes; return; }
+ [ "$1" = "--css-only" ] && { css_only=yes; return; }
+ [ "$1" = "--body-only" ] && { body_only=yes; return; }
+ if [ "$1" = "--palette=solarized" ]; then
+ # See http://ethanschoonover.com/solarized
+ P0=073642; P1=D30102; P2=859900; P3=B58900;
+ P4=268BD2; P5=D33682; P6=2AA198; P7=EEE8D5;
+ P8=002B36; P9=CB4B16; P10=586E75; P11=657B83;
+ P12=839496; P13=6C71C4; P14=93A1A1; P15=FDF6E3;
+ return;
+ elif [ "$1" = "--palette=solarized-xterm" ]; then
+ # Above mapped onto the xterm 256 color palette
+ P0=262626; P1=AF0000; P2=5F8700; P3=AF8700;
+ P4=0087FF; P5=AF005F; P6=00AFAF; P7=E4E4E4;
+ P8=1C1C1C; P9=D75F00; P10=585858; P11=626262;
+ P12=808080; P13=5F5FAF; P14=8A8A8A; P15=FFFFD7;
+ return;
+ elif [ "$1" = "--palette=tango" ]; then
+ # Gnome default
+ P0=000000; P1=CC0000; P2=4E9A06; P3=C4A000;
+ P4=3465A4; P5=75507B; P6=06989A; P7=D3D7CF;
+ P8=555753; P9=EF2929; P10=8AE234; P11=FCE94F;
+ P12=729FCF; P13=AD7FA8; P14=34E2E2; P15=EEEEEC;
+ return;
+ elif [ "$1" = "--palette=xterm" ]; then
+ P0=000000; P1=CD0000; P2=00CD00; P3=CDCD00;
+ P4=0000EE; P5=CD00CD; P6=00CDCD; P7=E5E5E5;
+ P8=7F7F7F; P9=FF0000; P10=00FF00; P11=FFFF00;
+ P12=5C5CFF; P13=FF00FF; P14=00FFFF; P15=FFFFFF;
+ return;
+ else # linux console
+ P0=000000; P1=AA0000; P2=00AA00; P3=AA5500;
+ P4=0000AA; P5=AA00AA; P6=00AAAA; P7=AAAAAA;
+ P8=555555; P9=FF5555; P10=55FF55; P11=FFFF55;
+ P12=5555FF; P13=FF55FF; P14=55FFFF; P15=FFFFFF;
+ [ "$1" = "--palette=linux" ] && return;
+ fi
+}
+
+processArg #defaults
+for var in "$@"; do processArg $var; done
+[ "$css_only" ] && [ "$body_only" ] && usage
+
+# Mac OSX's GNU sed is installed as gsed
+# use e.g. homebrew 'gnu-sed' to get it
+if ! sed --version >/dev/null 2>&1; then
+ if gsed --version >/dev/null 2>&1; then
+ alias sed=gsed
+ else
+ echo "Error, can't find an acceptable GNU sed." >&2
+ exit 1
+ fi
+fi
+
+[ "$css_only" ] || [ "$body_only" ] || printf '%s' "<html>
+<head>
+<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
+<style type=\"text/css\">
+"
+[ "$body_only" ] || printf ".ef0,.f0 { color: #$P0; } .eb0,.b0 { background-color: #$P0; }
+.ef1,.f1 { color: #$P1; } .eb1,.b1 { background-color: #$P1; }
+.ef2,.f2 { color: #$P2; } .eb2,.b2 { background-color: #$P2; }
+.ef3,.f3 { color: #$P3; } .eb3,.b3 { background-color: #$P3; }
+.ef4,.f4 { color: #$P4; } .eb4,.b4 { background-color: #$P4; }
+.ef5,.f5 { color: #$P5; } .eb5,.b5 { background-color: #$P5; }
+.ef6,.f6 { color: #$P6; } .eb6,.b6 { background-color: #$P6; }
+.ef7,.f7 { color: #$P7; } .eb7,.b7 { background-color: #$P7; }
+.ef8, .f0 > .bold,.bold > .f0 { color: #$P8; font-weight: normal; }
+.ef9, .f1 > .bold,.bold > .f1 { color: #$P9; font-weight: normal; }
+.ef10,.f2 > .bold,.bold > .f2 { color: #$P10; font-weight: normal; }
+.ef11,.f3 > .bold,.bold > .f3 { color: #$P11; font-weight: normal; }
+.ef12,.f4 > .bold,.bold > .f4 { color: #$P12; font-weight: normal; }
+.ef13,.f5 > .bold,.bold > .f5 { color: #$P13; font-weight: normal; }
+.ef14,.f6 > .bold,.bold > .f6 { color: #$P14; font-weight: normal; }
+.ef15,.f7 > .bold,.bold > .f7 { color: #$P15; font-weight: normal; }
+.eb8 { background-color: #$P8; }
+.eb9 { background-color: #$P9; }
+.eb10 { background-color: #$P10; }
+.eb11 { background-color: #$P11; }
+.eb12 { background-color: #$P12; }
+.eb13 { background-color: #$P13; }
+.eb14 { background-color: #$P14; }
+.eb15 { background-color: #$P15; }
+"
+# The default xterm 256 colour palette
+for red in 0 1 2 3 4 5 ; do
+ for green in 0 1 2 3 4 5 ; do
+ for blue in 0 1 2 3 4 5 ; do
+ c=$((16 + ($red * 36) + ($green * 6) + $blue))
+ r=$((($red * 40 + 55) * ($red > 0)))
+ g=$((($green * 40 + 55) * ($green > 0)))
+ b=$((($blue * 40 + 55) * ($blue > 0)))
+ [ "$body_only" ] || printf ".ef%d { color: #%2.2x%2.2x%2.2x; } " $c $r $g $b
+ [ "$body_only" ] || printf ".eb%d { background-color: #%2.2x%2.2x%2.2x; }\n" $c $r $g $b
+ done
+ done
+done
+for gray in $(seq 0 23); do
+ c=$(($gray+232))
+ l=$(($gray*10 + 8))
+ [ "$body_only" ] || printf ".ef%d { color: #%2.2x%2.2x%2.2x; } " $c $l $l $l
+ [ "$body_only" ] || printf ".eb%d { background-color: #%2.2x%2.2x%2.2x; }\n" $c $l $l $l
+done
+
+[ "$body_only" ] || printf '%s' '
+.f9 { color: '`[ "$dark_bg" ] && printf "#$P7;" || printf "#$P0;"`' }
+.b9 { background-color: #'`[ "$dark_bg" ] && printf $P0 || printf $P15`'; }
+.f9 > .bold,.bold > .f9, body.f9 > pre > .bold {
+ /* Bold is heavy black on white, or bright white
+ depending on the default background */
+ color: '`[ "$dark_bg" ] && printf "#$P15;" || printf "#$P0;"`'
+ font-weight: '`[ "$dark_bg" ] && printf 'normal;' || printf 'bold;'`'
+}
+.reverse {
+ /* CSS does not support swapping fg and bg colours unfortunately,
+ so just hardcode something that will look OK on all backgrounds. */
+ '"color: #$P0; background-color: #$P7;"'
+}
+.underline { text-decoration: underline; }
+.line-through { text-decoration: line-through; }
+.blink { text-decoration: blink; }
+
+/* Avoid pixels between adjacent span elements.
+ Note this only works for lines less than 80 chars
+ where we close span elements on the same line.
+span { display: inline-block; }
+*/
+'
+[ "$body_only" ] || [ "$css_only" ] && printf '%s\n' \
+'To use the css generated from --css-only, do: '\
+'<head><link rel="stylesheet" type="text/css" href="style.css"></head>' >&2
+[ "$css_only" ] && exit
+[ "$body_only" ] || printf '%s' '</style>
+</head>
+
+<body class="f9 b9">
+<pre>
+'
+[ "$body_only" ] && printf '%s\n' 'Be sure to use <body class="f9 b9"> and <pre>' >&2
+
+p='\x1b\[' #shortcut to match escape codes
+
+# Handle various xterm control sequences.
+# See /usr/share/doc/xterm-*/ctlseqs.txt
+sed "
+# escape ampersand and quote
+s#&#\&#g; s#\"#\"#g;
+s#\x1b[^\x1b]*\x1b\\\##g # strip anything between \e and ST
+s#\x1b][0-9]*;[^\a]*\a##g # strip any OSC (xterm title etc.)
+
+s#\r\$## # strip trailing \r
+
+# strip other non SGR escape sequences
+s#[\x07]##g
+s#\x1b[]>=\][0-9;]*##g
+s#\x1bP+.\{5\}##g
+# Mark cursor positioning codes \"Jr;c;
+s#${p}\([0-9]\{1,2\}\)G#\"J;\1;#g
+s#${p}\([0-9]\{1,2\}\);\([0-9]\{1,2\}\)H#\"J\1;\2;#g
+
+# Mark clear as \"Cn where n=1 is screen and n=0 is to end-of-line
+s#${p}H#\"C1;#g
+s#${p}K#\"C0;#g
+# Mark Cursor move columns as \"Mn where n is +ve for right, -ve for left
+s#${p}C#\"M1;#g
+s#${p}\([0-9]\{1,\}\)C#\"M\1;#g
+s#${p}\([0-9]\{1,\}\)D#\"M-\1;#g
+s#${p}\([0-9]\{1,\}\)P#\"X\1;#g
+
+s#${p}[0-9;?]*[^0-9;?m]##g
+
+" |
+
+# Normalize the input before transformation
+sed "
+# escape HTML (ampersand and quote done above)
+s#>#\>#g; s#<#\<#g;
+
+# handle truecolor
+s#${p}38;2;\([0-9]\{1,3\}\);\([0-9]\{1,3\}\);\([0-9]\{1,3\}\)m#\
+<span style=\"color:rgb(\1\,\2\,\3\)\">#g
+s#${p}48;2;\([0-9]\{1,3\}\);\([0-9]\{1,3\}\);\([0-9]\{1,3\}\)m#\
+<span style=\"background-color:rgb(\1\,\2\,\3\)\">#g
+
+# normalize SGR codes a little
+
+# split 256 colors out and mark so that they're not
+# recognised by the following 'split combined' line
+:e
+s#${p}\([0-9;]\{1,\}\);\([34]8;5;[0-9]\{1,3\}\)m#${p}\1m${p}¬\2m#g; t e
+s#${p}\([34]8;5;[0-9]\{1,3\}\)m#${p}¬\1m#g;
+
+:c
+s#${p}\([0-9]\{1,\}\);\([0-9;]\{1,\}\)m#${p}\1m${p}\2m#g; t c # split combined
+s#${p}0\([0-7]\)#${p}\1#g #strip leading 0
+s#${p}1m\(\(${p}[4579]m\)*\)#\1${p}1m#g #bold last (with clr)
+s#${p}m#${p}0m#g #add leading 0 to norm
+
+# undo any 256 color marking
+s#${p}¬\([34]8;5;[0-9]\{1,3\}\)m#${p}\1m#g;
+
+# map 16 color codes to color + bold
+s#${p}9\([0-7]\)m#${p}3\1m${p}1m#g;
+s#${p}10\([0-7]\)m#${p}4\1m${p}1m#g;
+
+# change 'reset' code to \"R
+s#${p}0m#\"R;#g
+" |
+
+# Convert SGR sequences to HTML
+sed "
+# common combinations to minimise html (optional)
+:f
+s#${p}3[0-7]m${p}3\([0-7]\)m#${p}3\1m#g; t f
+:b
+s#${p}4[0-7]m${p}4\([0-7]\)m#${p}4\1m#g; t b
+s#${p}3\([0-7]\)m${p}4\([0-7]\)m#<span class=\"f\1 b\2\">#g
+s#${p}4\([0-7]\)m${p}3\([0-7]\)m#<span class=\"f\2 b\1\">#g
+
+s#${p}1m#<span class=\"bold\">#g
+s#${p}4m#<span class=\"underline\">#g
+s#${p}5m#<span class=\"blink\">#g
+s#${p}7m#<span class=\"reverse\">#g
+s#${p}9m#<span class=\"line-through\">#g
+s#${p}3\([0-9]\)m#<span class=\"f\1\">#g
+s#${p}4\([0-9]\)m#<span class=\"b\1\">#g
+
+s#${p}38;5;\([0-9]\{1,3\}\)m#<span class=\"ef\1\">#g
+s#${p}48;5;\([0-9]\{1,3\}\)m#<span class=\"eb\1\">#g
+
+s#${p}[0-9;]*m##g # strip unhandled codes
+" |
+
+# Convert alternative character set and handle cursor movement codes
+# Note we convert here, as if we do at start we have to worry about avoiding
+# conversion of SGR codes etc., whereas doing here we only have to
+# avoid conversions of stuff between &...; or <...>
+#
+# Note we could use sed to do this based around:
+# sed 'y/abcdefghijklmnopqrstuvwxyz{}`~/âââââ°±â¤ââââââ¼âºâ»ââ¼â½ââ¤â´â¬ââ¤â¥Ï£â·/'
+# However that would be very awkward as we need to only conv some input.
+# The basic scheme that we do in the awk script below is:
+# 1. enable transliterate once "T1; is seen
+# 2. disable once "T0; is seen (may be on diff line)
+# 3. never transliterate between &; or <> chars
+# 4. track x,y movements and active display mode at each position
+# 5. buffer line/screen and dump when required
+sed "
+# change 'smacs' and 'rmacs' to \"T1 and \"T0 to simplify matching.
+s#\x1b(0#\"T1;#g;
+s#\x0E#\"T1;#g;
+
+s#\x1b(B#\"T0;#g
+s#\x0F#\"T0;#g
+" |
+(
+gawk '
+function dump_line(l,del,c,blanks,ret) {
+ for(c=1;c<maxX;c++) {
+ if ((c SUBSEP l) in attr || length(cur)) {
+ ret = ret blanks fixas(cur,attr[c,l])
+ if(del) delete attr[c,l]
+ blanks=""
+ }
+ if ((c SUBSEP l) in dump) {
+ ret=ret blanks dump[c,l]
+ if(del) delete dump[c,l]
+ blanks=""
+ } else blanks=blanks " "
+ }
+ if(length(cur)) ret=ret blanks
+ return ret
+}
+
+function dump_screen(l,ret) {
+ for(l=1;l<=maxY;l++)
+ ret=ret dump_line(l,0) "\n"
+ return ret fixas(cur, "")
+}
+
+function atos(a,i,ret) {
+ for(i=1;i<=length(a);i++) if(i in a) ret=ret a[i]
+ return ret
+}
+
+function fixas(a,s,spc,i,attr,rm,ret) {
+ spc=length(a)
+ l=split(s,attr,">")
+ for(i=1;i<=spc;i++) {
+ rm=rm?rm:(a[i]!=attr[i]">")
+ if(rm) {
+ ret=ret "</span>"
+ delete a[i];
+ }
+ }
+ for(i=1;i<l;i++) {
+ attr[i]=attr[i]">"
+ if(a[i]!=attr[i]) {
+ a[i]=attr[i]
+ ret = ret attr[i]
+ }
+ }
+ return ret
+}
+
+function encode(string,start,end,i,ret,pos,sc,buf) {
+ if(!end) end=length(string);
+ if(!start) start=1;
+ state=3
+ for(i=1;i<=length(string);i++) {
+ c=substr(string,i,1)
+ if(state==2) {
+ sc=sc c
+ if(c==";") {
+ c=sc
+ state=last_mode
+ } else continue
+ } else {
+ if(c=="\r") { x=1; continue }
+ if(c=="<") {
+ # Change attributes - store current active
+ # attributes in span array
+ split(substr(string,i),cord,">");
+ i+=length(cord[1])
+ span[++spc]=cord[1] ">"
+ continue
+ }
+ else if(c=="&") {
+ # All goes to single position till we see a semicolon
+ sc=c
+ state=2
+ continue
+ }
+ else if(c=="\b") {
+ # backspace move insertion point back 1
+ if(spc) attr[x,y]=atos(span)
+ x=x>1?x-1:1
+ continue
+ }
+ else if(c=="\"") {
+ split(substr(string,i+2),cord,";")
+ cc=substr(string,i+1,1);
+ if(cc=="T") {
+ # Transliterate on/off
+ if(cord[1]==1&&state==3) last_mode=state=4
+ if(cord[1]==0&&state==4) last_mode=state=3
+ }
+ else if(cc=="C") {
+ # Clear
+ if(cord[1]+0) {
+ # Screen - if Recording dump screen
+ if(dumpStatus==dsActive) ret=ret dump_screen()
+ dumpStatus=dsActive
+ delete dump
+ delete attr
+ x=y=1
+ } else {
+ # To end of line
+ for(pos=x;pos<maxX;pos++) {
+ dump[pos,y]=" "
+ if (!spc) delete attr[pos,y]
+ else attr[pos,y]=atos(span)
+ }
+ }
+ }
+ else if(cc=="J") {
+ # Jump to x,y
+ i+=length(cord[2])+1
+ # If line is higher - dump previous screen
+ if(dumpStatus==dsActive&&cord[1]<y) {
+ ret=ret dump_screen();
+ dumpStatus=dsNew;
+ }
+ x=cord[2]
+ if(length(cord[1]) && y!=cord[1]){
+ y=cord[1]
+ if(y>maxY) maxY=y
+ # Change y - start recording
+ dumpStatus=dumpStatus?dumpStatus:dsReset
+ }
+ }
+ else if(cc=="M") {
+ # Move left/right on current line
+ x+=cord[1]
+ }
+ else if(cc=="X") {
+ # delete on right
+ for(pos=x;pos<=maxX;pos++) {
+ nx=pos+cord[1]
+ if(nx<maxX) {
+ if((nx SUBSEP y) in attr) attr[pos,y] = attr[nx,y]
+ else delete attr[pos,y]
+ if((nx SUBSEP y) in dump) dump[pos,y] = dump[nx,y]
+ else delete dump[pos,y]
+ } else if(spc) {
+ attr[pos,y]=atos(span)
+ dump[pos,y]=" "
+ }
+ }
+ }
+ else if(cc=="R") {
+ # Reset attributes
+ while(spc) delete span[spc--]
+ }
+ i+=length(cord[1])+2
+ continue
+ }
+ else if(state==4&&i>=start&&i<=end&&c in Trans) c=Trans[c]
+ }
+ if(dumpStatus==dsReset) {
+ delete dump
+ delete attr
+ ret=ret"\n"
+ dumpStatus=dsActive
+ }
+ if(dumpStatus==dsNew) {
+ # After moving/clearing we are now ready to write
+ # somthing to the screen so start recording now
+ ret=ret"\n"
+ dumpStatus=dsActive
+ }
+ if(dumpStatus==dsActive||dumpStatus==dsOff) {
+ dump[x,y] = c
+ if(!spc) delete attr[x,y]
+ else attr[x,y] = atos(span)
+ if(++x>maxX) maxX=x;
+ }
+ }
+ # End of line if dumping increment y and set x back to first col
+ x=1
+ if(!dumpStatus) return ret dump_line(y,1);
+ else if(++y>maxY) maxY=y;
+ return ret
+}
+BEGIN{
+ OFS=FS
+ # dump screen status
+ dsOff=0 # Not dumping screen contents just write output direct
+ dsNew=1 # Just after move/clear waiting for activity to start recording
+ dsReset=2 # Screen cleared build new empty buffer and record
+ dsActive=3 # Currently recording
+ F="abcdefghijklmnopqrstuvwxyz{}`~"
+ T="âââââ°±â¤ââââââ¼âºâ»ââ¼â½ââ¤â´â¬ââ¤â¥Ï£â·"
+ maxX=80
+ delete cur;
+ x=y=1
+ for(i=1;i<=length(F);i++)Trans[substr(F,i,1)]=substr(T,i,1);
+}
+
+{ $0=encode($0) }
+1
+END {
+ if(dumpStatus) {
+ print dump_screen();
+ }
+}'
+)
+
+[ "$body_only" ] || printf '</pre>
+</body>
+</html>\n'
--
1.8.5.3
^ permalink raw reply [flat|nested] 17+ messages in thread