[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc_bugs

Title:DEC C Problem Reporting Forum
Notice:Report DEC C++ problems in TURRIS::C_PLUS_PLUS
Moderator:CXXC::REPETETCHEON
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1299
Total number of notes:6249

1296.0. "freopen ignores "a+" mode" by CSC32::J_HENSON (Don't get even, get ahead!) Fri May 23 1997 16:43

dec c v5.5-002, OpenVMS V7.1, Alpha

It appears that freopen is ignoring the "a+" mode under certain conditions.
As best I can tell, those conditions are 1) the 'new' file is an
existing file, and 2) the "shr" attribute is specified.  Instead of
appending new records to the end of an existing file, it is writing
new records at the beginning of the existing file and overwriting
existing records.

The following procedure illustrates this problem.

I checked the eco summary for alpacrt2_070, and could not find any
mention of a problem like this being fixed, so I figure I had better
post it here.

Thanks,

Jerry

==========================================================================

$cc/ver nl:
$create tst_freopen.c
#include errno                                                                  
#include    stdio                                                               
#include    rms                                                                 
                                                                                
main()                                                                          
{                                                                               
    int status;                                                                 
    FILE *New;                                                                  
    char file[] = "efclog:stm_tst.log";                                         
                                                                                
        printf("  Redirecting log file \n");                                    
        New = freopen(file,                                                     
                      "a+",                                                     
                       stdout,                                                  
                       "shr=put",                                               
                       "ctx=rec");                                              
/*                                                                              
*/                                                                              
                                                                                
        if ( New == 0)                                                          
          {                                                                     
            printf("Unable to Redirect logging  \n");                           
          }                                                                     
        else                                                                    
          {                                                                     
            status = printf(" Successfully redirected logging \n"); /* Line A   
*/                                                                              
            status = vaxc$errno;                                                
          }                                                                     
}                                                                               
$cc/stan=vaxc tst_freopen
$link tst_freopen
$def efclog []
$run tst_freopen
$type stm_tst.log
$run tst_freopen
$type stm_tst.log

T.RTitleUserPersonal
Name
DateLines
1296.1inserted into CRTL internalTLE::BORISBoris Gubenko, DEC C RTLFri May 23 1997 18:254
  This is being tracked in CRTL internal notes conference as problem
  number 1747.

  Boris
1296.2fixed in development streamTLE::BORISBoris Gubenko, DEC C RTLSun May 25 1997 13:1836
  This is the same bug that was reported in TURRIS::DECC note 2048 for a
  write() function on OpenVMS V7.1. The bug was introduced in OpenVMS V7.1
  in the course of implementation of conditional preloading of the first
  file record. It turned out then, that the bug affects all CRTL functions
  writing to a shared file.

  The fix that was ECOed for OpenVMS V7.1 included the following functions:

	. write()
	. fwrite()
	. decc$record_write()
	. fputs()
	. putc()
	. fputc()
	. putw()
	. fputwc()
	. fputws()

  Unfortunately, formatted output functions were overlooked so that latest ECO
  kit for OpenVMS V7.1 does not fix your customer's problem. In this particular
  case, however, the fprintf() should work and workaround would be using the
  fprintf() instead of printf(), i.e. replace 

            status = printf(" Successfully redirected logging \n");
  with
            status = fprintf(New, " Successfully redirected logging \n");

  We fixed the problem in our development stream. The fix will appear in VMS
  version following OpenVMS V7.1 and in the next ECO kit for OpenVMS V7.1.

  We apologize for any inconvenience this may have caused to you and your
  customer.
  
  Thanks for reporting this.

  Boris
1296.3thanksCSC32::J_HENSONDon't get even, get ahead!Tue May 27 1997 10:465
Boris,

Thanks for the update.  I'll pass it on.

Jerry