Projet_SETI_RISC-V/riscv-gnu-toolchain/newlib/winsup/cygwin/mkglobals_h
2023-03-06 14:48:14 +01:00

28 lines
607 B
Perl
Executable file

#!/usr/bin/perl
my @argv = @ARGV;
$_ = join('', <>);
s/\s+\n/\n/sog;
s/\n[^\n]*!globals.h[^\n]*\n/\n/sog;
s%/\*.*?\*/%%sog;
s/(enum\s.*?{.*?})/munge($1)/soge;
s/^(\s*)([a-zA-Z_])/$1extern $2/mog;
s/extern (extern|enum)/$1/sog;
s/\n\s*extern static[^\n]*\n/\n/sog;
s/\s+=.*?;/;/sog;
s/^\n+//sog;
s/#include "winsup\.h"\n//so;
s/-NL-/\n/sog;
s/-EQ-/=/sog;
s/\n{2,}/\n/sog;
print <<PRELUDE,$_;
/* $target - Autogenerated from @argv. Look there for comments. */
#pragma once
PRELUDE
close $target_fd;
sub munge($) {
my $val = shift;
$val =~ s/\n/-NL-/sog;
$val =~ s/=/-EQ-/sog;
return $val;
}