]> git.eshelyaron.com Git - emacs.git/commitdiff
(CCL_WRITE_CHAR): Don't use bcopy.
authorKenichi Handa <handa@m17n.org>
Fri, 18 Sep 1998 13:10:40 +0000 (13:10 +0000)
committerKenichi Handa <handa@m17n.org>
Fri, 18 Sep 1998 13:10:40 +0000 (13:10 +0000)
(ccl_driver): If BUFFER-MAGNIFICATION of the CCL program is 0,
cause error if the program is going to output some bytes.  When
outputing a string to notify an error, check the case that
DST_BYTES is zero.

src/ccl.c

index 54947f2d0c5b87e5fa21e0cae64c7e08ea207352..157992de0a7325279eecd2a2535705aab0c32284 100644 (file)
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -670,8 +670,7 @@ static tr_stack *mapping_stack_pointer;
        int len = CHAR_STRING (ch, work, str);          \
        if (dst + len <= (dst_bytes ? dst_end : src))   \
          {                                             \
-           bcopy (str, dst, len);                      \
-           dst += len;                                 \
+           while (len--) *dst++ = *str++;              \
          }                                             \
        else                                            \
          CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST);        \
@@ -751,6 +750,9 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
   if (ic >= ccl->eof_ic)
     ic = CCL_HEADER_MAIN;
 
+  if (ccl->buf_magnification ==0) /* We can't produce any bytes.  */
+    dst = NULL;
+
 #ifdef CCL_DEBUG
   ccl_backtrace_idx = 0;
 #endif
@@ -1543,6 +1545,9 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
       char msg[256];
       int msglen;
 
+      if (!dst)
+       dst = destination;
+
       switch (ccl->status)
        {
        case CCL_STAT_INVALID_CMD:
@@ -1554,7 +1559,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
            int j;
 
            msglen = strlen (msg);
-           if (dst + msglen <= dst_end)
+           if (dst + msglen <= (dst_bytes ? dst_end : src))
              {
                bcopy (msg, dst, msglen);
                dst += msglen;
@@ -1567,14 +1572,15 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
                  break;
                sprintf(msg, " %d", ccl_backtrace_table[i]);
                msglen = strlen (msg);
-               if (dst + msglen > dst_end)
+               if (dst + msglen > (dst_bytes ? dst_end : src))
                  break;
                bcopy (msg, dst, msglen);
                dst += msglen;
              }
+           goto ccl_finish;
          }
 #endif
-         goto ccl_finish;
+         break;
 
        case CCL_STAT_QUIT:
          sprintf(msg, "\nCCL: Quited.");
@@ -1585,7 +1591,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
        }
 
       msglen = strlen (msg);
-      if (dst + msglen <= dst_end)
+      if (dst + msglen <= (dst_bytes ? dst_end : src))
        {
          bcopy (msg, dst, msglen);
          dst += msglen;
@@ -1595,7 +1601,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed)
  ccl_finish:
   ccl->ic = ic;
   if (consumed) *consumed = src - source;
-  return dst - destination;
+  return (dst ? dst - destination : 0);
 }
 
 /* Setup fields of the structure pointed by CCL appropriately for the