| 263 | } |
| 264 | |
| 265 | void PiuCodeSearchData(xsMachine* the, KprCodeSearch self, xsStringValue data, xsIntegerValue size) |
| 266 | { |
| 267 | int offset, count, total = 0; |
| 268 | char *fromFile, *toFile, *fromLine, *toLine, *from, *to; |
| 269 | |
| 270 | offset = 0; |
| 271 | fromFile = data; |
| 272 | toFile = data + size; |
| 273 | for (;;) { |
| 274 | // if (!KprMessageContinue(self->message)) |
| 275 | // break; |
| 276 | count = fxMatchRegExp(NULL, self->code, self->data, fromFile, offset); |
| 277 | if (count <= 0) { |
| 278 | break; |
| 279 | } |
| 280 | if (self->data[0] == self->data[1]) { |
| 281 | break; |
| 282 | } |
| 283 | from = fromLine = fromFile + self->data[0]; |
| 284 | while (fromLine >= fromFile) { |
| 285 | char c = *fromLine; |
| 286 | if ((c == 10) || (c == 13)) |
| 287 | break; |
| 288 | fromLine--; |
| 289 | } |
| 290 | fromLine++; |
| 291 | while (fromLine < from) { |
| 292 | char c = *fromLine; |
| 293 | if ((c != 9) && (c != 32)) |
| 294 | break; |
| 295 | fromLine++; |
| 296 | } |
| 297 | to = toLine = fromFile + self->data[1]; |
| 298 | while (toLine < toFile) { |
| 299 | char c = *toLine; |
| 300 | if ((c == 10) || (c == 13)) |
| 301 | break; |
| 302 | toLine++; |
| 303 | } |
| 304 | toLine--; |
| 305 | while (toLine > to) { |
| 306 | char c = *toLine; |
| 307 | if ((c != 9) && (c != 32)) |
| 308 | break; |
| 309 | toLine--; |
| 310 | } |
| 311 | toLine++; |
| 312 | offset = self->data[1]; |
| 313 | if (!xsTest(xsVar(XS_FILE))) { |
| 314 | xsVar(XS_RESULTS) = xsNewArray(0); |
| 315 | xsVar(XS_FILE) = xsNewObject(); |
| 316 | xsDefine(xsVar(XS_FILE), xsID_name, xsVar(XS_NAME), xsDefault); |
| 317 | xsDefine(xsVar(XS_FILE), xsID_path, xsVar(XS_PATH), xsDefault); |
| 318 | xsDefine(xsVar(XS_FILE), xsID_title, xsVar(XS_TITLE), xsDefault); |
| 319 | xsDefine(xsVar(XS_FILE), xsID_items, xsVar(XS_RESULTS), xsDefault); |
| 320 | xsDefine(xsVar(XS_FILE), xsID_expanded, xsTrue, xsDefault); |
| 321 | (void)xsCall1(xsResult, xsID_push, xsVar(XS_FILE)); |
| 322 | (void)xsCall2(xsVar(XS_MAP), xsID_set, xsVar(XS_PATH), xsVar(XS_RESULTS)); |
no test coverage detected