8212587: equals in MakeBase does not handle empty strings correctly

Reviewed-by: erikj
This commit is contained in:
Magnus Ihse Bursie 2018-10-18 09:19:29 +02:00
parent c86ba29693
commit 10b754ee85
2 changed files with 19 additions and 3 deletions

View File

@ -656,8 +656,11 @@ dups = \
# String equals
equals = \
$(and $(findstring $(strip $1),$(strip $2)),\
$(findstring $(strip $2),$(strip $1)))
$(if $(strip $1)$(strip $2),$(strip \
$(and $(findstring $(strip $1),$(strip $2)),\
$(findstring $(strip $2),$(strip $1)))), \
true \
)
# Remove a whole list of prefixes
# $1 - List of prefixes

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -93,6 +93,7 @@ $(eval $(call TestNotContaining,foo bar,baz))
EQUALS_VALUE1 := value1$(SPACE)
EQUALS_VALUE2 := value2
EQUALS_EMPTY :=
ifneq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE2)), )
$(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE2)< are equal)
@ -102,6 +103,18 @@ ifeq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE1)), )
$(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE1)< are not equal)
endif
ifeq ($(call equals, $(EQUALS_EMPTY), $(EQUALS_EMPTY)), )
$(error The strings >$(EQUALS_EMPTY)< and >$(EQUALS_EMPTY)< are not equal)
endif
ifneq ($(call equals, $(EQUALS_EMPTY), $(EQUALS_VALUE2)), )
$(error The strings >$(EQUALS_EMPTY)< and >$(EQUALS_VALUE2)< are equal)
endif
ifneq ($(call equals, $(EQUALS_VALUE2), $(EQUALS_EMPTY)), )
$(error The strings >$(EQUALS_VALUE2)< and >$(EQUALS_EMPTY)< are equal)
endif
################################################################################
# Test remove-prefixes