Merge lp:~zorba-coders/zorba/file_regex into lp:zorba

Proposed by Gabriel Petrovay
Status: Merged
Approved by: Gabriel Petrovay
Approved revision: 10517
Merged at revision: 10518
Proposed branch: lp:~zorba-coders/zorba/file_regex
Merge into: lp:zorba
Diff against target: 84 lines (+27/-12)
1 file modified
modules/org/expath/ns/file.xq (+27/-12)
To merge this branch: bzr merge lp:~zorba-coders/zorba/file_regex
Reviewer Review Type Date Requested Status
Gabriel Petrovay (community) Approve
Paul J. Lucas Approve
Review via email: mp+79543@code.launchpad.net

Commit message

Corrected incorrect regular expressions in the file module.

Description of the change

Corrected incorrect regular expressions in the file module.

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) wrote :

Is it possible to create a test for this scenario?

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job file_regex-2011-10-17T21-24-01.686Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Pending.

Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job file_regex-2011-10-17T21-48-00.92Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve.

Revision history for this message
Gabriel Petrovay (gabipetrovay) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job file_regex-2011-10-18T19-07-00.313Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/org/expath/ns/file.xq'
2--- modules/org/expath/ns/file.xq 2011-08-17 23:28:19 +0000
3+++ modules/org/expath/ns/file.xq 2011-10-17 12:09:26 +0000
4@@ -730,20 +730,25 @@
5 declare function file:base-name($path as xs:string) as xs:string
6 {
7 let $delim := file:directory-separator()
8+ let $escapedDelim :=
9+ if ($delim eq "/") then
10+ $delim
11+ else
12+ fn:concat("\", $delim)
13 let $normalized-file :=
14 let $n := file:prepare-for-dirname-and-base-name($path)
15- return if ($delim eq "\" and fn:matches($n, "^[a-zA-Z]:$")) then
16- concat($n, "\")
17- else $n
18+ return if ($delim eq "\" and fn:matches($n, "^[a-zA-Z]:$")) then
19+ fn:concat($n, "\")
20+ else $n
21 return
22- if (matches($path, concat("^\", $delim, "+$"))) then
23+ if (fn:matches($path, fn:concat("^", $escapedDelim, "+$"))) then
24 ""
25- else if (file:directory-separator() eq '\' and matches($path, "^[a-zA-Z]:\\?$")) then
26+ else if ($delim eq "\" and fn:matches($path, "^[a-zA-Z]:\\?$")) then
27 ""
28 else if ($path eq "") then
29 "."
30 else
31- replace($normalized-file, concat("^.*\", $delim), '')
32+ fn:replace($normalized-file, fn:concat("^.*", $escapedDelim), "")
33 };
34
35 (:~
36@@ -786,20 +791,25 @@
37 declare function file:dir-name($path as xs:string) as xs:string
38 {
39 let $delim := file:directory-separator()
40+ let $escapedDelim :=
41+ if ($delim eq "/") then
42+ $delim
43+ else
44+ fn:concat("\", $delim)
45 let $normalized-file := file:prepare-for-dirname-and-base-name($path)
46 return
47- if (fn:matches($path, concat("^\", $delim, "+$"))) then
48+ if (fn:matches($path, fn:concat("^", $escapedDelim, "+$"))) then
49 $delim
50 else if ($normalized-file eq $delim) then
51 $delim
52- else if (file:directory-separator() eq '\' and fn:matches($path, "^[a-zA-Z]:\\$")) then
53+ else if ($delim eq "\" and fn:matches($path, "^[a-zA-Z]:\\$")) then
54 $path
55- else if (file:directory-separator() eq '\' and fn:matches($normalized-file, "^[a-zA-Z]:$")) then
56+ else if ($delim eq "\" and fn:matches($normalized-file, "^[a-zA-Z]:$")) then
57 fn:concat($normalized-file, '\')
58 else if ($path eq "") then
59 "."
60- else if (fn:matches($normalized-file, fn:concat("\", $delim))) then
61- fn:replace($normalized-file, fn:concat('^(.*)\', $delim,'.*'), '$1')
62+ else if (fn:matches($normalized-file, $escapedDelim)) then
63+ fn:replace($normalized-file, fn:concat("^(.*)", $escapedDelim, ".*"), "$1")
64 else
65 "."
66 };
67@@ -812,11 +822,16 @@
68 declare %private function file:prepare-for-dirname-and-base-name($path as xs:string) as xs:string
69 {
70 let $delim := file:directory-separator()
71+ let $escapedDelim :=
72+ if ($delim eq "/") then
73+ $delim
74+ else
75+ fn:concat("\", $delim)
76 let $normalize-path := file:path-to-native($path)
77 let $normalized :=
78 if ($normalize-path eq $delim) then
79 $normalize-path
80 else
81- fn:replace($normalize-path, fn:concat("\", $delim, '+$'), '')
82+ fn:replace($normalize-path, fn:concat($escapedDelim, "+$"), "")
83 return $normalized
84 };

Subscribers

People subscribed via source and target branches