| 580 | |
| 581 | |
| 582 | my_bool |
| 583 | File_parser::parse(uchar* base, MEM_ROOT *mem_root, |
| 584 | struct File_option *parameters, uint required, |
| 585 | Unknown_key_hook *hook) const |
| 586 | { |
| 587 | uint first_param= 0, found= 0; |
| 588 | const char *ptr= start; |
| 589 | const char *eol; |
| 590 | LEX_STRING *str; |
| 591 | List<LEX_STRING> *list; |
| 592 | DBUG_ENTER("File_parser::parse"); |
| 593 | |
| 594 | while (ptr < end && found < required) |
| 595 | { |
| 596 | const char *line= ptr; |
| 597 | if (*ptr == '#') |
| 598 | { |
| 599 | // it is comment |
| 600 | if (!(ptr= strchr(ptr, '\n'))) |
| 601 | { |
| 602 | my_error(ER_FPARSER_EOF_IN_COMMENT, MYF(0), line); |
| 603 | DBUG_RETURN(TRUE); |
| 604 | } |
| 605 | ptr++; |
| 606 | } |
| 607 | else |
| 608 | { |
| 609 | File_option *parameter= parameters+first_param, |
| 610 | *parameters_end= parameters+required; |
| 611 | int len= 0; |
| 612 | for (; parameter < parameters_end; parameter++) |
| 613 | { |
| 614 | len= parameter->name.length; |
| 615 | // check length |
| 616 | if (len < (end-ptr) && ptr[len] != '=') |
| 617 | continue; |
| 618 | // check keyword |
| 619 | if (memcmp(parameter->name.str, ptr, len) == 0) |
| 620 | break; |
| 621 | } |
| 622 | |
| 623 | if (parameter < parameters_end) |
| 624 | { |
| 625 | found++; |
| 626 | /* |
| 627 | if we found first parameter, start search from next parameter |
| 628 | next time. |
| 629 | (this small optimisation should work, because they should be |
| 630 | written in same order) |
| 631 | */ |
| 632 | if (parameter == parameters+first_param) |
| 633 | first_param++; |
| 634 | |
| 635 | // get value |
| 636 | ptr+= (len+1); |
| 637 | switch (parameter->type) { |
| 638 | case FILE_OPTIONS_STRING: |
| 639 | { |
nothing calls this directly
no test coverage detected