/* Basic character set support.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2009 Free Software Foundation, Inc.
+ 2008, 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009
+ 2005, 2006, 2007, 2008, 2009, 2010
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H14PRO021
#include <unistd.h>
#include <ctype.h>
#include <sys/types.h>
+#include <setjmp.h>
#include "lisp.h"
#include "character.h"
#include "charset.h"
int eof;
Lisp_Object suffixes;
struct charset_map_entries *head, *entries;
- int n_entries;
- int count = SPECPDL_INDEX ();
+ int n_entries, count;
+ USE_SAFE_ALLOCA;
suffixes = Fcons (build_string (".map"),
Fcons (build_string (".TXT"), Qnil));
+ count = SPECPDL_INDEX ();
specbind (Qfile_name_handler_alist, Qnil);
fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil);
unbind_to (count, Qnil);
|| ! (fp = fdopen (fd, "r")))
error ("Failure in loading charset map: %S", SDATA (mapfile));
- head = entries = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
+ large (larger than MAX_ALLOCA). */
+ SAFE_ALLOCA (head, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
+ entries = head;
+ bzero (entries, sizeof (struct charset_map_entries));
+
n_entries = 0;
eof = 0;
while (1)
if (n_entries > 0 && (n_entries % 0x10000) == 0)
{
- entries->next = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ SAFE_ALLOCA (entries->next, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
entries = entries->next;
+ bzero (entries, sizeof (struct charset_map_entries));
}
idx = n_entries % 0x10000;
entries->entry[idx].from = from;
close (fd);
load_charset_map (charset, head, n_entries, control_flag);
+ SAFE_FREE ();
}
static void
int n_entries;
int len = ASIZE (vec);
int i;
+ USE_SAFE_ALLOCA;
if (len % 2 == 1)
{
return;
}
- head = entries = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
+ large (larger than MAX_ALLOCA). */
+ SAFE_ALLOCA (head, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
+ entries = head;
+ bzero (entries, sizeof (struct charset_map_entries));
+
n_entries = 0;
for (i = 0; i < len; i += 2)
{
if (n_entries > 0 && (n_entries % 0x10000) == 0)
{
- entries->next = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ SAFE_ALLOCA (entries->next, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
entries = entries->next;
+ bzero (entries, sizeof (struct charset_map_entries));
}
idx = n_entries % 0x10000;
entries->entry[idx].from = from;
}
load_charset_map (charset, head, n_entries, control_flag);
+ SAFE_FREE ();
}
args[charset_arg_superset] = Qnil;
args[charset_arg_unify_map] = Qnil;
- plist[0] = intern (":name");
+ plist[0] = intern_c_string (":name");
plist[1] = args[charset_arg_name];
- plist[2] = intern (":dimension");
+ plist[2] = intern_c_string (":dimension");
plist[3] = args[charset_arg_dimension];
- plist[4] = intern (":code-space");
+ plist[4] = intern_c_string (":code-space");
plist[5] = args[charset_arg_code_space];
- plist[6] = intern (":iso-final-char");
+ plist[6] = intern_c_string (":iso-final-char");
plist[7] = args[charset_arg_iso_final];
- plist[8] = intern (":emacs-mule-id");
+ plist[8] = intern_c_string (":emacs-mule-id");
plist[9] = args[charset_arg_emacs_mule_id];
- plist[10] = intern (":ascii-compatible-p");
+ plist[10] = intern_c_string (":ascii-compatible-p");
plist[11] = args[charset_arg_ascii_compatible_p];
- plist[12] = intern (":code-offset");
+ plist[12] = intern_c_string (":code-offset");
plist[13] = args[charset_arg_code_offset];
args[charset_arg_plist] = Flist (14, plist);
charset_jisx0208_1978 = -1;
charset_jisx0208 = -1;
charset_ksc5601 = -1;
-
- for (i = 0; i < 128; i++)
- unibyte_to_multibyte_table[i] = i;
- for (; i < 256; i++)
- unibyte_to_multibyte_table[i] = BYTE8_TO_CHAR (i);
}
#ifdef emacs