Release coccinelle-0.2.0
[bpt/coccinelle.git] / scripts / extract_examples.pl
CommitLineData
9f8e26f4
C
1# Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
2# Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
3# This file is part of Coccinelle.
4#
5# Coccinelle is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, according to version 2 of the License.
8#
9# Coccinelle is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
16#
17# The authors reserve the right to distribute this or future versions of
18# Coccinelle under other licenses.
19
20
34e49164
C
21#!/usr/bin/perl
22#usage: ./extract_examples.pl ~/week-end/working-documents/examples.tex
23
24my $ex = 0;
25my $are_in = 0;
26while(<>) {
27
28 if(/\\section{/) {
29 $ex++;
30 open TMP, ">$ex.cocci" or die "$!";
31 }
32
33 if(/begin{verbatim}/) {
34 $are_in = 1;
35 #old: open TMP, ">$ex.cocci" or die "$!";
36 } elsif(/end{verbatim}/) {
37 $are_in = 0;
38 #old: $ex++;
39 } else {
40 if($are_in) { print TMP "$_"; }
41 }
42}