Hello community,

here is the log from the commit of package bff4 for openSUSE:Factory
checked in at Wed Jun 1 12:03:15 CEST 2011.



--------
New Changes file:

--- /dev/null   2010-08-26 16:28:41.000000000 +0200
+++ /mounts/work_src_done/STABLE/bff4/bff4.changes      2010-04-11 
11:32:16.000000000 +0200
@@ -0,0 +1,5 @@
+-------------------------------------------------------------------
+Sun Apr 11 09:32:03 UTC 2010 - [email protected]
+
+- new package
+

calling whatdependson for head-i586


New:
----
  arg.patch
  bff4.c
  bff4.changes
  bff4.spec

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ bff4.spec ++++++
#
# spec file for package bff4
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#



Name:           bff4
Version:        1
Release:        1
License:        OSI_COMPLIANT_FREE(Public domain)
Source0:        %{name}.c
Patch0:         arg.patch
Group:          Development/Languages/Other
Summary:        Fast Brainfuck interpreter
Url:            http://mazonka.com/brainf/

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Optimizing brainfuck implementation of dialect based on Daniel's dbfi (see "A 
very short self-interpreter")

This interpreter has only one input: program and input to the program have to 
be separated with ! e.g. ",.!a" prints 'a' To use it in interactive mode paste 
your program as input.

This program can be compiled with LNR macro defined. LNR is another 
optimization of linear loops (where '<>' balanced), e.g. [->+>++<<]. Linear 
loop is then executed in one step.

Oleg Mazonka 4.12.06  http://mazonka.com/

%prep
%__cp %{SOURCE0} .
%patch0

%build
gcc %{SOURCE0} -o %{name} %optflags
gcc %{SOURCE0} -DLNR -o %{name}lnr %optflags

%install
%__install -D -m 755 %{name} %buildroot%{_bindir}/%{name}
%__install -D -m 755 %{name}lnr %buildroot%{_bindir}/%{name}lnr

%clean
%__rm -rf %buildroot

%files
%defattr(-,root,root)
%{_bindir}/%{name}
%{_bindir}/%{name}lnr

%changelog
++++++ arg.patch ++++++
--- bff4.c      2007-06-13 06:28:04.000000000 +0200
+++ bff4_mod.c  2010-01-25 19:54:47.538918492 +0100
@@ -49,13 +49,15 @@ void * zalloc(void *p, int sz, int osz)
 }
 #define zalloci(p,sz,osz) zalloc(p,(sz)*sizeof(int),(osz)*sizeof(int));
 
+FILE * istrm;
+
 int getbf()
 {
        int a;
        next:
-       a = getchar();
+       a = getc(istrm);
        if( a==-1 ) return -1;
-       if( !strchr(",.[]+-<>!",a) ) goto next;         
+       if( !strchr(",.[]+-<>!",a) ) goto next;
        return a;
 }
 
@@ -119,11 +121,24 @@ int consume(op *o)
        return a;
 }
 
-int main()
+int main(int argc, char *argv[])
 {
        op * o=0, *z, *zend;
        int sz=0, i, *m, mp, msz;
-       int a = getbf();
+       int a;
+       
+       if(argc == 1) {
+               istrm = stdin;
+       }
+       else {
+               istrm = fopen(argv[1],"r");
+               if (istrm == NULL) {
+                       printf("error at opening file: %s\n", argv[1]);
+                       return 1;
+               }
+       }
+       
+       a = getbf();
        for(;;sz++)
        {
                o = zalloc(o,(sz+1)*sizeof(op),sz*sizeof(op));
@@ -229,6 +244,7 @@ int main()
                printf("\n");
 #endif
        }
+       fclose(istrm);
        return 0;
 }
 
++++++ bff4.c ++++++
/*
 Optimizing brainfuck implementation of dialect based on 
 Daniel's dbfi (see "A very short self-interpreter")

 This interpreter has only one input: program and input to the 
 program have to be separated with ! e.g. ",.!a" prints 'a'
 To use it in interactive mode paste your program as input.

 This program can be compiled with LNR macro defined.
 LNR is another optimization of linear loops (where '<>' balanced), e.g. 
[->+>++<<].
 Linear loop is then executed in one step.

 Oleg Mazonka 4.12.06  http://mazonka.com/

 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

typedef struct _op
{
        int shift, off;
        int * d, sz;
        struct _op * go;
        int c;
        int igo, linear;
        int * db, dbsz;
} op;

void printop(op *z)
{
        int j;
        printf("op='");
        if( !strchr("<>+-",z->c) ) printf("%c",(char)z->c);
        for( j=0; j<z->dbsz; j++ )  printf("%c",(char)z->db[j]);
        printf("' shift=%d off=%d go=%d { "
                        ,z->shift, z->off, z->igo );
        for( j=0; j<z->sz; j++ )
                printf("%d ",z->d[j]);
        printf("}\n");
}

void * zalloc(void *p, int sz, int osz)
{
        p = realloc(p,sz);
        memset((char*)p+osz,0,sz-osz);
        return p;
}
#define zalloci(p,sz,osz) zalloc(p,(sz)*sizeof(int),(osz)*sizeof(int));

int getbf()
{
        int a;
        next:
        a = getchar();
        if( a==-1 ) return -1;
        if( !strchr(",.[]+-<>!",a) ) goto next;         
        return a;
}

int consume(op *o)
{
        int mp=0,i;
        int a = o->c;

        if( strchr("[]",a) ) a=getbf();

        o->sz = 1;
        o->d = zalloci(0,1,0);
        o->off = 0;

        o->dbsz=0;
        o->db=0;

        for(;;a=getbf())
        {
          if( a==-1 || a=='!' ) break;
          if( strchr(",.[]",a) ) break;

          o->db = zalloci(o->db,o->dbsz+1,o->dbsz);
          o->db[o->dbsz++] = a;

          if( a=='+' ) o->d[mp]++;
          if( a=='-' ) o->d[mp]--;
          if( a=='>' )
          {
                mp++;
                if( mp>=o->sz ) 
                {
                        o->d = zalloci(o->d,o->sz+1,o->sz);
                        o->sz++;
                }
          }
          if( a=='<' )
          {
                if( mp>0 ) mp--;
                else 
                { 
                        o->off--; 
                        o->d = zalloci(o->d,o->sz+1,o->sz);
                        for( i=o->sz; i>0; i-- ) o->d[i] = o->d[i-1];
                        o->d[0] = 0;
                        o->sz++;
                }
          }
        }
        o->shift = mp + o->off;

        /* cut corners */
        while( o->sz && o->d[o->sz-1] == 0 ) o->sz--;
        while( o->sz && o->d[0] == 0 )
        {
          o->sz--;
          for( i=0; i<o->sz; i++ ) o->d[i] = o->d[i+1];
          o->off++;
        }

        return a;
}

int main()
{
        op * o=0, *z, *zend;
        int sz=0, i, *m, mp, msz;
        int a = getbf();
        for(;;sz++)
        {
                o = zalloc(o,(sz+1)*sizeof(op),sz*sizeof(op));
                if( a==-1 || a=='!' ) break;

                o[sz].c = a;
                if( strchr(",.",a) ){ a=getbf(); continue; }
                if( a==']' ) 
                {
                        int l=1, i=sz;
                        while(l&&i>=0){ i--;l+=(o[i].c==']')-(o[i].c=='['); }
                        if( i<0 ){ printf("unbalanced ']'\n"); exit(1); }
                        o[i].igo = sz;
                        o[sz].igo = i;
                }
                a = consume(o+sz);
        }

        for( i=0;i<sz;i++ )
        {
                o[i].go = &o[o[i].igo];
#ifdef LNR
                if( o[i].c == '[' && o[i].igo == i+1 && o[i].shift==0 && 
o[i].off <= 0 )        
                {
                        o[i].linear = -o[i].d[-o[i].off];
                        if( o[i].linear < 0 )
                        {
                          printf("Warning: infinite loop "); printop(&o[i]);
                          printf("linear=%d\n",o[i].linear);
                          o[i].linear = 0;
                        }
                }
                else o[i].linear = 0;
#endif

        }

        msz = 1000; /* any number */
        m = zalloci(0,msz,0);
        mp=0;

        z = o;
        zend = o+sz;
        for( ; z!=zend; ++z )
        {
#ifdef DBG
                printop(z);
#endif

                if( z->c == ']' )
                {
                        if( m[mp] ) z=z->go;
                }

                else if( z->c == '[' )
                {
                        if( !m[mp] ) z=z->go; 
                }

                else if( z->c == ',' ){ m[mp] = getchar(); continue; }

                else if( z->c == '.' ){ putchar(m[mp]); continue; }

                /* apply */
                if( z->sz )
                {
                        int nmsz = mp+z->sz+z->off;
                        if( nmsz > msz )
                        {
                          m = zalloci(m,nmsz,msz);
                          msz = nmsz;
                        }


#ifdef LNR
                        if( z->linear )
                        {
                                int del = m[mp]/z->linear;
                                for( i=0; i<z->sz; i++ ) 
m[mp+z->off+i]+=del*z->d[i];
                        }else
#endif
                                for( i=0; i<z->sz; i++ ) 
m[mp+z->off+i]+=z->d[i];

                }

                if( z->shift>0 )
                {  
                        int nmsz = mp+z->shift+1;
                        if( nmsz > msz )
                        {
                          m = zalloci(m,nmsz,msz);
                          msz = nmsz;
                        }
                }
                mp += z->shift;

#ifdef DBG
                for( i=0; i<msz; i++ )
                {
                  if( i==mp ) printf("'");
                  printf("%d ",m[i]); 
                }
                printf("\n");
#endif
        }
        return 0;
}


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Remember to have fun...

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to