From 4c82f679ba1653c28c22081117a5c4b6cb9e8984 Mon Sep 17 00:00:00 2001 From: dsmith Date: Fri, 5 May 2006 16:21:56 +0000 Subject: 2006-05-05 David Smith * translate.cxx (mapvar::exists): Added code for string array handling. Otherwise, string array elements always exist. --- ChangeLog | 5 +++++ translate.cxx | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 00cb5e5c..3c077983 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-05-05 David Smith + + * translate.cxx (mapvar::exists): Added code for string array + handling. Otherwise, string array elements always exist. + 2006-05-03 Josh Stone PR 2506 diff --git a/translate.cxx b/translate.cxx index ddbeea0d..30601cf2 100644 --- a/translate.cxx +++ b/translate.cxx @@ -550,7 +550,14 @@ struct mapvar string exists (vector const & indices) const { - return "((uintptr_t)" + call_prefix("get", indices) + ") != (uintptr_t) 0)"; + if (type() == pe_string) + return ("({ char *v = " + call_prefix("get", indices) + + "); (v != NULL && *v != '\\0');})"); + else if ((type() == pe_long) || (type() == pe_stats)) + return ("((uintptr_t)" + call_prefix("get", indices) + + ") != (uintptr_t) 0)"); + else + throw semantic_error("checking existence of an unsupported map type"); } string get (vector const & indices, bool pre_agg=false) const -- cgit