From: Ted Lemon Date: Sat, 31 Jul 1999 23:24:33 +0000 (+0000) Subject: Change behaviour of concat so that any null argument produces a null result. X-Git-Tag: V3-BETA-1-PATCH-2~5^2~145 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5b7abf8b6b21991d78a37dc20794aa1a341ad24;p=thirdparty%2Fdhcp.git Change behaviour of concat so that any null argument produces a null result. --- diff --git a/common/dhcp-eval.5 b/common/dhcp-eval.5 index 89fd9b332..2ab9d9c56 100644 --- a/common/dhcp-eval.5 +++ b/common/dhcp-eval.5 @@ -243,9 +243,9 @@ specified as a data expression. .B concat (\fIdata-expr1\fB, ..., \fIdata-exprN\fB)\fR .RS 0.25i The expressions are evaluated, and the results of each evaluation are -concatenated in the sequence that the subexpressions are listed. Any -subexpression that evaluates to null is treated as a zero-length string. -If all the arguments to concat are null, the result is also null. +concatenated in the sequence that the subexpressions are listed. If +any subexpression evaluates to null, the result of the concatenation +is null. .RE .PP .B reverse (\fInumeric-expr1\fB, \fIdata-expr2\fB)\fR diff --git a/common/tree.c b/common/tree.c index b3b31242b..b8cdc0ef1 100644 --- a/common/tree.c +++ b/common/tree.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: tree.c,v 1.44 1999/07/31 20:23:19 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: tree.c,v 1.45 1999/07/31 23:24:32 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -894,18 +894,18 @@ int evaluate_data_expression (result, packet, lease, memcpy (&result -> data [data.len], other.data, other.len + other.terminated); } else if (s0) - data_string_copy (result, &data, "expr_concat"); + data_string_forget (&data, "expr_concat"); else if (s1) - data_string_copy (result, &other, "expr_concat"); + data_string_forget (&other, "expr_concat"); #if defined (DEBUG_EXPRESSIONS) log_debug ("data: concat (%s, %s) = %s", s0 ? print_hex_1 (data.len, data.data, 20) : "NULL", s1 ? print_hex_2 (other.len, other.data, 20) : "NULL", - ((s0 || s1) + ((s0 && s1) ? print_hex_3 (result -> len, result -> data, 30) : "NULL")); #endif - return s0 || s1; + return s0 && s1; case expr_encode_int8: s0 = evaluate_numeric_expression (&len, packet, lease,