summaryrefslogtreecommitdiff
path: root/src/charset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c203
1 files changed, 64 insertions, 139 deletions
diff --git a/src/charset.c b/src/charset.c
index c349093ad3d..7ab9197bec4 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <stdio.h>
-#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/types.h>
@@ -128,13 +127,6 @@ int inhibit_load_charset_map;
Lisp_Object Vcurrent_iso639_language;
-/* Defined in chartab.c */
-extern void
-map_char_table_for_charset P_ ((void (*c_function) (Lisp_Object, Lisp_Object),
- Lisp_Object function, Lisp_Object table,
- Lisp_Object arg, struct charset *charset,
- unsigned from, unsigned to));
-
#define CODE_POINT_TO_INDEX(charset, code) \
((charset)->code_linear_p \
? (code) - (charset)->min_code \
@@ -268,11 +260,7 @@ struct charset_map_entries
*/
static void
-load_charset_map (charset, entries, n_entries, control_flag)
- struct charset *charset;
- struct charset_map_entries *entries;
- int n_entries;
- int control_flag;
+load_charset_map (struct charset *charset, struct charset_map_entries *entries, int n_entries, int control_flag)
{
Lisp_Object vec, table;
unsigned max_code = CHARSET_MAX_CODE (charset);
@@ -438,12 +426,10 @@ load_charset_map (charset, entries, n_entries, control_flag)
/* Read a hexadecimal number (preceded by "0x") from the file FP while
- paying attention to comment charcter '#'. */
+ paying attention to comment character '#'. */
static INLINE unsigned
-read_hex (fp, eof)
- FILE *fp;
- int *eof;
+read_hex (FILE *fp, int *eof)
{
int c;
unsigned n;
@@ -479,8 +465,6 @@ read_hex (fp, eof)
return n;
}
-extern Lisp_Object Qfile_name_handler_alist;
-
/* Return a mapping vector for CHARSET loaded from MAPFILE.
Each line of MAPFILE has this form
0xAAAA 0xCCCC
@@ -498,13 +482,8 @@ extern Lisp_Object Qfile_name_handler_alist;
Note that this function uses `openp' to open MAPFILE but ignores
`file-name-handler-alist' to avoid running any Lisp code. */
-extern void add_to_log P_ ((char *, Lisp_Object, Lisp_Object));
-
static void
-load_charset_map_from_file (charset, mapfile, control_flag)
- struct charset *charset;
- Lisp_Object mapfile;
- int control_flag;
+load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile, int control_flag)
{
unsigned min_code = CHARSET_MIN_CODE (charset);
unsigned max_code = CHARSET_MAX_CODE (charset);
@@ -532,7 +511,7 @@ load_charset_map_from_file (charset, mapfile, control_flag)
SAFE_ALLOCA (head, struct charset_map_entries *,
sizeof (struct charset_map_entries));
entries = head;
- bzero (entries, sizeof (struct charset_map_entries));
+ memset (entries, 0, sizeof (struct charset_map_entries));
n_entries = 0;
eof = 0;
@@ -559,7 +538,7 @@ load_charset_map_from_file (charset, mapfile, control_flag)
SAFE_ALLOCA (entries->next, struct charset_map_entries *,
sizeof (struct charset_map_entries));
entries = entries->next;
- bzero (entries, sizeof (struct charset_map_entries));
+ memset (entries, 0, sizeof (struct charset_map_entries));
}
idx = n_entries % 0x10000;
entries->entry[idx].from = from;
@@ -568,17 +547,13 @@ load_charset_map_from_file (charset, mapfile, control_flag)
n_entries++;
}
fclose (fp);
- close (fd);
load_charset_map (charset, head, n_entries, control_flag);
SAFE_FREE ();
}
static void
-load_charset_map_from_vector (charset, vec, control_flag)
- struct charset *charset;
- Lisp_Object vec;
- int control_flag;
+load_charset_map_from_vector (struct charset *charset, Lisp_Object vec, int control_flag)
{
unsigned min_code = CHARSET_MIN_CODE (charset);
unsigned max_code = CHARSET_MAX_CODE (charset);
@@ -599,7 +574,7 @@ load_charset_map_from_vector (charset, vec, control_flag)
SAFE_ALLOCA (head, struct charset_map_entries *,
sizeof (struct charset_map_entries));
entries = head;
- bzero (entries, sizeof (struct charset_map_entries));
+ memset (entries, 0, sizeof (struct charset_map_entries));
n_entries = 0;
for (i = 0; i < len; i += 2)
@@ -636,7 +611,7 @@ load_charset_map_from_vector (charset, vec, control_flag)
SAFE_ALLOCA (entries->next, struct charset_map_entries *,
sizeof (struct charset_map_entries));
entries = entries->next;
- bzero (entries, sizeof (struct charset_map_entries));
+ memset (entries, 0, sizeof (struct charset_map_entries));
}
idx = n_entries % 0x10000;
entries->entry[idx].from = from;
@@ -654,9 +629,7 @@ load_charset_map_from_vector (charset, vec, control_flag)
map it is (see the comment of load_charset_map for the detail). */
static void
-load_charset (charset, control_flag)
- struct charset *charset;
- int control_flag;
+load_charset (struct charset *charset, int control_flag)
{
Lisp_Object map;
@@ -679,22 +652,18 @@ load_charset (charset, control_flag)
DEFUN ("charsetp", Fcharsetp, Scharsetp, 1, 1, 0,
doc: /* Return non-nil if and only if OBJECT is a charset.*/)
- (object)
- Lisp_Object object;
+ (Lisp_Object object)
{
return (CHARSETP (object) ? Qt : Qnil);
}
-void map_charset_for_dump P_ ((void (*c_function) (Lisp_Object, Lisp_Object),
- Lisp_Object function, Lisp_Object arg,
- unsigned from, unsigned to));
+void map_charset_for_dump (void (*c_function) (Lisp_Object, Lisp_Object),
+ Lisp_Object function, Lisp_Object arg,
+ unsigned from, unsigned to);
void
-map_charset_for_dump (c_function, function, arg, from, to)
- void (*c_function) (Lisp_Object, Lisp_Object);
- Lisp_Object function, arg;
- unsigned from, to;
+map_charset_for_dump (void (*c_function) (Lisp_Object, Lisp_Object), Lisp_Object function, Lisp_Object arg, unsigned int from, unsigned int to)
{
int from_idx = CODE_POINT_TO_INDEX (temp_charset_work->current, from);
int to_idx = CODE_POINT_TO_INDEX (temp_charset_work->current, to);
@@ -750,12 +719,8 @@ map_charset_for_dump (c_function, function, arg, from, to)
}
void
-map_charset_chars (c_function, function, arg,
- charset, from, to)
- void (*c_function) P_ ((Lisp_Object, Lisp_Object));
- Lisp_Object function, arg;
- struct charset *charset;
- unsigned from, to;
+map_charset_chars (void (*c_function)(Lisp_Object, Lisp_Object), Lisp_Object function,
+ Lisp_Object arg, struct charset *charset, unsigned from, unsigned to)
{
Lisp_Object range;
int partial;
@@ -849,8 +814,7 @@ characters contained in CHARSET.
The optional 4th and 5th arguments FROM-CODE and TO-CODE specify the
range of code points (in CHARSET) of target characters. */)
- (function, charset, arg, from_code, to_code)
- Lisp_Object function, charset, arg, from_code, to_code;
+ (Lisp_Object function, Lisp_Object charset, Lisp_Object arg, Lisp_Object from_code, Lisp_Object to_code)
{
struct charset *cs;
unsigned from, to;
@@ -888,9 +852,7 @@ DEFUN ("define-charset-internal", Fdefine_charset_internal,
Sdefine_charset_internal, charset_arg_max, MANY, 0,
doc: /* For internal use only.
usage: (define-charset-internal ...) */)
- (nargs, args)
- int nargs;
- Lisp_Object *args;
+ (int nargs, Lisp_Object *args)
{
/* Charset attr vector. */
Lisp_Object attrs;
@@ -954,7 +916,7 @@ usage: (define-charset-internal ...) */)
if (! charset.code_linear_p)
{
charset.code_space_mask = (unsigned char *) xmalloc (256);
- bzero (charset.code_space_mask, 256);
+ memset (charset.code_space_mask, 0, 256);
for (i = 0; i < 4; i++)
for (j = charset.code_space[i * 4]; j <= charset.code_space[i * 4 + 1];
j++)
@@ -1077,7 +1039,7 @@ usage: (define-charset-internal ...) */)
charset.unified_p = 0;
- bzero (charset.fast_map, sizeof (charset.fast_map));
+ memset (charset.fast_map, 0, sizeof (charset.fast_map));
if (! NILP (args[charset_arg_code_offset]))
{
@@ -1210,8 +1172,8 @@ usage: (define-charset-internal ...) */)
struct charset *new_table
= (struct charset *) xmalloc (sizeof (struct charset)
* (charset_table_size + 16));
- bcopy (charset_table, new_table,
- sizeof (struct charset) * charset_table_size);
+ memcpy (new_table, charset_table,
+ sizeof (struct charset) * charset_table_size);
charset_table_size += 16;
charset_table = new_table;
}
@@ -1301,17 +1263,13 @@ usage: (define-charset-internal ...) */)
charset. */
static int
-define_charset_internal (name, dimension, code_space, min_code, max_code,
- iso_final, iso_revision, emacs_mule_id,
- ascii_compatible, supplementary,
- code_offset)
- Lisp_Object name;
- int dimension;
- unsigned char *code_space;
- unsigned min_code, max_code;
- int iso_final, iso_revision, emacs_mule_id;
- int ascii_compatible, supplementary;
- int code_offset;
+define_charset_internal (Lisp_Object name,
+ int dimension,
+ const unsigned char *code_space,
+ unsigned min_code, unsigned max_code,
+ int iso_final, int iso_revision, int emacs_mule_id,
+ int ascii_compatible, int supplementary,
+ int code_offset)
{
Lisp_Object args[charset_arg_max];
Lisp_Object plist[14];
@@ -1365,8 +1323,7 @@ define_charset_internal (name, dimension, code_space, min_code, max_code,
DEFUN ("define-charset-alias", Fdefine_charset_alias,
Sdefine_charset_alias, 2, 2, 0,
doc: /* Define ALIAS as an alias for charset CHARSET. */)
- (alias, charset)
- Lisp_Object alias, charset;
+ (Lisp_Object alias, Lisp_Object charset)
{
Lisp_Object attr;
@@ -1379,8 +1336,7 @@ DEFUN ("define-charset-alias", Fdefine_charset_alias,
DEFUN ("charset-plist", Fcharset_plist, Scharset_plist, 1, 1, 0,
doc: /* Return the property list of CHARSET. */)
- (charset)
- Lisp_Object charset;
+ (Lisp_Object charset)
{
Lisp_Object attrs;
@@ -1391,8 +1347,7 @@ DEFUN ("charset-plist", Fcharset_plist, Scharset_plist, 1, 1, 0,
DEFUN ("set-charset-plist", Fset_charset_plist, Sset_charset_plist, 2, 2, 0,
doc: /* Set CHARSET's property list to PLIST. */)
- (charset, plist)
- Lisp_Object charset, plist;
+ (Lisp_Object charset, Lisp_Object plist)
{
Lisp_Object attrs;
@@ -1412,8 +1367,7 @@ the same meaning as the `:unify-map' attribute in the function
`define-charset' (which see).
Optional third argument DEUNIFY, if non-nil, means to de-unify CHARSET. */)
- (charset, unify_map, deunify)
- Lisp_Object charset, unify_map, deunify;
+ (Lisp_Object charset, Lisp_Object unify_map, Lisp_Object deunify)
{
int id;
struct charset *cs;
@@ -1468,8 +1422,7 @@ CHARS is the number of characters in a dimension: 94 or 96.
This final char is for private use, thus the range is `0' (48) .. `?' (63).
If there's no unused final char for the specified kind of charset,
return nil. */)
- (dimension, chars)
- Lisp_Object dimension, chars;
+ (Lisp_Object dimension, Lisp_Object chars)
{
int final_char;
@@ -1486,8 +1439,7 @@ return nil. */)
}
static void
-check_iso_charset_parameter (dimension, chars, final_char)
- Lisp_Object dimension, chars, final_char;
+check_iso_charset_parameter (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char)
{
CHECK_NATNUM (dimension);
CHECK_NATNUM (chars);
@@ -1509,8 +1461,7 @@ DEFUN ("declare-equiv-charset", Fdeclare_equiv_charset, Sdeclare_equiv_charset,
On decoding by an ISO-2022 base coding system, when a charset
specified by DIMENSION, CHARS, and FINAL-CHAR is designated, behave as
if CHARSET is designated instead. */)
- (dimension, chars, final_char, charset)
- Lisp_Object dimension, chars, final_char, charset;
+ (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char, Lisp_Object charset)
{
int id;
int chars_flag;
@@ -1537,8 +1488,7 @@ if CHARSET is designated instead. */)
*/
int
-string_xstring_p (string)
- Lisp_Object string;
+string_xstring_p (Lisp_Object string)
{
const unsigned char *p = SDATA (string);
const unsigned char *endp = p + SBYTES (string);
@@ -1565,11 +1515,7 @@ string_xstring_p (string)
It may lookup a translation table TABLE if supplied. */
static void
-find_charsets_in_text (ptr, nchars, nbytes, charsets, table, multibyte)
- const unsigned char *ptr;
- EMACS_INT nchars, nbytes;
- Lisp_Object charsets, table;
- int multibyte;
+find_charsets_in_text (const unsigned char *ptr, EMACS_INT nchars, EMACS_INT nbytes, Lisp_Object charsets, Lisp_Object table, int multibyte)
{
const unsigned char *pend = ptr + nbytes;
@@ -1613,8 +1559,7 @@ Optional arg TABLE if non-nil is a translation table to look up.
If the current buffer is unibyte, the returned list may contain
only `ascii', `eight-bit-control', and `eight-bit-graphic'. */)
- (beg, end, table)
- Lisp_Object beg, end, table;
+ (Lisp_Object beg, Lisp_Object end, Lisp_Object table)
{
Lisp_Object charsets;
EMACS_INT from, from_byte, to, stop, stop_byte;
@@ -1665,8 +1610,7 @@ Optional arg TABLE if non-nil is a translation table to look up.
If STR is unibyte, the returned list may contain
only `ascii', `eight-bit-control', and `eight-bit-graphic'. */)
- (str, table)
- Lisp_Object str, table;
+ (Lisp_Object str, Lisp_Object table)
{
Lisp_Object charsets;
int i;
@@ -1691,9 +1635,7 @@ only `ascii', `eight-bit-control', and `eight-bit-graphic'. */)
value of Vchar_unify_table for C; i.e. it is nil, an integer, or a
charset symbol. */
int
-maybe_unify_char (c, val)
- int c;
- Lisp_Object val;
+maybe_unify_char (int c, Lisp_Object val)
{
struct charset *charset;
@@ -1726,9 +1668,7 @@ maybe_unify_char (c, val)
CHARSET. */
int
-decode_char (charset, code)
- struct charset *charset;
- unsigned code;
+decode_char (struct charset *charset, unsigned int code)
{
int c, char_index;
enum charset_method method = CHARSET_METHOD (charset);
@@ -1807,9 +1747,7 @@ Lisp_Object charset_work;
use CHARSET's strict_max_char instead of max_char. */
unsigned
-encode_char (charset, c)
- struct charset *charset;
- int c;
+encode_char (struct charset *charset, int c)
{
unsigned code;
enum charset_method method = CHARSET_METHOD (charset);
@@ -1923,8 +1861,7 @@ CODE-POINT may be a cons (HIGHER-16-BIT-VALUE . LOWER-16-BIT-VALUE).
Optional argument RESTRICTION specifies a way to map the pair of CCS
and CODE-POINT to a character. Currently not supported and just ignored. */)
- (charset, code_point, restriction)
- Lisp_Object charset, code_point, restriction;
+ (Lisp_Object charset, Lisp_Object code_point, Lisp_Object restriction)
{
int c, id;
unsigned code;
@@ -1954,8 +1891,7 @@ Return nil if CHARSET doesn't include CH.
Optional argument RESTRICTION specifies a way to map CH to a
code-point in CCS. Currently not supported and just ignored. */)
- (ch, charset, restriction)
- Lisp_Object ch, charset, restriction;
+ (Lisp_Object ch, Lisp_Object charset, Lisp_Object restriction)
{
int id;
unsigned code;
@@ -1980,8 +1916,7 @@ DEFUN ("make-char", Fmake_char, Smake_char, 1, 5, 0,
CODE1 through CODE4 are optional, but if you don't supply sufficient
position codes, it is assumed that the minimum code in each dimension
is specified. */)
- (charset, code1, code2, code3, code4)
- Lisp_Object charset, code1, code2, code3, code4;
+ (Lisp_Object charset, Lisp_Object code1, Lisp_Object code2, Lisp_Object code3, Lisp_Object code4)
{
int id, dimension;
struct charset *charsetp;
@@ -2059,10 +1994,7 @@ is specified. */)
Vcharset_ordered_list. */
struct charset *
-char_charset (c, charset_list, code_return)
- int c;
- Lisp_Object charset_list;
- unsigned *code_return;
+char_charset (int c, Lisp_Object charset_list, unsigned int *code_return)
{
int maybe_null = 0;
@@ -2083,8 +2015,9 @@ char_charset (c, charset_list, code_return)
return charset;
}
charset_list = XCDR (charset_list);
- if (c <= MAX_UNICODE_CHAR
- && EQ (charset_list, Vcharset_non_preferred_head))
+ if (! maybe_null
+ && c <= MAX_UNICODE_CHAR
+ && EQ (charset_list, Vcharset_non_preferred_head))
return CHARSET_FROM_ID (charset_unicode);
}
return (maybe_null ? NULL
@@ -2099,8 +2032,7 @@ DEFUN ("split-char", Fsplit_char, Ssplit_char, 1, 1, 0,
The charset is decided by the current priority order of charsets.
A position-code is a byte value of each dimension of the code-point of
CH in the charset. */)
- (ch)
- Lisp_Object ch;
+ (Lisp_Object ch)
{
struct charset *charset;
int c, dimension;
@@ -2130,8 +2062,7 @@ DEFUN ("char-charset", Fchar_charset, Schar_charset, 1, 2, 0,
If optional 2nd arg RESTRICTION is non-nil, it is a list of charsets
from which to find the charset. It may also be a coding system. In
that case, find the charset from what supported by that coding system. */)
- (ch, restriction)
- Lisp_Object ch, restriction;
+ (Lisp_Object ch, Lisp_Object restriction)
{
struct charset *charset;
@@ -2168,8 +2099,7 @@ DEFUN ("charset-after", Fcharset_after, Scharset_after, 0, 1, 0,
Return charset of a character in the current buffer at position POS.
If POS is nil, it defauls to the current point.
If POS is out of range, the value is nil. */)
- (pos)
- Lisp_Object pos;
+ (Lisp_Object pos)
{
Lisp_Object ch;
struct charset *charset;
@@ -2191,8 +2121,7 @@ by their DIMENSION, CHARS, and FINAL-CHAR,
whereas Emacs distinguishes them by charset symbol.
See the documentation of the function `charset-info' for the meanings of
DIMENSION, CHARS, and FINAL-CHAR. */)
- (dimension, chars, final_char)
- Lisp_Object dimension, chars, final_char;
+ (Lisp_Object dimension, Lisp_Object chars, Lisp_Object final_char)
{
int id;
int chars_flag;
@@ -2211,7 +2140,7 @@ DEFUN ("clear-charset-maps", Fclear_charset_maps, Sclear_charset_maps,
Internal use only.
Clear temporary charset mapping tables.
It should be called only from temacs invoked for dumping. */)
- ()
+ (void)
{
if (temp_charset_work)
{
@@ -2229,8 +2158,7 @@ DEFUN ("charset-priority-list", Fcharset_priority_list,
Scharset_priority_list, 0, 1, 0,
doc: /* Return the list of charsets ordered by priority.
HIGHESTP non-nil means just return the highest priority one. */)
- (highestp)
- Lisp_Object highestp;
+ (Lisp_Object highestp)
{
Lisp_Object val = Qnil, list = Vcharset_ordered_list;
@@ -2249,9 +2177,7 @@ DEFUN ("set-charset-priority", Fset_charset_priority, Sset_charset_priority,
1, MANY, 0,
doc: /* Assign higher priority to the charsets given as arguments.
usage: (set-charset-priority &rest charsets) */)
- (nargs, args)
- int nargs;
- Lisp_Object *args;
+ (int nargs, Lisp_Object *args)
{
Lisp_Object new_head, old_list, arglist[2];
Lisp_Object list_2022, list_emacs_mule;
@@ -2303,8 +2229,7 @@ DEFUN ("charset-id-internal", Fcharset_id_internal, Scharset_id_internal,
0, 1, 0,
doc: /* Internal use only.
Return charset identification number of CHARSET. */)
- (charset)
- Lisp_Object charset;
+ (Lisp_Object charset)
{
int id;
@@ -2377,7 +2302,7 @@ See also `charset-priority-list' and `set-charset-priority'. */)
void
-init_charset ()
+init_charset (void)
{
Lisp_Object tempdir;
tempdir = Fexpand_file_name (build_string ("charsets"), Vdata_directory);
@@ -2395,7 +2320,7 @@ Please check your installation!\n",
void
-init_charset_once ()
+init_charset_once (void)
{
int i, j, k;
@@ -2416,7 +2341,7 @@ init_charset_once ()
#ifdef emacs
void
-syms_of_charset ()
+syms_of_charset (void)
{
DEFSYM (Qcharsetp, "charsetp");
@@ -2439,8 +2364,8 @@ syms_of_charset ()
Vemacs_mule_charset_list = Qnil;
/* Don't staticpro them here. It's done in syms_of_fns. */
- QCtest = intern (":test");
- Qeq = intern ("eq");
+ QCtest = intern_c_string (":test");
+ Qeq = intern_c_string ("eq");
staticpro (&Vcharset_hash_table);
{