* [Patch] Expression spec: Add clarification for String compare
@ 2018-10-16 1:12 Yonghong Zhu
2018-10-16 6:50 ` Gao, Liming
0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-10-16 1:12 UTC (permalink / raw)
To: edk2-devel; +Cc: Liming Gao, Michael Kinney, Kevin W Shaw
Relational and equality operators require both operands to be of
the same type.
Treat the string 'A' and "A" as same type, but for "A" and L"A"
are not same type since one is general string, another is unicode
string.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Kevin W Shaw <kevin.w.shaw@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
2_expression_overview.md | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/2_expression_overview.md b/2_expression_overview.md
index c29a632..bf66ffe 100644
--- a/2_expression_overview.md
+++ b/2_expression_overview.md
@@ -1,9 +1,9 @@
<!--- @file
2 Expression Overview
- Copyright (c) 2014-2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014-2018, Intel Corporation. All rights reserved.<BR>
Redistribution and use in source (original document form) and 'compiled'
forms (converted to PDF, epub, HTML and other formats) with or without
modification, are permitted provided that the following conditions are met:
@@ -81,14 +81,17 @@ directives section do not apply.
10. Multiplicative and additive operators require both operands to be
arithmetic in type.
11. Relational and equality operators require both operands to be of the same
- type. Relational comparison on string literals and byte arrays must be
- performed comparing the byte values, left to right. The first pair of bytes
- (or a single extra byte) that is not equal will determine the result of the
- comparison. The following are examples of string comparisons:
+ type. The single quote string and double quote string are same type as
+ general string, while the string start with `L` character is the unicode
+ string. Unicode string should not compare with general string. Relational
+ comparison on string literals and byte arrays must be performed comparing
+ the byte values, left to right. The first pair of bytes (or a single extra
+ byte) that is not equal will determine the result of the comparison. The
+ following are examples of string comparisons:
```
Foo = "zero", Bar = "three";
```
`Foo < Bar` will evaluate to zero (AKA, FALSE), as "z" is greater than "t".
```
--
2.6.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch] Expression spec: Add clarification for String compare
2018-10-16 1:12 [Patch] Expression spec: Add clarification for String compare Yonghong Zhu
@ 2018-10-16 6:50 ` Gao, Liming
0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-10-16 6:50 UTC (permalink / raw)
To: Zhu, Yonghong, edk2-devel@lists.01.org; +Cc: Kinney, Michael D, Shaw, Kevin W
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: Zhu, Yonghong
> Sent: Tuesday, October 16, 2018 9:12 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Shaw, Kevin W <kevin.w.shaw@intel.com>
> Subject: [Patch] Expression spec: Add clarification for String compare
>
> Relational and equality operators require both operands to be of
> the same type.
> Treat the string 'A' and "A" as same type, but for "A" and L"A"
> are not same type since one is general string, another is unicode
> string.
>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Cc: Kevin W Shaw <kevin.w.shaw@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
> ---
> 2_expression_overview.md | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/2_expression_overview.md b/2_expression_overview.md
> index c29a632..bf66ffe 100644
> --- a/2_expression_overview.md
> +++ b/2_expression_overview.md
> @@ -1,9 +1,9 @@
> <!--- @file
> 2 Expression Overview
>
> - Copyright (c) 2014-2017, Intel Corporation. All rights reserved.<BR>
> + Copyright (c) 2014-2018, Intel Corporation. All rights reserved.<BR>
>
> Redistribution and use in source (original document form) and 'compiled'
> forms (converted to PDF, epub, HTML and other formats) with or without
> modification, are permitted provided that the following conditions are met:
>
> @@ -81,14 +81,17 @@ directives section do not apply.
>
> 10. Multiplicative and additive operators require both operands to be
> arithmetic in type.
>
> 11. Relational and equality operators require both operands to be of the same
> - type. Relational comparison on string literals and byte arrays must be
> - performed comparing the byte values, left to right. The first pair of bytes
> - (or a single extra byte) that is not equal will determine the result of the
> - comparison. The following are examples of string comparisons:
> + type. The single quote string and double quote string are same type as
> + general string, while the string start with `L` character is the unicode
> + string. Unicode string should not compare with general string. Relational
> + comparison on string literals and byte arrays must be performed comparing
> + the byte values, left to right. The first pair of bytes (or a single extra
> + byte) that is not equal will determine the result of the comparison. The
> + following are examples of string comparisons:
> ```
> Foo = "zero", Bar = "three";
> ```
> `Foo < Bar` will evaluate to zero (AKA, FALSE), as "z" is greater than "t".
> ```
> --
> 2.6.1.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-16 6:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-16 1:12 [Patch] Expression spec: Add clarification for String compare Yonghong Zhu
2018-10-16 6:50 ` Gao, Liming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox