Skip to content

Commit 3ca6ccd

Browse files
committed
Code cleanup (duplicates, typos, naming)
1 parent 5bc2b86 commit 3ca6ccd

30 files changed

+215
-294
lines changed

include/sass/compiler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ extern "C" {
118118
// Note: LibSass does not write the file, implementers should write to this path.
119119
ADDAPI void ADDCALL sass_compiler_set_srcmap_path(struct SassCompiler* compiler, const char* path);
120120

121+
// Getter for source-map path (where to store the source-mapping).
122+
// Note: if path is not explicitly given, we will deduct one from input path.
123+
// Note: the value will only be deducted after the main render phase is completed.
124+
// Note: LibSass does not write the file, implementers should write to this path.
125+
ADDAPI const char* ADDCALL sass_compiler_get_srcmap_path(struct SassCompiler* compiler);
126+
121127
// Setter for source-map root (simply passed to the resulting srcmap info).
122128
// Note: if not given, no root attribute will be added to the srcmap info object.
123129
ADDAPI void ADDCALL sass_compiler_set_srcmap_root(struct SassCompiler* compiler, const char* root);

src/ast_expressions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ namespace Sass {
106106
if (auto str = item->isaString()) { // Ex
107107
auto& value = str->value();
108108
for (size_t i = 0; i < value.size(); i++) {
109-
if (value[i] == $single_quote) return $double_quote;
110-
if (value[i] == $double_quote) containsDoubleQuote = true;
109+
if (value[i] == $apos) return $quote;
110+
if (value[i] == $quote) containsDoubleQuote = true;
111111
}
112112
}
113113
}
114-
return containsDoubleQuote ? $single_quote : $double_quote;
114+
return containsDoubleQuote ? $apos : $quote;
115115
}
116116

117117
PlainCssCallable2::PlainCssCallable2(

src/ast_expressions.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ namespace Sass {
283283
{
284284
ADD_CONSTREF(EnvKey, name);
285285
ADD_REF(sass::vector<EnvRef>, vidxs);
286-
// ADD_REF(EnvRef, vidx2);
287286
ADD_CONSTREF(sass::string, ns);
288287
ADD_PROPERTY(bool, withinLoop);
289288
public:

src/ast_selectors.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ namespace Sass {
252252
// Returns whether this is a private selector.
253253
// That is, whether it begins with `-` or `_`.
254254
bool isPrivate() const {
255-
return name_[0] == Character::$dash
255+
return name_[0] == Character::$minus
256256
|| name_[0] == Character::$underscore;
257257
}
258258

src/ast_statements.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,14 +748,11 @@ namespace Sass {
748748
class AssignRule final : public Statement
749749
{
750750
private:
751+
ADD_REF(EnvRef, vidx);
751752
ADD_CONSTREF(EnvKey, variable);
752753
ADD_CONSTREF(sass::string, ns);
753754
ADD_CONSTREF(ExpressionObj, value);
754-
ADD_REF(sass::vector<EnvRef>, vidxs);
755-
756-
ADD_REF(EnvRef, vidx2);
757755
ADD_PROPERTY(bool, withinLoop);
758-
759756
ADD_CONSTREF(bool, is_default); // ToDO rename
760757
ADD_CONSTREF(bool, is_global); // ToDO rename
761758
public:

src/capi_compiler.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,16 @@ namespace Sass {
115115
compiler.content = std::move(output.buffer);
116116

117117
// Create options to render source map and footer.
118-
SrcMapOptions options(compiler.srcmap_options);
118+
SrcMapOptions& options(compiler.srcmap_options);
119119
// Deduct some options always from original values.
120120
// ToDo: is there really any need to customize this?
121121
if (options.origin.empty() || options.origin == "stream://stdout") {
122122
options.origin = compiler.getOutputPath();
123123
}
124124
if (options.path.empty() || options.path == "stream://stdout") {
125-
options.path = options.origin + ".map";
125+
if (!options.origin.empty() && options.origin != "stream://stdout") {
126+
options.path = options.origin + ".map";
127+
}
126128
}
127129

128130
switch (options.mode) {
@@ -507,6 +509,16 @@ extern "C" {
507509
Compiler::unwrap(compiler).srcmap_options.path = path;
508510
}
509511

512+
// Getter for source-map path (where to store the source-mapping).
513+
// Note: if path is not explicitly given, we will deduct one from input path.
514+
// Note: the value will only be deducted after the main render phase is completed.
515+
// Note: LibSass does not write the file, implementers should write to this path.
516+
const char* ADDCALL sass_compiler_get_srcmap_path(struct SassCompiler* compiler)
517+
{
518+
const sass::string& path(Compiler::unwrap(compiler).srcmap_options.path);
519+
return path.empty() ? nullptr : path.c_str();
520+
}
521+
510522
// Setter for source-map root (simply passed to the resulting srcmap info).
511523
// Note: if not given, no root attribute will be added to the srcmap info object.
512524
void ADDCALL sass_compiler_set_srcmap_root(struct SassCompiler* compiler, const char* root)

src/capi_sass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ namespace Sass {
216216
// Init everything to false
217217
SrcMapOptions() :
218218
mode(SASS_SRCMAP_NONE),
219-
embed_contents(true),
219+
embed_contents(false),
220220
file_urls(false)
221221
{}
222222

src/capi_values.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,4 @@
88
// to get the __EXTENSIONS__ fix on Solaris.
99
#include "capi_sass.hpp"
1010

11-
// Getter for callee entry
12-
// const char* ADDCALL sass_callee_get_name(struct SassCallee* entry) { return entry->name; }
13-
// const char* ADDCALL sass_callee_get_path(struct SassCallee* entry) { return entry->path; }
14-
// uint32_t ADDCALL sass_callee_get_line(struct SassCallee* entry) { return entry->line; }
15-
// uint32_t ADDCALL sass_callee_get_column(struct SassCallee* entry) { return entry->column; }
16-
// enum Sass_Callee_Type ADDCALL sass_callee_get_type(struct SassCallee* entry) { return entry->type; }
17-
18-
19-
// Explicit functions to take ownership of the memory
20-
// Resets our own property since we do not know if it is still alive
21-
// char* ADDCALL sass_import_take_source(struct SassImport* entry) { char* ptr = entry->source; entry->source = 0; return ptr; }
22-
// char* ADDCALL sass_import_take_srcmap(struct SassImport* entry) { char* ptr = entry->srcmap; entry->srcmap = 0; return ptr; }
23-
2411
#endif

src/character.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ namespace Sass {
4444
}
4545

4646
// Returns whether [character] is
47-
// starting a utf8 multibyte sequence.
47+
// starting a utf8 multi-byte sequence.
4848
inline bool isUtf8StartByte(uint8_t character) {
4949
return (character & 192) == 192;
5050
}
5151

5252
// Returns whether [character] is
53-
// part of a utf8 multibyte sequence.
53+
// part of a utf8 multi-byte sequence.
5454
inline bool isUtf8Continuation(uint8_t character) {
5555
return (character & 192) == 128;
5656
}

src/charcode.hpp

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ namespace Sass {
4242
const uint8_t $bs = 0x08;
4343

4444
// "Horizontal Tab" control character.
45-
const uint8_t $ht = 0x09;
46-
47-
// "Horizontal Tab" control character, common name.
4845
const uint8_t $tab = 0x09;
4946

5047
// "Line feed" control character.
@@ -126,63 +123,30 @@ namespace Sass {
126123
// Character '!'.
127124
const uint8_t $exclamation = 0x21;
128125

129-
// Character '"', short name.
130-
const uint8_t $quot = 0x22;
131-
132126
// Character '"'.
133127
const uint8_t $quote = 0x22;
134128

135-
// Character '"'.
136-
const uint8_t $double_quote = 0x22;
137-
138-
// Character '"'.
139-
const uint8_t $quotation = 0x22;
140-
141129
// Character '#'.
142130
const uint8_t $hash = 0x23;
143131

144-
// Character '$'.
145-
const uint8_t $$ = 0x24;
146-
147132
// Character '$'.
148133
const uint8_t $dollar = 0x24;
149134

150135
// Character '%'.
151136
const uint8_t $percent = 0x25;
152137

153-
// Character '&', short name.
154-
const uint8_t $amp = 0x26;
155-
156138
// Character '&'.
157139
const uint8_t $ampersand = 0x26;
158140

159141
// Character "'".
160142
const uint8_t $apos = 0x27;
161143

162-
// Character '''.
163-
const uint8_t $apostrophe = 0x27;
164-
165-
// Character '''.
166-
const uint8_t $single_quote = 0x27;
167-
168144
// Character '('.
169145
const uint8_t $lparen = 0x28;
170146

171-
// Character '('.
172-
const uint8_t $open_paren = 0x28;
173-
174-
// Character '('.
175-
const uint8_t $open_parenthesis = 0x28;
176-
177147
// Character ')'.
178148
const uint8_t $rparen = 0x29;
179149

180-
// Character ')'.
181-
const uint8_t $close_paren = 0x29;
182-
183-
// Character ')'.
184-
const uint8_t $close_parenthesis = 0x29;
185-
186150
// Character '*'.
187151
const uint8_t $asterisk = 0x2A;
188152

@@ -195,24 +159,12 @@ namespace Sass {
195159
// Character '-'.
196160
const uint8_t $minus = 0x2D;
197161

198-
// Character '-'.
199-
const uint8_t $dash = 0x2D;
200-
201162
// Character '.'.
202163
const uint8_t $dot = 0x2E;
203164

204-
// Character '.'.
205-
const uint8_t $fullstop = 0x2E;
206-
207165
// Character '/'.
208166
const uint8_t $slash = 0x2F;
209167

210-
// Character '/'.
211-
const uint8_t $solidus = 0x2F;
212-
213-
// Character '/'.
214-
const uint8_t $division = 0x2F;
215-
216168
// Character '0'.
217169
const uint8_t $0 = 0x30;
218170

@@ -252,30 +204,12 @@ namespace Sass {
252204
// Character '<'.
253205
const uint8_t $lt = 0x3C;
254206

255-
// Character '<'.
256-
const uint8_t $less_than = 0x3C;
257-
258-
// Character '<'.
259-
const uint8_t $langle = 0x3C;
260-
261-
// Character '<'.
262-
const uint8_t $open_angle = 0x3C;
263-
264207
// Character '='.
265208
const uint8_t $equal = 0x3D;
266209

267210
// Character '>'.
268211
const uint8_t $gt = 0x3E;
269212

270-
// Character '>'.
271-
const uint8_t $greater_than = 0x3E;
272-
273-
// Character '>'.
274-
const uint8_t $rangle = 0x3E;
275-
276-
// Character '>'.
277-
const uint8_t $close_angle = 0x3E;
278-
279213
// Character '?'.
280214
const uint8_t $question = 0x3F;
281215

@@ -363,18 +297,12 @@ namespace Sass {
363297
// Character '['.
364298
const uint8_t $lbracket = 0x5B;
365299

366-
// Character '['.
367-
const uint8_t $open_bracket = 0x5B;
368-
369300
// Character '\'.
370301
const uint8_t $backslash = 0x5C;
371302

372303
// Character ']'.
373304
const uint8_t $rbracket = 0x5D;
374305

375-
// Character ']'.
376-
const uint8_t $close_bracket = 0x5D;
377-
378306
// Character '^'.
379307
const uint8_t $circumflex = 0x5E;
380308

@@ -480,9 +408,6 @@ namespace Sass {
480408
// Character '{'.
481409
const uint8_t $lbrace = 0x7B;
482410

483-
// Character '{'.
484-
const uint8_t $open_brace = 0x7B;
485-
486411
// Character '|'.
487412
const uint8_t $pipe = 0x7C;
488413

@@ -492,9 +417,6 @@ namespace Sass {
492417
// Character '}'.
493418
const uint8_t $rbrace = 0x7D;
494419

495-
// Character '}'.
496-
const uint8_t $close_brace = 0x7D;
497-
498420
// Character '~'.
499421
const uint8_t $tilde = 0x7E;
500422

0 commit comments

Comments
 (0)