Author: iratqq
Date: Sun Mar  9 03:54:47 2008
New Revision: 5284

Modified:
   trunk/uim/wnnlib.c
   trunk/uim/wnnlib.h

Log:
* uim/wnnlib.c
  (wstrncpy):
  - New function.
  (wstrcpy):
  - Remove.
  (jcGetCandidate):
  - Change API. Add argument of string length.
  - Replace with wstrncpy().
* uim/wnnlib.h (jcGetCandidate):
  - Change API.


Modified: trunk/uim/wnnlib.c
==============================================================================
--- trunk/uim/wnnlib.c  (original)
+++ trunk/uim/wnnlib.c  Sun Mar  9 03:54:47 2008
@@ -426,7 +426,7 @@
  *     $B<!8uJd$N>pJs$rJV$9!#(B
  *     $B<!8uJd0lMw$r=P$9$?$a$K$O:G=i$K$3$N4X?t$r8F$V$H$h$$!#(B
  *
- * int jcGetCandidate(jcConvBuf *buf, int n, wchar *candstr)
+ * int jcGetCandidate(jcConvBuf *buf, int n, wchar *candstr, int len)
  *     $B;XDj$5$l$?8uJdHV9f$NJ8;zNs$rJV$9!#%+%l%s%H8uJdHV9f$O$3$NHV9f$K(B
  *     $BJQ$o$k!#I=<(%P%C%U%!$OJQ2=$7$J$$!#(B
  *     [EMAIL PROTECTED](B wnnlib 
$B$O<!8uJd$,MQ0U$5$l$F$$$J$1$l$PMQ0U$7$?$,!"$3$N%P!<%8%g%s(B
@@ -693,7 +693,7 @@
 #endif

 /* $B%U%!%s%/[EMAIL PROTECTED]@(B */
-static wchar *wstrcpy(wchar *, wchar *);
+static wchar *wstrncpy(wchar *, wchar *, int);
 static int wstrlen(wchar *);
 static void moveKBuf(jcConvBuf *, int, int);
 static void moveDBuf(jcConvBuf *, int, int);
@@ -752,13 +752,15 @@
         return (int)(*s1 - *s2);
 }

-static wchar *
-wstrcpy(wchar *s1, wchar *s2)
+wchar *
+wstrncpy(wchar *s1, wchar *s2, int n)
 {
-       wchar   *ret = s1;
+       wchar   *ret = s1;

-       while (*s1++ = *s2++)
+       while (n-- > 0 && (*s1++ = *s2++))
                ;
+       while (n-- > 0)
+               *s1++ = 0;

        return ret;
 }
@@ -2915,7 +2917,7 @@

 /* jcGetCandidate -- $B;XDj$5$l$?HV9f$N8uJd$r<h$j=P$9(B */
 int
-jcGetCandidate(jcConvBuf *buf, int n, wchar *candstr)
+jcGetCandidate(jcConvBuf *buf, int n, wchar *candstr, int len)
 {
        wchar   tmp[CL_BUFSZ];

@@ -2938,7 +2940,7 @@
        /* $BJ8;zNs$r%3%T!<(B */
        ki2_jl_get_zenkouho_kanji(buf->wnn, n, tmp, CL_BUFSZ);
        tmp[CL_BUFSZ - 1] = 0;
-       wstrcpy(candstr, tmp);
+       wstrncpy(candstr, tmp, len);

        return 0;
 }
@@ -2949,7 +2951,7 @@
   wchar buf[BUFSIZ];
   char str[BUFSIZ * sizeof(wchar)];

-  if (jcGetCandidate(C_PTR(buf_), C_INT(n_), buf) != 0)
+  if (jcGetCandidate(C_PTR(buf_), C_INT(n_), buf, sizeof(buf)) != 0)
     return uim_scm_f();
   if (sizeof(str) < wstrlen(buf) * sizeof(wchar))
     return uim_scm_f();

Modified: trunk/uim/wnnlib.h
==============================================================================
--- trunk/uim/wnnlib.h  (original)
+++ trunk/uim/wnnlib.h  Sun Mar  9 03:54:47 2008
@@ -168,7 +168,7 @@
 extern int jcNext(jcConvBuf *buf, int small, int prev);
 extern int jcCandidateInfo(jcConvBuf *buf, int small,
                           int *ncandp, int *curcandp);
-extern int jcGetCandidate(jcConvBuf *buf, int n, wchar *candstr);
+extern int jcGetCandidate(jcConvBuf *buf, int n, wchar *candstr, int);
 extern int jcSelect(jcConvBuf *buf, int n);
 extern int jcDotOffset(jcConvBuf *buf);
 extern int jcIsConverted(jcConvBuf *buf, int cl);

Reply via email to