Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sass on apple #87

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blah/blah.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"fmt"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"path/filepath"
"strings"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

// Context handles the interactions with libsass. Context
Expand Down
2 changes: 1 addition & 1 deletion context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"testing"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

func TestContextFile(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"strings"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"testing"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

type unsupportedStruct struct {
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"os"

libsass "github.com/wellington/go-libsass"
libsass "github.com/tom-un/go-libsass"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/customfunc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"log"
"os"

"github.com/wellington/go-libsass"
"github.com/tom-un/go-libsass"
)

// cryptotext is of type libsass.SassFunc. As libsass compiles the
Expand Down
2 changes: 1 addition & 1 deletion examples/custompreamble/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"os"

"github.com/wellington/go-libsass"
"github.com/tom-un/go-libsass"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/options/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"os"

libsass "github.com/wellington/go-libsass"
libsass "github.com/tom-un/go-libsass"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion export.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package libsass

import "github.com/wellington/go-libsass/libs"
import "github.com/tom-un/go-libsass/libs"

// Error takes a Go error and returns a libsass Error
func Error(err error) SassValue {
Expand Down
2 changes: 1 addition & 1 deletion func.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"sync"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

var ghMu sync.RWMutex
Expand Down
2 changes: 1 addition & 1 deletion func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

func TestFunc_simpletypes(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/wellington/go-libsass
module github.com/tom-un/go-libsass

go 1.18

Expand Down
2 changes: 1 addition & 1 deletion header.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"strconv"
"sync"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

var globalHeaders []string
Expand Down
2 changes: 1 addition & 1 deletion importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

var (
Expand Down
41 changes: 32 additions & 9 deletions libsass-build/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "utf8_string.hpp"
#include "sass_functions.hpp"
#include "sass2scss.h"
#include <fcntl.h>

#ifdef _WIN32
# include <windows.h>
Expand Down Expand Up @@ -429,22 +430,44 @@ namespace Sass {
CloseHandle(hFile);
// just convert from unsigned char*
char* contents = (char*) pBuffer;
#else
#elif __APPLE__
// TODO: waiting for https://github.com/sass/libsass/pull/3183 to be merged.
// On OSX `fopen` can fail with "too many open files" but succeeds using `open`.
struct stat st;
if (stat(path.c_str(), &st) == -1 || S_ISDIR(st.st_mode)) return 0;
std::ifstream file(path.c_str(), std::ios::in | std::ios::binary | std::ios::ate);
int file = open(path.c_str(), O_RDONLY);
char* contents = 0;
if (file.is_open()) {
size_t size = file.tellg();
// allocate an extra byte for the null char
// and another one for edge-cases in lexer
if (file != -1) {
size_t size = st.st_size;
contents = (char*) malloc((size+2)*sizeof(char));
file.seekg(0, std::ios::beg);
file.read(contents, size);
read(file, contents, size);
contents[size+0] = '\0';
contents[size+1] = '\0';
file.close();
close(file);
}
#else
// Read the file using `<cstdio>` instead of `<fstream>` for better portability.
// The `<fstream>` header initializes `<locale>` and this buggy in GCC4/5 with static linking.
// See:
// https://www.spinics.net/lists/gcchelp/msg46851.html
// https://github.com/sass/sassc-ruby/issues/128
struct stat st;
if (stat(path.c_str(), &st) == -1 || S_ISDIR(st.st_mode)) return 0;
FILE* fd = std::fopen(path.c_str(), "rb");
if (fd == nullptr) return nullptr;
const std::size_t size = st.st_size;
char* contents = static_cast<char*>(malloc(st.st_size + 2 * sizeof(char)));
if (std::fread(static_cast<void*>(contents), 1, size, fd) != size) {
free(contents);
std::fclose(fd);
return nullptr;
}
if (std::fclose(fd) != 0) {
free(contents);
return nullptr;
}
contents[size] = '\0';
contents[size + 1] = '\0';
#endif
std::string extension;
if (path.length() > 5) {
Expand Down
2 changes: 1 addition & 1 deletion toscss.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package libsass
import (
"io"

"github.com/wellington/go-libsass/libs"
"github.com/tom-un/go-libsass/libs"
)

// ToScss converts Sass to Scss with libsass sass2scss.h
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package libsass

import "github.com/wellington/go-libsass/libs"
import "github.com/tom-un/go-libsass/libs"

// Version reports libsass version information
func Version() string {
Expand Down