From 0d3c194d404d9586a7dfe1b75c6db36b7cf54810 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 22 Mar 2015 15:12:16 -0700 Subject: [PATCH] Clean up some unused stuff (win32) --- old/document.cpp | 181 ----------------------------------------------- pysass.cpp | 2 - setup.py | 4 +- win32/unistd.h | 44 ------------ 4 files changed, 2 insertions(+), 229 deletions(-) delete mode 100644 old/document.cpp delete mode 100644 win32/unistd.h diff --git a/old/document.cpp b/old/document.cpp deleted file mode 100644 index d8763938..00000000 --- a/old/document.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#ifdef _WIN32 -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) -#endif - -#include -#include -#include "document.hpp" -#include "eval_apply.hpp" -#include "error.hpp" -#include -#include -#include -#include - -namespace Sass { - - Document::Document(Context& ctx) : context(ctx) - { ++context.ref_count; } - - Document::Document(const Document& doc) - : path(doc.path), - source(doc.source), - position(doc.position), - end(doc.end), - line(doc.line), - own_source(doc.own_source), - context(doc.context), - root(doc.root), - lexed(doc.lexed) - { ++doc.context.ref_count; } - - Document::~Document() - { --context.ref_count; } - - Document Document::make_from_file(Context& ctx, string path) - { - std::FILE *f; - const char* path_str = path.c_str(); - struct stat st; - string tmp; - - // Resolution order for ambiguous imports: - // (1) filename as given - // (2) underscore + given - // (3) underscore + given + extension - // (4) given + extension - - // if the file as given isn't found ... - if (stat(path_str, &st) == -1 || S_ISDIR(st.st_mode)) { - // then try "_" + given - const char *full_path_str = path.c_str(); - const char *file_name_str = Prelexer::folders(full_path_str); - string folder(Token::make(full_path_str, file_name_str).to_string()); - string partial_filename("_" + string(file_name_str)); - tmp = folder + partial_filename; - path_str = tmp.c_str(); - // if "_" + given isn't found ... - if (stat(path_str, &st) == -1 || S_ISDIR(st.st_mode)) { - // then try "_" + given + ".scss" - tmp += ".scss"; - path_str = tmp.c_str(); - // if "_" + given + ".scss" isn't found ... - if (stat(path_str, &st) == -1 || S_ISDIR(st.st_mode)) { - // then try given + ".scss" - string non_partial_filename(string(file_name_str) + ".scss"); - tmp = folder + non_partial_filename; - path_str = tmp.c_str(); - // if we still can't find the file, then throw an error - if (stat(path_str, &st) == -1 || S_ISDIR(st.st_mode)) { - throw path; - } - } - } - } - f = std::fopen(path_str, "rb"); - size_t len = st.st_size; - char* source = new char[len + 1]; - size_t bytes_read = std::fread(source, sizeof(char), len, f); - if (bytes_read != len) { - std::cerr << "Warning: possible error reading from " << path << std::endl; - } - if (std::ferror(f)) throw path; - source[len] = '\0'; - char* end = source + len; - if (std::fclose(f)) throw path; - const char *file_name_str = Prelexer::folders(path_str); - string include_path(path_str, file_name_str - path_str); - - Document doc(ctx); - doc.path = path_str; - doc.line = 1; - doc.root = ctx.new_Node(Node::root, path, 1, 0); - doc.lexed = Token::make(); - doc.own_source = true; - doc.source = source; - doc.end = end; - doc.position = source; - doc.context.source_refs.push_back(source); - - return doc; - } - - Document Document::make_from_source_chars(Context& ctx, const char* src, string path, bool own_source) - { - Document doc(ctx); - doc.path = path; - doc.line = 1; - doc.root = ctx.new_Node(Node::root, path, 1, 0); - doc.lexed = Token::make(); - doc.own_source = own_source; - doc.source = src; - doc.end = src + std::strlen(src); - doc.position = src; - if (own_source) doc.context.source_refs.push_back(src); - - return doc; - } - - Document Document::make_from_token(Context& ctx, Token t, string path, size_t line_number) - { - Document doc(ctx); - doc.path = path; - doc.line = line_number; - doc.root = ctx.new_Node(Node::root, path, 1, 0); - doc.lexed = Token::make(); - doc.own_source = false; - doc.source = t.begin; - doc.end = t.end; - doc.position = doc.source; - - return doc; - } - - void Document::throw_syntax_error(string message, size_t ln) - { throw Error(Error::syntax, path, ln ? ln : line, message); } - - void Document::throw_read_error(string message, size_t ln) - { throw Error(Error::read, path, ln ? ln : line, message); } - - using std::string; - using std::stringstream; - using std::endl; - - string Document::emit_css(CSS_Style style) { - stringstream output; - switch (style) { - case echo: - root.echo(output); - break; - case nested: - root.emit_nested_css(output, 0, true, false, context.source_comments); - break; - case expanded: - root.emit_expanded_css(output, ""); - break; - case compressed: - root.emit_compressed_css(output); - break; - default: - break; - } - string retval(output.str()); - // trim trailing whitespace - if (!retval.empty()) { - size_t newlines = 0; - size_t i = retval.length(); - while (i--) { - if (retval[i] == '\n') { - ++newlines; - continue; - } - else { - break; - } - } - retval.resize(retval.length() - newlines); - retval += "\n"; - } - return retval; - } -} diff --git a/pysass.cpp b/pysass.cpp index 01dda201..cce25b27 100644 --- a/pysass.cpp +++ b/pysass.cpp @@ -1,5 +1,3 @@ -#include -#include #include #include #include "sass_context.h" diff --git a/setup.py b/setup.py index d44f5959..6ba728ae 100644 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ def spawn(self, cmd): spawn(cmd, dry_run=self.dry_run) from distutils.msvc9compiler import MSVCCompiler MSVCCompiler.spawn = spawn - flags = ['-I' + os.path.abspath('win32'), '/EHsc'] + flags = ['/EHsc'] link_flags = [] else: flags = ['-fPIC', '-std=c++0x', '-Wall', '-Wno-parentheses'] @@ -205,7 +205,7 @@ def run(self): 'README.rst', os.path.join(LIBSASS_DIR, 'Makefile'), os.path.join(LIBSASS_DIR, 'Makefile.am'), - 'win32/*.h', 'test/*.sass' + 'test/*.sass' ] }, scripts=['sassc.py'], diff --git a/win32/unistd.h b/win32/unistd.h deleted file mode 100644 index 2ded7f1a..00000000 --- a/win32/unistd.h +++ /dev/null @@ -1,44 +0,0 @@ -/* http://stackoverflow.com/a/826027/383405 */ -#ifndef _UNISTD_H -#define _UNISTD_H 1 - -/* This file intended to serve as a drop-in replacement for - * unistd.h on Windows - * Please add functionality as neeeded - */ - -#include -#include -#include /* for getpid() and the exec..() family */ -#include /* for _getcwd() */ -#include /* for _S_IFDIR */ - -#define srandom srand -#define random rand - -/* Values for the second argument to access. - These may be OR'd together. */ -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -//#define X_OK 1 /* execute permission - unsupported in windows*/ -#define F_OK 0 /* Test for existence. */ - -#define access _access -#define ftruncate _chsize -#define getcwd _getcwd -#define S_ISDIR(B) ((B)&_S_IFDIR) - -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -/* should be in some equivalent to */ -typedef __int8 int8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; - -#endif /* unistd.h */