Release coccinelle-0.2.2-rc1
[bpt/coccinelle.git] / standard.iso
index e392aa8..555f6ee 100644 (file)
@@ -131,34 +131,85 @@ signed => signed int
 
 
 // ---------------------------------------------------------------------------
-// Boolean isomorphisms
+// Boolean isomorphisms for int and pointer types
 // ---------------------------------------------------------------------------
 
 // the space at the beginning of the line is very important!
 Expression
-@ not_int1 @ 
+@ not_int1 @
 int X; 
 @@
- !X => 0 == X
+ !X => X == 0
+
+TestExpression
+@ not_int2 @
+int X; 
+@@
+ X => X != 0
 
 // the space at the beginning of the line is very important!
 Expression
-@ not_int2 @ 
-int X; 
+@ not_ptr1 @
+expression *X; 
 @@
- !X => X == 0
+ !X => X == NULL
+
+TestExpression
+@ not_ptr2 @
+expression *X;
+@@
+ X => X != NULL
+
+// ---------------------------------------------------------------------------
+// Boolean isomorphisms
+// ---------------------------------------------------------------------------
+
+Expression
+@commeq@
+expression E;
+constant C;
+@@
+
+E == C <=> C == E
+
+Expression
+@commneq@
+expression E;
+constant C;
+@@
+
+E != C <=> C != E
 
 Expression
 @ is_zero @ 
 expression X; 
 @@
-X == 0 <=> 0 == X => !X
+X == 0 => !X
 
-TestExpression
+// X should be a test expression, but X!=0 doesn't have to be one
+// not nice at all...  ToTestExpression sets everything after the first
+// pattern in the iso rule to be TestExpression
+ToTestExpression
 @ isnt_zero @ 
 expression X; 
 @@
-X != 0 <=> 0 != X => X
+X != 0 => X
+
+Expression
+@ is_null @ 
+expression X; 
+@@
+X == NULL => !X
+
+ToTestExpression
+@ isnt_null1 @ 
+expression X; 
+@@
+X != NULL => X
+
+// ---------------------------------------------------------------------------
+// Bit operations
+// ---------------------------------------------------------------------------
 
 Expression
 @ bitor_comm @ 
@@ -337,80 +388,10 @@ expression E;
 
  (E) => E
 
-// ---------------------------------------------------------------------------
-// Pointer isomorphisms
-// ---------------------------------------------------------------------------
-
-// the space at the beginning of the line is very important!
-Expression
-@ not_ptr1 @ 
-expression *X; 
-@@
- !X => NULL == X
-
-// the space at the beginning of the line is very important!
-Expression
-@ not_ptr2 @ 
-expression *X; 
-@@
- !X => X == NULL
-
-Expression
-@ is_null @ 
-expression X; 
-@@
-X == NULL <=> NULL == X => !X
-
-Expression
-@ isnt_null1 @ 
-expression X; 
-@@
-X != NULL <=> NULL != X
-
-TestExpression
-@ isnt_null1 @ 
-expression X; 
-@@
-NULL != X => X
-
-// pointer arithmetic equivalences
-
 // ---------------------------------------------------------------------------
 // Statement isomorphisms
 // ---------------------------------------------------------------------------
 
-// ----------------
-// If
-// ----------------
-
-Statement
-@ int_if_test1 @
-int X;
-statement S1, S2;
-@@
-if (X) S1 else S2 => if (X != 0) S1 else S2 <=> if (0 != X) S1 else S2
-
-Statement
-@ int_if_test2 @
-int X;
-statement S;
-@@
-if (X) S => if (X != 0) S <=> if (0 != X) S
-
-Statement
-@ ptr_if_test1 @
-expression *X;
-statement S1, S2;
-@@
-if (X) S1 else S2 => if (X != NULL) S1 else S2 => if (NULL != X) S1 else S2
-
-Statement
-@ ptr_if_test2 @
-expression *X;
-statement S;
-@@
-if (X) S => if (X != NULL) S <=> if (NULL != X) S
-
 // ---------------------------------------------------------------------------
 // Value isomorphisms
 // ---------------------------------------------------------------------------
@@ -424,11 +405,15 @@ ArgExpression
 @@
  0 => '\0'
 
+// ----------------
+// If
+// ----------------
+
 // ****************************************************************************
 // if structure isomorphisms 
 // ****************************************************************************
 
-// these after after the above so that the introduced negation will distribute
+// these are after the above so that the introduced negation will distribute
 // properly over the argument to likely/unlikely
 
 Statement