Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #254 from picrin-scheme/c89-porting
Browse files Browse the repository at this point in the history
C89 porting
  • Loading branch information
nyuichi committed Feb 1, 2015
2 parents 7997af4 + b727567 commit a90a90e
Show file tree
Hide file tree
Showing 15 changed files with 334 additions and 430 deletions.
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
set(CMAKE_C_FLAGS "-O2 -Wall -Wextra")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG=1")

option(USE_C11_FEATURE "Enable c11 feature" OFF)
if(USE_C11_FEATURE)
add_definitions(-std=c11)
else()
add_definitions(-std=c99) # at least c99 is required
option(STRICT_C89_MODE "Strict c89 mode" OFF)
if(STRICT_C89_MODE)
add_definitions(-std=c89 -ansi -pedantic)
endif()

include_directories(extlib/benz/include)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/picrin-scheme/picrin.png)](https://travis-ci.org/picrin-scheme/picrin)
[![Docs Status](https://readthedocs.org/projects/picrin/badge/?version=latest)](https://picrin.readthedocs.org/)

Picrin is a lightweight scheme implementation intended to comply with full R7RS specification. Its code is written in pure C99 and does not require any special external libraries installed on the platform.
Picrin is a lightweight scheme implementation intended to comply with full R7RS specification. Its code is written in pure C89 and does not require any special external libraries installed on the platform.

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion contrib/10.regexp/src/regexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pic_regexp_regexp(pic_state *pic)
reg->flags = flags;

if ((err = regcomp(&reg->reg, ptrn, cflags)) != 0) {
char errbuf[regerror(err, &reg->reg, NULL, 0)];
char errbuf[256];

regerror(err, &reg->reg, errbuf, sizeof errbuf);
regexp_dtor(pic, &reg->reg);
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Introduction
============

Picrin is a lightweight scheme implementation intended to comply with full R7RS specification. Its code is written in pure C99 and does not require any special external libraries installed on the platform.
Picrin is a lightweight scheme implementation intended to comply with full R7RS specification. Its code is written in pure C89 and does not require any special external libraries installed on the platform.

- R7RS compatibility
- reentrant design (all VM states are stored in single global state object)
Expand Down
18 changes: 11 additions & 7 deletions etc/mkloader.pl
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@

foreach my $file (@ARGV) {
my $var = &escape_v($file);
print "static const char *$var =\n";
print "static const char ${var}[][80] = {\n";

open IN, $file;
while (<IN>) {
chomp;
local $/ = undef;
my $src = <IN>;
close IN;

my @lines = $src =~ /.{0,80}/gs;
foreach (@lines) {
s/\\/\\\\/g;
s/"/\\"/g;
print "\"$_\\n\"\n";
s/\n/\\n/g;
print "\"$_\",\n";
}
print ";\n\n";
print "};\n\n";
}
close IN;

print <<EOL;
void
Expand All @@ -42,7 +46,7 @@
my $var = &escape_v($file);
my $basename = basename($file);
my $dirname = basename(dirname($file));
print " pic_load_cstr(pic, $var);\n";
print " pic_load_cstr(pic, &${var}[0][0]);\n";
print<<EOL
}
pic_catch {
Expand Down
Loading

0 comments on commit a90a90e

Please sign in to comment.