Revision | de8b542bdf9598e3e464e2cfdb9549be8dbca6a5 (tree) |
---|---|
Time | 2014-12-01 18:13:56 |
Author | komutan <t_komuta@nift...> |
Commiter | komutan |
微修正
@@ -95,25 +95,22 @@ namespace NMeCab.Extension | ||
95 | 95 | private unsafe static string GetCsvElement(char* csvRow, int rowLength, int index) |
96 | 96 | { |
97 | 97 | char* end = csvRow + rowLength; |
98 | + int count = 0; | |
99 | + int len = 0; | |
98 | 100 | |
99 | - for (int i = 0; i < index; i++) | |
101 | + while (csvRow != end) | |
100 | 102 | { |
101 | - while (*csvRow != ',') | |
103 | + if (*csvRow == ',') | |
102 | 104 | { |
103 | - if (csvRow == end) return null; | |
104 | - csvRow++; | |
105 | + if (count == index) return new string(csvRow - len, 0, len); | |
106 | + count++; | |
107 | + len = 0; | |
105 | 108 | } |
106 | - csvRow++; | |
107 | - } | |
108 | - | |
109 | - int len = 0; | |
110 | - while (csvRow != end && *csvRow != ',') | |
111 | - { | |
112 | 109 | len++; |
113 | 110 | csvRow++; |
114 | 111 | } |
115 | 112 | |
116 | - return new string(csvRow - len, 0, len); | |
113 | + return count == index ? new string(csvRow - len, 0, len) : null; | |
117 | 114 | } |
118 | 115 | } |
119 | 116 | } |