Skip to content
Browse files

Added error checks on close(). Made a standard read-only coda for the…

… generated files. Turned off unnecessary interpolation.

git-svn-id: https://svn.parrot.org/parrot/trunk@38777 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent bb9544c commit 6baf83e8dc8e7fc64b7414a5e832991b62445123 @petdance petdance committed
Showing with 36 additions and 33 deletions.
  1. +36 −33 config/gen/core_pmcs.pm
View
69 config/gen/core_pmcs.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, Parrot Foundation.
+# Copyright (C) 2001-2009, Parrot Foundation.
# $Id$
=head1 NAME
@@ -42,11 +42,11 @@ sub runstep {
sub generate_h {
my ( $self, $conf ) = @_;
- my $file = "include/parrot/core_pmcs.h";
+ my $file = 'include/parrot/core_pmcs.h';
$conf->append_configure_log($file);
- open( my $OUT, ">", "$file.tmp" );
+ open( my $OUT, '>', "$file.tmp" );
- print {$OUT} <<"END_H";
+ print {$OUT} <<'END_H';
/*
* DO NOT EDIT THIS FILE
*
@@ -56,33 +56,27 @@ sub generate_h {
#ifndef PARROT_CORE_PMCS_H_GUARD
#define PARROT_CORE_PMCS_H_GUARD
-/* &gen_from_enum(pmctypes.pasm) subst(s/enum_class_(\\w+)/\$1/e) */
+/* &gen_from_enum(pmctypes.pasm) subst(s/enum_class_(\w+)/$1/e) */
enum {
END_H
- my @pmcs = split( / /, $conf->data->get('pmc_names') );
+ my @pmcs = split( qr/ /, $conf->data->get('pmc_names') );
my $i = 0;
foreach (@pmcs) {
print {$OUT} " enum_class_$_,\t/* $i */\n";
$i++;
}
- print {$OUT} <<"END_H";
+ print {$OUT} <<'END_H';
enum_class_core_max
};
/* &end_gen */
#endif /* PARROT_CORE_PMCS_H_GUARD */
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
END_H
+ print {$OUT} coda();
- close $OUT;
+ close $OUT or die "Can't close file: $!";;
move_if_diff( "$file.tmp", $file );
@@ -93,12 +87,12 @@ sub generate_c {
my ( $self, $conf ) = @_;
my $file = "src/core_pmcs.c";
- my @pmcs = split( / /, $conf->data->get('pmc_names') );
+ my @pmcs = split( qr/ /, $conf->data->get('pmc_names') );
$conf->append_configure_log($file);
- open( my $OUT, ">", "$file.tmp" );
+ open( my $OUT, '>', "$file.tmp" );
- print {$OUT} <<"END_C";
+ print {$OUT} <<'END_C';
/*
* DO NOT EDIT THIS FILE
*
@@ -114,7 +108,7 @@ END_C
print {$OUT} "extern void Parrot_${_}_class_init(PARROT_INTERP, int, int);\n" foreach (@pmcs);
- print {$OUT} <<"END_C";
+ print {$OUT} <<'END_C';
/* This isn't strictly true, but the headerizer should not bother */
@@ -137,14 +131,14 @@ END_C
foreach ( @pmcs[ -1 .. -1 ] );
print {$OUT} " Parrot_${_}_class_init(interp, enum_class_${_}, pass);\n"
foreach ( @pmcs[ 0 .. $#pmcs - 1 ] );
- print {$OUT} <<"END_C";
+ print {$OUT} <<'END_C';
if (!pass) {
parrot_global_setup_2(interp);
}
}
}
-static void register_pmc(PARROT_INTERP, PMC *registry, int pmc_id)
+static void register_pmc(PARROT_INTERP, NOTNULL(PMC *registry), int pmc_id)
{
STRING * const key = interp->vtables[pmc_id]->whoami;
VTABLE_set_integer_keyed_str(interp, registry, key, pmc_id);
@@ -159,15 +153,10 @@ END_C
print {$OUT} <<'END_C';
}
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
END_C
+ print {$OUT} coda();
- close $OUT;
+ close $OUT or die "Can't close file: $!";
move_if_diff( "$file.tmp", $file );
@@ -178,10 +167,10 @@ sub generate_pm {
my ( $self, $conf ) = @_;
my $file = "lib/Parrot/PMC.pm";
- my @pmcs = split( / /, $conf->data->get('pmc_names') );
+ my @pmcs = split( qr/ /, $conf->data->get('pmc_names') );
$conf->append_configure_log($file);
- open( my $OUT, ">", "$file.tmp" );
+ open( my $OUT, '>', "$file.tmp" );
print $OUT <<'END_PM';
# DO NOT EDIT THIS FILE
@@ -203,22 +192,36 @@ END_PM
for my $num ( 0 .. $#pmcs ) {
my $id = $num + 1;
- print $OUT "\t$pmcs[$num] => $id,\n";
+ print {$OUT} "\t$pmcs[$num] => $id,\n";
}
- print $OUT <<'END_PM';
+ print {$OUT} <<'END_PM';
);
1;
END_PM
- close $OUT;
+ close $OUT or die "Can't close file: $!";
move_if_diff( "$file.tmp", $file );
return;
}
+sub coda {
+ my $v = 'vim';
+
+ # Translate it in code so vim doesn't think this file itself is readonly
+ return <<"HERE"
+/*
+ * Local variables:
+ * c-file-style: "parrot"
+ * End:
+ * ${v}: readonly expandtab shiftwidth=4:
+ */
+HERE
+}
+
1;
# Local Variables:

0 comments on commit 6baf83e

Please sign in to comment.
Something went wrong with that request. Please try again.