Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
92450f84
Commit
92450f84
authored
Apr 13, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catching file I/O errors.
parent
ddbc68b5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
9 deletions
+22
-9
document.cpp
document.cpp
+15
-8
document.hpp
document.hpp
+1
-0
document_parser.cpp
document_parser.cpp
+5
-0
exceptional.scss
exceptional.scss
+1
-1
No files found.
document.cpp
View file @
92450f84
...
@@ -54,17 +54,19 @@ namespace Sass {
...
@@ -54,17 +54,19 @@ namespace Sass {
{
{
if
(
!
source
)
{
if
(
!
source
)
{
std
::
FILE
*
f
;
std
::
FILE
*
f
;
// TO DO: CHECK f AGAINST NULL/0
f
=
std
::
fopen
(
path
.
c_str
(),
"rb"
);
f
=
std
::
fopen
(
path
.
c_str
(),
"rb"
);
std
::
fseek
(
f
,
0
,
SEEK_END
);
if
(
!
f
)
throw
path
;
if
(
std
::
fseek
(
f
,
0
,
SEEK_END
))
throw
path
;
int
len
=
std
::
ftell
(
f
);
int
len
=
std
::
ftell
(
f
);
if
(
len
<
0
)
throw
path
;
std
::
rewind
(
f
);
std
::
rewind
(
f
);
// TO DO:
WRAP THE new[] IN A TRY/CATCH BLOCK
// TO DO:
CATCH THE POTENTIAL badalloc EXCEPTION
source
=
new
char
[
len
+
1
];
source
=
new
char
[
len
+
1
];
std
::
fread
(
source
,
sizeof
(
char
),
len
,
f
);
std
::
fread
(
source
,
sizeof
(
char
),
len
,
f
);
if
(
std
::
ferror
(
f
))
throw
path
;
source
[
len
]
=
'\0'
;
source
[
len
]
=
'\0'
;
end
=
source
+
len
;
end
=
source
+
len
;
std
::
fclose
(
f
)
;
if
(
std
::
fclose
(
f
))
throw
path
;
own_source
=
true
;
own_source
=
true
;
}
}
position
=
source
;
position
=
source
;
...
@@ -80,17 +82,19 @@ namespace Sass {
...
@@ -80,17 +82,19 @@ namespace Sass {
lexed
(
Token
::
make
())
lexed
(
Token
::
make
())
{
{
std
::
FILE
*
f
;
std
::
FILE
*
f
;
// TO DO: CHECK f AGAINST NULL/0
f
=
std
::
fopen
(
path
.
c_str
(),
"rb"
);
f
=
std
::
fopen
(
path
.
c_str
(),
"rb"
);
std
::
fseek
(
f
,
0
,
SEEK_END
);
if
(
!
f
)
throw
path
;
if
(
std
::
fseek
(
f
,
0
,
SEEK_END
))
throw
path
;
int
len
=
std
::
ftell
(
f
);
int
len
=
std
::
ftell
(
f
);
if
(
len
<
0
)
throw
path
;
std
::
rewind
(
f
);
std
::
rewind
(
f
);
// TO DO:
WRAP THE new[] IN A TRY/CATCH BLOCK
// TO DO:
CATCH THE POTENTIAL badalloc EXCEPTION
source
=
new
char
[
len
+
1
];
source
=
new
char
[
len
+
1
];
std
::
fread
(
source
,
sizeof
(
char
),
len
,
f
);
std
::
fread
(
source
,
sizeof
(
char
),
len
,
f
);
if
(
std
::
ferror
(
f
))
throw
path
;
source
[
len
]
=
'\0'
;
source
[
len
]
=
'\0'
;
end
=
source
+
len
;
end
=
source
+
len
;
std
::
fclose
(
f
)
;
if
(
std
::
fclose
(
f
))
throw
path
;
position
=
source
;
position
=
source
;
context
.
source_refs
.
push_back
(
source
);
context
.
source_refs
.
push_back
(
source
);
++
context
.
ref_count
;
++
context
.
ref_count
;
...
@@ -116,6 +120,9 @@ namespace Sass {
...
@@ -116,6 +120,9 @@ namespace Sass {
void
Document
::
syntax_error
(
string
message
,
size_t
ln
)
void
Document
::
syntax_error
(
string
message
,
size_t
ln
)
{
throw
Error
(
Error
::
syntax
,
ln
?
ln
:
line_number
,
path
,
message
);
}
{
throw
Error
(
Error
::
syntax
,
ln
?
ln
:
line_number
,
path
,
message
);
}
void
Document
::
read_error
(
string
message
,
size_t
ln
)
{
throw
Error
(
Error
::
read
,
ln
?
ln
:
line_number
,
path
,
message
);
}
using
std
::
string
;
using
std
::
string
;
using
std
::
stringstream
;
using
std
::
stringstream
;
using
std
::
endl
;
using
std
::
endl
;
...
...
document.hpp
View file @
92450f84
...
@@ -154,6 +154,7 @@ namespace Sass {
...
@@ -154,6 +154,7 @@ namespace Sass {
const
char
*
look_for_attrib
(
const
char
*
start
=
0
);
const
char
*
look_for_attrib
(
const
char
*
start
=
0
);
void
syntax_error
(
string
message
,
size_t
ln
=
0
);
void
syntax_error
(
string
message
,
size_t
ln
=
0
);
void
read_error
(
string
message
,
size_t
ln
=
0
);
string
emit_css
(
CSS_Style
style
);
string
emit_css
(
CSS_Style
style
);
...
...
document_parser.cpp
View file @
92450f84
...
@@ -46,10 +46,15 @@ namespace Sass {
...
@@ -46,10 +46,15 @@ namespace Sass {
const
char
*
curr_path_start
=
path
.
c_str
();
const
char
*
curr_path_start
=
path
.
c_str
();
const
char
*
curr_path_end
=
folders
(
curr_path_start
);
const
char
*
curr_path_end
=
folders
(
curr_path_start
);
string
current_path
(
curr_path_start
,
curr_path_end
-
curr_path_start
);
string
current_path
(
curr_path_start
,
curr_path_end
-
curr_path_start
);
try
{
Document
importee
(
current_path
+
import_path
,
context
);
Document
importee
(
current_path
+
import_path
,
context
);
importee
.
parse_scss
();
importee
.
parse_scss
();
return
importee
.
root
;
return
importee
.
root
;
}
}
catch
(
string
path
)
{
read_error
(
"error reading file
\"
"
+
path
+
"
\"
"
);
}
}
Node
Document
::
parse_mixin_definition
()
Node
Document
::
parse_mixin_definition
()
{
{
...
...
exceptional.scss
View file @
92450f84
...
@@ -21,5 +21,5 @@ div[hux ~= "hello"] {
...
@@ -21,5 +21,5 @@ div[hux ~= "hello"] {
foo
:
boo
;
foo
:
boo
;
@include
moogoo
;
@include
moogoo
;
dux
:
mux
;
dux
:
mux
;
color
:
foo
(
$x
:
)
;
@import
"foogoo"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment