Skip to content

Commit e3c8dac

Browse files
committed
Web: Add "Online Demo" page
1 parent 7792758 commit e3c8dac

4 files changed

Lines changed: 111 additions & 0 deletions

File tree

htdocs/demo/index.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5+
<title>Developer Information - Cppcheck</title>
6+
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Orbitron&amp;text=Cppcheck" />
7+
<link rel="stylesheet" type="text/css" href="/site/css/all.css" />
8+
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
9+
<link rel="alternate" type="application/atom+xml" title="Recent Commits to cppcheck:master"
10+
href="https://github.com/danmar/cppcheck/commits/master.atom" />
11+
<link rel="alternate" type="application/atom+xml" title="Trac Timeline"
12+
href="http://sourceforge.net/apps/trac/cppcheck/timeline?changeset=on&amp;ticket=on&amp;milestone=on&amp;wiki=on&amp;max=50&amp;daysback=90&amp;format=rss" />
13+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
14+
<script src="/site/js/github.js" type="text/javascript"></script>
15+
<script type="text/javascript">
16+
function checkCodeLength() {
17+
if (document.f.code.value.length > 1024) {
18+
alert('code length exceeded');
19+
return false;
20+
}
21+
return true;
22+
}
23+
</script>
24+
</head>
25+
<body>
26+
<div id="header">
27+
<div class="wrap">
28+
<h1>Cppcheck</h1>
29+
<p>A tool for static C/C++ code analysis</p>
30+
</div> <!-- .wrap -->
31+
</div> <!-- #header -->
32+
<div id="tabs">
33+
<div class="wrap">
34+
<ul>
35+
<li><a href="/">Home</a></li>
36+
<li><a href="http://sourceforge.net/apps/mediawiki/cppcheck/">Wiki</a></li>
37+
<li><a href="http://sourceforge.net/apps/phpbb/cppcheck/">Forum</a></li>
38+
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Trac</a></li>
39+
<li><a href="/devinfo/" title="Developer Information">Developer Info</a></li>
40+
<li><strong><a href="/demo/">Online Demo</a></strong></li>
41+
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
42+
</ul>
43+
</div> <!-- .wrap -->
44+
</div> <!-- #tabs -->
45+
<div id="content">
46+
<div class="wrap">
47+
<h2>Online Demo</h2>
48+
<form action="http://cppcheck.sourceforge.net/cgi-bin/democlient.cgi" name="f" onsubmit="return checkCodeLength();" method="post" target="_blank">
49+
<p><label for="code">Enter code:</label><br />
50+
<textarea id="code" name="code" rows="20" cols="80">
51+
void f()
52+
{
53+
char *p;
54+
*p = 0;
55+
}
56+
</textarea><br />
57+
<input type="submit" value="Check" /> (max 1024 characters)</p>
58+
</form>
59+
<h3>Examples</h3>
60+
<p>This code can be copy and pasted in the edit box above.</p>
61+
<h4>NULL pointers</h4>
62+
<pre class="code">void f1(struct fred_t *p)
63+
{
64+
<em>// dereference p and then check if it's NULL</em>
65+
int x = p-&gt;x;
66+
if (p)
67+
do_something(x);
68+
}
69+
70+
void f2()
71+
{
72+
const char *p = NULL;
73+
for (int i = 0; str[i] != '\0'; i++)
74+
{
75+
if (str[i] == ' ')
76+
{
77+
p = str + i;
78+
break;
79+
}
80+
}
81+
82+
<em>// p is NULL if str doesn't have a space. If str always has a</em>
83+
<em>// a space then the condition (str[i] != '\0') would be redundant</em>
84+
return p[1];
85+
}
86+
87+
void f3(int a)
88+
{
89+
struct fred_t *p = NULL;
90+
if (a == 1)
91+
p = fred1;
92+
93+
<em>// if a is not 1 then p is NULL</em>
94+
p-&gt;x = 0;
95+
}</pre>
96+
</div> <!-- .wrap -->
97+
</div> <!-- #content -->
98+
</body>
99+
</html>

htdocs/devinfo/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<li><a href="http://sourceforge.net/apps/phpbb/cppcheck/">Forum</a></li>
3434
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Trac</a></li>
3535
<li><strong><a href="/devinfo/" title="Developer Information">Developer Info</a></strong></li>
36+
<li><a href="/demo/">Online Demo</a></li>
3637
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
3738
</ul>
3839
</div> <!-- .wrap -->

htdocs/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<li><a href="http://sourceforge.net/apps/phpbb/cppcheck/">Forum</a></li>
3131
<li><a href="http://sourceforge.net/apps/trac/cppcheck/">Trac</a></li>
3232
<li><a href="/devinfo/" title="Developer Information">Developer Info</a></li>
33+
<li><a href="/demo/">Online Demo</a></li>
3334
<li><a href="http://sourceforge.net/projects/cppcheck/">Project page</a></li>
3435
</ul>
3536
</div> <!-- .wrap -->

htdocs/site/css/all.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ a.downloadnow em {
117117
font-style: normal;
118118
}
119119

120+
/* Source Code */
121+
pre.code {
122+
padding: .5em;
123+
background: #f7f7f7;
124+
border: 1px solid #e2e2e2;
125+
}
126+
pre.code em {
127+
color: green;
128+
}
129+
120130
/* Printing */
121131
@media print {
122132
#header { color: black; border-bottom: 1px solid black; }

0 commit comments

Comments
 (0)