[Plib-cvs] plib/src/ssg ssgLoadAC.cxx,1.31,1.32
Brought to you by:
sjbaker
From: James J. <pu...@us...> - 2003-07-11 11:16:46
|
Update of /cvsroot/plib/plib/src/ssg In directory sc8-pr-cvs1:/tmp/cvs-serv29124 Modified Files: ssgLoadAC.cxx Log Message: From Melchior Franz: unfortunately, the last patch fixed plib's unwillingness to accept ACs with DOS endings. But now it doesn't accept data fields containing \n... This fixes the above. Index: ssgLoadAC.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgLoadAC.cxx,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- ssgLoadAC.cxx 4 Jul 2003 13:51:58 -0000 1.31 +++ ssgLoadAC.cxx 11 Jul 2003 11:16:43 -0000 1.32 @@ -349,13 +349,20 @@ static int do_data ( char *s ) { int len = strtol ( s, NULL, 0 ) ; - char buffer [ len + 3 ] ; /* data + \r + \n + \0 */ - fgets ( buffer, len + 3, loader_fd ) ; current_data = new char [ len + 1 ] ; - strncpy ( current_data, buffer, len ) ; + for ( int i = 0 ; i < len ; i++ ) + current_data [ i ] = getc ( loader_fd ) ; + current_data [ len ] = '\0' ; + + int c; + while ( ( c = getc( loader_fd ) ) != EOF ) /* Final RETURN */ + if ( c != '\r' && c != '\n' ) { + ungetc ( c, loader_fd ) ; + break ; + } ssgBranch *br = current_options -> createBranch ( current_data ) ; |