File: fix-flex

package info (click to toggle)
rasqal 0.9.8-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,880 kB
  • ctags: 2,047
  • sloc: sh: 8,759; ansic: 7,301; lex: 1,879; perl: 1,750; yacc: 1,628; makefile: 747
file content (40 lines) | stat: -rwxr-xr-x 730 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl
#
# $Id: fix-flex,v 1.2 2004/08/13 16:04:27 cmdjb Exp $
#
# Format output generated by flex 2.5.31
#
# Usage:
#  flex -o$output $input
#  perl fix-flex $output > $tmp
#  mv $tmp $output
#
# (C) Copyright 2004 Dave Beckett <Dave.Beckett@bristol.ac.uk>
# University of Bristol
#

print <<'EOT';
#ifdef HAVE_CONFIG_H
#include <rasqal_config.h>
#endif

#ifdef WIN32
#include <win32_rasqal_config.h>
#endif

EOT

while(<>) {
  # the default parser tries to free(NULL)
  s/(^\s+)(free\(.*ptr.*\))/${1}if(ptr) $2/;

  # flex has %option nounistd however it does not work in 2.5.31
  # It is safe to add yet another wrapper. 
  $_=<<"EOT" if m%^(\#include \<unistd.h\>)$%;
#ifndef YY_NO_UNISTD_H
$1
#endif
EOT

  print;
}