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
commit6f8f0de3baab46caa027662020f06824375fbb07 (patch)
tree81c3d161282ca145e9406ece1355a5372950d01c /mixlib
parent66750c39f3181bd993d51188cd28ecbc80748946 (diff)
downloadmdk-6f8f0de3baab46caa027662020f06824375fbb07.tar.gz
mdk-6f8f0de3baab46caa027662020f06824375fbb07.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);