[C2hs] Patch for ignoring #itent directives

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Mon May 9 07:40:43 EDT 2005


Hello,

Some C header files have this odd '#ident' directive.

For example, /usr/include/vte/vte.h :

 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef vte_vte_h_included
#define vte_vte_h_included

#ident "$Id: vte.h,v 1.78 2004/05/01 07:12:51 nalin Exp $"

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

So, here's a patch to ignore these things. It's basically a copy'n'paste
of the code of the pragma :: CLexer

Duncan

Index: CLexer.hs
===================================================================
RCS file: /cvsroot/gtk2hs/gtk2hs/tools/c2hs/c/CLexer.hs,v
retrieving revision 1.3
diff -U3 -r1.3 CLexer.hs
--- CLexer.hs   19 Jan 2005 18:34:46 -0000      1.3
+++ CLexer.hs   9 May 2005 11:33:54 -0000
@@ -504,6 +504,7 @@
          >||< whitespace
          >||< linedir
          >||< pragma
+         >||< rcsident

 -- whitespace (follows K&R A2.1)
 --
@@ -555,6 +556,17 @@
          where
            ppwhite = (char ' ' >|< char '\t')`star` epsilon

+-- #itent directive, eg used by rcs/cvs
+--
+-- * we simply ignore any #itent (but take care to update the position
+--   information)
+--
+rcsident :: CLexer
+rcsident  = char '#' +> ppwhite +> string "ident" +> anyButNL`star` char '\n'
+         `lexmeta` \_ pos ns -> (Nothing, retPos pos, ns, Nothing)
+         where
+           ppwhite = (char ' ' >|< char '\t')`star` epsilon
+
 -- identifiers and keywords (follows K&R A2.3 and A2.4)
 --
 identOrKW :: CLexer




More information about the C2hs mailing list