| 358 | Use join fields JF_1 and JF_2 respectively. */ |
| 359 | |
| 360 | static int |
| 361 | keycmp (struct line const *line1, struct line const *line2, |
| 362 | idx_t jf_1, idx_t jf_2) |
| 363 | { |
| 364 | /* Start of field to compare in each file. */ |
| 365 | char *beg1; |
| 366 | char *beg2; |
| 367 | |
| 368 | idx_t len1; |
| 369 | idx_t len2; /* Length of fields to compare. */ |
| 370 | int diff; |
| 371 | |
| 372 | if (jf_1 < line1->nfields) |
| 373 | { |
| 374 | beg1 = line1->fields[jf_1].beg; |
| 375 | len1 = line1->fields[jf_1].len; |
| 376 | } |
| 377 | else |
| 378 | { |
| 379 | beg1 = NULL; |
| 380 | len1 = 0; |
| 381 | } |
| 382 | |
| 383 | if (jf_2 < line2->nfields) |
| 384 | { |
| 385 | beg2 = line2->fields[jf_2].beg; |
| 386 | len2 = line2->fields[jf_2].len; |
| 387 | } |
| 388 | else |
| 389 | { |
| 390 | beg2 = NULL; |
| 391 | len2 = 0; |
| 392 | } |
| 393 | |
| 394 | if (len1 == 0) |
| 395 | return len2 == 0 ? 0 : -1; |
| 396 | if (len2 == 0) |
| 397 | return 1; |
| 398 | |
| 399 | if (ignore_case) |
| 400 | { |
| 401 | /* FIXME: ignore_case does not work with NLS (in particular, |
| 402 | with multibyte chars). */ |
| 403 | diff = memcasecmp (beg1, beg2, MIN (len1, len2)); |
| 404 | } |
| 405 | else |
| 406 | { |
| 407 | if (hard_LC_COLLATE) |
| 408 | return xmemcoll (beg1, len1, beg2, len2); |
| 409 | diff = memcmp (beg1, beg2, MIN (len1, len2)); |
| 410 | } |
| 411 | |
| 412 | if (diff) |
| 413 | return diff; |
| 414 | return _GL_CMP (len1, len2); |
| 415 | } |
| 416 | |
| 417 | /* Check that successive input lines PREV and CURRENT from input file |
no outgoing calls
no test coverage detected