[svn:parrot] r49374 - in trunk: compilers/imcc include/parrot t/codingstd
plobsing at svn.parrot.org
plobsing at svn.parrot.org
Wed Sep 29 02:23:25 UTC 2010
Author: plobsing
Date: Wed Sep 29 02:23:16 2010
New Revision: 49374
URL: https://trac.parrot.org/parrot/changeset/49374
Log:
[C89] eliminate and add test against trailing commas in enums
Added:
trunk/t/codingstd/c_enum.t
Modified:
trunk/compilers/imcc/imc.h
trunk/include/parrot/hash.h
trunk/include/parrot/imageio.h
trunk/include/parrot/runcore_api.h
Modified: trunk/compilers/imcc/imc.h
==============================================================================
--- trunk/compilers/imcc/imc.h Wed Sep 29 00:42:18 2010 (r49373)
+++ trunk/compilers/imcc/imc.h Wed Sep 29 02:23:16 2010 (r49374)
@@ -59,7 +59,7 @@
enum {
IMCC_FATAL_EXCEPTION = 1,
IMCC_FATALY_EXCEPTION = 2,
- IMCC_PARSEFAIL_EXCEPTION = 3,
+ IMCC_PARSEFAIL_EXCEPTION = 3
};
#define N_ELEMENTS(x) (sizeof (x)/sizeof ((x)[0]))
Modified: trunk/include/parrot/hash.h
==============================================================================
--- trunk/include/parrot/hash.h Wed Sep 29 00:42:18 2010 (r49373)
+++ trunk/include/parrot/hash.h Wed Sep 29 02:23:16 2010 (r49374)
@@ -34,7 +34,7 @@
Hash_key_type_PMC,
Hash_key_type_ptr,
Hash_key_type_PMC_ptr,
- Hash_key_type_STRING_enc,
+ Hash_key_type_STRING_enc
} Hash_key_type;
/* &end_gen */
Modified: trunk/include/parrot/imageio.h
==============================================================================
--- trunk/include/parrot/imageio.h Wed Sep 29 00:42:18 2010 (r49373)
+++ trunk/include/parrot/imageio.h Wed Sep 29 02:23:16 2010 (r49374)
@@ -20,7 +20,7 @@
enum {
enum_PackID_normal = 0,
- enum_PackID_seen = 1,
+ enum_PackID_seen = 1
};
#endif /* PARROT_IMAGEIO_H_GUARD */
Modified: trunk/include/parrot/runcore_api.h
==============================================================================
--- trunk/include/parrot/runcore_api.h Wed Sep 29 00:42:18 2010 (r49373)
+++ trunk/include/parrot/runcore_api.h Wed Sep 29 02:23:16 2010 (r49374)
@@ -37,7 +37,7 @@
typedef enum Parrot_runcore_flags {
RUNCORE_REENTRANT_FLAG = 1 << 0,
- RUNCORE_FUNC_TABLE_FLAG = 1 << 1,
+ RUNCORE_FUNC_TABLE_FLAG = 1 << 1
} Parrot_runcore_flags;
Added: trunk/t/codingstd/c_enum.t
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/t/codingstd/c_enum.t Wed Sep 29 02:23:16 2010 (r49374)
@@ -0,0 +1,45 @@
+#! perl
+# Copyright (C) 2010, Parrot Foundation.
+# $Id$
+
+use strict;
+use warnings;
+
+use lib qw[ . lib ../lib ../../lib ];
+use Test::More tests => 1;
+use Parrot::Distribution;
+
+my $DIST = Parrot::Distribution->new;
+my @files = @ARGV ? <@ARGV> : $DIST->get_c_language_files();
+
+check_enums(@files);
+
+exit;
+
+sub check_enums {
+ my @trailing_comma;
+
+ foreach my $file (@_) {
+ my $path = @ARGV ? $file : $file->path();
+ my $buf = $DIST->slurp($path);
+
+ # strip ', ", and C comments
+ $buf =~ s{ (?:
+ (?: (') (?: \\\\ | \\' | [^'] )* (') ) # remove ' string
+ | (?: (") (?: \\\\ | \\" | [^"] )* (") ) # remove " string
+ | /(\*) .*? (\*)/ # remove C comment
+ )
+ }{defined $1 ? "$1$2" : defined $3 ? "$3$4" : "$5$6"}egsx;
+
+ if ($buf =~ /enum \s+ (?: (\w+) \s+ )? {
+ [^}]+,
+ \s+ } (?: \s+ (\w+) )?/x) {
+ my $name = $1 || $2 || '(anonymous)';
+ push @trailing_comma => "$path: $name";
+ }
+ }
+
+ is( join("\n", @trailing_comma), "", <<END_DESCRIPTION );
+trailing commas in enums are not legal C89
+END_DESCRIPTION
+}
More information about the parrot-commits
mailing list