Skip to content

Commit

Permalink
parser-common: allow :: in source file paths
Browse files Browse the repository at this point in the history
It is used as a separator in file names of perl man pages.

Resolves: https://issues.redhat.com/browse/OSH-687
  • Loading branch information
kdudka committed Oct 23, 2024
1 parent b8aeaa2 commit 9fb4d90
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/parser-common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
#define RE_CHECKER_NAME_MISRA "(?:MISRA C(?:\\+\\+)?-[0-9]+ (?:Directive|Rule) [0-9.-]+)"
#define RE_CHECKER_NAME RE_CHECKER_NAME_SA "|" RE_CHECKER_NAME_CERT "|" RE_CHECKER_NAME_MISRA

#define RE_PATH_LOCAL "[^:]+"
// the `::` separators are used in file names of perl man pages
#define RE_PATH_LOCAL "[^:]+(?:::[A-Za-z][^:]+)*"
#define RE_PATH_URL "http(?:s)?://[^:]+(?::[0-9]+)?[^:]+"
#define RE_PATH RE_PATH_LOCAL "|" RE_PATH_URL

Expand Down
1 change: 1 addition & 0 deletions tests/csgrep/0131-unicontrol-perl-man-page-args.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--mode=json
39 changes: 39 additions & 0 deletions tests/csgrep/0131-unicontrol-perl-man-page-stdin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod:655: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod:657: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod:658: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod:659: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod:655: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod:657: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod:658: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod:659: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:952: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:953: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:956: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:957: warning: bidirectional control characters: ['\u202b', '\u202c']

Error: UNICONTROL_WARNING:
/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm:958: warning: bidirectional control characters: ['\u202b', '\u202c']

186 changes: 186 additions & 0 deletions tests/csgrep/0131-unicontrol-perl-man-page-stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
{
"defects": [
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod",
"line": 655,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod",
"line": 657,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod",
"line": 658,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/lib/DateTime/Locale/fa_IR.pod",
"line": 659,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod",
"line": 655,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod",
"line": 657,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod",
"line": 658,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/lib/DateTime/Locale/fa_IR.pod",
"line": 659,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm",
"line": 952,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm",
"line": 953,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm",
"line": 956,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm",
"line": 957,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
},
{
"checker": "UNICONTROL_WARNING",
"tool": "unicontrol",
"key_event_idx": 0,
"events": [
{
"file_name": "/builddir/build/BUILD/DateTime-Locale-1.31/blib/man3/DateTime::Locale::fa_IR.3pm",
"line": 958,
"event": "warning",
"message": "bidirectional control characters: ['\\u202b', '\\u202c']",
"verbosity_level": 0
}
]
}
]
}
1 change: 1 addition & 0 deletions tests/csgrep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,4 @@ test_csgrep("0125-sarif-parser-bom" )
test_csgrep("0126-cov-parser-imp-flag" )
test_csgrep("0127-cov-writer-noloc" )
test_csgrep("0128-cov-parser-noloc" )
test_csgrep("0131-unicontrol-perl-man-page" )

0 comments on commit 9fb4d90

Please sign in to comment.