Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  output.c  Sprache: C


//------------------------------------------------------------------------------
//
//  modifications by CO3
//
//------------------------------------------------------------------------------
//  Einbau von Nlmod() wegen der Zeilenzahl
//
/*
 * ACCENT 
 * 
 * A Compiler Compiler for the Entire Class of Context-Free Languages
 * 
 * Copyright (C) 1999  Friedrich Wilhelm Schroeer
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */



#define PRIVATE static

#include <stdio.h>

/*--------------------------------------------------------------------*/

#define OutBufSize 6000
#define FlushPos 5000

/*--------------------------------------------------------------------*/

PRIVATE long OutputLineCount = 0;
PRIVATE long OutputLineCountCo3 = 0;        // CO3

PRIVATE char OutBuf[OutBufSize];
PRIVATE char *OutBufPtr;
PRIVATE FILE *OutFile;

/*--------------------------------------------------------------------*/

OpenOutput (Name)
   char *Name;
{
   OutFile = fopen(Name, "w");

   if (OutFile == NULL) {
      printf("cannot open %s\n", Name); exit(1);
   }
   OutBufPtr = &OutBuf[0];
   OutputLineCount = 0;
   return 1;
}

/*--------------------------------------------------------------------*/
CloseOutput ()
{
   fwrite(OutBuf, 1, OutBufPtr - &OutBuf[0], OutFile);
   fclose(OutFile);
}

/*--------------------------------------------------------------------*/
Put(Str)
   char *Str;
{
   while(*Str) *OutBufPtr++ = *Str++; 
}

//----------------------------------------------------------------------
// CO3 Änderung prototype yygrammp.h
FILE *co3proto=0;
Putco3(char *Str) {
  if (!co3proto) {
    co3proto=fopen("yygrammp.h","w");
    fprintf(co3proto,"%s\n","void init_lexelem(void);");
    fprintf(co3proto,"%s\n","void first_lexval(void);");
    fprintf(co3proto,"%s\n","void next_lexval(void);");
    fprintf(co3proto,"%s\n","void get_lexval(void);");
    fprintf(co3proto,"%s\n","void init_dirsets(void);");
    fprintf(co3proto,"%s\n","int yyselect(void);");
    fprintf(co3proto,"%s\n","int yytransparent(int);");
    fprintf(co3proto,"%s\n","int yymallocerror(void);");
    }
  fprintf(co3proto,"%s",Str);
 Put(Str);   
return;}
Nlco3 () {fprintf(co3proto,";\n");}
// Ende CO3-Änderung
//----------------------------------------------------------------------

/*--------------------------------------------------------------------*/
PutBlockText(Str)
   char *Str;
{
   while(*Str) {
      if (*Str == '\n') {
         Nl();
         Str++;
      }
      else
         *OutBufPtr++ = *Str++; 
   }
}

/*--------------------------------------------------------------------*/
PutI (N)
   long N;
{
   if (N < 0) {
      *OutBufPtr++ = '-';
      N = -N;
   }
   if (N < 10) {
      *OutBufPtr++ = N + '0';
   }
   else if (N < 100) {
      *OutBufPtr++ = N/10 + '0';
      *OutBufPtr++ = N%10 + '0';
   }
   else {
      char buf[50];
      register i;
      register n = N;

      i = 0;

      do {
         buf[++i] = (n % 10) + '0';
         n = n / 10;
      } while (n);

      while (i)
         *OutBufPtr++ = buf[i--];
   }
}

/*--------------------------------------------------------------------*/
Nl ()
{
   if (OutBufPtr > &OutBuf[FlushPos]) {
      fwrite(OutBuf, 1, OutBufPtr - &OutBuf[0], OutFile);
      OutBufPtr = &OutBuf[0];
   }

#ifdef EMIT_CR
   *OutBufPtr++ = '\r';
#endif
   *OutBufPtr++ = '\n';
   OutputLineCount++;
}

/*--------------------------------------------------------------------*/
Nlmod ()
{
   if (OutBufPtr > &OutBuf[FlushPos]) {
      fwrite(OutBuf, 1, OutBufPtr - &OutBuf[0], OutFile);
      OutBufPtr = &OutBuf[0];
   }

if (OutputLineCountCo3%3==2) {
#ifdef EMIT_CR
   *OutBufPtr++ = '\r';
#endif
   *OutBufPtr++ = '\n';
   OutputLineCount++;
   OutputLineCountCo3=0;}
else
  OutputLineCountCo3++;

}

/*--------------------------------------------------------------------*/

GetOutputLineCount(ref_n)
   int * ref_n;
{
   *ref_n = OutputLineCount;
}

/*--------------------------------------------------------------------*/

Messung
CHZG
859010091

¤ Dauer der Verarbeitung: 0.81 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

letze Version des Elbe Quellennavigators


letze Version des Demonstrationsprogramms Goedel
letze Version des Bille Abgleichprogramms
Version

Jenseits des Üblichen ....

Besucher

Besucher

Statistik
#Sources=1,188,840
#Domains=962,818