From 5b8bb647271d5d69c81a30540b40ef4d84e3aa84 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 12 Mar 2015 00:54:09 +0300 Subject: [PATCH] Revert "New tool: unpragma_once.pl" This reverts commit c47f196281b0a15829bdc5cb9debc8f961e7f921. --- libuavcan/tools/unpragma_once.pl | 59 -------------------------------- 1 file changed, 59 deletions(-) delete mode 100755 libuavcan/tools/unpragma_once.pl diff --git a/libuavcan/tools/unpragma_once.pl b/libuavcan/tools/unpragma_once.pl deleted file mode 100755 index e21e759827..0000000000 --- a/libuavcan/tools/unpragma_once.pl +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env perl -############################################################################### -# Purpose: Remove all occurrences of "#pragma once" from the source tree. -# Usage: "unpragma-once *.h" or "find . -name \*.h | xargs unpragma-once" -# Author: Vadim Zeitlin -# Licence: Free Software released under BSD license -# Copyright: (C) 2011 TT-Solutions SARL -############################################################################### -# Pavel Kirienko , 2015: -# Include guard naming adapted to UAVCAN coding style. -############################################################################### - -use warnings; -use strict; -use autodie; - -use File::Copy qw(move); -use File::Spec (); -use File::Temp (); -use IO::Handle; - -sub process_single_file -{ - my $filename = shift; - - my ($volume, $dir, $basename) = File::Spec->splitpath($filename); - - open my $in, '<', $filename; - my $out = File::Temp->new(DIR => $volume . $dir); - - my $guard = ''; - my $last_was_empty = 0; - while (<$in>) { - if (/^#pragma\s+once\s+$/) { - die "Duplicate #pragma once at $filename:$.\n" if $guard; - - ($guard = uc $filename) =~ s/[\/\.]/_/g; - $guard .= "_INCLUDED"; - print $out "#ifndef $guard\n"; - print $out "#define $guard\n"; - } - else { - $last_was_empty = ($_ =~ /^\s*$/); - print $out $_ - } - } - - if ($guard) { - print $out "\n" unless $last_was_empty; - print $out "#endif // $guard\n"; - - $out->flush(); - move($out->filename, $filename); - } -} - -for (@ARGV) { - process_single_file $_ -}