Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit590fccf

Browse files
committed
Updated to Java commit 23f9801 (2012.03.23): fix reporting of invalid character in unicode character/string literals
1 parente20d119 commit590fccf

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

‎Clojure/Clojure.Tests/clojure/test_clojure/reader.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
;; Strings
5050

5151
(defntemp-file
52-
[prefix suffix]
52+
[& ignore];;; [prefix suffix]
5353
(FileInfo.;;; (doto (File/createTempFile prefix suffix)
5454
(Path/GetTempFileName)));;; (.deleteOnExit)))
5555

@@ -58,7 +58,7 @@
5858
(if (=:string source)
5959
(read-string form)
6060
(do
61-
(spit file form)
61+
(spit file form:file-mode System.IO.FileMode/Truncate)
6262
(let [v (load-file (str file))] (.Delete file) v))));;; (load-file (str file)))))
6363

6464
(defncode-units
@@ -73,7 +73,7 @@
7373
(doseq [source [:string:file]]
7474
(testing (str"Valid string literals read from" (name source))
7575
(are [x form] (= x (code-units
76-
(read-from sourcef (str"\"" form"\""))))
76+
(read-from source(temp-file) (str"\"" form"\""))));;; f => (temp-file)
7777
[]""
7878
[34]"\\\""
7979
[10]"\\n"
@@ -281,7 +281,7 @@
281281
(let [f (temp-file"clojure.core-reader""test")]
282282
(doseq [source [:string:file]]
283283
(testing (str"Valid char literals read from" (name source))
284-
(are [x form] (= x (read-from sourcef form))
284+
(are [x form] (= x (read-from source(temp-file) form));;; f -> (temp-file)
285285
(first"o")"\\o"
286286
(char0)"\\o0"
287287
(char0)"\\o000"

‎Clojure/Clojure/CljCompiler/Compiler.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,31 +1580,42 @@ private static Expr AnalyzeSeq(ParserContext pcon, ISeq form, string name )
15801580
[Serializable]
15811581
publicsealedclassCompilerException:Exception
15821582
{
1583+
1584+
#region Data
1585+
1586+
stringFileSource{get;set;}
1587+
1588+
#endregion
1589+
15831590
#region C-tors
15841591

15851592
publicCompilerException()
15861593
{
1594+
FileSource="<unknown>";
15871595
}
15881596

15891597
publicCompilerException(stringmessage)
15901598
:base(message)
15911599
{
1600+
FileSource="<unknown>";
15921601
}
15931602

15941603
publicCompilerException(stringmessage,ExceptioninnerException)
15951604
:base(message,innerException)
15961605
{
1606+
FileSource="<unknown>";
15971607
}
15981608

15991609
publicCompilerException(stringsource,intline,Exceptioncause)
16001610
:base(ErrorMsg(source,line,cause.ToString()),cause)
16011611
{
1602-
Source=source;
1612+
FileSource=source;
16031613
}
16041614

16051615
privateCompilerException(SerializationInfoinfo,StreamingContextcontext)
16061616
:base(info,context)
16071617
{
1618+
FileSource="<unknown>";
16081619
}
16091620

16101621
#endregion

‎Clojure/Clojure/Lib/LispReader.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static int readUnicodeChar(string token, int offset, int length, int radix)
254254
{
255255
intd=CharValueInRadix(token[i],radix);
256256
if(d==-1)
257-
thrownewArgumentException("Invalid digit: "+(char)d);
257+
thrownewArgumentException("Invalid digit: "+token[i]);
258258
uc=uc*radix+d;
259259
}
260260
return(char)uc;
@@ -265,7 +265,7 @@ static int readUnicodeChar(PushbackTextReader r, int initch, int radix, int leng
265265

266266
intuc=CharValueInRadix(initch,radix);
267267
if(uc==-1)
268-
thrownewArgumentException("Invalid digit: "+initch);
268+
thrownewArgumentException("Invalid digit: "+(char)initch);
269269
inti=1;
270270
for(;i<length;++i)
271271
{
@@ -739,7 +739,7 @@ protected override object Read(PushbackTextReader r, char backslash)
739739
{
740740
charc=(char)readUnicodeChar(token,1,4,16);
741741
if(c>='\uD800'&&c<='\uDFFF')// surrogate code unit?
742-
thrownewInvalidOperationException("Invalid character constant:\\u"+((int)c).ToString("X"));
742+
thrownewInvalidOperationException("Invalid character constant:\\u"+((int)c).ToString("x"));
743743
returnc;
744744
}
745745
elseif(token.StartsWith("o"))
@@ -804,7 +804,8 @@ protected override object Read(PushbackTextReader r, char doublequote)
804804
break;
805805
default:
806806
{
807-
if(CharValueInRadix(ch,8)!=-1)
807+
//if (CharValueInRadix(ch, 8) != -1) -- this is correct, but we end up with different error message for 8,9 than JVM, so do the following to match:
808+
if(Char.IsDigit((char)ch))
808809
{
809810
ch=readUnicodeChar((PushbackTextReader)r,ch,8,3,false);
810811
if(ch>255)//octal377

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp