From cabe9044380df45c1d5d57243955b49de721861a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 11 Dec 2015 11:17:31 +0200 Subject: Improve and document Ruby support in 'etags' * lib-src/etags.c (Ruby_suffixes): Add ".ruby". (Ruby_functions): Support "module" and overloaded operators. (Ruby_help): Mention "module". * test/etags/ruby-src/test.rb: * test/etags/ruby-src/test1.ruby: New files. * test/etags/Makefile (RBSRC): New tests. (SRCS): Add ${RBSRC}. * test/etags/ETAGS.good_1: * test/etags/ETAGS.good_2: * test/etags/ETAGS.good_3: * test/etags/ETAGS.good_4: * test/etags/ETAGS.good_5: * test/etags/ETAGS.good_6: * test/etags/CTAGS.good: Adapt to the new Ruby tests. * doc/man/etags.1: Mention Ruby support. * etc/NEWS: Mention Ruby support. --- lib-src/etags.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'lib-src') diff --git a/lib-src/etags.c b/lib-src/etags.c index c91cef40bfa..cd49f7199ba 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -724,10 +724,10 @@ static const char Python_help [] = generate a tag."; static const char *Ruby_suffixes [] = - { "rb", NULL }; + { "rb", "ruby", NULL }; static const char Ruby_help [] = - "In Ruby code, 'def' or 'class' at the beginning of a line\n\ -generate a tag."; + "In Ruby code, 'def' or 'class' or 'module' at the beginning of\n\ +a line generate a tag."; /* Can't do the `SCM' or `scm' prefix with a version number. */ static const char *Scheme_suffixes [] = @@ -4552,15 +4552,19 @@ Ruby_functions (FILE *inf) LOOP_ON_INPUT_LINES (inf, lb, cp) { cp = skip_spaces (cp); - if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class")) + if (LOOKING_AT (cp, "def") + || LOOKING_AT (cp, "class") + || LOOKING_AT (cp, "module")) { char *name = cp; - while (!notinname (*cp)) + /* Ruby method names can end in a '='. Also, operator overloading can + define operators whose names include '='. */ + while (!notinname (*cp) || *cp == '=') cp++; - make_tag(name, cp -name, true, - lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + make_tag (name, cp - name, true, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); } } } -- cgit v1.2.1