[svn-commits] tilghman: branch tilghman/issue16461 r271556 - /team/tilghman/issue16461/funcs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 21 16:08:59 CDT 2010


Author: tilghman
Date: Mon Jun 21 16:08:55 2010
New Revision: 271556

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=271556
Log:
All tests pass, now to devise some line write tests.

Modified:
    team/tilghman/issue16461/funcs/func_env.c

Modified: team/tilghman/issue16461/funcs/func_env.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/issue16461/funcs/func_env.c?view=diff&rev=271556&r1=271555&r2=271556
==============================================================================
--- team/tilghman/issue16461/funcs/func_env.c (original)
+++ team/tilghman/issue16461/funcs/func_env.c Mon Jun 21 16:08:55 2010
@@ -796,7 +796,7 @@
 				if (fread(fbuf, 1, sizeof(fbuf), ff) < sizeof(fbuf) && !feof(ff)) {
 					ast_log(LOG_ERROR, "Short read?!!\n");
 				}
-				fseeko(ff, cur + vlength - length, SEEK_CUR);
+				fseeko(ff, cur + vlength - length, SEEK_SET);
 				if (fwrite(fbuf, 1, sizeof(fbuf), ff) < sizeof(fbuf)) {
 					ast_log(LOG_ERROR, "Short write?!!\n");
 				}
@@ -808,9 +808,10 @@
 		} else {
 			/* Most complex -- need to open a gap */
 			char fbuf[4096];
-			off_t lastwritten;
+			off_t lastwritten = flength + vlength - length;
 			fseeko(ff, vlength - length, SEEK_END);
 			while (offset + sizeof(fbuf) < ftello(ff)) {
+				ast_debug(1, "This should not execute (yet) in our tests.\n");
 				fseeko(ff, -1 * (sizeof(fbuf) + (vlength - length)), SEEK_CUR);
 				if (fread(fbuf, 1, sizeof(fbuf), ff) < sizeof(fbuf)) {
 					ast_log(LOG_ERROR, "Short read?!!\n");
@@ -823,12 +824,14 @@
 					fclose(ff);
 					return -1;
 				}
-			}
-			/* Note the location of this last buffer -- we must not overwrite this position. */
-			lastwritten = ftello(ff) - sizeof(fbuf);
+				/* Note the location of this last buffer -- we must not overwrite this position. */
+				lastwritten = ftello(ff) - sizeof(fbuf);
+			}
 			fseek(ff, offset + length, SEEK_SET);
 			/* Doesn't matter how much we read -- just need to restrict the write */
-			if (fread(fbuf, 1, sizeof(fbuf), ff)) { }
+			if (fread(fbuf, 1, sizeof(fbuf), ff) && !feof(ff)) {
+				ast_log(LOG_ERROR, "Short read?!!\n");
+			}
 			fseek(ff, offset, SEEK_SET);
 			/* Write out the value, then write just up until where we last moved some data */
 			if (fwrite(value, 1, vlength, ff) < vlength) {




More information about the svn-commits mailing list