OSDN Git Service

nkf32.dll で SetNkfOption のバグ修正
[nkf/nkf.git] / nkf32dll.c
index facbb4b..c2208d7 100644 (file)
@@ -341,11 +341,58 @@ int CALLBACK SetNkfOption(LPSTR optStr)
     return 0;
 }
 
+int findspace(const char* str)
+{
+       int find_n = 0;
+       while (*str != 0) {
+               if (*str == ' ') {
+                       find_n++;
+               }
+               str++;
+       }
+       return find_n;
+}
+// \83I\83v\83V\83\87\83\93\82ª \8bó\94\92\82Å\8bæ\90Ø\82ç\82ê\82Ä\82¢\82é\8fê\8d\87\82É options \82ð\95¡\90\94\8cÄ\82Ñ\8fo\82·
+void callOptions()
+{
+       char *work = strdup(optStr0);
+       int len = strlen(optStr0);
+       for (int i = 0; i < len; i++) {
+               if (work[i] == ' ') {
+                       work[i] = '\0';
+               }
+       }
+       int i = 0;
+       while (i < len)
+       {
+               // \95\8e\9a\82ð\92T\82·
+               if (work[i] != '\0') {
+                       // options \8cÄ\82Ñ\8fo\82µ
+                       options(&work[i]);
+
+                       // \95\8e\9a\82Ì\8fI\92[\82ð\92T\82·
+                       while (work[i] != '\0' && i < len) {
+                               i++;
+                       }
+               }
+               else {
+                       i++;
+               }
+       }
+       free(work);
+}
+
 void options0(void)
 {
     reinit();
     if ( optStr0 != NULL ) {
-        options(optStr0);
+               // option \82Ì\92\86\82É \8bó\94\92\82ª\82 \82Á\82½\8fê\8d\87 options \82ð\95ª\8a\84\82µ\82Ä\8cÄ\82Ñ\8fo\82·
+               if (findspace(optStr0) > 0) {
+                       callOptions();
+               }
+               else {
+                       options(optStr0);
+               }
     }
 }