Sha256: 336ce6ca399ec7ff8453d3ffafe2982872aa8caa0b501af3aee66cd0d2448434

Contents?: true

Size: 1.69 KB

Versions: 25

Compression:

Stored size: 1.69 KB

Contents

#include "util_string.hpp"

#include <algorithm>

namespace Sass {
namespace Util {

std::string rtrim(const std::string &str) {
  std::string trimmed = str;
  size_t pos_ws = trimmed.find_last_not_of(" \t\n\v\f\r");
  if (pos_ws != std::string::npos) {
    trimmed.erase(pos_ws + 1);
  } else {
    trimmed.clear();
  }
  return trimmed;
}

std::string normalize_newlines(const std::string& str) {
  std::string result;
  result.reserve(str.size());
  std::size_t pos = 0;
  while (true) {
    const std::size_t newline = str.find_first_of("\n\f\r", pos);
    if (newline == std::string::npos) break;
    result.append(str, pos, newline - pos);
    result += '\n';
    if (str[newline] == '\r' && str[newline + 1] == '\n') {
      pos = newline + 2;
    } else {
      pos = newline + 1;
    }
  }
  result.append(str, pos, std::string::npos);
  return result;
}

std::string normalize_underscores(const std::string& str) {
  std::string normalized = str;
  std::replace(normalized.begin(), normalized.end(), '_', '-');
  return normalized;
}

std::string normalize_decimals(const std::string& str) {
  std::string normalized;
  if (!str.empty() && str[0] == '.') {
    normalized.reserve(str.size() + 1);
    normalized += '0';
    normalized += str;
  } else {
    normalized = str;
  }
  return normalized;
}

char opening_bracket_for(char closing_bracket) {
  switch (closing_bracket) {
    case ')': return '(';
    case ']': return '[';
    case '}': return '{';
    default: return '\0';
  }
}

char closing_bracket_for(char opening_bracket) {
  switch (opening_bracket) {
    case '(': return ')';
    case '[': return ']';
    case '{': return '}';
    default: return '\0';
  }
}

}  // namespace Sass
}  // namespace Util

Version data entries

25 entries across 16 versions & 2 rubygems

Version Path
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sassc-2.2.1/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sassc-2.2.0/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sassc-2.2.1/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sassc-2.2.0/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sassc-2.2.0/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sassc-2.2.1/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sassc-2.2.0/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sassc-2.2.1/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/ext/libsass/src/util_string.cpp
sassc-2.2.1 ext/libsass/src/util_string.cpp
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/ext/libsass/src/util_string.cpp
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/sassc-2.2.0/ext/libsass/src/util_string.cpp
sassc-2.2.0 ext/libsass/src/util_string.cpp
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/sassc-2.1.0-x86_64-linux/ext/libsass/src/util_string.cpp
sassc-2.1.0-x86_64-linux ext/libsass/src/util_string.cpp
sassc-2.1.0 ext/libsass/src/util_string.cpp
sassc-2.1.0.pre3-x86_64-linux ext/libsass/src/util_string.cpp