diff options
author | Adrian Thurston <thurston@complang.org> | 2014-10-20 13:13:17 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2014-10-20 13:13:17 -0400 |
commit | b80b33c1aed3249526fda05fb1a448daf7e95e23 (patch) | |
tree | c51a4d8b58d06ae46aa3bdff7c0e9623c76b22ca | |
parent | 4fb75c4ef62e8b543d27a8fb269c0ff0d35fe8af (diff) | |
download | colm-b80b33c1aed3249526fda05fb1a448daf7e95e23.tar.gz |
added the append open mode ('a')
-rw-r--r-- | src/tree.c | 2 | ||||
-rw-r--r-- | test/open2.lm | 23 |
2 files changed, 25 insertions, 0 deletions
@@ -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 |