瀏覽代碼

Add the latest version

Andrew Savchenko 9 年之前
父節點
當前提交
6e69f2d233
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      translit.c

+ 5 - 4
translit.c

@@ -4,6 +4,7 @@
  * Data is taken from stdin and is returned to stdout.
  *
  * Licensed under GPL-3.
+ * ® 2012 - 2015 Andrew Savchenko <bircoph gmail com>
  */
 
 #include <stdio.h>
@@ -24,7 +25,7 @@ const char *const ct[ALPHA_CNT][TRANSL_CNT]={
     {"д", "d", NULL},
     {"е", "e", "je", "ye", NULL},
     {"ё", "e", "jo", "yo", NULL},
-    {"ж", "j", "z", NULL},
+    {"ж", "j", "z", "zh", NULL},
     {"з", "z", NULL},
     {"и", "i", NULL},
     {"й", "j", "i", NULL},
@@ -82,9 +83,9 @@ void convline(char *in, char *out, size_t out_start, size_t out_len)
                     fork = malloc(sizeof(char)*fork_len);
                     
                     // copy base value
-                    strcpy(fork, out);
+                    memcpy(fork, out, out_start);
                     // get value from conversion table
-                    strcpy(fork+out_start, ct[i][j]);
+                    memcpy(fork+out_start, ct[i][j], tr_len);
                     // fork further expansion for an alternative translation
                     convline(in+2, fork, out_start+tr_len, fork_len);
                 }
@@ -98,7 +99,7 @@ void convline(char *in, char *out, size_t out_start, size_t out_len)
                 }
                 
                 // get value from conversion table
-                strcpy(out+out_start, ct[i][1]);
+                memcpy(out+out_start, ct[i][1], tr_len);
 
                 // go to next char
                 out_start += tr_len;