Donate Share

GNU Make Standard Library

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Usage of $(eval) considered harmful.

You are viewing a single message from this topic. View all messages.

  1. 2007-12-20 03:45:05 UTC
    Here are fixes for all usages of $(eval) [excluding the test file that also has issues]. Note that I use _splitchar.gen for fixing both strlen and substr functions. Fixing push/pop/set was much easier, simply needed to do some extra escaping. It should also be noted that many characters can not be used as keys to the associative array (space, pound, left paren, right paren, dollar to name a few).

    tr = $(__gmsl_tr3)$(eval _tr.t:=$(call _tr.gen,$1))$(_tr.t)

    _tr.gen=$(if $1, \
    $$(subst $$(word $(words $1),$$1),$(strip \
    $$(word $(words $1),$$2)),$(strip \
    $(call _tr.gen,$(call rest,$1)))), \
    $$3)

    define __gmsl_newline


    endef
    __gmsl_tab := $(subst ,,) #
    __gmsl_space := $(subst ,,) #
    __gmsl_pound := $(subst \,,\#)
    __gmsl_backslash := $(subst x,,\)
    __gmsl_comma := ,
    __gmsl_paren_o := (
    __gmsl_paren_c := )
    __gmsl_characters := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    __gmsl_characters += a b c d e f g h i j k l m n o p q r s t u v w x y z
    __gmsl_characters += 0 1 2 3 4 5 6 7 8 9
    __gmsl_characters += ` ~ ! @ % ^ & * - _ = +
    __gmsl_characters += { } [ ] \ : ; ' " < > . / ? |
    __gmsl_characters += $$(__gmsl_pound) $$$$ $$(__gmsl_comma)
    __gmsl_characters += $$(__gmsl_paren_o) $$(__gmsl_paren_c)

    _splitchar.gen=$(strip $(if $1, \
    $$(subst $(firstword $1),$(firstword $1) ,$(call \
    _splitchar.gen,$(call rest,$1))), \
    $$(subst $$(__gmsl_newline),§§§ ,$$(subst \
    $$(__gmsl_tab),§§ ,$$(subst \
    $$(__gmsl_space),§ ,$$1)))))

    $(eval strlen=$$(__gmsl_tr1)$$(words \
    $(call _splitchar.gen,$(__gmsl_characters))))

    $(eval substr=$$(__gmsl_tr3)$$(subst §, ,$$(subst $$(__gmsl_space),,$(strip \
    $$(subst §§,$$(__gmsl_tab),$$(subst §§§,$$(__gmsl_newline),$$(wordlist \
    $$2,$$3,$(call _splitchar.gen,$(__gmsl_characters)))))))))

    push = $(__gmsl_tr2)$(eval __gmsl_stack_$1 := $$2 $(if $(filter-out undefined,\
    $(origin __gmsl_stack_$1)),$$(__gmsl_stack_$1)))

    pop = $(__gmsl_tr1)$(strip $(if $(filter-out undefined,$(origin
    __gmsl_stack_$1)), \
    $(call first,$(__gmsl_stack_$1)) \
    $(eval __gmsl_stack_$1 := $$(call rest,$$(__gmsl_stack_$1)))))

    set = $(__gmsl_tr3)$(eval __gmsl_aa_$1_$2 = $$3)
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.