Skip to content

Commit

Permalink
Merge pull request #794 from mgreter/fix/copy-context-options
Browse files Browse the repository at this point in the history
Fix bug with options not being copied correctly
  • Loading branch information
xzyfer committed Jan 2, 2015
2 parents fa5d68d + 5e031da commit 31521ef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Libsass
by Aaron Leung ([@akhleung]) and Hampton Catlin ([@hcatlin])

[![Linux CI](https://travis-ci.org/sass/libsass.png?branch=master)](https://travis-ci.org/sass/libsass)
[![Windows CI](https://ci.appveyor.com/api/projects/status/s88o0u5qra2ng4vy/branch/master?svg=true)](https://ci.appveyor.com/project/sass/libsass/branch/master)
[![Windows CI](https://ci.appveyor.com/api/projects/status/github/sass/libsass?svg=true)](https://ci.appveyor.com/project/sass/libsass/branch/master)
[![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=283068)](https://www.bountysource.com/trackers/283068-libsass?utm_source=283068&utm_medium=shield&utm_campaign=TRACKER_BADGE)
[![Coverage Status](https://img.shields.io/coveralls/sass/libsass.svg)](https://coveralls.io/r/sass/libsass?branch=feature%2Ftest-travis-ci-3)

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cache:
- C:\Ruby21-x64\bin

install:
- git clone https://github.com/mgreter/sassc.git --branch feature/build-dll-win-mingw
- git clone https://github.com/sass/sassc.git
- git clone https://github.com/sass/sass-spec.git
- set PATH=C:\Ruby%ruby_version%\bin;%PATH%
- set SASS_LIBSASS_PATH=..
Expand Down
19 changes: 14 additions & 5 deletions sass_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ extern "C" {
void* root;
};

static void copy_options(struct Sass_Options* to, struct Sass_Options* from) { *to = *from; }

#define IMPLEMENT_SASS_OPTION_ACCESSOR(type, option) \
type ADDCALL sass_option_get_##option (struct Sass_Options* options) { return options->option; } \
Expand Down Expand Up @@ -498,7 +499,11 @@ extern "C" {
if (c_ctx->error_status)
return c_ctx->error_status;
Context::Data cpp_opt = Context::Data();
try { cpp_opt.source_c_str(data_ctx->source_string); }
try {
if (data_ctx->source_string == 0) { throw(runtime_error("Data context has no source string")); }
if (*data_ctx->source_string == 0) { throw(runtime_error("Data context has empty source string")); }
cpp_opt.source_c_str(data_ctx->source_string);
}
catch (...) { return handle_errors(c_ctx) || 1; }
return sass_compile_context(c_ctx, cpp_opt);
}
Expand All @@ -510,7 +515,11 @@ extern "C" {
if (c_ctx->error_status)
return c_ctx->error_status;
Context::Data cpp_opt = Context::Data();
try { cpp_opt.entry_point(file_ctx->input_path); }
try {
if (file_ctx->input_path == 0) { throw(runtime_error("File context has no input path")); }

This comment has been minimized.

Copy link
@smikes

smikes Jan 2, 2015

After pulling master onto OSX, I get a failure here. Not sure why.. my working dir seems to be messed up somehow.

This comment has been minimized.

Copy link
@xzyfer

xzyfer via email Jan 5, 2015

Author Contributor

This comment has been minimized.

Copy link
@xzyfer

xzyfer via email Jan 5, 2015

Author Contributor

This comment has been minimized.

Copy link
@smikes

smikes via email Jan 5, 2015

This comment has been minimized.

Copy link
@smikes

smikes Jan 5, 2015

It was transient and is gone now.

if (*file_ctx->input_path == 0) { throw(runtime_error("File context has empty input path")); }
cpp_opt.entry_point(file_ctx->input_path);
}
catch (...) { return handle_errors(c_ctx) || 1; }
return sass_compile_context(c_ctx, cpp_opt);
}
Expand Down Expand Up @@ -567,7 +576,7 @@ extern "C" {
++this_func_data;
}
}
// Deallocate inc paths
// Free custom importer
if (options->include_paths) {
struct string_list* cur;
struct string_list* next;
Expand Down Expand Up @@ -643,8 +652,8 @@ extern "C" {
struct Sass_Options* ADDCALL sass_context_get_options(struct Sass_Context* ctx) { return ctx; }
struct Sass_Options* ADDCALL sass_file_context_get_options(struct Sass_File_Context* ctx) { return ctx; }
struct Sass_Options* ADDCALL sass_data_context_get_options(struct Sass_Data_Context* ctx) { return ctx; }
void ADDCALL sass_file_context_set_options (struct Sass_File_Context* ctx, struct Sass_Options* opt) { (Sass_Options) *ctx = *opt; }
void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* ctx, struct Sass_Options* opt) { (Sass_Options) *ctx = *opt; }
void ADDCALL sass_file_context_set_options (struct Sass_File_Context* ctx, struct Sass_Options* opt) { copy_options(ctx, opt); }
void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* ctx, struct Sass_Options* opt) { copy_options(ctx, opt); }

// Create getter and setters for options
IMPLEMENT_SASS_OPTION_ACCESSOR(int, precision);
Expand Down

0 comments on commit 31521ef

Please sign in to comment.