Mercurial > repo
view share/delvs-master/bf.h @ 8509:272663b31668
<b_jonas> slashlearn block device/Block devices are a concession made in Unix to make raw hard disks and magnetic tape have a similar interface to regular files and terminals. Since magnetic tapes can\'t write individual bytes, only entire blocks, the interface isn\'t exactly the same, thus the dreaded dd obs= option was born.
author | HackBot |
---|---|
date | Fri, 17 Jun 2016 08:35:50 +0000 |
parents | 38a5b4d8a98e |
children |
line wrap: on
line source
#include <stdio.h> #define c g->code #define p g->pointer #define f g->file struct Data { const char *code; char vars[30000]; char *pointer; }; void dummyLexer(struct Data *g) { while(*c) if(*c++ == ']') return; } void lexer(struct Data *g) { const char *cc = c; while(*c) { switch (*c++) { case '>': ++p; break; case '<': --p; break; case '+': ++*p; break; case '-': --*p; break; case '.': putchar(*p); break; case ',': *p = getchar(); break; case '[': cc = c; if(!*p) dummyLexer(g); while(*p) { c = cc; // restore char position to start of loop lexer(g); } break; case ']': return; default: // everything else is comments break; } } return; } /* * Usage: * struct Data g; * g.code = file; * g.pointer = &g.data[15000]; * lexer(&g); */