From fe8ae97b03d5bbdb53039462f74c2bd59c62daf3 Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Thu, 9 Oct 2014 19:21:36 -0500 Subject: [PATCH 1/4] Add additional parameter where commandline syntax can be fetched from --- context.cpp | 4 +++- sass_interface.cpp | 8 +++++++- sass_interface.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/context.cpp b/context.cpp index 6efd70f160..ddebc0d474 100644 --- a/context.cpp +++ b/context.cpp @@ -211,7 +211,9 @@ namespace Sass { { Block* root = 0; for (size_t i = 0; i < queue.size(); ++i) { - Parser p(Parser::from_c_str(queue[i].second, *this, queue[i].first, Position(1 + i, 1, 1))); + string parsedata=string(source_c_str)+string("\n")+string(queue[i].second); +// printf("Data to parse %s\n",parsedata.c_str()); + Parser p(Parser::from_c_str(parsedata.c_str(), *this, queue[i].first, Position(1 + i, 1, 1))); Block* ast = p.parse(); if (i == 0) root = ast; style_sheets[queue[i].first] = ast; diff --git a/sass_interface.cpp b/sass_interface.cpp index 1695312a97..a28b49e106 100644 --- a/sass_interface.cpp +++ b/sass_interface.cpp @@ -190,8 +190,14 @@ extern "C" { else { output_path = c_ctx->output_path; } + if (c_ctx->source_string==NULL) + { + c_ctx->source_string="//"; + } Context cpp_ctx( - Context::Data().entry_point(input_path) + + Context::Data().source_c_str(c_ctx->source_string) + .entry_point(input_path) .output_path(output_path) .output_style((Output_Style) c_ctx->options.output_style) .source_comments(c_ctx->options.source_comments) diff --git a/sass_interface.h b/sass_interface.h index 0a20b80536..1d49223fb2 100644 --- a/sass_interface.h +++ b/sass_interface.h @@ -53,6 +53,7 @@ struct sass_context { }; struct sass_file_context { + const char* source_string; const char* input_path; const char* output_path; char* output_string; From 5d3a4396ec9d215cf2d66db9d6be1248d6c34094 Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Thu, 9 Oct 2014 20:03:28 -0500 Subject: [PATCH 2/4] Correct off by one issue with line numbers --- context.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/context.cpp b/context.cpp index ddebc0d474..f716a0571f 100644 --- a/context.cpp +++ b/context.cpp @@ -211,9 +211,8 @@ namespace Sass { { Block* root = 0; for (size_t i = 0; i < queue.size(); ++i) { - string parsedata=string(source_c_str)+string("\n")+string(queue[i].second); -// printf("Data to parse %s\n",parsedata.c_str()); - Parser p(Parser::from_c_str(parsedata.c_str(), *this, queue[i].first, Position(1 + i, 1, 1))); + string parsedata=string(source_c_str)+string("\n")+string(queue[i].second); + Parser p(Parser::from_c_str(parsedata.c_str(), *this, queue[i].first, Position(1 + i, 0, 1))); Block* ast = p.parse(); if (i == 0) root = ast; style_sheets[queue[i].first] = ast; From 49e12507608610c68f12d40d2b91e677d3d136de Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Thu, 9 Oct 2014 20:04:46 -0500 Subject: [PATCH 3/4] correct poor formatting --- context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/context.cpp b/context.cpp index f716a0571f..2f3cd92813 100644 --- a/context.cpp +++ b/context.cpp @@ -211,8 +211,8 @@ namespace Sass { { Block* root = 0; for (size_t i = 0; i < queue.size(); ++i) { - string parsedata=string(source_c_str)+string("\n")+string(queue[i].second); - Parser p(Parser::from_c_str(parsedata.c_str(), *this, queue[i].first, Position(1 + i, 0, 1))); + string parsedata=string(source_c_str)+string("\n")+string(queue[i].second); + Parser p(Parser::from_c_str(parsedata.c_str(), *this, queue[i].first, Position(1 + i, 0, 1))); Block* ast = p.parse(); if (i == 0) root = ast; style_sheets[queue[i].first] = ast; From f44b8caade7373844f2df7c388df0f0cdbb4ab63 Mon Sep 17 00:00:00 2001 From: Hampton Catlin Date: Sun, 12 Oct 2014 10:32:11 -0400 Subject: [PATCH 4/4] adding some documentation on source_string in the file context --- sass_interface.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sass_interface.h b/sass_interface.h index 1d49223fb2..4faf601f46 100644 --- a/sass_interface.h +++ b/sass_interface.h @@ -53,9 +53,12 @@ struct sass_context { }; struct sass_file_context { - const char* source_string; + // Input Path is the path to the Sass file for processing const char* input_path; const char* output_path; + // Source string is an optional way to inject some Sass before the file is executed + // to allow for dynamic changes in execution w/o a file change. + const char* source_string; char* output_string; char* source_map_string; struct sass_options options;