Changes between Initial Version and Version 1 of VarNames/Test


Ignore:
Timestamp:
Feb 5, 2012 1:12:39 PM (6 years ago)
Author:
rado
Comment:

migrate wiki.mutt.org

Legend:

Unmodified
Added
Removed
Modified
  • VarNames/Test

    v1 v1  
     1Before you can use this patch script for init.h, you must at least
     2once execute the conversion VarNames/Script to produce the $PATCHFILE used in this script.
     3You have to enable it in the script before you call it (`filename != /dev/null`).
     4Make sure you change `$PATCHFILE` in both scripts to point to the same file.
     5
     6Then read the script '#'-comments below for usage:
     7{{{
     8 save script to file (maybe call it "varspatcher")
     9 chmod a+x varspatcher
     10}}}
     11then go into a newly unpacked source dir of mutt:
     12{{{
     13 mv init.h org-init.h
     14 fullpathto.../varspatcher < org-init.h > init.h
     15}}}
     16and then build mutt as usual and try it with your converted config.
     17If all was fine, the patched mutt should work as usual with your config, if the regular mutt worked fine, too.
     18
     19If you encounter your converted config not to work smoothly, then
     20report feedback as explained in VarNames/Script.
     21
     22----
     23{{{
     24#!/usr/bin/perl -w
     25###
     26# written 16 Aug 2006 by RadoQ
     27#
     28# This script is meant to use the $PATCHFILE from /Script to
     29# replace the vars in init.h and so to produce a mutt binary that
     30# will work _only_ with the new varnames _without_ any synonyms to
     31# see whether your config was _correctly_ converted by /Script.
     32#
     33# Syntax: ./patchscript < old-init.h > new-init.h
     34
     35use strict;
     36
     37my $PATCHFILE='tr-list';        ### where the conversion list is saved from /Script.
     38my $line='';
     39my %trans=();
     40
     41open(TRANSLIST,"<$PATCHFILE") || die "Can't open file $PATCHFILE for init.h patch";
     42while ($line = <TRANSLIST>) {
     43        if ($line =~ /:/) {
     44                chomp($line);
     45                $line =~ /^\s*(\S+)\s*:\s*(\S+)/o;
     46                $trans{$1}=$2;
     47        }
     48}
     49close(TRANSLIST);
     50
     51### skip regular stuff before the vars
     52while (defined($line = <STDIN>) && ($line !~ m,\Q/*++*/\E,o)) {
     53        print $line;
     54}
     55print $line;
     56
     57### now the gory stuff
     58VARS:
     59while (defined($line = <STDIN>) && ($line !~ m,\Q/*--*/\E,o)) {
     60
     61if ($line =~ /DT_SYN/) { next VARS; }
     62if ($line =~ /^\s*\{/) {
     63        $line =~ m,"([^"]*)",o;
     64        if (exists($trans{$1})) { $line =~ s,"([^"]*)",'"'.$trans{$1}.'"',e ;}
     65}
     66        print $line;
     67}
     68print $line;
     69
     70### skip regular stuff after the vars
     71while (($line = <STDIN>) ) {
     72        print $line;
     73}
     74
     75### EOF
     76}}}