Skip to content

Commit

Permalink
version 4.0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ab25cq committed May 3, 2018
1 parent fe96f5b commit 6f480ae
Show file tree
Hide file tree
Showing 27 changed files with 390 additions and 33 deletions.
1 change: 1 addition & 0 deletions ABC
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEF
182 changes: 182 additions & 0 deletions CGI.clcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class System
LC_PAPER: static int;
LC_TELEPHONE: static int;
LC_TIME:static int;

LOCK_SH: static int;
LOCK_EX: static int;
LOCK_UN: static int;

def setlocale(category:int, locale:String): static native String throws Exception;

Expand All @@ -24,8 +28,186 @@ class System
inherit();
System.initialize_cgi_system();
}

def flock(fd:int, operation:int): static native throws Exception;
}

class CGI
{
}

module MCSVFileToList
{
def putcsv(fname:String) {
if(self.length() > 0) {
file := File(fname, "w");

item := self.head.item;

if(item.className().equals("String")) {
self2:SELF<String> = self.toAnonymous();

n := 0;

self2.each {
qit := it.quotedString();
file.write(qit);

if(n != self2.length()-1) {
file.write(",");
}

n++;
}
}

file.close();
}
}
}

class List <T:Object>
{
include MCSVFileToList;
}

class EqualableList <T:IEqualable>
{
include MCSVFileToList;
}

class SortableList<T:ISortable>
{
include MCSVFileToList;
}

class File
{
def createListFromCSV(fname:String): static SortableList<String> {
result := SortableList<String>();

file := p"\{fname}".read().toString();

str:= "";

for(i:=0; i<file.length(); i++) {
c := file.chars(i);

if(c == '\\') {
c2 := file.chars(i+1);
i++;

if(c2 != '\0') {
str.append(c2);
}
}
elif(c == ',') {
result.add(str);

str = "";
}
else {
str.append(c);
}
}

if(str.length() != 0) {
result.add(str);
}

return result;
}

def lock(shared:bool) throws Exception {
if(self.fd == -1 && self.stream.identifyWith(null)) {
throw Exception("Can't find file descriptor");
}

if(!self.stream.identifyWith(null)) {
fd:int = fileno(self.stream);

if(shared) {
flock(fd, System.LOCK_SH);
}
else {
flock(fd, System.LOCK_EX);
}
}
else {
if(shared) {
flock(self.fd, System.LOCK_SH);
}
else {
flock(self.fd, System.LOCK_EX);
}
}
}

def unlock() throws Exception {
if(self.fd == -1 && self.stream.identifyWith(null)) {
throw Exception("Can't find file descriptor");
}

if(!self.stream.identifyWith(null)) {
fd:int = fileno(self.stream);

flock(fd, System.LOCK_UN);
}
else {
flock(fd, System.LOCK_UN);
}
}

def lockBlock(fname:String, shared:bool, block:lambda()): static throws Exception {
file:File = new File(fname, "w");
file.lock(shared);
block();
file.unlock();
file.close();
#unlink(fname);
}

def lockBlock(shared:bool, block:lambda()) throws Exception {
self.lock(shared);
block();
self.unlock();
}
}

class String
{
def quotedString():String {
result := "";
for(i:int = 0; i<self.length(); i++) {
c := self.chars(i);
if((c <= 127) && !((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))) {
result.append('\\');
result.append(c);
}
else {
result.append(c);
}
}

return result;
}

def getPlainTextFromQuotedString(): String {
result := "";
for(i:int = 0; i<self.length(); i++) {
c := self.chars(i);
if(c == '\\') {
c2 := self.chars(i+1);
if(c2 != '\0') {
result.append(c2);
}
i++;
}
else {
result.append(c);
}
}

return result;
}
}
16 changes: 16 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@

version 4.0.2

CSVファイルの入出力をサポート。ファイルのロック用のメソッドの用意。

コンパイラーにバグがありました。修正。

JITのバグを修正

version 4.0.2

CSV File was supported. flock was supported.

Fixed compiler bug.

Fixed JIT bug.

version 4.0.1

CGIのためのライブラリを作り始めています。System.setlocaleの追加。System.setenvの第3引数を省略できるようにしました。
Expand Down
1 change: 0 additions & 1 deletion Container.clcl
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,6 @@ module MEqualableList
}

def join():String {
println("join2");
return self.join("");
}

Expand Down
6 changes: 6 additions & 0 deletions File.clcl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class System
def getcwd(): native static String throws Exception;

def put_fun_to_hash_for_native_method(path:String, fun_name:String, native_method:pointer): static native;

def fileno(stream:pointer@FILE): native static int;
}

class tm
Expand Down Expand Up @@ -492,6 +494,10 @@ class File
def write(buf:Buffer):int throws Exception {
return self.write(buf, buf.len);
}
def write(str:String):int throws Exception {
buf := str.toBuffer();
return self.write(buf);
}

def write(file_name:String, buf:Buffer, mode:mode_t): static int throws Exception
{
Expand Down
1 change: 1 addition & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ test: parser
PWD=`pwd` ./cclover2 code/SystemCallTest.clcl
PWD=`pwd` ./cclover2 code/ReflectionTest.clcl
PWD=`pwd` ./cclover2 code/AllocSize.clcl
PWD=`pwd` ./cclover2 code/CGITest.clcl
PWD=`pwd` ./clover2 code/main.cl

if locale -a | grep ja_JP.utf8; then export LANG="ja_JP_utf8"; export LC_ALL="ja_JP.utf8"; PWD=`pwd` ./clover2 code/char.cl; else export LANG="C.UTF-8"; export LC_ALL="C.UTF-8"; PWD=`pwd` ./clover2 code/char.cl; fi
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# clover2 computer language

[![Build Status](https://travis-ci.org/ab25cq/clover2.svg?branch=master)](https://travis-ci.org/ab25cq/clover2)
version 4.0.1
version 4.0.2

サポートしている機能

Expand Down
1 change: 1 addition & 0 deletions a.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A\,A\,A,B\,B\,B,C\+C\+C
Empty file added a.lock
Empty file.
48 changes: 48 additions & 0 deletions code/CGITest.clcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class CGITest
{
def main():static {
a := "aaa+:c&";

Clover.test("CGI test1", a.quotedString().equals("aaa\\+\\:c\\&"));
Clover.test("CGI test2", a.quotedString().getPlainTextFromQuotedString().equals("aaa+:c&"));

for(i:=0; i<100; i++) {
pid := fork() {
File.lockBlock("a.lock", true) {
"ABC".write("ABC");
}

exit(0);
}

File.lockBlock("a.lock", true) {
"DEF".write("ABC");
}

status:wait_status = 0;
waitpid(pid, &status, System.WUNTRACED);
}

Clover.test("CGI test3", true);

b := slist { "AAA", "BBB", "CCC" };

b.putcsv("a.csv");

Clover.test("CGI test4", p"a.csv".read().toString().equals("AAA,BBB,CCC"));

c := File.createListFromCSV("a.csv");

Clover.test("CGI test5", c.equals(slist { "AAA", "BBB", "CCC" }));

d := slist { "A,A,A", "B,B,B", "C+C+C" };

d.putcsv("a.csv");

e := File.createListFromCSV("a.csv");

e.toString().println();

Clover.test("CGI test6", e.equals(slist { "A,A,A", "B,B,B", "C+C+C" }));
}
}
2 changes: 2 additions & 0 deletions code/main.cl
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,5 @@ println("RefelectionTest");
ReflectionTest.main();
println("AllocaSizeClass");
AllocSizeClass.main();
println("CGITest");
CGITest.main();
4 changes: 4 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

clover2 (4.0.2-1) unstable; urgency=medium

* CSV File was supported. flock was supported. Fixed compiler bug. Fixed JIT bug.

clover2 (4.0.1-1) unstable; urgency=medium

* Started to make CGI library. System.setlocale was appended. Fixed compiler bug.
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Section: unknown
Priority: optional
Maintainer: Daisuke Minato <[email protected]>
Build-Depends: debhelper (>= 9), autotools-dev, libpcre3-dev, libreadline-dev, clang, libreadline7
Standards-Version: 4.0.1
Standards-Version: 4.0.2
Homepage: https://github.com/ab25cq/clover2/wiki
Vcs-Git: https://github.com/ab25cq/clover2.git

Expand Down
6 changes: 3 additions & 3 deletions debian/files
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
clover2-dbgsym_4.0.1-1_amd64.deb debug extra
clover2_4.0.1-1_amd64.buildinfo unknown optional
clover2_4.0.1-1_amd64.deb unknown optional
clover2-dbgsym_4.0.2-1_amd64.deb debug extra
clover2_4.0.2-1_amd64.buildinfo unknown optional
clover2_4.0.2-1_amd64.deb unknown optional
8 changes: 4 additions & 4 deletions install_deb.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/bin/bash

if test -e ../clover2_4.0.1-1_i386.deb
if test -e ../clover2_4.0.2-1_i386.deb
then
if dpkg -l | egrep ^clover2
then
sudo apt-get remove clover2
fi

sudo dpkg -i ../clover2_4.0.1-1_i386.deb
sudo dpkg -i ../clover2_4.0.2-1_i386.deb
fi

if test -e ../clover2_4.0.1-1_amd64.deb
if test -e ../clover2_4.0.2-1_amd64.deb
then
if dpkg -l | egrep ^clover2
then
sudo apt-get remove clover2
fi

sudo dpkg -i ../clover2_4.0.1-1_amd64.deb
sudo dpkg -i ../clover2_4.0.2-1_amd64.deb
fi
Loading

0 comments on commit 6f480ae

Please sign in to comment.