packages feed

hlibsass 0.1.7.0 → 0.1.8.0

raw patch · 18 files changed

+125/−72 lines, 18 filessetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,6 +1,11 @@ # Change Log All notable changes to this project will be documented in this file. +## [0.1.8.0] - 2018-11-25+### Changed+- Update to Libsass 3.5.5+- Use `gmake` instead of `make` if available+ ## [0.1.7.0] - 2018-03-24 ### Changed - Update to Libsass 3.5.2@@ -78,6 +83,7 @@ - Bindings to Libsass C API - Basic tests +[0.1.8.0]: https://github.com/jakubfijalkowski/hlibsass/compare/v0.1.7.0...v0.1.8.0 [0.1.7.0]: https://github.com/jakubfijalkowski/hlibsass/compare/v0.1.6.1...v0.1.7.0 [0.1.6.1]: https://github.com/jakubfijalkowski/hlibsass/compare/v0.1.6.0...v0.1.6.1 [0.1.6.0]: https://github.com/jakubfijalkowski/hlibsass/compare/v0.1.5.2...v0.1.6.0
Setup.hs view
@@ -8,12 +8,15 @@                                                      LocalBuildInfo (..),                                                      absoluteInstallDirs,                                                      localPkgDescr)+import           Distribution.Simple.Program.Find   (findProgramOnSearchPath,+                                                     defaultProgramSearchPath) import           Distribution.Simple.Setup import           Distribution.Simple.Utils          (cabalVersion,                                                      installExecutableFile,                                                      rawSystemExit,                                                      rawSystemStdout) import           Distribution.System+import qualified Distribution.Verbosity             as Verbosity import           System.Directory                   (getCurrentDirectory)  #if MIN_VERSION_Cabal(2, 0, 0)@@ -42,14 +45,30 @@         hooksFix = if cabalVersion < mkVersion [1, 20, 0]                        then hooks { postInst = installLibsass }                        else hooks+execMake :: Verbosity.Verbosity -> String -> String -> IO ()+execMake verbosity build_target target = do+    gmakePath <- findProgramOnSearchPath Verbosity.silent defaultProgramSearchPath "gmake"+    let makeExec = case gmakePath of +#if MIN_VERSION_Cabal(1, 24, 0)+                     Just (p, _) -> p+#else+                     Just p -> p+#endif+                     Nothing -> "make"+        baseArgs = if null build_target+                      then [makeExec, "--directory=libsass"]+                      else ["BUILD=" ++ build_target, makeExec, "--directory=libsass"]+        makeArgs = if null target+                      then baseArgs+                      else baseArgs ++ [target]+    rawSystemExit verbosity "env" makeArgs  makeLibsass :: Args -> ConfigFlags -> IO HookedBuildInfo makeLibsass _ f = do     let verbosity = fromFlag $ configVerbosity f         external = getCabalFlag "externalLibsass" f         target = if getCabalFlag "sharedLibsass" f then "shared" else "static"-    unless external $ rawSystemExit verbosity "env"-         ["BUILD=" ++ target, "make", "--directory=libsass"]+    unless external $ execMake verbosity target ""     return emptyHookedBuildInfo  disablePostConfHooks :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ()@@ -119,8 +138,7 @@  cleanLibsass :: Args -> CleanFlags -> PackageDescription -> () -> IO () cleanLibsass _ flags _ _ =-    rawSystemExit (fromFlag $ cleanVerbosity flags) "env"-        ["make", "--directory=libsass", "clean"]+    execMake (fromFlag $ cleanVerbosity flags) "" "clean"  updateLibsassVersion :: Args -> SDistFlags -> IO HookedBuildInfo updateLibsassVersion _ flags = do
hlibsass.cabal view
@@ -1,5 +1,5 @@ name:                hlibsass-version:             0.1.7.0+version:             0.1.8.0 license:             MIT license-file:        LICENSE author:              Jakub Fijałkowski <fiolek94@gmail.com>
libsass/VERSION view
@@ -1,1 +1,1 @@-3.5.2+3.5.5
libsass/src/cencode.c view
@@ -47,7 +47,7 @@ 			*codechar++ = base64_encode_value(result); 			result = (fragment & 0x003) << 4; 			#ifndef _MSC_VER-				__attribute__ ((fallthrough));+				/* fall through */ 			#endif 	case step_B: 			if (plainchar == plaintextend)@@ -61,7 +61,7 @@ 			*codechar++ = base64_encode_value(result); 			result = (fragment & 0x00f) << 2; 			#ifndef _MSC_VER-				__attribute__ ((fallthrough));+				/* fall through */ 			#endif 	case step_C: 			if (plainchar == plaintextend)
libsass/src/cssize.cpp view
@@ -559,7 +559,7 @@      std::string m1 = std::string(mq1->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");     std::string t1 = mq1->media_type() ? mq1->media_type()->to_string(ctx.c_options) : "";-    std::string m2 = std::string(mq2->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");+    std::string m2 = std::string(mq2->is_restricted() ? "only" : mq2->is_negated() ? "not" : "");     std::string t2 = mq2->media_type() ? mq2->media_type()->to_string(ctx.c_options) : "";  
libsass/src/debugger.hpp view
@@ -627,6 +627,7 @@     Number_Ptr expression = Cast<Number>(node);     std::cerr << ind << "Number " << expression;     std::cerr << " (" << pstate_source_position(node) << ")";+    std::cerr << " [delayed: " << expression->is_delayed() << "] ";     std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";     std::cerr << " [" << expression->value() << expression->unit() << "]" <<       " [hash: " << expression->hash() << "] " <<
libsass/src/eval.cpp view
@@ -599,10 +599,6 @@           switch (op_type) {             case Sass_OP::EQ: return *l_n == *r_c ? bool_true : bool_false;             case Sass_OP::NEQ: return *l_n == *r_c ? bool_false : bool_true;-            case Sass_OP::LT: return *l_n < *r_c ? bool_true : bool_false;-            case Sass_OP::GTE: return *l_n < *r_c ? bool_false : bool_true;-            case Sass_OP::LTE: return *l_n < *r_c || *l_n == *r_c ? bool_true : bool_false;-            case Sass_OP::GT: return *l_n < *r_c || *l_n == *r_c ? bool_false : bool_true;             case Sass_OP::ADD: case Sass_OP::SUB: case Sass_OP::MUL: case Sass_OP::DIV: case Sass_OP::MOD:               return Operators::op_number_color(op_type, *l_n, *r_c, ctx.c_options, b_in->pstate());             default: break;@@ -643,10 +639,6 @@           switch (op_type) {             case Sass_OP::EQ: return *l_c == *r_n ? bool_true : bool_false;             case Sass_OP::NEQ: return *l_c == *r_n ? bool_false : bool_true;-            case Sass_OP::LT: return *l_c < *r_n ? bool_true : bool_false;-            case Sass_OP::GTE: return *l_c < *r_n ? bool_false : bool_true;-            case Sass_OP::LTE: return *l_c < *r_n || *l_c == *r_n ? bool_true : bool_false;-            case Sass_OP::GT: return *l_c < *r_n || *l_c == *r_n ? bool_false : bool_true;             case Sass_OP::ADD: case Sass_OP::SUB: case Sass_OP::MUL: case Sass_OP::DIV: case Sass_OP::MOD:               return Operators::op_color_number(op_type, *l_c, *r_n, ctx.c_options, b_in->pstate());             default: break;@@ -1265,13 +1257,6 @@    Expression_Ptr Eval::operator()(String_Constant_Ptr s)   {-    if (!s->is_delayed() && name_to_color(s->value())) {-      Color_Ptr c = SASS_MEMORY_COPY(name_to_color(s->value())); // copy-      c->pstate(s->pstate());-      c->disp(s->value());-      c->is_delayed(true);-      return c;-    }     return s;   } 
libsass/src/expand.cpp view
@@ -246,7 +246,8 @@       std::string str(prop->to_string(ctx.c_options));       new_p = SASS_MEMORY_NEW(String_Constant, old_p->pstate(), str);     }-    Expression_Obj value = d->value()->perform(&eval);+    Expression_Obj value = d->value();+    if (value) value = value->perform(&eval);     Block_Obj bb = ab ? operator()(ab) : NULL;     if (!bb) {       if (!value || (value->is_invisible() && !d->is_important())) return 0;
libsass/src/functions.cpp view
@@ -467,7 +467,7 @@       double s;       double l = (max + min) / 2.0; -      if (max == min) {+      if (NEAR_EQUAL(max, min)) {         h = s = 0; // achromatic       }       else {
libsass/src/inspect.cpp view
@@ -658,6 +658,9 @@     }      std::stringstream hexlet;+    // dart sass compressed all colors in regular css always+    // ruby sass and libsass does it only when not delayed+    // since color math is going to be removed, this can go too     bool compressed = opt.output_style == COMPRESSED;     hexlet << '#' << std::setw(1) << std::setfill('0');     // create a short color hexlet if there is any need for it@@ -681,9 +684,6 @@     if (name != "") {       ss << name;     }-    else if (r == 0 && g == 0 && b == 0 && a == 0) {-      ss << "transparent";-    }     else if (a >= 1) {       if (res_name != "") {         if (compressed && hexlet.str().size() < res_name.size()) {@@ -1057,7 +1057,7 @@       case Complex_Selector::REFERENCE:         append_mandatory_space();         append_string("/");-        c->reference()->perform(this);+        if (c->reference()) c->reference()->perform(this);         append_string("/");         append_mandatory_space();       break;
libsass/src/operators.cpp view
@@ -54,6 +54,22 @@     bool lte(Expression_Obj lhs, Expression_Obj rhs) { return cmp(lhs, rhs, Sass_OP::LTE) || eq(lhs, rhs); }     bool gte(Expression_Obj lhs, Expression_Obj rhs) { return !cmp(lhs, rhs, Sass_OP::GTE) || eq(lhs, rhs); } +    /* colour math deprecation warning */+    void op_color_deprecation(enum Sass_OP op, std::string lsh, std::string rhs, const ParserState& pstate)+    {+      std::string op_str(+        op == Sass_OP::ADD ? "plus" :+          op == Sass_OP::DIV ? "div" :+            op == Sass_OP::SUB ? "minus" :+              op == Sass_OP::MUL ? "times" : ""+      );++      std::string msg("The operation `" + lsh + " " + op_str + " " + rhs + "` is deprecated and will be an error in future versions.");+      std::string tail("Consider using Sass's color functions instead.\nhttp://sass-lang.com/documentation/Sass/Script/Functions.html#other_color_functions");++      deprecated(msg, tail, false, pstate);+    }+     /* static function, throws OperationError, has no traces but optional pstate for returned value */     Value_Ptr op_strings(Sass::Operand operand, Value& lhs, Value& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed)     {@@ -107,12 +123,16 @@     /* static function, throws OperationError, has no traces but optional pstate for returned value */     Value_Ptr op_colors(enum Sass_OP op, const Color& lhs, const Color& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed)     {+       if (lhs.a() != rhs.a()) {         throw Exception::AlphaChannelsNotEqual(&lhs, &rhs, op);       }-      if (op == Sass_OP::DIV && (!rhs.r() || !rhs.g() || !rhs.b())) {+      if ((op == Sass_OP::DIV || op == Sass_OP::MOD) && (!rhs.r() || !rhs.g() || !rhs.b())) {         throw Exception::ZeroDivisionError(lhs, rhs);       }++      op_color_deprecation(op, lhs.to_string(), rhs.to_string(), pstate);+       return SASS_MEMORY_NEW(Color,                              pstate,                              ops[op](lhs.r(), rhs.r()),@@ -127,15 +147,15 @@       double lval = lhs.value();       double rval = rhs.value(); +      if (op == Sass_OP::MOD && rval == 0) {+        return SASS_MEMORY_NEW(String_Quoted, pstate, "NaN");+      }+       if (op == Sass_OP::DIV && rval == 0) {         std::string result(lval ? "Infinity" : "NaN");         return SASS_MEMORY_NEW(String_Quoted, pstate, result);       } -      if (op == Sass_OP::MOD && rval == 0) {-        throw Exception::ZeroDivisionError(lhs, rhs);-      }-       size_t l_n_units = lhs.numerators.size();       size_t l_d_units = lhs.numerators.size();       size_t r_n_units = rhs.denominators.size();@@ -195,9 +215,11 @@     Value_Ptr op_number_color(enum Sass_OP op, const Number& lhs, const Color& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed)     {       double lval = lhs.value();+       switch (op) {         case Sass_OP::ADD:         case Sass_OP::MUL: {+          op_color_deprecation(op, lhs.to_string(), rhs.to_string(opt), pstate);           return SASS_MEMORY_NEW(Color,                                 pstate,                                 ops[op](lval, rhs.r()),@@ -208,6 +230,7 @@         case Sass_OP::SUB:         case Sass_OP::DIV: {           std::string color(rhs.to_string(opt));+          op_color_deprecation(op, lhs.to_string(), color, pstate);           return SASS_MEMORY_NEW(String_Quoted,                                 pstate,                                 lhs.to_string(opt)@@ -223,10 +246,14 @@     Value_Ptr op_color_number(enum Sass_OP op, const Color& lhs, const Number& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed)     {       double rval = rhs.value();-      if (op == Sass_OP::DIV && rval == 0) {++      if ((op == Sass_OP::DIV || op == Sass_OP::DIV) && rval == 0) {         // comparison of Fixnum with Float failed?         throw Exception::ZeroDivisionError(lhs, rhs);       }++      op_color_deprecation(op, lhs.to_string(), rhs.to_string(), pstate);+       return SASS_MEMORY_NEW(Color,                             pstate,                             ops[op](lhs.r(), rval),
libsass/src/parser.cpp view
@@ -1578,7 +1578,7 @@     return nr;   } -  Expression_Ptr Parser::lexed_hex_color(const ParserState& pstate, const std::string& parsed)+  Value_Ptr Parser::lexed_hex_color(const ParserState& pstate, const std::string& parsed)   {     Color_Ptr color = NULL;     if (parsed[0] != '#') {@@ -1598,6 +1598,19 @@                                1, // alpha channel                                parsed);     }+    else if (parsed.length() == 5) {+      std::string r(2, parsed[1]);+      std::string g(2, parsed[2]);+      std::string b(2, parsed[3]);+      std::string a(2, parsed[4]);+      color = SASS_MEMORY_NEW(Color,+                               pstate,+                               static_cast<double>(strtol(r.c_str(), NULL, 16)),+                               static_cast<double>(strtol(g.c_str(), NULL, 16)),+                               static_cast<double>(strtol(b.c_str(), NULL, 16)),+                               static_cast<double>(strtol(a.c_str(), NULL, 16)) / 255,+                               parsed);+    }     else if (parsed.length() == 7) {       std::string r(parsed.substr(1,2));       std::string g(parsed.substr(3,2));@@ -1628,6 +1641,19 @@     return color;   } +  Value_Ptr Parser::color_or_string(const std::string& lexed) const+  {+    if (auto color = name_to_color(lexed)) {+      auto c = SASS_MEMORY_NEW(Color, color);+      c->is_delayed(true);+      c->pstate(pstate);+      c->disp(lexed);+      return c;+    } else {+      return SASS_MEMORY_NEW(String_Constant, pstate, lexed);+    }+  }+   // parse one value for a list   Expression_Obj Parser::parse_value()   {@@ -1670,7 +1696,7 @@     { return SASS_MEMORY_NEW(Null, pstate); }      if (lex< identifier >()) {-      return SASS_MEMORY_NEW(String_Constant, pstate, lexed);+      return color_or_string(lexed);     }      if (lex< percentage >())@@ -1681,17 +1707,7 @@     { return lexed_hex_color(lexed); }      if (lex< hexa >())-    {-      std::string s = lexed.to_string();--      deprecated(-        "The value \""+s+"\" is currently parsed as a string, but it will be parsed as a color in",-        "future versions of Sass. Use \"unquote('"+s+"')\" to continue parsing it as a string.",-        true, pstate-      );--      return SASS_MEMORY_NEW(String_Quoted, pstate, lexed);-    }+    { return lexed_hex_color(lexed); }      if (lex< sequence < exactly <'#'>, identifier > >())     { return SASS_MEMORY_NEW(String_Quoted, pstate, lexed); }@@ -1710,10 +1726,6 @@     if (lex< variable >())     { return SASS_MEMORY_NEW(Variable, pstate, Util::normalize_underscores(lexed)); } -    // Special case handling for `%` proceeding an interpolant.-    if (lex< sequence< exactly<'%'>, optional< percentage > > >())-    { return SASS_MEMORY_NEW(String_Constant, pstate, lexed); }-     css_error("Invalid CSS", " after ", ": expected expression (e.g. 1px, bold), was ");      // unreachable statement@@ -1841,7 +1853,7 @@     return schema->length() > 0 ? schema.detach() : NULL;   } -  String_Constant_Obj Parser::parse_static_value()+  Value_Obj Parser::parse_static_value()   {     lex< static_value >();     Token str(lexed);@@ -1852,8 +1864,7 @@     --str.end;     --position; -    String_Constant_Ptr str_node = SASS_MEMORY_NEW(String_Constant, pstate, str.time_wspace());-    return str_node;+    return color_or_string(str.time_wspace());;   }    String_Obj Parser::parse_string()@@ -1962,7 +1973,7 @@         if (lex< re_static_expression >()) {           ex = SASS_MEMORY_NEW(String_Constant, pstate, lexed);         } else {-          ex = parse_list();+          ex = parse_list(true);         }         ex->is_interpolant(true);         schema->append(ex);@@ -1986,7 +1997,7 @@         }         if (peek < exactly < '-' > >()) break;       }-      else if (lex< sequence < identifier > >()) {+      else if (lex< identifier >()) {         schema->append(SASS_MEMORY_NEW(String_Constant, pstate, lexed));         if ((*position == '"' || *position == '\'') || peek < alternatives < alpha > >()) {            // need_space = true;@@ -2155,6 +2166,7 @@       while (pp && peek< exactly< hash_lbrace > >(pp)) {         pp = sequence< interpolant, real_uri_value >(pp);       }+      if (!pp) return 0;       position = pp;       return parse_interpolated_chunk(Token(p, position));     }@@ -2691,7 +2703,9 @@     if ((rv = lex_interp_string())) return rv;     if ((rv = lex_interp_uri())) return rv;     if ((rv = lex_interpolation())) return rv;-    return rv;+     if (lex< alternatives< hex, hex0 > >())+    { return lexed_hex_color(lexed); }+   return rv;   }    String_Schema_Obj Parser::parse_almost_any_value()@@ -2777,6 +2791,7 @@       >(p)     ) {       bool could_be_property = peek< sequence< exactly<'-'>, exactly<'-'> > >(p) != 0;+      bool could_be_escaped = false;       while (p < q) {         // did we have interpolations?         if (*p == '#' && *(p+1) == '{') {@@ -2785,9 +2800,10 @@         }         // A property that's ambiguous with a nested selector is interpreted as a         // custom property.-        if (*p == ':') {+        if (*p == ':' && !could_be_escaped) {           rv.is_custom_property = could_be_property || p+1 == q || peek< space >(p+1);         }+        could_be_escaped = *p == '\\';         ++ p;       }       // store anyway  }
libsass/src/parser.hpp view
@@ -290,7 +290,7 @@     String_Obj parse_url_function_argument();     String_Obj parse_interpolated_chunk(Token, bool constant = false, bool css = true);     String_Obj parse_string();-    String_Constant_Obj parse_static_value();+    Value_Obj parse_static_value();     String_Schema_Obj parse_css_variable_value(bool top_level = true);     String_Schema_Obj parse_css_variable_value_token(bool top_level = true);     String_Obj parse_ie_property();@@ -325,6 +325,8 @@     Error_Obj parse_error();     Debug_Obj parse_debug(); +    Value_Ptr color_or_string(const std::string& lexed) const;+     // be more like ruby sass     Expression_Obj lex_almost_any_value_token();     Expression_Obj lex_almost_any_value_chars();@@ -380,12 +382,12 @@     static Number_Ptr lexed_number(const ParserState& pstate, const std::string& parsed);     static Number_Ptr lexed_dimension(const ParserState& pstate, const std::string& parsed);     static Number_Ptr lexed_percentage(const ParserState& pstate, const std::string& parsed);-    static Expression_Ptr lexed_hex_color(const ParserState& pstate, const std::string& parsed);+    static Value_Ptr lexed_hex_color(const ParserState& pstate, const std::string& parsed);   private:     Number_Ptr lexed_number(const std::string& parsed) { return lexed_number(pstate, parsed); };     Number_Ptr lexed_dimension(const std::string& parsed) { return lexed_dimension(pstate, parsed); };     Number_Ptr lexed_percentage(const std::string& parsed) { return lexed_percentage(pstate, parsed); };-    Expression_Ptr lexed_hex_color(const std::string& parsed) { return lexed_hex_color(pstate, parsed); };+    Value_Ptr lexed_hex_color(const std::string& parsed) { return lexed_hex_color(pstate, parsed); };      static const char* re_attr_sensitive_close(const char* src);     static const char* re_attr_insensitive_close(const char* src);
libsass/src/prelexer.cpp view
@@ -1606,7 +1606,7 @@       >(src);     } -    extern const char css_variable_url_top_level_negates[] = "()[]{}\"'#/;!";+    extern const char css_variable_url_top_level_negates[] = "()[]{}\"'#/;";     const char* css_variable_top_level_value(const char* src) {       return sequence<         alternatives<
libsass/src/sass.cpp view
@@ -33,8 +33,10 @@   void* ADDCALL sass_alloc_memory(size_t size)   {     void* ptr = malloc(size);-    if (ptr == NULL)-      out_of_memory();+    if (ptr == NULL) {+      std::cerr << "Out of memory.\n";+      exit(EXIT_FAILURE);+    }     return ptr;   } 
libsass/src/util.hpp view
@@ -12,11 +12,6 @@  namespace Sass { -  #define out_of_memory() do {            \-      std::cerr << "Out of memory.\n";    \-      exit(EXIT_FAILURE);                 \-    } while (0)-   double round(double val, size_t precision = 0);   double sass_strtod(const char* str);   const char* safe_str(const char *, const char* = "");
tests/Main.hs view
@@ -35,7 +35,7 @@ #ifndef EXTERNAL_LIBSASS     it "should report correct version" $ do         str <- peekCString libsass_version-        str `shouldBe` "3.5.2"+        str `shouldBe` "3.5.5" #endif      it "should support quoted strings" $ withCString "sample" $ \cstr -> do