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
5a0eae49
Commit
5a0eae49
authored
Apr 13, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Storing the error status and message into the interface struct.
parent
f5dc2c38
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
6 deletions
+53
-6
exceptional.scss
exceptional.scss
+2
-1
sass_interface.cpp
sass_interface.cpp
+35
-4
sass_interface.h
sass_interface.h
+6
-0
sassc.c
sassc.c
+10
-1
No files found.
exceptional.scss
View file @
5a0eae49
...
@@ -21,5 +21,6 @@ div[hux ~= "hello"] {
...
@@ -21,5 +21,6 @@ div[hux ~= "hello"] {
foo
:
boo
;
foo
:
boo
;
@include
moogoo
;
@include
moogoo
;
dux
:
mux
;
dux
:
mux
;
@import
"foogoo"
;
@import
bugaboo
"foogoo"
blah
:
blah
;
}
}
sass_interface.cpp
View file @
5a0eae49
#include <iostream>
#include <iostream>
#include <sstream>
#include <string>
#include <string>
#include <cstdlib>
#include <cstdlib>
#include <unistd.h>
#include <unistd.h>
...
@@ -53,13 +54,28 @@ extern "C" {
...
@@ -53,13 +54,28 @@ extern "C" {
Context
cpp_ctx
(
c_ctx
->
options
.
include_paths
);
Context
cpp_ctx
(
c_ctx
->
options
.
include_paths
);
Document
doc
(
0
,
c_ctx
->
input_string
,
cpp_ctx
);
Document
doc
(
0
,
c_ctx
->
input_string
,
cpp_ctx
);
c_ctx
->
output_string
=
process_document
(
doc
,
c_ctx
->
options
.
output_style
);
c_ctx
->
output_string
=
process_document
(
doc
,
c_ctx
->
options
.
output_style
);
c_ctx
->
error_message
=
0
;
c_ctx
->
error_status
=
0
;
}
}
catch
(
Error
&
e
)
{
catch
(
Error
&
e
)
{
cerr
<<
"ERROR -- "
<<
e
.
file_name
<<
", line "
<<
e
.
line_number
<<
": "
<<
e
.
message
<<
endl
;
stringstream
msg_stream
;
msg_stream
<<
"ERROR -- "
<<
e
.
file_name
<<
", line "
<<
e
.
line_number
<<
": "
<<
e
.
message
<<
endl
;
string
msg
(
msg_stream
.
str
());
char
*
msg_str
=
(
char
*
)
malloc
(
msg
.
size
()
+
1
);
strcpy
(
msg_str
,
msg
.
c_str
());
c_ctx
->
error_status
=
1
;
c_ctx
->
output_string
=
0
;
c_ctx
->
output_string
=
0
;
c_ctx
->
error_message
=
msg_str
;
}
}
catch
(
bad_alloc
&
ba
)
{
catch
(
bad_alloc
&
ba
)
{
cerr
<<
"ERROR -- unable to allocate memory: "
<<
ba
.
what
()
<<
endl
;
stringstream
msg_stream
;
msg_stream
<<
"ERROR -- unable to allocate memory: "
<<
ba
.
what
()
<<
endl
;
string
msg
(
msg_stream
.
str
());
char
*
msg_str
=
(
char
*
)
malloc
(
msg
.
size
()
+
1
);
strcpy
(
msg_str
,
msg
.
c_str
());
c_ctx
->
error_status
=
1
;
c_ctx
->
output_string
=
0
;
c_ctx
->
error_message
=
msg_str
;
}
}
// TO DO: CATCH EVERYTHING ELSE
// TO DO: CATCH EVERYTHING ELSE
return
0
;
return
0
;
...
@@ -72,13 +88,28 @@ extern "C" {
...
@@ -72,13 +88,28 @@ extern "C" {
Context
cpp_ctx
(
c_ctx
->
options
.
include_paths
);
Context
cpp_ctx
(
c_ctx
->
options
.
include_paths
);
Document
doc
(
c_ctx
->
input_path
,
0
,
cpp_ctx
);
Document
doc
(
c_ctx
->
input_path
,
0
,
cpp_ctx
);
c_ctx
->
output_string
=
process_document
(
doc
,
c_ctx
->
options
.
output_style
);
c_ctx
->
output_string
=
process_document
(
doc
,
c_ctx
->
options
.
output_style
);
c_ctx
->
error_message
=
0
;
c_ctx
->
error_status
=
0
;
}
}
catch
(
Error
&
e
)
{
catch
(
Error
&
e
)
{
cerr
<<
"ERROR -- "
<<
e
.
file_name
<<
", line "
<<
e
.
line_number
<<
": "
<<
e
.
message
<<
endl
;
stringstream
msg_stream
;
msg_stream
<<
"ERROR -- "
<<
e
.
file_name
<<
", line "
<<
e
.
line_number
<<
": "
<<
e
.
message
<<
endl
;
string
msg
(
msg_stream
.
str
());
char
*
msg_str
=
(
char
*
)
malloc
(
msg
.
size
()
+
1
);
strcpy
(
msg_str
,
msg
.
c_str
());
c_ctx
->
error_status
=
1
;
c_ctx
->
output_string
=
0
;
c_ctx
->
output_string
=
0
;
c_ctx
->
error_message
=
msg_str
;
}
}
catch
(
bad_alloc
&
ba
)
{
catch
(
bad_alloc
&
ba
)
{
cerr
<<
"ERROR -- unable to allocate memory: "
<<
ba
.
what
()
<<
endl
;
stringstream
msg_stream
;
msg_stream
<<
"ERROR -- unable to allocate memory: "
<<
ba
.
what
()
<<
endl
;
string
msg
(
msg_stream
.
str
());
char
*
msg_str
=
(
char
*
)
malloc
(
msg
.
size
()
+
1
);
strcpy
(
msg_str
,
msg
.
c_str
());
c_ctx
->
error_status
=
1
;
c_ctx
->
output_string
=
0
;
c_ctx
->
error_message
=
msg_str
;
}
}
// TO DO: CATCH EVERYTHING ELSE
// TO DO: CATCH EVERYTHING ELSE
return
0
;
return
0
;
...
...
sass_interface.h
View file @
5a0eae49
...
@@ -16,18 +16,24 @@ struct sass_context {
...
@@ -16,18 +16,24 @@ struct sass_context {
char
*
input_string
;
char
*
input_string
;
char
*
output_string
;
char
*
output_string
;
struct
sass_options
options
;
struct
sass_options
options
;
int
error_status
;
char
*
error_message
;
};
};
struct
sass_folder_context
{
struct
sass_folder_context
{
char
*
search_path
;
char
*
search_path
;
char
*
output_path
;
char
*
output_path
;
struct
sass_options
options
;
struct
sass_options
options
;
int
error_status
;
char
*
error_message
;
};
};
struct
sass_file_context
{
struct
sass_file_context
{
char
*
input_path
;
char
*
input_path
;
char
*
output_string
;
char
*
output_string
;
struct
sass_options
options
;
struct
sass_options
options
;
int
error_status
;
char
*
error_message
;
};
};
struct
sass_context
*
sass_new_context
();
struct
sass_context
*
sass_new_context
();
...
...
sassc.c
View file @
5a0eae49
...
@@ -34,7 +34,16 @@ int main(int argc, char** argv)
...
@@ -34,7 +34,16 @@ int main(int argc, char** argv)
sass_compile_file
(
ctx
);
sass_compile_file
(
ctx
);
if
(
ctx
->
output_string
)
printf
(
"%s"
,
ctx
->
output_string
);
if
(
ctx
->
error_status
)
{
if
(
ctx
->
error_message
)
printf
(
"%s"
,
ctx
->
error_message
);
else
printf
(
"An error occured; no error message available.
\n
"
);
}
else
if
(
ctx
->
output_string
)
{
printf
(
"%s"
,
ctx
->
output_string
);
}
else
{
printf
(
"Unknown internal error.
\n
"
);
}
sass_free_file_context
(
ctx
);
sass_free_file_context
(
ctx
);
return
0
;
return
0
;
...
...
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