DOS Style line ending brakes display output. The match is detected but not displayed. See the attached mock-up source tree. egrep for MYMAP_ the search matches '1' and '2' are not visible, but "operational". A better fix should run the characters of 'tempstring' , if there are non-displayable chars it should still display the file name, function, and line number, but replace the matched text with ellipsis.
Proposed change:
Index: display.c
===================================================================
RCS file: /cvsroot/cscope/cscope/src/display.c,v
retrieving revision 1.33
diff -u -r1.33 display.c
--- display.c 20 May 2012 12:24:17 -0000 1.33
+++ display.c 14 Nov 2012 16:16:00 -0000
@@ -229,6 +229,12 @@
linenum, tempstring) < 4) {
break;
}
+ {
+ char *cr = strchr( tempstring, '\r' );
+ if( cr ) {
+ *cr = 0;
+ }
+ }
++nextline;
displine[disprefs] = screenline;
mock-up src tree to show the problem.
I know this subject has been discussed before, however I too would like to request that this capability be added.
It is a vital capability to have if a person is doing cross-platform development that spans UNIX-like and DOS-like systems, where no matter which end-of-line convention you choose to use in your source files the display in cscope is mangled.
I have a much simpler patch than the original submitter that I hope can be considered for inclusion:
diff -ruN cscope-15.8a/src/display.c cscope/src/display.c
--- cscope-15.8a/src/display.c 2012-05-20 07:24:17.000000000 -0500
+++ cscope/src/display.c 2012-12-04 17:17:01.500165190 -0600
@@ -225,7 +225,7 @@
disprefs < mdisprefs && screenline <= lastdispline;
++disprefs, ++screenline) {
/* read the reference line */
- if (fscanf(refsfound, "%" PATHLEN_STR "s%" PATHLEN_STR "s%" NUMLEN_STR "s %" TEMPSTRING_LEN_STR "[^\n]", file, function,
+ if (fscanf(refsfound, "%" PATHLEN_STR "s%" PATHLEN_STR "s%" NUMLEN_STR "s %" TEMPSTRING_LEN_STR "[^\r\n]", file, function,
linenum, tempstring) < 4) {
break;
}
Sorry for the mangled patch -- I'm kind of new to sourceforge and couldn't find a better way to include it here. Just look carefully for the change of "[^\n]" to "[^\r\n]" just after TEMPSTRING_LEN_STR. This affects only the display of the output line -- it doesn't affect the actual underlying cscope database or other internal representation, so it targets just the issue in question and nothing more.