summaryrefslogtreecommitdiffhomepage
path: root/mixlib
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2004-06-06 23:35:35 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2004-06-06 23:35:35 +0000
commit09128780c9d19785c4b1ca5b3928fe3968fd282b (patch)
treef0d5b2456972c504009d3eafbdfd486a84d85292 /mixlib
parenta2d52ab5fea1b291d4cda0e7c792e2d0bb36f834 (diff)
downloadmdk-09128780c9d19785c4b1ca5b3928fe3968fd282b.tar.gz
mdk-09128780c9d19785c4b1ca5b3928fe3968fd282b.tar.bz2
(read_): blocks in input char devices must be separated by newline characters.
Diffstat (limited to 'mixlib')
-rw-r--r--mixlib/xmix_device.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/mixlib/xmix_device.c b/mixlib/xmix_device.c
index 47b6397..92d9c4f 100644
--- a/mixlib/xmix_device.c
+++ b/mixlib/xmix_device.c
@@ -4,21 +4,21 @@
* Last change: Time-stamp: "2001-05-10 01:10:25 jao"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
*/
@@ -41,8 +41,8 @@ const size_t SIZES_[] = {
};
const mix_device_mode_t MODES_[] = {
- mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN,
- mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN,
+ mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN,
+ mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN,
mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN, mix_dev_BIN,
mix_dev_BIN, mix_dev_CHAR, mix_dev_CHAR, mix_dev_CHAR, mix_dev_CHAR,
mix_dev_CHAR
@@ -97,12 +97,11 @@ construct_device_with_file_ (mix_device_t *result,
}
-
/*
Write a block to the device.
*/
static gboolean
-write_ (mix_device_t *dev, const mix_word_t *block)
+write_ (mix_device_t *dev, const mix_word_t *block)
{
gboolean result;
@@ -113,37 +112,51 @@ write_ (mix_device_t *dev, const mix_word_t *block)
else
result = mix_io_write_word_array (GET_CHANNEL_ (dev),
block, SIZES_[dev->type]);
- if (result && mix_device_mode(dev) == mix_dev_CHAR)
+ if (result && mix_device_mode(dev) == mix_dev_CHAR)
putc ('\n', mix_io_to_FILE (GET_CHANNEL_ (dev)));
fflush (mix_io_to_FILE (GET_CHANNEL_ (dev)));
-
+
return result;
}
static gboolean
-read_ (mix_device_t *dev, mix_word_t *block)
+read_ (mix_device_t *dev, mix_word_t *block)
{
+ gboolean result;
+
if (FMODES_[dev->type] == mix_io_WRITE) return FALSE;
if (MODES_[dev->type] == mix_dev_CHAR)
- return mix_io_read_word_array_as_char (GET_CHANNEL_ (dev),
- block, SIZES_[dev->type]);
+ {
+ result = mix_io_read_word_array_as_char (GET_CHANNEL_ (dev),
+ block, SIZES_[dev->type]);
+ if (result)
+ {
+ int c;
+ FILE *f = mix_io_to_FILE (GET_CHANNEL_ (dev));
+ do {
+ c = getc (f);
+ } while (c != EOF && c != '\n');
+ }
+ }
else
- return mix_io_read_word_array (GET_CHANNEL_ (dev),
- block, SIZES_[dev->type]);
+ result = mix_io_read_word_array (GET_CHANNEL_ (dev),
+ block, SIZES_[dev->type]);
+
+ return result;
}
static gboolean
-ioc_ (mix_device_t *dev, mix_short_t arg)
+ioc_ (mix_device_t *dev, mix_short_t arg)
{
int m;
FILE *file;
-
+
m = mix_short_magnitude(arg);
if (mix_short_is_negative(arg)) m = -m;
m *= sizeof (mix_word_t) * SIZES_[dev->type];
file = mix_io_to_FILE (GET_CHANNEL_(dev));
-
+
if (dev->type >= mix_dev_TAPE_0 && dev->type <= mix_dev_TAPE_7)
{
if (m == 0) rewind (file);