Author: zhuqing
Date: 2011-09-27 03:22:37 -0400 (Tue, 27 Sep 2011)
New Revision: 3746
Modified:
trunk/osprey/be/cg/cgdwarf.cxx
Log:
Fix bug877.
Fix compiler failure when program does not end with a new line character.
Code Review: Sun-Chan.
Modified: trunk/osprey/be/cg/cgdwarf.cxx
===================================================================
--- trunk/osprey/be/cg/cgdwarf.cxx 2011-09-24 09:30:58 UTC (rev 3745)
+++ trunk/osprey/be/cg/cgdwarf.cxx 2011-09-27 07:22:37 UTC (rev 3746)
@@ -2895,8 +2895,12 @@
for (i = cur_file->max_line_printed; i < USRCPOS_linenum(usrcpos); i++) {
if (fgets (text, sizeof(text), cur_file->fileptr) != NULL) {
// check for really long line
- if (strlen(text) >= 1023) text[1022] = '\n';
-#if defined(TARG_SL)
+ int len = strlen(text);
+ if (len >= sizeof(text)-1)
+ text[sizeof(text)-2] = '\n';
+
+ // This also may happen when "no newline at the end of the file."
+
// Fixed a source information bug with IPA turn on. When turning on
// IPA there is no '\n' after source line info "#endif\0", but correct
// content should be "#endif\n\0". This will cause real instruction
@@ -2906,11 +2910,11 @@
// mv16 $4, $0
// With IPA:
// #endif mv16 $4, $0
- if (text[strlen(text)-1] != '\n') {
- text[strlen(text)+1] = '\0';
- text[strlen(text)] = '\n';
+ if (len == 0 || text[len-1] != '\n') {
+ text[len] = '\n';
+ text[len+1] = '\0';
}
-#endif
+
fprintf (Asm_File, "%s%4d %s", ASM_CMNT_LINE, i+1, text);
}
}
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel