From 2477a12bbacf4b067840e801e5ca9ec1ebafecf9 Mon Sep 17 00:00:00 2001 From: Buck Golemon Date: Tue, 27 May 2014 10:02:48 -0700 Subject: [PATCH] graceful degredation when given out-of-bounds line numbers --- libcpychecker_html/make_html.py | 6 +++++- libcpychecker_html/script.js | 16 +++++++++------- libcpychecker_html/style-noprefix.css | 1 + libcpychecker_html/style.css | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/libcpychecker_html/make_html.py b/libcpychecker_html/make_html.py index 51e1a9c2..4777d842 100755 --- a/libcpychecker_html/make_html.py +++ b/libcpychecker_html/make_html.py @@ -70,7 +70,11 @@ def head(self): 'http-equiv': 'Content-Type', 'content': 'text/html; charset=utf-8' }), - E.TITLE('%s -- GCC Python Plugin' % self.data['filename']), + # get_string() _mysql.c -- GCC Python Plugin + E.TITLE('%s() %s -- GCC Python Plugin' % ( + self.data['function']['name'], + self.data['filename'], + )), ) head.extend( E.STYLE( diff --git a/libcpychecker_html/script.js b/libcpychecker_html/script.js index 517f9e7d..11c41ac1 100644 --- a/libcpychecker_html/script.js +++ b/libcpychecker_html/script.js @@ -40,18 +40,22 @@ $(function() { // backwards, that starts a new subflow var $states = $report.find('.states li'); var source_flow = []; - var last_line = null; + var last_line = Infinity; $states.each(function() { var $state = $(this); var lineno = parseInt($state.data('line'), 10); var $assoc_line = $line_index[lineno]; + + if ( $assoc_line === undefined ) { + // The commentary mentioned a line that we're not showing. + return; + } $state.data('line-element', $assoc_line); $state.prepend($('

').text(String(lineno))); var flow; - if (! last_line || last_line >= lineno) { - // Mark commentary that starts a new subflow (but not the - // first) + if (last_line >= lineno) { + // This is a new subflow, possibly the first. if (source_flow.length) { $state.addClass('new-subflow'); } @@ -97,11 +101,9 @@ $(function() { flow.shift(); } // Lines between the start and end of a subflow, or before the - // start of the first subflow, or after the end of the last - // subflow, get undotted lines + // start of the first subflow get undotted lines else if ( (idx == 0 && flow.length) || - (idx == source_flow.length - 1 && ! flow.length) || (started[idx] && flow.length) ) { $paths = $paths.add($('', { "class": "flow-line" }).html('​')); diff --git a/libcpychecker_html/style-noprefix.css b/libcpychecker_html/style-noprefix.css index 424ece50..02243056 100644 --- a/libcpychecker_html/style-noprefix.css +++ b/libcpychecker_html/style-noprefix.css @@ -279,6 +279,7 @@ img { } .states li.new-subflow { border-top-width: 4px; + border-top-color: black; } .states h2 { float: right; diff --git a/libcpychecker_html/style.css b/libcpychecker_html/style.css index 8401e4df..396a4929 100755 --- a/libcpychecker_html/style.css +++ b/libcpychecker_html/style.css @@ -357,6 +357,7 @@ img { } .states li.new-subflow { border-top-width: 4px; + border-top-color: black; } .states h2 { float: right;