summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Blandy <jimb@red-bean.com>1999-09-16 05:21:06 +0000
committerJim Blandy <jimb@red-bean.com>1999-09-16 05:21:06 +0000
commit9553eaa41304337917f7f18d97d31b70dfa39d45 (patch)
treeca90440bc91d4d8d14c514a436603e33c3371276
parent05b2e765175016ca1dbb62332aa3b8ac19e68820 (diff)
downloadguile-jimb_mb_branch_1.tar.gz
* mb.c, mb.h, mbconv.c, mbconv.h, mbbasic.c, check_mb.c:jimb_mb_branch_1
(scm_mb_char_len): Renamed from scm_mb_len_char. (scm_mb_char_len_func): Renamed from scm_mb_len_char_func. (scm_mb_put, scm_mb_put_func): Swapped arguments, so destination comes first. (scm_mb_iconv_too_big): Renamed from scm_mb_iconv_more_room.
-rw-r--r--libguile/check_mb.c10
-rw-r--r--libguile/mb.c92
-rw-r--r--libguile/mb.h10
-rw-r--r--libguile/mbbasic.c10
-rw-r--r--libguile/mbconv.c8
-rw-r--r--libguile/mbconv.h4
6 files changed, 69 insertions, 65 deletions
diff --git a/libguile/check_mb.c b/libguile/check_mb.c
index 5e1f2cb96..f913e141f 100644
--- a/libguile/check_mb.c
+++ b/libguile/check_mb.c
@@ -112,8 +112,8 @@ test_one_char_encodings ()
int i;
int len;
- /* scm_mb_len_char should return a sane value. */
- len = scm_mb_len_char (p->character);
+ /* scm_mb_char_len should return a sane value. */
+ len = scm_mb_char_len (p->character);
if (len <= 0 || len > scm_mb_max_len)
exit (1);
if (len != p->encoding_length)
@@ -122,7 +122,7 @@ test_one_char_encodings ()
/* scm_mb_put should return the same length, and write that many
characters, but no more. */
memset (buffer, 1, sizeof (buffer));
- if (scm_mb_put (p->character, buffer) != len)
+ if (scm_mb_put (buffer, p->character) != len)
exit (1);
for (i = 0; i < len; i++)
if (buffer[i] == 1)
@@ -215,7 +215,7 @@ test_string_encodings ()
{
start[i] = t - buffer;
p = &pairs[perm[i]];
- t += scm_mb_put (p->character, t);
+ t += scm_mb_put (t, p->character);
bytes += p->encoding_length;
}
if (t != buffer + bytes)
@@ -473,7 +473,7 @@ one_conversion (const char *code1, const char *code2,
&outptr, &outbytesleft);
if (split < text2_len)
{
- if (result != scm_mb_iconv_more_room)
+ if (result != scm_mb_iconv_too_big)
exit (1);
}
else
diff --git a/libguile/mb.c b/libguile/mb.c
index a449c7d4d..0ccb811d7 100644
--- a/libguile/mb.c
+++ b/libguile/mb.c
@@ -1,43 +1,47 @@
-/* Copyright (C) 1999 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, 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 software; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307 USA
- *
- * As a special exception, the Free Software Foundation gives permission
- * for additional uses of the text contained in its release of GUILE.
- *
- * The exception is that, if you link the GUILE library with other files
- * to produce an executable, this does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * Your use of that executable is in no way restricted on account of
- * linking the GUILE library code into it.
- *
- * This exception does not however invalidate any other reasons why
- * the executable file might be covered by the GNU General Public License.
- *
- * This exception applies only to the code released by the
- * Free Software Foundation under the name GUILE. If you copy
- * code from other Free Software Foundation releases into a copy of
- * GUILE, as the General Public License permits, the exception does
- * not apply to the code that you add in this way. To avoid misleading
- * anyone as to the status of such modified files, you must delete
- * this exception notice from them.
- *
- * If you write modifications of your own for GUILE, it is your choice
- * whether to permit this exception to apply to your modifications.
- * If you do not wish that, delete this exception notice. */
+/* mb.c --- functions for dealing with multibyte text
+ Jim Blandy <jimb@red-bean.com> --- August 1999
+
+ Copyright (C) 1999 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, 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 software; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307 USA
+
+ As a special exception, the Free Software Foundation gives permission
+ for additional uses of the text contained in its release of GUILE.
+
+ The exception is that, if you link the GUILE library with other files
+ to produce an executable, this does not by itself cause the
+ resulting executable to be covered by the GNU General Public License.
+ Your use of that executable is in no way restricted on account of
+ linking the GUILE library code into it.
+
+ This exception does not however invalidate any other reasons why
+ the executable file might be covered by the GNU General Public License.
+
+ This exception applies only to the code released by the
+ Free Software Foundation under the name GUILE. If you copy
+ code from other Free Software Foundation releases into a copy of
+ GUILE, as the General Public License permits, the exception does
+ not apply to the code that you add in this way. To avoid misleading
+ anyone as to the status of such modified files, you must delete
+ this exception notice from them.
+
+ If you write modifications of your own for GUILE, it is your choice
+ whether to permit this exception to apply to your modifications.
+ If you do not wish that, delete this exception notice. */
+
/* Headers. */
@@ -105,7 +109,7 @@ scm_mb_get_func (const unsigned char *p)
}
int
-scm_mb_put_func (scm_char_t c, unsigned char *p)
+scm_mb_put_func (unsigned char *p, scm_char_t c)
{
if (c < 0)
return 0;
@@ -167,7 +171,7 @@ scm_mb_len_func (unsigned char b)
}
int
-scm_mb_len_char_func (scm_char_t c)
+scm_mb_char_len_func (scm_char_t c)
{
return (IS_ASCII_CHAR (c) ? 1
: c < FIRST_CHAR1O ? 0 : c <= LAST_CHAR1O ? 2
@@ -404,12 +408,12 @@ scm_mb_fixed_to_multibyte (const scm_char_t *fixed, int len, int *result_len)
over the string like this than to possibly recopy it. */
buf_size = 0;
for (i = 0; i < len; i++)
- buf_size += scm_mb_len_char (fixed[i]);
+ buf_size += scm_mb_char_len (fixed[i]);
buf = scm_must_malloc (buf_size + 1, "scm_mb_fixed_to_multibyte");
p = buf;
for (i = 0; i < len; i++)
- p += scm_mb_put (fixed[i], p);
+ p += scm_mb_put (p, fixed[i]);
/* Was the size we computed actually correct? */
if (p != buf + buf_size)
diff --git a/libguile/mb.h b/libguile/mb.h
index d4a5fb13a..0e0ce4ba2 100644
--- a/libguile/mb.h
+++ b/libguile/mb.h
@@ -77,9 +77,9 @@ extern scm_char_t scm_mb_get_func (const unsigned char *p);
/* Store the encoding of the Guile character C at P, and return the
encoding's length in bytes. */
-#define scm_mb_put(c, p) \
- ((c) < 128 ? (*(p) = c, 1) : scm_mb_put_func ((c), (p)))
-extern int scm_mb_put_func (scm_char_t c, unsigned char *p);
+#define scm_mb_put(p, c) \
+ ((c) < 128 ? (*(p) = c, 1) : scm_mb_put_func ((p), (c)))
+extern int scm_mb_put_func (unsigned char *p, scm_char_t c);
/* The length of the longest character encoding, in bytes. */
#define scm_mb_max_len (4)
@@ -94,8 +94,8 @@ extern int scm_mb_put_func (scm_char_t c, unsigned char *p);
extern int scm_mb_len_func (unsigned char b);
/* Given a Guile character, return the length of its encoding. */
-#define scm_mb_len_char(c) (scm_mb_len_char_func(c))
-extern int scm_mb_len_char_func (scm_char_t c);
+#define scm_mb_char_len(c) (scm_mb_char_len_func(c))
+extern int scm_mb_char_len_func (scm_char_t c);
diff --git a/libguile/mbbasic.c b/libguile/mbbasic.c
index c70e39741..55c924cfb 100644
--- a/libguile/mbbasic.c
+++ b/libguile/mbbasic.c
@@ -104,7 +104,7 @@ emacs_mule_write (void *cookie,
while (in < in_end)
{
- const char *next = out + scm_mb_len_char (*in);
+ const char *next = out + scm_mb_char_len (*in);
if (next > out_end)
{
*inbuf = in;
@@ -112,10 +112,10 @@ emacs_mule_write (void *cookie,
*outbuf = out;
*outbytesleft = out_end - out;
- return scm_mb_write_more_room;
+ return scm_mb_write_too_big;
}
- out += scm_mb_put (*in, out);
+ out += scm_mb_put (*out, in);
in++;
}
@@ -194,7 +194,7 @@ iso8859_write (void *priv,
*outbuf = out;
*outbytesleft = out_end - out;
- return scm_mb_write_more_room;
+ return scm_mb_write_too_big;
}
c = *in++;
@@ -311,7 +311,7 @@ us_ascii_write (void *priv,
*outbuf = out;
*outbytesleft = out_end - out;
- return scm_mb_write_more_room;
+ return scm_mb_write_too_big;
}
c = *in++;
diff --git a/libguile/mbconv.c b/libguile/mbconv.c
index 6d586fed1..1b4995ac2 100644
--- a/libguile/mbconv.c
+++ b/libguile/mbconv.c
@@ -271,7 +271,7 @@ scm_mb_iconv (struct scm_mb_iconv *context,
switch (errno)
{
case EILSEQ: return scm_mb_iconv_bad_encoding;
- case E2BIG: return scm_mb_iconv_more_room;
+ case E2BIG: return scm_mb_iconv_too_big;
case EINVAL: return scm_mb_iconv_incomplete_encoding;
default:
scm_syserror ("scm_mb_iconv");
@@ -303,7 +303,7 @@ scm_mb_iconv (struct scm_mb_iconv *context,
while (*inbytesleft > 0 || ours->valid > 0)
{
if (! outbuf || *outbytesleft <= 0)
- return scm_mb_iconv_more_room;
+ return scm_mb_iconv_too_big;
/* Convert as many characters as possible from the input buffer
into the intermediate scm_char_t buffer. */
@@ -347,8 +347,8 @@ scm_mb_iconv (struct scm_mb_iconv *context,
{
case scm_mb_write_ok:
break;
- case scm_mb_write_more_room:
- return scm_mb_iconv_more_room;
+ case scm_mb_write_too_big:
+ return scm_mb_iconv_too_big;
default:
abort ();
}
diff --git a/libguile/mbconv.h b/libguile/mbconv.h
index dcd39c76b..c52620ab5 100644
--- a/libguile/mbconv.h
+++ b/libguile/mbconv.h
@@ -67,7 +67,7 @@ extern struct scm_mb_iconv *scm_mb_iconv_open (const char *tocode,
/* Error return values for scm_mb_iconv. */
enum scm_mb_iconv_result {
- scm_mb_iconv_more_room = -1,
+ scm_mb_iconv_too_big = -1,
scm_mb_iconv_bad_encoding = -2,
scm_mb_iconv_incomplete_encoding = -3
};
@@ -111,7 +111,7 @@ enum scm_mb_write_result
scm_mb_write_ok,
/* Write needs more room. */
- scm_mb_write_more_room
+ scm_mb_write_too_big
};