Use gnulib's mktime module.
[bpt/emacs.git] / src / ccl.c
index c1c566e..ca4a147 100644 (file)
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -43,7 +43,7 @@ Lisp_Object Vcode_conversion_map_vector;
 /* Alist of fontname patterns vs corresponding CCL program.  */
 Lisp_Object Vfont_ccl_encoder_alist;
 
-/* This symbol is a property which assocates with ccl program vector.
+/* This symbol is a property which associates with ccl program vector.
    Ex: (get 'ccl-big5-encoder 'ccl-program) returns ccl program vector.  */
 Lisp_Object Qccl_program;
 
@@ -72,8 +72,6 @@ Lisp_Object Vtranslation_hash_table_vector;
 #define GET_HASH_TABLE(id) \
   (XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)])))
 
-extern int charset_unicode;
-
 /* CCL (Code Conversion Language) is a simple language which has
    operations on one input buffer, one output buffer, and 7 registers.
    The syntax of CCL is described in `ccl.el'.  Emacs Lisp function
@@ -450,7 +448,7 @@ extern int charset_unicode;
    Therefore, the instruction code range is 0..16384(0x3fff).
  */
 
-/* Read a multibyte characeter.
+/* Read a multibyte character.
    A code point is stored into reg[rrr].  A charset ID is stored into
    reg[RRR].  */
 
@@ -862,11 +860,7 @@ struct ccl_prog_stack
 static struct ccl_prog_stack ccl_prog_stack_struct[256];
 
 void
-ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
-     struct ccl_program *ccl;
-     int *source, *destination;
-     int src_size, dst_size;
-     Lisp_Object charset_list;
+ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size, int dst_size, Lisp_Object charset_list)
 {
   register int *reg = ccl->reg;
   register int ic = ccl->ic;
@@ -883,9 +877,6 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
   int eof_ic = ccl->eof_ic;
   int eof_hit = 0;
 
-  if (ic >= eof_ic)
-    ic = CCL_HEADER_MAIN;
-
   if (ccl->buf_magnification == 0) /* We can't read/produce any bytes.  */
     dst = NULL;
 
@@ -1365,7 +1356,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
                    if (point >= size) continue;
                    map = AREF (Vcode_conversion_map_vector, point);
 
-                   /* Check map varidity.  */
+                   /* Check map validity.  */
                    if (!CONSP (map)) continue;
                    map = XCDR (map);
                    if (!VECTORP (map)) continue;
@@ -1376,7 +1367,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
 
                    /* check map type,
                       [STARTPOINT VAL1 VAL2 ...] or
-                      [t ELELMENT STARTPOINT ENDPOINT]  */
+                      [t ELEMENT STARTPOINT ENDPOINT]  */
                    if (NUMBERP (content))
                      {
                        point = XUINT (content);
@@ -1538,7 +1529,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
                      if (point >= map_vector_size) continue;
                      map = AREF (Vcode_conversion_map_vector, point);
 
-                     /* Check map varidity.  */
+                     /* Check map validity.  */
                      if (!CONSP (map)) continue;
                      map = XCDR (map);
                      if (!VECTORP (map)) continue;
@@ -1722,7 +1713,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
            msglen = strlen (msg);
            if (dst + msglen <= (dst_bytes ? dst_end : src))
              {
-               bcopy (msg, dst, msglen);
+               memcpy (dst, msg, msglen);
                dst += msglen;
              }
 
@@ -1735,7 +1726,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
                msglen = strlen (msg);
                if (dst + msglen > (dst_bytes ? dst_end : src))
                  break;
-               bcopy (msg, dst, msglen);
+               memcpy (dst, msg, msglen);
                dst += msglen;
              }
            goto ccl_finish;
@@ -1768,7 +1759,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
          int i = src_end - src;
          if (dst_bytes && (dst_end - dst) < i)
            i = dst_end - dst;
-         bcopy (src, dst, i);
+         memcpy (dst, src, i);
          src += i;
          dst += i;
 #else
@@ -1798,8 +1789,7 @@ ccl_driver (ccl, source, destination, src_size, dst_size, charset_list)
    or nil if CCL contains invalid data.  */
 
 static Lisp_Object
-resolve_symbol_ccl_program (ccl)
-     Lisp_Object ccl;
+resolve_symbol_ccl_program (Lisp_Object ccl)
 {
   int i, veclen, unresolved = 0;
   Lisp_Object result, contents, val;
@@ -1870,9 +1860,7 @@ resolve_symbol_ccl_program (ccl)
    symbols, return Qnil.  */
 
 static Lisp_Object
-ccl_get_compiled_code (ccl_prog, idx)
-     Lisp_Object ccl_prog;
-     int *idx;
+ccl_get_compiled_code (Lisp_Object ccl_prog, int *idx)
 {
   Lisp_Object val, slot;
 
@@ -1913,9 +1901,7 @@ ccl_get_compiled_code (ccl_prog, idx)
 
    If CCL_PROG is nil, we just reset the structure pointed by CCL.  */
 int
-setup_ccl_program (ccl, ccl_prog)
-     struct ccl_program *ccl;
-     Lisp_Object ccl_prog;
+setup_ccl_program (struct ccl_program *ccl, Lisp_Object ccl_prog)
 {
   int i;
 
@@ -1956,8 +1942,7 @@ setup_ccl_program (ccl, ccl_prog)
 /* Check if CCL is updated or not.  If not, re-setup members of CCL.  */
 
 int
-check_ccl_update (ccl)
-     struct ccl_program *ccl;
+check_ccl_update (struct ccl_program *ccl)
 {
   Lisp_Object slot, ccl_prog;
 
@@ -1980,9 +1965,8 @@ check_ccl_update (ccl)
 
 DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0,
        doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code.
-See the documentation of  `define-ccl-program' for the detail of CCL program.  */)
-     (object)
-     Lisp_Object object;
+See the documentation of `define-ccl-program' for the detail of CCL program.  */)
+  (Lisp_Object object)
 {
   Lisp_Object val;
 
@@ -2016,8 +2000,7 @@ the corresponding register after the execution.
 
 See the documentation of `define-ccl-program' for a definition of CCL
 programs.  */)
-     (ccl_prog, reg)
-     Lisp_Object ccl_prog, reg;
+  (Lisp_Object ccl_prog, Lisp_Object reg)
 {
   struct ccl_program ccl;
   int i;
@@ -2061,7 +2044,7 @@ If R0..R7 are nil, they are initialized to 0.
 If IC is nil, it is initialized to head of the CCL program.
 
 If optional 4th arg CONTINUE is non-nil, keep IC on read operation
-when read buffer is exausted, else, IC is always set to the end of
+when read buffer is exhausted, else, IC is always set to the end of
 CCL-PROGRAM on exit.
 
 It returns the contents of write buffer as a string,
@@ -2071,18 +2054,17 @@ is a unibyte string.  By default it is a multibyte string.
 
 See the documentation of `define-ccl-program' for the detail of CCL program.
 usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBYTE-P)  */)
-     (ccl_prog, status, str, contin, unibyte_p)
-     Lisp_Object ccl_prog, status, str, contin, unibyte_p;
+  (Lisp_Object ccl_prog, Lisp_Object status, Lisp_Object str, Lisp_Object contin, Lisp_Object unibyte_p)
 {
   Lisp_Object val;
   struct ccl_program ccl;
   int i;
   int outbufsize;
   unsigned char *outbuf, *outp;
-  int str_chars, str_bytes;
+  EMACS_INT str_chars, str_bytes;
 #define CCL_EXECUTE_BUF_SIZE 1024
   int source[CCL_EXECUTE_BUF_SIZE], destination[CCL_EXECUTE_BUF_SIZE];
-  int consumed_chars, consumed_bytes, produced_chars;
+  EMACS_INT consumed_chars, consumed_bytes, produced_chars;
 
   if (setup_ccl_program (&ccl, ccl_prog) < 0)
     error ("Invalid CCL program");
@@ -2146,7 +2128,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY
              if (outp - outbuf + MAX_MULTIBYTE_LENGTH * ccl.produced
                  > outbufsize)
                {
-                 int offset = outp - outbuf;
+                 EMACS_INT offset = outp - outbuf;
                  outbufsize += MAX_MULTIBYTE_LENGTH * ccl.produced;
                  outbuf = (unsigned char *) xrealloc (outbuf, outbufsize);
                  outp = outbuf + offset;
@@ -2158,7 +2140,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY
            {
              if (outp - outbuf + ccl.produced > outbufsize)
                {
-                 int offset = outp - outbuf;
+                 EMACS_INT offset = outp - outbuf;
                  outbufsize += ccl.produced;
                  outbuf = (unsigned char *) xrealloc (outbuf, outbufsize);
                  outp = outbuf + offset;
@@ -2202,8 +2184,7 @@ DEFUN ("register-ccl-program", Fregister_ccl_program, Sregister_ccl_program,
 CCL-PROG should be a compiled CCL program (vector), or nil.
 If it is nil, just reserve NAME as a CCL program name.
 Return index number of the registered CCL program.  */)
-     (name, ccl_prog)
-     Lisp_Object name, ccl_prog;
+     (Lisp_Object name, Lisp_Object ccl_prog)
 {
   int len = ASIZE (Vccl_program_table);
   int idx;
@@ -2232,7 +2213,7 @@ Return index number of the registered CCL program.  */)
 
       slot = AREF (Vccl_program_table, idx);
       if (!VECTORP (slot))
-       /* This is the first unsed slot.  Register NAME here.  */
+       /* This is the first unused slot.  Register NAME here.  */
        break;
 
       if (EQ (name, AREF (slot, 0)))
@@ -2278,8 +2259,7 @@ DEFUN ("register-code-conversion-map", Fregister_code_conversion_map,
        2, 2, 0,
        doc: /* Register SYMBOL as code conversion map MAP.
 Return index number of the registered map.  */)
-     (symbol, map)
-     Lisp_Object symbol, map;
+  (Lisp_Object symbol, Lisp_Object map)
 {
   int len = ASIZE (Vcode_conversion_map_vector);
   int i;
@@ -2318,7 +2298,7 @@ Return index number of the registered map.  */)
 
 
 void
-syms_of_ccl ()
+syms_of_ccl (void)
 {
   staticpro (&Vccl_program_table);
   Vccl_program_table = Fmake_vector (make_number (32), Qnil);