#!/usr/bin/env perl

use strict;
use warnings;
use File::Temp 'tempfile';

my $infile = "src/ngx_http_memc_response.c";
my ($out, $outfile) = tempfile();
open my $in, $infile
    or die "Cannot open $infile for reading: $!\n";
my $hits = 0;
while (<$in>) {
    if (/ \b memc_ (?: storage | flush_all | version | stats | delete | incr_decr )
             _en_main \b /x)
     {
        #warn "HIT!";
        $hits++;
        next;
    }
    print $out $_;
}
close $in;
close $out;
if ($hits) {
    my $cmd = "cp $outfile $infile";
    system($cmd) == 0
        or die "Cannot run command \"$cmd\": $!";
}
#die;

__END__

This script is to fix the following clang warnings when using Ragel 6.8/6.9/etc:

src/ngx_http_memc_response.c:33:18: error: unused variable 'memc_storage_en_main' [-Werror,-Wunused-const-variable]
static const int memc_storage_en_main = 1;
                 ^
src/ngx_http_memc_response.c:46:18: error: unused variable 'memc_flush_all_en_main' [-Werror,-Wunused-const-variable]
static const int memc_flush_all_en_main = 1;
                 ^
src/ngx_http_memc_response.c:59:18: error: unused variable 'memc_version_en_main' [-Werror,-Wunused-const-variable]
static const int memc_version_en_main = 1;
                 ^
src/ngx_http_memc_response.c:72:18: error: unused variable 'memc_stats_en_main' [-Werror,-Wunused-const-variable]
static const int memc_stats_en_main = 1;
                 ^
src/ngx_http_memc_response.c:85:18: error: unused variable 'memc_delete_en_main' [-Werror,-Wunused-const-variable]
static const int memc_delete_en_main = 1;
                 ^
src/ngx_http_memc_response.c:98:18: error: unused variable 'memc_incr_decr_en_main' [-Werror,-Wunused-const-variable]
static const int memc_incr_decr_en_main = 1;
                 ^
6 errors generated.
