From: Andre Noll Date: Sun, 1 Aug 2010 11:25:59 +0000 (+0200) Subject: Merge branch 't/error2' X-Git-Tag: v0.4.4~6 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=75cf863ef7a7cf5fe346f098ffb07a472b8366ec;hp=f20f4e2e747e7ef38ceadec6ee777f23ce0eca83 Merge branch 't/error2' --- diff --git a/configure.ac b/configure.ac index d8f55ce2..8fbf49a6 100644 --- a/configure.ac +++ b/configure.ac @@ -652,53 +652,14 @@ AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)]) AC_DEFUN([add_para],[$(for i in $@; do printf "para_$i "; done)]) AC_DEFUN([objlist_to_errlist],[$(for i in $@; do printf "DEFINE_ERRLIST($(echo $i| tr 'a-z' 'A-Z'));"; done) [const char **para_errlist[[]]] = {$(for i in $@; do printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; done) }]) ############################################################# error2.h -AC_DEFUN([define_safe_error_enums], -[ - exe="" - for i in $executables; do -# eval echo checking if $1 is linked into $i - for j in $(eval echo \$${i}_errlist_objs); do - if test $j = $1; then - exe="$exe $i" - break; - fi - done - done - #echo "$1 gets linked into $exe" - safe_errlists="" - for i in $all_errlist_objs; do - for j in $exe; do - found=0 - for k in $(eval echo \$${j}_errlist_objs); do - if test $k = $i; then - found=1 - break; - fi - done - if test $found -eq 0; then - break; - fi - done - if test $found -eq 1; then - safe_errlists="$safe_errlists $i" - fi - done - #echo "safe errlists for $1: $safe_errlists" - ss_defs="" - for i in $safe_errlists; do - echo "SS_ENUM($(echo $i | tr 'a-z' 'A-Z'));" - done -] -) - - AC_MSG_NOTICE(creating error2.h) +for i in $executables; do + echo "$i: " + eval echo \$${i}_errlist_objs +done | ./error2.pl > error2.h for obj in $all_errlist_objs; do SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z')," - echo "#ifdef MAIN_INPUT_FILE_IS_$obj" - define_safe_error_enums($obj) - echo "#endif" -done > error2.h +done AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM, [enum {$SS NUM_SS}], [list of all objects that use paraslash's error facility] @@ -714,28 +675,19 @@ lyrics_id duration directory lyrics_name image_name path hash channels last_played num_chunks chunk_time amplification artist title year album comment" -# $1: prefix, $2: items -AC_DEFUN([make_enum_items], [$( - for i in $2; do - printf "$1_$(echo $i | tr 'a-z' 'A-Z'), " - done -)]) - -# $1: prefix, $2: items -AC_DEFUN([make_enum_array], [$( - for i in $2; do - printf "\"$i\", " - done -)]) - -AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, - make_enum_items(SI, $status_items), - [enum of all status items] -) -AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, - make_enum_array(SI, $status_items), - [char * array of all status items] -) +result= +for i in $status_items; do + result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), " +done +AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result], + [enum of all status items]) + +result= +for i in $status_items; do + result="$result \"$i\", " +done +AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result], + [char * array of all status items]) AC_SUBST(executables, add_para($executables)) diff --git a/error2.pl b/error2.pl new file mode 100755 index 00000000..78ff2c56 --- /dev/null +++ b/error2.pl @@ -0,0 +1,58 @@ +#!/usr/bin/env perl + +use warnings; +use strict; + +my %matrix; +my @executables; +my %objects; + +sub make_matrix +{ + my ($line, $e, @fields, $field); + + while (defined($line = <>)) { + chomp($line); + if ($line =~ "^ *\$") { + next; + } + @fields = split(" ", $line); + while (defined(($field = shift(@fields)))) { + if ($field =~ ":\$") { + $field =~ s/://; + $e = $field; + push(@executables, $e); + next; + } + $matrix{$e . ">" . $field} = 1; + $objects{$field} = 1; + } + } +} + +sub print_safe_objects +{ + my @objs = keys(%objects); + my ($o1, $o2, $e); + + foreach $o1 (@objs) { + print("#ifdef MAIN_INPUT_FILE_IS_$o1\n"); + O2: foreach $o2 (@objs) { + foreach $e (@executables) { + if (!defined($matrix{$e . ">" . $o1})) { + next; + } + if (defined($matrix{$e . ">" . $o2})) { + next; + } + next O2; + } + $_ = $o2; + tr/a-z/A-Z/; + printf("SS_ENUM(%s);\n", $_); + } + print("#endif\n"); + } +} +make_matrix; +print_safe_objects;