From 2c08f40aa9c5a027b8eebb4efce4c937d0bb99d3 Mon Sep 17 00:00:00 2001 From: Navin P <74448943+navinp0304@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:32:24 +0530 Subject: [PATCH 01/10] Add support for $ in fortran identifiers and clickable .i include files. (#4642) fixes #4610 Signed-off-by: Navin P S Co-authored-by: Vladimir Kotal --- .../fortran/FortranAnalyzerFactory.java | 3 +- .../main/jflex/analysis/fortran/Fortran.lexh | 2 +- .../fortran/FortranSymbolTokenizer.lex | 2 + .../jflex/analysis/fortran/FortranXref.lex | 11 ++-- .../analysis/fortran/FortranXrefTest.java | 2 +- .../test/resources/analysis/fortran/sample.f | 12 ++++ .../analysis/fortran/sample_xref.html | 56 ++++++++++------- .../analysis/fortran/samplesymbols.txt | 4 ++ .../resources/analysis/fortran/sampletags | 60 +++++++++++++++---- 9 files changed, 110 insertions(+), 42 deletions(-) diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/fortran/FortranAnalyzerFactory.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/fortran/FortranAnalyzerFactory.java index 3bc256d38d9..f3ec4b32a53 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/fortran/FortranAnalyzerFactory.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/fortran/FortranAnalyzerFactory.java @@ -49,7 +49,8 @@ public class FortranAnalyzerFactory extends FileAnalyzerFactory { "F95", "F03", "F08", - "F15"}; + "F15", + "F77"}; public FortranAnalyzerFactory() { super(null, null, SUFFIXES, null, null, "text/plain", AbstractAnalyzer.Genre.PLAIN, NAME, true); diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/Fortran.lexh b/opengrok-indexer/src/main/jflex/analysis/fortran/Fortran.lexh index 86994f85da2..7e9577f4588 100644 --- a/opengrok-indexer/src/main/jflex/analysis/fortran/Fortran.lexh +++ b/opengrok-indexer/src/main/jflex/analysis/fortran/Fortran.lexh @@ -22,7 +22,7 @@ * Portions Copyright (c) 2017, Chris Fraire . */ -Identifier = [a-zA-Z_] [a-zA-Z0-9_]* +Identifier = [a-zA-Z_] [a-zA-Z0-9_$]* Label = [0-9]+ Number = ([0-9]+\.[0-9]+|[0-9][0-9]* | [0][xX] [0-9a-fA-F]+ )([uUdDlL]+)? diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex index c0763088939..8be50e0afeb 100644 --- a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex +++ b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranSymbolTokenizer.lex @@ -52,11 +52,13 @@ import org.opengrok.indexer.analysis.JFlexSymbolMatcher; return yystate(); } } +{WhspChar}* "include" {WhspChar}* (\'[^\'\n\r]+\'| \"[^\"\n\r]+\") {} {Number} {} \" { yybegin(STRING); } \' { yybegin(QSTRING); } \! { yybegin(SCOMMENT); } + "C" { yybegin(SCOMMENT); } } { diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex index 685bfb5bc1d..037eafd4973 100644 --- a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex +++ b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex @@ -59,7 +59,7 @@ import org.opengrok.indexer.web.HtmlConsts; } %} -File = [a-zA-Z]{FNameChar}* ".inc" +File = [a-zA-Z]{FNameChar}* "." ("i"|"inc") %state STRING SCOMMENT QSTRING LCOMMENT @@ -86,13 +86,14 @@ File = [a-zA-Z]{FNameChar}* ".inc" onFilteredSymbolMatched(yytext(), yychar, Consts.kwd, false); } +"'" ({File}|{FPath}) "'" | "<" ({File}|{FPath}) ">" { chkLOC(); - onNonSymbolMatched("<", yychar); - String file = yytext(); - file = file.substring(1, file.length() - 1); + String cmatch = yytext(); + onNonSymbolMatched(cmatch.substring(0, 1), yychar); + String file = cmatch.substring(1, cmatch.length() - 1); onFilelikeMatched(file, yychar + 1); - onNonSymbolMatched(">", yychar + 1 + file.length()); + onNonSymbolMatched(cmatch.substring(cmatch.length() - 1, 1), yychar + 1 + file.length()); } /*{Hier} diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/fortran/FortranXrefTest.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/fortran/FortranXrefTest.java index dd7983a3e4a..e43a5f0140c 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/fortran/FortranXrefTest.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/fortran/FortranXrefTest.java @@ -40,7 +40,7 @@ void sampleTest() throws IOException { writeAndCompare(new FortranAnalyzerFactory(), "analysis/fortran/sample.f", "analysis/fortran/sample_xref.html", - readTagsFromResource("analysis/fortran/sampletags"), 28); + readTagsFromResource("analysis/fortran/sampletags"), 32); } @Test diff --git a/opengrok-indexer/src/test/resources/analysis/fortran/sample.f b/opengrok-indexer/src/test/resources/analysis/fortran/sample.f index 7fd7257c30d..014f3e70443 100644 --- a/opengrok-indexer/src/test/resources/analysis/fortran/sample.f +++ b/opengrok-indexer/src/test/resources/analysis/fortran/sample.f @@ -227,4 +227,16 @@ SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) * End of DGESV * END + +* A Fortran 77 subroutine that ends in $ +* ===================================================================== + SUBROUTINE SUBF77$() +* + INTEGER VARF77$ + VARF77$ = 0 +* +* ===================================================================== +* + CALL SUBF77$ + CALL 'http://example.com' diff --git a/opengrok-indexer/src/test/resources/analysis/fortran/sample_xref.html b/opengrok-indexer/src/test/resources/analysis/fortran/sample_xref.html index bde8dc1e5b0..1adb6dc847b 100644 --- a/opengrok-indexer/src/test/resources/analysis/fortran/sample_xref.html +++ b/opengrok-indexer/src/test/resources/analysis/fortran/sample_xref.html @@ -4,7 +4,7 @@ sampleFile - OpenGrok cross reference for /sampleFile 1* Copyright (c) 2013 Samuel Halliday +function get_sym_list(){return [];} /* ]]> */1* Copyright (c) 2013 Samuel Halliday 2* Copyright (c) 1992-2011 The University of Tennessee and The University 3* of Tennessee Research Foundation. All rights 4* reserved. @@ -176,7 +176,7 @@ 170*> \ingroup doubleGEsolve 171* 172* ===================================================================== -173 SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) +173 SUBROUTINE DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO ) 174* 175* -- LAPACK driver routine (version 3.4.0) -- 176* -- LAPACK is a software package provided by Univ. of Tennessee, -- @@ -184,11 +184,11 @@ 178* November 2011 179* 180* .. Scalar Arguments .. -181 INTEGER INFO, LDA, LDB, N, NRHS +181 INTEGER INFO, LDA, LDB, N, NRHS 182* .. 183* .. Array Arguments .. -184 INTEGER IPIV( * ) -185 DOUBLE PRECISION A( LDA, * ), B( LDB, * ) +184 INTEGER IPIV( * ) +185 DOUBLE PRECISION A( LDA, * ), B( LDB, * ) 186* .. 187* 188* ===================================================================== @@ -203,36 +203,48 @@ 197* 198* Test the input parameters. 199* -200 INFO = 0 + 0xFFFF - 0XFF - 0xFF00 -201 IF( N.LT.0 ) THEN -202 INFO = -1 -203 ELSE IF( NRHS.LT.0 ) THEN -204 INFO = -2 -205 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN -206 INFO = -4 -207 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN -208 INFO = -7 +200 INFO = 0 + 0xFFFF - 0XFF - 0xFF00 +201 IF( N.LT.0 ) THEN +202 INFO = -1 +203 ELSE IF( NRHS.LT.0 ) THEN +204 INFO = -2 +205 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN +206 INFO = -4 +207 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN +208 INFO = -7 209 END IF -210 IF( INFO.NE.0 ) THEN -211 CALL XERBLA( 'DGESV ', -INFO ) +210 IF( INFO.NE.0 ) THEN +211 CALL XERBLA( 'DGESV ', -INFO ) 212 RETURN 213 END IF 214* 215* Compute the LU factorization of A. 216* -217 CALL DGETRF( N, N, A, LDA, IPIV, INFO ) -218 IF( INFO.EQ.0 ) THEN +217 CALL DGETRF( N, N, A, LDA, IPIV, INFO ) +218 IF( INFO.EQ.0 ) THEN 219* 220* Solve the system A*X = B, overwriting B with X. 221* -222 CALL DGETRS( 'No transpose', N, NRHS, A, LDA, IPIV, B, LDB, -223 $ INFO ) +222 CALL DGETRS( 'No transpose', N, NRHS, A, LDA, IPIV, B, LDB, +223 $ INFO ) 224 END IF 225 RETURN 226* 227* End of DGESV 228* 229 END -230 CALL 'http://example.com' -231 +230 +231* A Fortran 77 subroutine that ends in $ +232* ===================================================================== +233 SUBROUTINE SUBF77$() +234* +235 INTEGER VARF77$ +236 VARF77$ = 0 +237* +238* ===================================================================== +239* +240 CALL SUBF77$ +241 +242 CALL 'http://example.com' +243 diff --git a/opengrok-indexer/src/test/resources/analysis/fortran/samplesymbols.txt b/opengrok-indexer/src/test/resources/analysis/fortran/samplesymbols.txt index a41cfb276bb..5e80e84474b 100644 --- a/opengrok-indexer/src/test/resources/analysis/fortran/samplesymbols.txt +++ b/opengrok-indexer/src/test/resources/analysis/fortran/samplesymbols.txt @@ -52,3 +52,7 @@ IPIV B LDB INFO +SUBF77$ +VARF77$ +VARF77$ +SUBF77$ diff --git a/opengrok-indexer/src/test/resources/analysis/fortran/sampletags b/opengrok-indexer/src/test/resources/analysis/fortran/sampletags index 4c3bfc07496..ce971b069f4 100644 --- a/opengrok-indexer/src/test/resources/analysis/fortran/sampletags +++ b/opengrok-indexer/src/test/resources/analysis/fortran/sampletags @@ -1,16 +1,52 @@ +!_TAG_EXTRA_DESCRIPTION anonymous /Include tags for non-named objects like lambda/ +!_TAG_EXTRA_DESCRIPTION fileScope /Include tags of file scope/ +!_TAG_EXTRA_DESCRIPTION pseudo /Include pseudo tags/ +!_TAG_EXTRA_DESCRIPTION subparser /Include tags generated by subparsers/ +!_TAG_FIELD_DESCRIPTION epoch /the last modified time of the input file (only for F\/file kind tag)/ +!_TAG_FIELD_DESCRIPTION file /File-restricted scoping/ +!_TAG_FIELD_DESCRIPTION input /input file/ +!_TAG_FIELD_DESCRIPTION name /tag name/ +!_TAG_FIELD_DESCRIPTION pattern /pattern/ +!_TAG_FIELD_DESCRIPTION typeref /Type and name of a variable or typedef/ !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ -!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_KIND_DESCRIPTION!Fortran E,enum /enumerations/ +!_TAG_KIND_DESCRIPTION!Fortran L,local /local, common block, and namelist variables/ +!_TAG_KIND_DESCRIPTION!Fortran M,method /type bound procedures/ +!_TAG_KIND_DESCRIPTION!Fortran N,enumerator /enumeration values/ +!_TAG_KIND_DESCRIPTION!Fortran S,submodule /submodules/ +!_TAG_KIND_DESCRIPTION!Fortran b,blockData /block data/ +!_TAG_KIND_DESCRIPTION!Fortran c,common /common blocks/ +!_TAG_KIND_DESCRIPTION!Fortran e,entry /entry points/ +!_TAG_KIND_DESCRIPTION!Fortran f,function /functions/ +!_TAG_KIND_DESCRIPTION!Fortran i,interface /interface contents, generic names, and operators/ +!_TAG_KIND_DESCRIPTION!Fortran k,component /type and structure components/ +!_TAG_KIND_DESCRIPTION!Fortran l,label /labels/ +!_TAG_KIND_DESCRIPTION!Fortran m,module /modules/ +!_TAG_KIND_DESCRIPTION!Fortran n,namelist /namelists/ +!_TAG_KIND_DESCRIPTION!Fortran p,program /programs/ +!_TAG_KIND_DESCRIPTION!Fortran s,subroutine /subroutines/ +!_TAG_KIND_DESCRIPTION!Fortran t,type /derived types and structures/ +!_TAG_KIND_DESCRIPTION!Fortran v,variable /program (global) and module variables/ +!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/ +!_TAG_OUTPUT_FILESEP slash /slash or backslash/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ +!_TAG_OUTPUT_VERSION 0.0 /current.age/ +!_TAG_PARSER_VERSION!Fortran 1.1 /current.age/ +!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/ +!_TAG_PROC_CWD /home/navin.parakkal/OpenGrok/opengrok-indexer/src/test/resources/analysis/fortran/ // !_TAG_PROGRAM_AUTHOR Universal Ctags Team // !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ !_TAG_PROGRAM_URL https://ctags.io/ /official site/ -!_TAG_PROGRAM_VERSION 0.0.0 /b13cb551/ -!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ -DGESV grok.f /^ SUBROUTINE DGESV(/;" subroutine line:173 signature:(N, NRHS, A, LDA, IPIV, B, LDB, INFO) -INFO grok.f /^ INTEGER INFO,/;" local line:181 subroutine:DGESV -LDA grok.f /^ INTEGER INFO, LDA,/;" local line:181 subroutine:DGESV -LDB grok.f /^ INTEGER INFO, LDA, LDB,/;" local line:181 subroutine:DGESV -N grok.f /^ INT/;" local line:181 subroutine:DGESV -NRHS grok.f /^ INTEGER INFO, LDA, LDB, N, NRHS$/;" local line:181 subroutine:DGESV -IPIV grok.f /^ INTEGER IPIV(/;" local line:184 subroutine:DGESV -A grok.f /^ DOUBLE PRECISION A(/;" local line:185 subroutine:DGESV -B grok.f /^ DOUBL/;" local line:185 subroutine:DGESV +!_TAG_PROGRAM_VERSION 6.1.0 /p6.1.20240714.0/ +A sample.f /^ DOUBLE PRECISION A( LDA,/;" L subroutine:DGESV file: +B sample.f /^ DOUBLE PRECISION A( LDA, * ), B( LDB,/;" L subroutine:DGESV file: +DGESV sample.f /^ SUBROUTINE DGESV(/;" s +INFO sample.f /^ INTEGER INFO,/;" L subroutine:DGESV file: +IPIV sample.f /^ INTEGER IPIV(/;" L subroutine:DGESV file: +LDA sample.f /^ INTEGER INFO, LDA,/;" L subroutine:DGESV file: +LDB sample.f /^ INTEGER INFO, LDA, LDB,/;" L subroutine:DGESV file: +N sample.f /^ INTEGER INFO, LDA, LDB, N, NR/;" L subroutine:DGESV file: +NRHS sample.f /^ INTEGER INFO, LDA, LDB, N, NRHS$/;" L subroutine:DGESV file: +SUBF77$ sample.f /^ SUBROUTINE SUBF77$(/;" s +VARF77$ sample.f /^ INTEGER VARF77\$$/;" L subroutine:SUBF77$ file: From 252a540686020875ed981135214c6ba196488d95 Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Tue, 8 Oct 2024 10:05:50 +0200 Subject: [PATCH 02/10] quote path in log statement (#4669) --- .../org/opengrok/indexer/configuration/Configuration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java index d9fed1c0ace..11ecca956f5 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java @@ -18,7 +18,7 @@ */ /* - * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * Portions Copyright (c) 2017, 2020, Chris Fraire . * Portions Copyright (c) 2020, Aleksandr Kirillov . */ @@ -1510,7 +1510,7 @@ public void encodeObject(OutputStream out) { } public static Configuration read(File file) throws IOException { - LOGGER.log(Level.INFO, "Reading configuration from {0}", file.getCanonicalPath()); + LOGGER.log(Level.INFO, "Reading configuration from ''{0}''", file.getCanonicalPath()); try (FileInputStream in = new FileInputStream(file)) { return decodeObject(in); } From e68aafe3e247d950d007cfe1204ca3f54300c8c6 Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Fri, 11 Oct 2024 16:21:51 +0200 Subject: [PATCH 03/10] do not constrain the output of the Groups command in opengrok-groups (#4671) fixes #4670 Also, do not install Python packages on Linux as the system environment is externally managed --- dev/before_install | 6 --- .../src/main/python/opengrok_tools/groups.py | 5 ++- .../python/opengrok_tools/utils/command.py | 29 +++++++++--- .../main/python/opengrok_tools/utils/java.py | 6 ++- tools/src/test/python/test_command.py | 44 +++++++++++++++---- 5 files changed, 64 insertions(+), 26 deletions(-) diff --git a/dev/before_install b/dev/before_install index f7ff69c982d..22ed36a5194 100755 --- a/dev/before_install +++ b/dev/before_install @@ -28,12 +28,6 @@ if [[ "$RUNNER_OS" == "Linux" ]]; then # Bitkeeper install failure is not critical, so exit code is not checked. sudo ./dev/install-bitkeeper.sh - sudo -H ./dev/install-python-packages.sh - if [[ $? != 0 ]]; then - echo "cannot install Python packages" - exit 1 - fi - sudo ./dev/install-universal_ctags.sh if [[ $? != 0 ]]; then echo "cannot install Universal ctags" diff --git a/tools/src/main/python/opengrok_tools/groups.py b/tools/src/main/python/opengrok_tools/groups.py index a034eff629f..7c0689e94af 100755 --- a/tools/src/main/python/opengrok_tools/groups.py +++ b/tools/src/main/python/opengrok_tools/groups.py @@ -18,7 +18,7 @@ # CDDL HEADER END # -# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. # import argparse @@ -51,7 +51,8 @@ def main(): cmd = Java(args.options, classpath=args.jar, java=args.java, java_opts=args.java_opts, redirect_stderr=False, main_class='org.opengrok.indexer.configuration.Groups', - logger=logger, doprint=args.doprint) + logger=logger, doprint=args.doprint, + max_line_length=-1, max_lines=-1) cmd.execute() ret = cmd.getretcode() if ret is None or ret != SUCCESS_EXITVAL: diff --git a/tools/src/main/python/opengrok_tools/utils/command.py b/tools/src/main/python/opengrok_tools/utils/command.py index 190fe8d96fd..06cd9ce9797 100644 --- a/tools/src/main/python/opengrok_tools/utils/command.py +++ b/tools/src/main/python/opengrok_tools/utils/command.py @@ -18,7 +18,7 @@ # # -# Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. # import logging @@ -49,10 +49,13 @@ class Command: ERRORED = "errored" TIMEDOUT = "timed out" + MAX_LINE_LENGTH_DEFAULT = 250 + MAX_LINES_DEFAULT = 10000 + def __init__(self, cmd, args_subst=None, args_append=None, logger=None, excl_subst=False, work_dir=None, env_vars=None, timeout=None, redirect_stderr=True, resource_limits=None, doprint=False, - max_line_length=250, max_lines=10000): + max_line_length=None, max_lines=None): if doprint is None: doprint = False @@ -72,8 +75,17 @@ def __init__(self, cmd, args_subst=None, args_append=None, logger=None, self.doprint = doprint self.err = None self.returncode = None - self.max_line_length = int(max_line_length) - self.max_lines = int(max_lines) + + # Convert the maximums to integers to avoid exceptions when using them as indexes + # in case they are passed as floats. + if (max_line_length is None): + self.max_line_length = self.MAX_LINE_LENGTH_DEFAULT + else: + self.max_line_length = int(max_line_length) + if (max_lines is None): + self.max_lines = self.MAX_LINES_DEFAULT + else: + self.max_lines = int(max_lines) self.logger = logger or logging.getLogger(__name__) @@ -162,7 +174,10 @@ class OutputThread(threading.Thread): stdout/stderr buffers fill up. """ - def __init__(self, event, logger, doprint=False, max_line_length=250, max_lines=10000): + def __init__(self, event, logger, doprint=False, + max_line_length=Command.MAX_LINE_LENGTH_DEFAULT, + max_lines=Command.MAX_LINES_DEFAULT): + super(OutputThread, self).__init__() self.read_fd, self.write_fd = os.pipe() self.pipe_fobj = os.fdopen(self.read_fd, encoding='utf8') @@ -195,11 +210,11 @@ def run(self): line = line.rstrip() # This will remove not only newline but also whitespace. # Assuming that self.max_line_length is bigger than 3. - if len(line) > self.max_line_length: + if self.max_line_length > 0 and len(line) > self.max_line_length: line = line[:self.max_line_length] + "..." # Shorten the list to be one less than the maximum because a line is going to be added. - if len(self.out) >= self.max_lines: + if self.max_lines > 0 and len(self.out) >= self.max_lines: self.out = self.out[-self.max_lines + 1:] self.out[0] = "... " diff --git a/tools/src/main/python/opengrok_tools/utils/java.py b/tools/src/main/python/opengrok_tools/utils/java.py index d8d659e7ee7..1dc0b44e596 100755 --- a/tools/src/main/python/opengrok_tools/utils/java.py +++ b/tools/src/main/python/opengrok_tools/utils/java.py @@ -37,7 +37,8 @@ class Java(Command): def __init__(self, command, logger=None, main_class=None, java=None, jar=None, java_opts=None, classpath=None, env_vars=None, - redirect_stderr=True, doprint=False): + redirect_stderr=True, doprint=False, + max_line_length=None, max_lines=None): if not java: java = self.FindJava(logger) @@ -72,7 +73,8 @@ def __init__(self, command, logger=None, main_class=None, java=None, logger.debug("Java command: {}".format(java_command)) super().__init__(java_command, logger=logger, env_vars=env, - redirect_stderr=redirect_stderr, doprint=doprint) + redirect_stderr=redirect_stderr, doprint=doprint, + max_line_length=max_line_length, max_lines=max_lines) def FindJava(self, logger): """ diff --git a/tools/src/test/python/test_command.py b/tools/src/test/python/test_command.py index ef77a58b1c9..3543ddd3a02 100755 --- a/tools/src/test/python/test_command.py +++ b/tools/src/test/python/test_command.py @@ -20,7 +20,7 @@ # # -# Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 2024, Oracle affiliates. All rights reserved. # Portions Copyright (c) 2020, Krystof Tulinger # @@ -29,6 +29,8 @@ import tempfile import time +from enum import Enum + import pytest from conftest import posix_only, system_binary @@ -181,19 +183,39 @@ def test_stderr(): assert 'root' in "\n".join(cmd.getoutput()) +class LongTestMode(Enum): + """ + Enum to parametrize the long output test below. + """ + ORIGINAL = 1 + SHORTEN = 2 + UNLIMITED = 3 + + # This test needs the "/bin/cat" command, therefore it is Unix only. @posix_only -@pytest.mark.parametrize('shorten', [True, False]) -def test_long_output(shorten): +@pytest.mark.parametrize("mode", [LongTestMode.SHORTEN, LongTestMode.ORIGINAL, LongTestMode.UNLIMITED]) +def test_long_output(mode): """ Test that output thread in the Command class captures all the output. (and also it does not hang the command by filling up the pipe) + Also test the truncation. + By default, stderr is redirected to stdout. """ - num_lines = 5000 - line_length = 1000 - # should be enough to fill a pipe + num_lines_orig = 15000 + line_length_orig = 1000 + + # By using different values than the defaults, the modes which set the lengths + # to non-negative/not-None values will verify that non-default values are acted upon. + assert line_length_orig > Command.MAX_LINE_LENGTH_DEFAULT + assert num_lines_orig > Command.MAX_LINES_DEFAULT + + num_lines = num_lines_orig + line_length = line_length_orig + + # Should be enough to fill a pipe on most systems. num_bytes = num_lines * (line_length + 1) with tempfile.NamedTemporaryFile() as file: for _ in range(num_lines): @@ -202,9 +224,12 @@ def test_long_output(shorten): file.flush() assert os.path.getsize(file.name) == num_bytes - if shorten: + if mode is LongTestMode.SHORTEN: num_lines //= 2 line_length //= 2 + elif mode is LongTestMode.UNLIMITED: + num_lines = -1 + line_length = -1 cmd = Command(["/bin/cat", file.name], max_lines=num_lines, max_line_length=line_length) cmd.execute() @@ -212,11 +237,12 @@ def test_long_output(shorten): assert cmd.getstate() == Command.FINISHED assert cmd.getretcode() == 0 assert cmd.geterroutput() is None - assert len(cmd.getoutput()) == num_lines - if shorten: + if mode is LongTestMode.SHORTEN: + assert len(cmd.getoutput()) == num_lines # Add 3 for the '...' suffix. assert all(len(x) <= line_length + 3 for x in cmd.getoutput()) else: + assert len(cmd.getoutput()) == num_lines_orig assert len("\n".join(cmd.getoutput()) + "\n") == num_bytes From fc478df1d21db874df32b93375390ae6af19110b Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Fri, 11 Oct 2024 16:26:57 +0200 Subject: [PATCH 04/10] 1.13.23 --- distribution/pom.xml | 8 ++++---- opengrok-indexer/pom.xml | 4 ++-- opengrok-web/pom.xml | 4 ++-- plugins/pom.xml | 4 ++-- pom.xml | 2 +- suggester/pom.xml | 2 +- tools/pom.xml | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/distribution/pom.xml b/distribution/pom.xml index 4f932ef278c..460bbf273c4 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -7,7 +7,7 @@ org.opengrok opengrok-top - 1.13.22 + 1.13.23 opengrok-dist @@ -28,20 +28,20 @@ org.opengrok opengrok - 1.13.22 + 1.13.23 org.opengrok opengrok-web - 1.13.22 + 1.13.23 war org.opengrok tools - 1.13.22 + 1.13.23 pom diff --git a/opengrok-indexer/pom.xml b/opengrok-indexer/pom.xml index f2e3799c381..9781efd86e0 100644 --- a/opengrok-indexer/pom.xml +++ b/opengrok-indexer/pom.xml @@ -29,11 +29,11 @@ Portions Copyright (c) 2020-2020, Lubos Kosco . org.opengrok opengrok-top - 1.13.22 + 1.13.23 opengrok - 1.13.22 + 1.13.23 jar OpenGrok Indexer diff --git a/opengrok-web/pom.xml b/opengrok-web/pom.xml index 91c5c22d23d..7ea2da4a740 100644 --- a/opengrok-web/pom.xml +++ b/opengrok-web/pom.xml @@ -28,11 +28,11 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . org.opengrok opengrok-top - 1.13.22 + 1.13.23 opengrok-web - 1.13.22 + 1.13.23 war OpenGrok Web diff --git a/plugins/pom.xml b/plugins/pom.xml index 205abe521fd..02a15d99c96 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -28,11 +28,11 @@ Portions Copyright (c) 2020, Chris Fraire . org.opengrok opengrok-top - 1.13.22 + 1.13.23 plugins - 1.13.22 + 1.13.23 jar OpenGrok authorization plugins diff --git a/pom.xml b/pom.xml index 2a0218a11c2..4dcbbb36b8d 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . org.opengrok opengrok-top - 1.13.22 + 1.13.23 pom OpenGrok diff --git a/suggester/pom.xml b/suggester/pom.xml index 02ef66f1d77..a9db898f7af 100644 --- a/suggester/pom.xml +++ b/suggester/pom.xml @@ -28,7 +28,7 @@ Portions Copyright (c) 2020, Chris Fraire . opengrok-top org.opengrok - 1.13.22 + 1.13.23 suggester diff --git a/tools/pom.xml b/tools/pom.xml index 43448ac0ab0..1b7f26de3c2 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -29,11 +29,11 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire . org.opengrok opengrok-top - 1.13.22 + 1.13.23 tools - 1.13.22 + 1.13.23 pom OpenGrok tools From 785896c3c8709731cca53bc6791419743dfcdefe Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Thu, 17 Oct 2024 09:17:58 +0200 Subject: [PATCH 05/10] enforce Java version (#4677) current version of Lucene will fail with 22 or later --- .../org/opengrok/indexer/index/Indexer.java | 8 +++- .../opengrok/indexer/util/RuntimeUtil.java | 48 +++++++++++++++++++ .../java/org/opengrok/web/WebappListener.java | 10 ++-- 3 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 opengrok-indexer/src/main/java/org/opengrok/indexer/util/RuntimeUtil.java diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java index 435e098f57e..c235674f9a4 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java @@ -18,7 +18,7 @@ */ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * Portions Copyright (c) 2011, Jens Elkner. * Portions Copyright (c) 2017, 2020, Chris Fraire . */ @@ -86,6 +86,8 @@ import org.opengrok.indexer.util.OptionParser; import org.opengrok.indexer.util.Statistics; +import static org.opengrok.indexer.util.RuntimeUtil.checkJavaVersion; + /** * Creates and updates an inverted source index as well as generates Xref, file * stats etc., if specified in the options. @@ -371,7 +373,9 @@ public static void main(String[] argv) { } LOGGER.log(Level.INFO, "Indexer version {0} ({1}) running on Java {2}", - new Object[]{Info.getVersion(), Info.getRevision(), System.getProperty("java.version")}); + new Object[]{Info.getVersion(), Info.getRevision(), Runtime.version()}); + + checkJavaVersion(); // Create history cache first. if (searchRepositories) { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/RuntimeUtil.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/RuntimeUtil.java new file mode 100644 index 00000000000..3669e47d624 --- /dev/null +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/RuntimeUtil.java @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * See LICENSE.txt included in this distribution for the specific + * language governing permissions and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at LICENSE.txt. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + */ +package org.opengrok.indexer.util; + +public class RuntimeUtil { + private RuntimeUtil() { + // private for static + } + + /* + * interval of supported Java versions + */ + static final int JAVA_VERSION_MIN = 11; + static final int JAVA_VERSION_MAX = 21; + + /** + * @throws RuntimeException if the Java runtime version is outside + * {@link #JAVA_VERSION_MIN} and {@link #JAVA_VERSION_MAX}. + */ + public static void checkJavaVersion() throws RuntimeException { + Runtime.Version javaVersion = Runtime.version(); + int majorVersion = javaVersion.version().get(0); + if (majorVersion < JAVA_VERSION_MIN || majorVersion > JAVA_VERSION_MAX) { + throw new RuntimeException(String.format("unsupported Java version %d [%d,%d)", + majorVersion, JAVA_VERSION_MIN, JAVA_VERSION_MAX)); + } + } +} diff --git a/opengrok-web/src/main/java/org/opengrok/web/WebappListener.java b/opengrok-web/src/main/java/org/opengrok/web/WebappListener.java index 114849bb2e0..7c806d9c5e4 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/WebappListener.java +++ b/opengrok-web/src/main/java/org/opengrok/web/WebappListener.java @@ -18,7 +18,7 @@ */ /* - * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * Portions Copyright (c) 2018, 2019, Chris Fraire . */ package org.opengrok.web; @@ -55,6 +55,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import static org.opengrok.indexer.util.RuntimeUtil.checkJavaVersion; + /** * Initialize webapp context. * @@ -77,8 +79,10 @@ public void contextInitialized(final ServletContextEvent servletContextEvent) { ServletContext context = servletContextEvent.getServletContext(); RuntimeEnvironment env = RuntimeEnvironment.getInstance(); - LOGGER.log(Level.INFO, "Starting webapp with version {0} ({1})", - new Object[]{Info.getVersion(), Info.getRevision()}); + LOGGER.log(Level.INFO, "Starting webapp with version {0} ({1}) on Java {2}", + new Object[]{Info.getVersion(), Info.getRevision(), Runtime.version()}); + + checkJavaVersion(); String configPath = Optional.ofNullable(context.getInitParameter("CONFIGURATION")) .orElseThrow(() -> new WebappError("CONFIGURATION parameter missing in the web.xml file")); From d186ae69245541a2602a17427e4ad0bd20bd8f1d Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Tue, 29 Oct 2024 11:17:16 +0100 Subject: [PATCH 06/10] fall back to the default temporary directory for ctags check fixes #4574 --- .../configuration/RuntimeEnvironment.java | 2 +- .../org/opengrok/indexer/util/CtagsUtil.java | 19 ++++++---- .../opengrok/indexer/util/CtagsUtilTest.java | 36 ++++++++++++++++--- pom.xml | 2 +- 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java index 8d24bed9436..2f04697971d 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java @@ -711,7 +711,7 @@ public synchronized boolean validateUniversalCtags() { ctagsLanguages.addAll(languages); } - ctagsFound = CtagsUtil.validate(ctagsBinary); + ctagsFound = CtagsUtil.isValid(ctagsBinary); } if (ctagsFound) { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/CtagsUtil.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/CtagsUtil.java index bdea93b4354..e8b8f42bed2 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/CtagsUtil.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/CtagsUtil.java @@ -25,6 +25,7 @@ import org.apache.commons.lang3.SystemUtils; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.VisibleForTesting; import org.opengrok.indexer.analysis.Ctags; import org.opengrok.indexer.analysis.Definitions; import org.opengrok.indexer.configuration.RuntimeEnvironment; @@ -60,29 +61,33 @@ private CtagsUtil() { /** * Check that {@code ctags} program exists and is working. - * @param ctagsBinary name of the ctags program or path + * @param ctagsBinary name of the {@code ctags} program or path * @return true if the program works, false otherwise */ - public static boolean validate(String ctagsBinary) { + public static boolean isValid(String ctagsBinary) { if (!isUniversalCtags(ctagsBinary)) { return false; } - return canProcessFiles(RuntimeEnvironment.getInstance().getSourceRootFile()); + // The source root can be read-only. In such case, fall back to the default + // temporary directory as a second-best choice how to test that ctags is working. + return (canProcessFiles(RuntimeEnvironment.getInstance().getSourceRootFile()) || + canProcessFiles(new File(System.getProperty("java.io.tmpdir")))); } /** - * Run ctags program on a known temporary file to be created under given path and see if it was possible - * to get some symbols. + * Run {@code ctags} program on a known temporary file to be created under given path + * and see if it was possible to get some symbols. * @param baseDir directory to use for storing the temporary file * @return true if at least one symbol was found, false otherwise */ - private static boolean canProcessFiles(File baseDir) { + @VisibleForTesting + static boolean canProcessFiles(File baseDir) { Path inputPath; try { inputPath = File.createTempFile("ctagsValidation", ".c", baseDir).toPath(); } catch (IOException e) { - LOGGER.log(Level.WARNING, "cannot create temporary file in ''{0}''", baseDir); + LOGGER.log(Level.WARNING, String.format("cannot create temporary file in '%s'", baseDir), e); return false; } final String resourceFileName = "sample.c"; diff --git a/opengrok-indexer/src/test/java/org/opengrok/indexer/util/CtagsUtilTest.java b/opengrok-indexer/src/test/java/org/opengrok/indexer/util/CtagsUtilTest.java index f2442d2d1e9..5bef12d45d5 100644 --- a/opengrok-indexer/src/test/java/org/opengrok/indexer/util/CtagsUtilTest.java +++ b/opengrok-indexer/src/test/java/org/opengrok/indexer/util/CtagsUtilTest.java @@ -18,12 +18,14 @@ */ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Chris Fraire . */ package org.opengrok.indexer.util; import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; import org.opengrok.indexer.configuration.RuntimeEnvironment; import java.io.IOException; @@ -35,6 +37,9 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.times; /** * Represents a container for tests of {@link CtagsUtil}. @@ -51,19 +56,40 @@ void getLanguages() { } @Test - void validate() throws IOException { + void testIsValid() throws IOException { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); Path tmpSourceRoot = Files.createTempDirectory("srcRootCtagsValidationTest"); env.setSourceRoot(tmpSourceRoot.toString()); assertTrue(env.getSourceRootFile().exists()); - assertTrue(CtagsUtil.validate(env.getCtags())); + assertTrue(CtagsUtil.isValid(env.getCtags())); Files.delete(tmpSourceRoot); } + /** + * Simulate non-writable source root and verify that {@link CtagsUtil#isValid(String)} still returns true + * as it should fall back to default temporary directory. + */ @Test - void testValidateWithInvalidExtraOptions() throws IOException { + void testIsValidNoWritableSourceRoot() throws IOException { + RuntimeEnvironment env = RuntimeEnvironment.getInstance(); + Path tmpSourceRoot = Files.createTempDirectory("negativeCtagsValidationTest"); + env.setSourceRoot(tmpSourceRoot.toString()); + assertTrue(env.getSourceRootFile().exists()); + + try (MockedStatic mocked = mockStatic(CtagsUtil.class, Mockito.CALLS_REAL_METHODS)) { + mocked.when(() -> CtagsUtil.canProcessFiles(env.getSourceRootFile())).thenReturn(false); + assertTrue(CtagsUtil.isValid(env.getCtags())); + mocked.verify(() -> CtagsUtil.canProcessFiles(eq(env.getSourceRootFile())), + times(2)); // one extra for the lambda call above + } + + Files.delete(tmpSourceRoot); + } + + @Test + void testIsValidWithInvalidExtraOptions() throws IOException { RuntimeEnvironment env = RuntimeEnvironment.getInstance(); Path tmpSourceRoot = Files.createTempDirectory("srcRootCtagsValidationTestExtraArgs"); env.setSourceRoot(tmpSourceRoot.toString()); @@ -74,7 +100,7 @@ void testValidateWithInvalidExtraOptions() throws IOException { String extraOptionsAbsPath = extraOptionsPath.toAbsolutePath().toString(); env.setCTagsExtraOptionsFile(extraOptionsAbsPath); - assertFalse(CtagsUtil.validate(env.getCtags())); + assertFalse(CtagsUtil.isValid(env.getCtags())); // cleanup env.setCTagsExtraOptionsFile(null); diff --git a/pom.xml b/pom.xml index 4dcbbb36b8d..ca74fbfb047 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,7 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . 3.0.0-M5 3.13.0 1.11.4 - 3.12.4 + 5.2.0 2.14.0 From b57a3755dcb3b552e1bcd0deeacf5999117fc3e7 Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Tue, 29 Oct 2024 12:53:01 +0100 Subject: [PATCH 07/10] 1.13.24 --- distribution/pom.xml | 8 ++++---- opengrok-indexer/pom.xml | 4 ++-- opengrok-web/pom.xml | 4 ++-- plugins/pom.xml | 4 ++-- pom.xml | 2 +- suggester/pom.xml | 2 +- tools/pom.xml | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/distribution/pom.xml b/distribution/pom.xml index 460bbf273c4..5c9c4d2103c 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -7,7 +7,7 @@ org.opengrok opengrok-top - 1.13.23 + 1.13.24 opengrok-dist @@ -28,20 +28,20 @@ org.opengrok opengrok - 1.13.23 + 1.13.24 org.opengrok opengrok-web - 1.13.23 + 1.13.24 war org.opengrok tools - 1.13.23 + 1.13.24 pom diff --git a/opengrok-indexer/pom.xml b/opengrok-indexer/pom.xml index 9781efd86e0..efd158cc768 100644 --- a/opengrok-indexer/pom.xml +++ b/opengrok-indexer/pom.xml @@ -29,11 +29,11 @@ Portions Copyright (c) 2020-2020, Lubos Kosco . org.opengrok opengrok-top - 1.13.23 + 1.13.24 opengrok - 1.13.23 + 1.13.24 jar OpenGrok Indexer diff --git a/opengrok-web/pom.xml b/opengrok-web/pom.xml index 7ea2da4a740..462f6b0cb25 100644 --- a/opengrok-web/pom.xml +++ b/opengrok-web/pom.xml @@ -28,11 +28,11 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . org.opengrok opengrok-top - 1.13.23 + 1.13.24 opengrok-web - 1.13.23 + 1.13.24 war OpenGrok Web diff --git a/plugins/pom.xml b/plugins/pom.xml index 02a15d99c96..c6bf65c0d90 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -28,11 +28,11 @@ Portions Copyright (c) 2020, Chris Fraire . org.opengrok opengrok-top - 1.13.23 + 1.13.24 plugins - 1.13.23 + 1.13.24 jar OpenGrok authorization plugins diff --git a/pom.xml b/pom.xml index ca74fbfb047..1916c5241e3 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . org.opengrok opengrok-top - 1.13.23 + 1.13.24 pom OpenGrok diff --git a/suggester/pom.xml b/suggester/pom.xml index a9db898f7af..f9569e0eea0 100644 --- a/suggester/pom.xml +++ b/suggester/pom.xml @@ -28,7 +28,7 @@ Portions Copyright (c) 2020, Chris Fraire . opengrok-top org.opengrok - 1.13.23 + 1.13.24 suggester diff --git a/tools/pom.xml b/tools/pom.xml index 1b7f26de3c2..96ee7bb0f10 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -29,11 +29,11 @@ Portions Copyright (c) 2017-2018, 2020, Chris Fraire . org.opengrok opengrok-top - 1.13.23 + 1.13.24 tools - 1.13.23 + 1.13.24 pom OpenGrok tools From 5a9dc776a0bb59ff4510fe66223e1a896fb34869 Mon Sep 17 00:00:00 2001 From: Navin Parakkal Date: Sat, 16 Nov 2024 14:21:52 +0000 Subject: [PATCH 08/10] Fix end length for substring in FortranXref.lex --- .../src/main/jflex/analysis/fortran/FortranXref.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex index 037eafd4973..65d7a2ac0e6 100644 --- a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex +++ b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex @@ -93,7 +93,7 @@ File = [a-zA-Z]{FNameChar}* "." ("i"|"inc") onNonSymbolMatched(cmatch.substring(0, 1), yychar); String file = cmatch.substring(1, cmatch.length() - 1); onFilelikeMatched(file, yychar + 1); - onNonSymbolMatched(cmatch.substring(cmatch.length() - 1, 1), yychar + 1 + file.length()); + onNonSymbolMatched(cmatch.substring(cmatch.length() - 1, cmatch.length()), yychar + 1 + file.length()); } /*{Hier} From d527cdb3f717b96c55ebbaeb2ce89c99fb77c4d1 Mon Sep 17 00:00:00 2001 From: Navin P Date: Sat, 16 Nov 2024 14:21:52 +0000 Subject: [PATCH 09/10] Fix end length for substring in FortranXref.lex --- .../src/main/jflex/analysis/fortran/FortranXref.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex index 037eafd4973..65d7a2ac0e6 100644 --- a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex +++ b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex @@ -93,7 +93,7 @@ File = [a-zA-Z]{FNameChar}* "." ("i"|"inc") onNonSymbolMatched(cmatch.substring(0, 1), yychar); String file = cmatch.substring(1, cmatch.length() - 1); onFilelikeMatched(file, yychar + 1); - onNonSymbolMatched(cmatch.substring(cmatch.length() - 1, 1), yychar + 1 + file.length()); + onNonSymbolMatched(cmatch.substring(cmatch.length() - 1, cmatch.length()), yychar + 1 + file.length()); } /*{Hier} From ba3e4773968e606eb2ddc3dc8fa9d93ace0e9cfe Mon Sep 17 00:00:00 2001 From: Navin P Date: Sat, 16 Nov 2024 14:21:52 +0000 Subject: [PATCH 10/10] Fix end length for substring in FortranXref.lex --- .../src/main/jflex/analysis/fortran/FortranXref.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex index 037eafd4973..65d7a2ac0e6 100644 --- a/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex +++ b/opengrok-indexer/src/main/jflex/analysis/fortran/FortranXref.lex @@ -93,7 +93,7 @@ File = [a-zA-Z]{FNameChar}* "." ("i"|"inc") onNonSymbolMatched(cmatch.substring(0, 1), yychar); String file = cmatch.substring(1, cmatch.length() - 1); onFilelikeMatched(file, yychar + 1); - onNonSymbolMatched(cmatch.substring(cmatch.length() - 1, 1), yychar + 1 + file.length()); + onNonSymbolMatched(cmatch.substring(cmatch.length() - 1, cmatch.length()), yychar + 1 + file.length()); } /*{Hier}