diff options
author | axel <axel@liljencrantz.se> | 2005-10-19 22:07:44 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2005-10-19 22:07:44 +1000 |
commit | 83fcc293055a8eb9b94171cc0c665a9691d08f01 (patch) | |
tree | e007a2840d292fffe42b1e2ada14ecf9196b402b /main.c | |
parent | 4fb2dc3f55f1b55ba9893a7f4a321bb641451539 (diff) |
Do not break stdin when reading a script
darcs-hash:20051019120744-ac50b-67cc9a5c4f6509eb8a012aff32fcd9606933d0ab.gz
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -235,7 +235,7 @@ int main( int argc, char **argv ) if( my_optind == argc ) { reader_push_current_filename( L"(stdin)" ); - res = reader_read(); + res = reader_read( 0 ); reader_pop_current_filename(); } else @@ -244,13 +244,9 @@ int main( int argc, char **argv ) char *file = *(argv+1); int i; string_buffer_t sb; - - if( close( 0 ) ) - { - wperror(L"close"); - return 1; - } - if( open(file, O_RDONLY) == -1 ) + int fd; + + if( ( fd = open(file, O_RDONLY) ) == -1 ) { wperror( L"open" ); return 1; @@ -274,7 +270,7 @@ int main( int argc, char **argv ) } reader_push_current_filename( str2wcs( file ) ); - res = reader_read(); + res = reader_read( fd ); if( res ) { |