summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2014-10-20 13:13:17 -0400
committerAdrian Thurston <thurston@complang.org>2014-10-20 13:13:17 -0400
commitb80b33c1aed3249526fda05fb1a448daf7e95e23 (patch)
treec51a4d8b58d06ae46aa3bdff7c0e9623c76b22ca
parent4fb75c4ef62e8b543d27a8fb269c0ff0d35fe8af (diff)
downloadcolm-b80b33c1aed3249526fda05fb1a448daf7e95e23.tar.gz
added the append open mode ('a')
-rw-r--r--src/tree.c2
-rw-r--r--test/open2.lm23
2 files changed, 25 insertions, 0 deletions
diff --git a/src/tree.c b/src/tree.c
index 2f0aaa39..ca7b9d6a 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -218,6 +218,8 @@ Stream *openFile( Program *prg, Tree *name, Tree *mode )
fopenMode = "rb";
else if ( memcmp( givenMode, "w", stringLength(headMode) ) == 0 )
fopenMode = "wb";
+ else if ( memcmp( givenMode, "a", stringLength(headMode) ) == 0 )
+ fopenMode = "ab";
else {
fatal( "unknown file open mode: %s\n", givenMode );
}
diff --git a/test/open2.lm b/test/open2.lm
new file mode 100644
index 00000000..5bbf9e02
--- /dev/null
+++ b/test/open2.lm
@@ -0,0 +1,23 @@
+##### LM #####
+lex
+ token t /any*/
+end
+
+def d [t]
+
+int testAppend( Fn: str Mode: str )
+{
+ S: stream = open( Fn Mode )
+ send S "colm networks
+}
+
+testAppend( 'working/open2.w' ('w') )
+testAppend( 'working/open2.w' ('a') )
+
+S: stream = open( 'working/open2.w' ('r') )
+parse D: d [S]
+print( D )
+
+##### EXP #####
+colm networks
+colm networks