commit 441c56bfe9ef475e12e9d169a415137443f19f89 Author: Egeyar Bagcioglu Date: Sat Jan 11 22:32:41 2020 +0100 Add a new argument, set_cur to ios_open. diff --git a/ChangeLog b/ChangeLog index a5320800..67bfc04b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2020-01-11 Egeyar Bagcioglu + + * src/ios.c (ios_open): Add argument set_cur to control making + the newly opened IO space the current IO space. + * src/ios.h (ios_open): Add the new argument, set_cur. + * src/poke.c (parse_args): Call ios_open with set_cur 1. + * src/pk-file.c (pk_cmd_file): Likewise. + * src/pvm.jitter (instruction open): Likewise. + 2020-01-11 Egeyar Bagcioglu * src/ios.c (ios_write_int_common): Add specifiers "static inline". diff --git a/src/ios.c b/src/ios.c index 53ab61fd..58d203d1 100644 --- a/src/ios.c +++ b/src/ios.c @@ -159,7 +159,7 @@ ios_shutdown (void) } int -ios_open (const char *handler) +ios_open (const char *handler, int set_cur) { struct ios *io = NULL; struct ios_dev_if **dev_if = NULL; @@ -193,7 +193,8 @@ ios_open (const char *handler) io->next = io_list; io_list = io; - cur_io = io; + if (set_cur == 1) + cur_io = io; return io->id; diff --git a/src/ios.h b/src/ios.h index e748d2b0..e09c8800 100644 --- a/src/ios.h +++ b/src/ios.h @@ -106,11 +106,12 @@ typedef int64_t ios_off; The functions declared below are used to manage this collection. */ -/* Open an IO space using a handler and make it the current space. - Return IOS_ERROR if there is an error opening the space (such as an - unrecognized handler), the ID of the new IOS otherwise. */ +/* Open an IO space using a handler and if set_cur is set to 1, make + the newly opened IO space the current space. Return IOS_ERROR if + there is an error opening the space (such as an unrecognized + handler), the ID of the new IOS otherwise. */ -int ios_open (const char *handler); +int ios_open (const char *handler, int set_cur); /* Close the given IO space, freing all used resources and flushing the space cache associated with the space. */ diff --git a/src/pk-file.c b/src/pk-file.c index 39939491..52f00f77 100644 --- a/src/pk-file.c +++ b/src/pk-file.c @@ -127,7 +127,7 @@ pk_cmd_file (int argc, struct pk_cmd_arg argv[], uint64_t uflags) } errno = 0; - if (IOS_ERROR == ios_open (filename)) + if (IOS_ERROR == ios_open (filename, 1)) { pk_printf (_("Error opening %s: %s\n"), filename, strerror (errno)); diff --git a/src/poke.c b/src/poke.c index b8e98efe..a945c940 100644 --- a/src/poke.c +++ b/src/poke.c @@ -287,7 +287,7 @@ parse_args (int argc, char *argv[]) if (optind < argc) { - if (ios_open (argv[optind++]) == IOS_ERROR) + if (ios_open (argv[optind++], 1) == IOS_ERROR) goto exit_failure; optind++; diff --git a/src/pvm.jitter b/src/pvm.jitter index fa53d6ca..14801b38 100644 --- a/src/pvm.jitter +++ b/src/pvm.jitter @@ -609,7 +609,7 @@ end instruction open () # ( STR -- INT ) code char *filename = PVM_VAL_STR (JITTER_TOP_STACK ()); - int ret = ios_open (filename); + int ret = ios_open (filename, 1); if (ret == IOS_ERROR) PVM_RAISE (PVM_E_IO);