diff options
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 111 |
1 files changed, 103 insertions, 8 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index ff75de45659..ca50f35f80b 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -729,7 +729,9 @@ static const char Python_help [] = | |||
| 729 | generate a tag."; | 729 | generate a tag."; |
| 730 | 730 | ||
| 731 | static const char *Ruby_suffixes [] = | 731 | static const char *Ruby_suffixes [] = |
| 732 | { "rb", "ruby", NULL }; | 732 | { "rb", "ru", "rbw", NULL }; |
| 733 | static const char *Ruby_filenames [] = | ||
| 734 | { "Rakefile", "Thorfile", NULL }; | ||
| 733 | static const char Ruby_help [] = | 735 | static const char Ruby_help [] = |
| 734 | "In Ruby code, 'def' or 'class' or 'module' at the beginning of\n\ | 736 | "In Ruby code, 'def' or 'class' or 'module' at the beginning of\n\ |
| 735 | a line generate a tag. Constants also generate a tag."; | 737 | a line generate a tag. Constants also generate a tag."; |
| @@ -813,7 +815,7 @@ static language lang_names [] = | |||
| 813 | { "proc", no_lang_help, plain_C_entries, plain_C_suffixes }, | 815 | { "proc", no_lang_help, plain_C_entries, plain_C_suffixes }, |
| 814 | { "prolog", Prolog_help, Prolog_functions, Prolog_suffixes }, | 816 | { "prolog", Prolog_help, Prolog_functions, Prolog_suffixes }, |
| 815 | { "python", Python_help, Python_functions, Python_suffixes }, | 817 | { "python", Python_help, Python_functions, Python_suffixes }, |
| 816 | { "ruby", Ruby_help, Ruby_functions, Ruby_suffixes }, | 818 | { "ruby", Ruby_help,Ruby_functions,Ruby_suffixes,Ruby_filenames }, |
| 817 | { "scheme", Scheme_help, Scheme_functions, Scheme_suffixes }, | 819 | { "scheme", Scheme_help, Scheme_functions, Scheme_suffixes }, |
| 818 | { "tex", TeX_help, TeX_commands, TeX_suffixes }, | 820 | { "tex", TeX_help, TeX_commands, TeX_suffixes }, |
| 819 | { "texinfo", Texinfo_help, Texinfo_nodes, Texinfo_suffixes }, | 821 | { "texinfo", Texinfo_help, Texinfo_nodes, Texinfo_suffixes }, |
| @@ -1484,8 +1486,16 @@ get_language_from_filename (char *file, int case_sensitive) | |||
| 1484 | { | 1486 | { |
| 1485 | language *lang; | 1487 | language *lang; |
| 1486 | const char **name, **ext, *suffix; | 1488 | const char **name, **ext, *suffix; |
| 1489 | char *slash; | ||
| 1487 | 1490 | ||
| 1488 | /* Try whole file name first. */ | 1491 | /* Try whole file name first. */ |
| 1492 | slash = strrchr (file, '/'); | ||
| 1493 | if (slash != NULL) | ||
| 1494 | file = slash + 1; | ||
| 1495 | #ifdef DOS_NT | ||
| 1496 | else if (file[0] && file[1] == ':') | ||
| 1497 | file += 2; | ||
| 1498 | #endif | ||
| 1489 | for (lang = lang_names; lang->name != NULL; lang++) | 1499 | for (lang = lang_names; lang->name != NULL; lang++) |
| 1490 | if (lang->filenames != NULL) | 1500 | if (lang->filenames != NULL) |
| 1491 | for (name = lang->filenames; *name != NULL; name++) | 1501 | for (name = lang->filenames; *name != NULL; name++) |
| @@ -4621,6 +4631,7 @@ static void | |||
| 4621 | Ruby_functions (FILE *inf) | 4631 | Ruby_functions (FILE *inf) |
| 4622 | { | 4632 | { |
| 4623 | char *cp = NULL; | 4633 | char *cp = NULL; |
| 4634 | bool reader = false, writer = false, alias = false, continuation = false; | ||
| 4624 | 4635 | ||
| 4625 | LOOP_ON_INPUT_LINES (inf, lb, cp) | 4636 | LOOP_ON_INPUT_LINES (inf, lb, cp) |
| 4626 | { | 4637 | { |
| @@ -4629,7 +4640,9 @@ Ruby_functions (FILE *inf) | |||
| 4629 | char *name; | 4640 | char *name; |
| 4630 | 4641 | ||
| 4631 | cp = skip_spaces (cp); | 4642 | cp = skip_spaces (cp); |
| 4632 | if (c_isalpha (*cp) && c_isupper (*cp)) /* constants */ | 4643 | if (!continuation |
| 4644 | /* Constants. */ | ||
| 4645 | && c_isalpha (*cp) && c_isupper (*cp)) | ||
| 4633 | { | 4646 | { |
| 4634 | char *bp, *colon = NULL; | 4647 | char *bp, *colon = NULL; |
| 4635 | 4648 | ||
| @@ -4643,7 +4656,7 @@ Ruby_functions (FILE *inf) | |||
| 4643 | if (cp > name + 1) | 4656 | if (cp > name + 1) |
| 4644 | { | 4657 | { |
| 4645 | bp = skip_spaces (cp); | 4658 | bp = skip_spaces (cp); |
| 4646 | if (*bp == '=' && c_isspace (bp[1])) | 4659 | if (*bp == '=' && !(bp[1] == '=' || bp[1] == '>')) |
| 4647 | { | 4660 | { |
| 4648 | if (colon && !c_isspace (colon[1])) | 4661 | if (colon && !c_isspace (colon[1])) |
| 4649 | name = colon + 1; | 4662 | name = colon + 1; |
| @@ -4652,12 +4665,14 @@ Ruby_functions (FILE *inf) | |||
| 4652 | } | 4665 | } |
| 4653 | } | 4666 | } |
| 4654 | } | 4667 | } |
| 4655 | else if ((is_method = LOOKING_AT (cp, "def")) /* module/class/method */ | 4668 | else if (!continuation |
| 4656 | || (is_class = LOOKING_AT (cp, "class")) | 4669 | /* Modules, classes, methods. */ |
| 4657 | || LOOKING_AT (cp, "module")) | 4670 | && ((is_method = LOOKING_AT (cp, "def")) |
| 4671 | || (is_class = LOOKING_AT (cp, "class")) | ||
| 4672 | || LOOKING_AT (cp, "module"))) | ||
| 4658 | { | 4673 | { |
| 4659 | const char self_name[] = "self."; | 4674 | const char self_name[] = "self."; |
| 4660 | const size_t self_size1 = sizeof ("self.") - 1; | 4675 | const size_t self_size1 = sizeof (self_name) - 1; |
| 4661 | 4676 | ||
| 4662 | name = cp; | 4677 | name = cp; |
| 4663 | 4678 | ||
| @@ -4689,6 +4704,86 @@ Ruby_functions (FILE *inf) | |||
| 4689 | make_tag (name, cp - name, true, | 4704 | make_tag (name, cp - name, true, |
| 4690 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 4705 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
| 4691 | } | 4706 | } |
| 4707 | else | ||
| 4708 | { | ||
| 4709 | /* Tag accessors and aliases. */ | ||
| 4710 | |||
| 4711 | if (!continuation) | ||
| 4712 | reader = writer = alias = false; | ||
| 4713 | |||
| 4714 | while (*cp && *cp != '#') | ||
| 4715 | { | ||
| 4716 | if (!continuation) | ||
| 4717 | { | ||
| 4718 | reader = writer = alias = false; | ||
| 4719 | if (LOOKING_AT (cp, "attr_reader")) | ||
| 4720 | reader = true; | ||
| 4721 | else if (LOOKING_AT (cp, "attr_writer")) | ||
| 4722 | writer = true; | ||
| 4723 | else if (LOOKING_AT (cp, "attr_accessor")) | ||
| 4724 | { | ||
| 4725 | reader = true; | ||
| 4726 | writer = true; | ||
| 4727 | } | ||
| 4728 | else if (LOOKING_AT (cp, "alias_method")) | ||
| 4729 | alias = true; | ||
| 4730 | } | ||
| 4731 | if (reader || writer || alias) | ||
| 4732 | { | ||
| 4733 | do { | ||
| 4734 | char *np = cp; | ||
| 4735 | |||
| 4736 | if (*np == ':') | ||
| 4737 | np++; | ||
| 4738 | cp = skip_name (cp); | ||
| 4739 | if (reader) | ||
| 4740 | { | ||
| 4741 | make_tag (np, cp - np, true, | ||
| 4742 | lb.buffer, cp - lb.buffer + 1, | ||
| 4743 | lineno, linecharno); | ||
| 4744 | continuation = false; | ||
| 4745 | } | ||
| 4746 | if (writer) | ||
| 4747 | { | ||
| 4748 | size_t name_len = cp - np + 1; | ||
| 4749 | char *wr_name = xnew (name_len + 1, char); | ||
| 4750 | |||
| 4751 | memcpy (wr_name, np, name_len - 1); | ||
| 4752 | memcpy (wr_name + name_len - 1, "=", 2); | ||
| 4753 | pfnote (wr_name, true, lb.buffer, cp - lb.buffer + 1, | ||
| 4754 | lineno, linecharno); | ||
| 4755 | continuation = false; | ||
| 4756 | } | ||
| 4757 | if (alias) | ||
| 4758 | { | ||
| 4759 | if (!continuation) | ||
| 4760 | make_tag (np, cp - np, true, | ||
| 4761 | lb.buffer, cp - lb.buffer + 1, | ||
| 4762 | lineno, linecharno); | ||
| 4763 | continuation = false; | ||
| 4764 | while (*cp && *cp != '#' && *cp != ';') | ||
| 4765 | { | ||
| 4766 | if (*cp == ',') | ||
| 4767 | continuation = true; | ||
| 4768 | else if (!c_isspace (*cp)) | ||
| 4769 | continuation = false; | ||
| 4770 | cp++; | ||
| 4771 | } | ||
| 4772 | if (*cp == ';') | ||
| 4773 | continuation = false; | ||
| 4774 | } | ||
| 4775 | cp = skip_spaces (cp); | ||
| 4776 | } while ((alias | ||
| 4777 | ? (*cp == ',') | ||
| 4778 | : (continuation = (*cp == ','))) | ||
| 4779 | && (cp = skip_spaces (cp + 1), *cp && *cp != '#')); | ||
| 4780 | } | ||
| 4781 | if (*cp != '#') | ||
| 4782 | cp = skip_name (cp); | ||
| 4783 | while (*cp && *cp != '#' && notinname (*cp)) | ||
| 4784 | cp++; | ||
| 4785 | } | ||
| 4786 | } | ||
| 4692 | } | 4787 | } |
| 4693 | } | 4788 | } |
| 4694 | 4789 | ||