diff --git a/htdocs/demo/index.php b/htdocs/demo/index.php new file mode 100644 index 000000000..1067db4c4 --- /dev/null +++ b/htdocs/demo/index.php @@ -0,0 +1,99 @@ + + + + + Developer Information - Cppcheck + + + + + + + + + + + +
+
+ +
+
+
+
+

Online Demo

+
+


+
+ (max 1024 characters)

+
+

Examples

+

This code can be copy and pasted in the edit box above.

+

NULL pointers

+
void f1(struct fred_t *p)
+{
+    // dereference p and then check if it's NULL
+    int x = p->x;
+    if (p)
+        do_something(x);
+}
+
+void f2()
+{
+    const char *p = NULL;
+    for (int i = 0; str[i] != '\0'; i++)
+    {
+        if (str[i] == ' ')
+        {
+            p = str + i;
+            break;
+        }
+    }
+
+    // p is NULL if str doesn't have a space. If str always has a
+    // a space then the condition (str[i] != '\0') would be redundant
+    return p[1];
+}
+
+void f3(int a)
+{
+    struct fred_t *p = NULL;
+    if (a == 1)
+        p = fred1;
+
+    // if a is not 1 then p is NULL
+    p->x = 0;
+}
+
+
+ + \ No newline at end of file diff --git a/htdocs/devinfo/index.php b/htdocs/devinfo/index.php index fffc3859c..f2fd41625 100644 --- a/htdocs/devinfo/index.php +++ b/htdocs/devinfo/index.php @@ -33,6 +33,7 @@
  • Forum
  • Trac
  • Developer Info
  • +
  • Online Demo
  • Project page
  • diff --git a/htdocs/index.php b/htdocs/index.php index b8dc1b09d..569401aee 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -30,6 +30,7 @@ uninitialized variables, unused functions" />
  • Forum
  • Trac
  • Developer Info
  • +
  • Online Demo
  • Project page
  • diff --git a/htdocs/site/css/all.css b/htdocs/site/css/all.css index 5a4d3b762..8526d2ed0 100644 --- a/htdocs/site/css/all.css +++ b/htdocs/site/css/all.css @@ -117,6 +117,16 @@ a.downloadnow em { font-style: normal; } +/* Source Code */ +pre.code { + padding: .5em; + background: #f7f7f7; + border: 1px solid #e2e2e2; +} +pre.code em { + color: green; +} + /* Printing */ @media print { #header { color: black; border-bottom: 1px solid black; }