Last Comment Bug 415963 - [1.1] Implement XPath number functions: power, random, and compare
: [1.1] Implement XPath number functions: power, random, and compare
Status: RESOLVED FIXED
: fixed1.8.1.13
Product: Core Graveyard
Classification: Graveyard
Component: XForms (show other bugs)
: Trunk
: x86 Windows XP
: -- normal (vote)
: ---
Assigned To: Merle Sterling
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-02-06 11:29 PST by Merle Sterling
Modified: 2016-07-15 14:46 PDT (History)
3 users (show)
Rsandysunshine91: wanted‑fennec1.0?
Rsandysunshine91: in‑testsuite?
Rsandysunshine91: in‑litmus?
See Also:
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
testcase: power() (1.13 KB, application/xhtml+xml)
2008-02-06 11:31 PST, Merle Sterling
no flags Details
testcase: random() (1.32 KB, application/xhtml+xml)
2008-02-06 11:33 PST, Merle Sterling
no flags Details
testcase: compare() (1.49 KB, application/xhtml+xml)
2008-02-06 11:33 PST, Merle Sterling
no flags Details
patch (3.22 KB, patch)
2008-02-06 11:37 PST, Merle Sterling
aaronr: review+
Details | Diff | Splinter Review
patch2 (3.76 KB, patch)
2008-02-08 17:05 PST, Merle Sterling
bugs: review+
Details | Diff | Splinter Review
patch for 1.8 branch (9.12 KB, patch)
2008-02-12 15:06 PST, Merle Sterling
aaronr: review+
bugs: review+
jonas: superreview+
Details | Diff | Splinter Review
patch2 for 1.8 branch (8.80 KB, patch)
2008-02-14 16:56 PST, Merle Sterling
dveditz: approval1.8.1.13+
Details | Diff | Splinter Review
patch checked into 1.8 (7.10 KB, patch)
2008-03-04 19:15 PST, aaronr
no flags Details | Diff | Splinter Review

Description Merle Sterling 2008-02-06 11:29:13 PST
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b4pre) Gecko/2008020507 Minefield/3.0b4pre

We need to implement the XPath number functions power(), random(), and compare() for XForms 1.1.



Reproducible: Always
Comment 1 Merle Sterling 2008-02-06 11:31:25 PST
Created attachment 301706 [details]
testcase: power()
Comment 2 Merle Sterling 2008-02-06 11:33:12 PST
Created attachment 301707 [details]
testcase: random()
Comment 3 Merle Sterling 2008-02-06 11:33:42 PST
Created attachment 301708 [details]
testcase: compare()
Comment 4 Merle Sterling 2008-02-06 11:37:17 PST
Created attachment 301711 [details] [diff] [review]
patch
Comment 5 aaronr 2008-02-08 10:06:12 PST
Comment on attachment 301711 [details] [diff] [review]
patch

>Index: nsXFormsXPathFunctions.cpp
>===================================================================

>+NS_IMETHODIMP
>+nsXFormsXPathFunctions::Random(PRBool aSeed, double *aResult)
>+{
>+    if (aSeed) {
>+      // initialize random seed.
>+      srand (0);

You can use PR_GetRandomNoise to come up with a seed to use instead of using 0 all the time.

With that, r=me
Comment 6 Merle Sterling 2008-02-08 17:03:32 PST
(In reply to comment #5)
> (From update of attachment 301711 [details] [diff] [review])
> >Index: nsXFormsXPathFunctions.cpp
> >===================================================================
> >+NS_IMETHODIMP
> >+nsXFormsXPathFunctions::Random(PRBool aSeed, double *aResult)
> >+{
> >+    if (aSeed) {
> >+      // initialize random seed.
> >+      srand (0);
> You can use PR_GetRandomNoise to come up with a seed to use instead of using 0
> all the time.
> With that, r=me

That should have been srand(time(NULL)) but I'll use PR_GetRandomNoise.


Comment 7 Merle Sterling 2008-02-08 17:05:30 PST
Created attachment 302229 [details] [diff] [review]
patch2

Merging with the latest version of the file on the trunk; using PR_GetRandomNoise to generate a seed.
Comment 8 aaronr 2008-02-12 11:37:27 PST
checked into trunk for msterlin.  Now we need the 1.8 branch version of the patch.
Comment 9 Merle Sterling 2008-02-12 15:06:11 PST
Created attachment 302917 [details] [diff] [review]
patch for 1.8 branch
Comment 10 aaronr 2008-02-14 09:32:36 PST
Comment on attachment 302917 [details] [diff] [review]
patch for 1.8 branch

Jonas, can you please review so that we can get approval to put it into 1.8?  Thanks.
Comment 11 Jonas Sicking (:sicking) No longer reading bugmail consistently 2008-02-14 16:08:19 PST
Comment on attachment 302917 [details] [diff] [review]
patch for 1.8 branch

>+      double result = 0;
>+      if (string1.Length() > string2.Length()) {
>+        result = 1;
>+      } else if (string1.Length() < string2.Length()) {
>+        result = -1;
>+      } else {
>+        result = strcmp(NS_ConvertUTF16toUTF8(string1).get(),
>+                        NS_ConvertUTF16toUTF8(string2).get());
>+      }

This looks wrong. Is "z" < "aa" really right? Spec says lexicographic comparison.

sr=me with that fixed or checked.
Comment 12 Merle Sterling 2008-02-14 16:56:10 PST
Created attachment 303416 [details] [diff] [review]
patch2 for 1.8 branch

Removing length check for compare().
Comment 13 aaronr 2008-02-15 10:40:49 PST
Comment on attachment 303416 [details] [diff] [review]
patch2 for 1.8 branch

Asking for approval for 1.8 branch.  This code is reachable only by xforms xpath evaluators which should only ever be instantiated by the xforms extension.  This should have no impact on any other xpath user.
Comment 14 Daniel Veditz [:dveditz] 2008-02-15 11:38:41 PST
Comment on attachment 303416 [details] [diff] [review]
patch2 for 1.8 branch

Seems a little odd to be adding features to the branch -- xforms users will now have to require a specific minimum version.

approved for 1.8.1.13, a=dveditz for release-drivers
Comment 15 aaronr 2008-03-04 19:15:33 PST
Created attachment 307384 [details] [diff] [review]
patch checked into 1.8

patch checked into 1.8.  Same code as previous patch, just updated to the branch.
Comment 16 aaronr 2008-03-04 19:19:42 PST
checked into 1.8 branch for msterlin

Note You need to log in before you can comment on or make changes to this bug.