lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r464350 - /lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm
Date Mon, 16 Oct 2006 01:05:32 GMT
Author: marvin
Date: Sun Oct 15 18:05:30 2006
New Revision: 464350

URL: http://svn.apache.org/viewvc?view=rev&rev=464350
Log:
Have slurp_file add a terminating NULL byte.  Have capture_output always
append a newline to the C source code it receives, so that gcc won't complain
about a missing terminating newline.

Modified:
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm?view=diff&rev=464350&r1=464349&r2=464350
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm Sun Oct 15 18:05:30 2006
@@ -35,6 +35,7 @@
     if (app_source_fh == NULL)
         die("Error opening file '%s': %s", TRY_SOURCE_PATH, strerror(errno));
     fwrite(source, source_len, sizeof(char), app_source_fh);
+    fprintf(app_source_fh, "\n"); /* terminating newline to quiet compiler */
     if (fclose(app_source_fh))
         die("Error closing file '%s': %s", TRY_SOURCE_PATH, strerror(errno));
 
@@ -104,9 +105,10 @@
     }
 
     /* allocate memory and read the file */
-    contents = (char*)malloc(len * sizeof(char));
+    contents = (char*)malloc(len * sizeof(char) + 1);
     if (contents == NULL)
         die("Out of memory at %d, %s", __FILE__, __LINE__);
+    contents[len] = '\0';
     check_val = fread(contents, sizeof(char), len, file);
 
     /* weak error check, because CRLF might result in fewer chars read */



Mime
View raw message