Skip to content

Commit

Permalink
* filesys.e: Fixed bug in defaultext(). Windows now handles unix-styl…
Browse files Browse the repository at this point in the history
…e slashes in supplied path name.

* text.e: Now only defines TO_LOWER for unix.
* Add optional lines to code page files for unit testing purposes.
* remove debugging line.
* t_text.e: Added more unittest coverage for codepage handling.
  • Loading branch information
Derek Parnell committed Sep 5, 2010
1 parent bd5c054 commit f0e79b2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/std/filesys.e
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ public function defaultext( sequence path, sequence defext)
-- There is a dot in the file name part
return path
end if
if path[i] = SLASH then
if find(path[i], SLASHES) then
if i = length(path) then
-- No file name in supplied path
return path
Expand Down
3 changes: 2 additions & 1 deletion include/std/text.e
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ public function trim(sequence source, object what=" \t\r\n", integer ret_index =
end if
end function


ifdef UNIX then
constant TO_LOWER = 'a' - 'A'
end ifdef

sequence lower_case_SET = {}
sequence upper_case_SET = {}
Expand Down
4 changes: 3 additions & 1 deletion source/codepage/0737.ecp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ FF = U+00A0 : NO-BREAK SPACE
58 = 78
59 = 79
5A = 7A
.
80 = 98
81 = 99
82 = 9A
Expand All @@ -309,6 +310,7 @@ FF = U+00A0 : NO-BREAK SPACE
94 = AD
95 = AE
96 = AF
.
97 = E0
EA = E1
EB = E2
Expand All @@ -319,4 +321,4 @@ EE = E6
EF = E7
F5 = E8
E9 = F0

-----
3 changes: 3 additions & 0 deletions source/codepage/1251.ecp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Based on data found at http://msdn.microsoft.com/en-us/goglobal/bb964654.aspx
--HEAD--
Title = Windows 1251 (Cyrillic)
BPC = 1
Expand Down Expand Up @@ -285,6 +286,7 @@ FF = U+044F : CYRILLIC SMALL LETTER YA
58 = 78
59 = 79
5A = 7A
.
80 = 90
81 = 83
8A = 9A
Expand Down Expand Up @@ -332,3 +334,4 @@ DC = FC
DD = FD
DE = FE
DF = FF
---
2 changes: 1 addition & 1 deletion tests/t_declasgn_wrning.e
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ elsedef
test_equal("with warning -=", -1, gets(fn))

close(fn)
--fn=delete_file("warning.lst")
fn=delete_file("warning.lst")

end if
end ifdef
Expand Down
14 changes: 13 additions & 1 deletion tests/t_text.e
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test_equal("Encoding #2", {"ASCII", "", ""}, get_encoding_properties())
test_equal("Encoding uppercase #2", "THE CAT IN THE HAT", upper("the cat in the hat"))
test_equal("Encoding lowercase #3", "the cat in the hat", lower("THE CAT IN THE HAT"))

set_encoding_properties("1251")
set_encoding_properties("../source/codepage/1251")
object ec
ec = get_encoding_properties()
test_equal("Encoding #3", "Windows 1251 (Cyrillic)", ec[1])
Expand All @@ -133,6 +133,18 @@ test_equal("Encoding uppercase #4", {#80,#81,#8A,#8C,#8D,#8E,#8F,#A1,#A3,#A5,#A8

set_encoding_properties("", "", "")

set_encoding_properties("0737")

ec = get_encoding_properties()
test_equal("Encoding #5", "OEM 737 (Greek)", ec[1])
test_equal("Encoding uppercase #5", "THE CAT IN THE HAT", upper("the cat in the hat"))
-- Test greek characters
test_equal("Encoding uppercase #6", {#80,#81,#82,#83,#84,#85,#86,#87,#88,#89,#8A,#8B,#8C,#8D,#8E,#8F,#90,#91,#92,#93,#94,#95,#96,#97,#EA,#EB,#EC,#F4,#ED,#EE,#EF,#F5,#E9},
upper({#98,#99,#9A,#9B,#9C,#9D,#9E,#9F,#A0,#A1,#A2,#A3,#A4,#A5,#A6,#A7,#A8,#A9,#AB,#AC,#AD,#AE,#AF,#E0,#E1,#E2,#E3,#E4,#E5,#E6,#E7,#E8,#F0}))

set_encoding_properties("", "", "")


-- quote()
test_equal("quote #1", "\"The small man\"", quote("The small man"))
test_equal("quote #2", "(The small man)", quote("The small man", {"(", ")"} ))
Expand Down

0 comments on commit f0e79b2

Please sign in to comment.