Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-

[C] lisp to bbcode [BBCODE] [FAGGOTRY]

Name: Anonymous 2007-12-27 22:52


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

#define MAX_NESTING 128
#define MAX_POST_SIZE 4096

typedef struct {

    int id;
    const char * name;

} Tags;

typedef struct {

    int memory[MAX_NESTING];
    int * ptr;
    size_t elements;

} Stack;

void stackinit(Stack *);
int pushid(Stack *, int);
int popid(Stack *);

#define pushid(x,y) ((x)->elements++ == MAX_NESTING ? -1 : (*(x)->ptr++ = y))
#define popid(x) ((x)->elements ? (x)->elements--,*--(x)->ptr : 0)
#define stackinit(x) (void)((x)->elements = 0, (x)->ptr = (x)->memory)

int main(void) {

    char buf[MAX_POST_SIZE] = {0};
    char * p = buf;
    int c;
    size_t n;
    Stack stack;

    Tags tags[] = {
        { 0, ")"},
        { 1, "br"},
        { 2, "b"},
        { 3, "i"},
        { 4, "u"},
        { 5, "o"},
        { 6, "code"},
        { 7, "spoiler"} /*add more tags */
    };

    stackinit(&stack);


    fread(buf, 1, sizeof buf - 1, stdin);
    while(*p != 0) {
        if(*p == '\\' && p[1]) {
            putchar(p[1]);
            p += 2;
            continue;
        } else if(*p == '(') {
            if(p[1] == ' ') {
                p++;
                continue;
            }

            if(strtok(++p, " \n") == NULL) {
                fputs(p, stdout);
                break;
            } else {
                printf("[%s]", p);
               
                for(n = 0; n < sizeof tags / sizeof tags[0]; n++)
                    if(strcmp(p, tags[n].name) == 0)
                        if(pushid(&stack, tags[n].id) == -1) {
                            fprintf(stderr, "max nesting level reached\n");
                            return -1;
                        }
                p += strlen(p);
            }
        }
        else if(*p == ')') {
            c = popid(&stack);
            for(n = 0; n < sizeof tags / sizeof tags[0]; n++)
                if(c == tags[n].id) {
                    c ? printf("[/%s]", tags[n].name) : putchar(*tags[n].name);
                    break;
                }
        }

        else putchar(*p);

        p++;
    }

    putchar('\n');


    return 0;

}


Example:

$ cc foo.c -o a
$ ./a
(i (b this is bold and italic) and this just italic)
^D
[i][b]this is bold and italic[/b] and this just italic[/i]

Name: Anonymous 2007-12-28 0:40

(i (b (o (u EXPERT PROGRAMMER))))

Name: Anonymous 2007-12-28 0:47

push? pop?
What happened to the cons and cudders?

Name: Anonymous 2007-12-28 0:54

Why didn't you write that in lisp?

Name: Anonymous 2007-12-28 1:25

So let me get this straight, you wrote a C program to convert LISP code into BBCode code. What next, writing a Python interpreter in LISP in C to convert BBCode to Python in Python?

Name: Anonymous 2007-12-28 1:29

This actually isn't a bad idea

Name: Anonymous 2007-12-28 4:22

>>1
You're the man.  Not a malloc in sight.  Truly Enlightened C is winrar.

I'd have made Tags an anonymous type, however:

struct { int id; const char * name; } tags[] = {
        { 0, ")"},
        { 1, "br"},
        { 2, "b"},
        { 3, "i"},
        { 4, "u"},
        { 5, "o"},
        { 6, "code"},
        { 7, "spoiler"} /*add more tags */
    };

Name: Anonymous 2007-12-28 5:54

>>7
There are no mallocs only because he uses arbitrarily-sized buffers to hold the input and tag stack. And he didn't even make MAX_NESTING large enough to handle the total possible number of tags that MAX_POST_SIZE might contain. Not very enlightened.

Name: Anonymous 2007-12-28 6:03

>>8
It truly is EXPERT QUALITY.

Name: Anonymous 2007-12-28 10:15

You forgot [s] and [m].

Name: Anonymous 2007-12-28 11:39

peh, it'd be even faster to do in PERL with a couple regex's.

>>7
Hard-on for purely stack-allocated memory? I hope your fucking overly revered stack fucking overflows when you shit some nice large arrays on it because you were too fucking pussy to dynamically allocate them on the heap.

inb4 C99 variable static array sizes.

Name: Anonymous 2007-12-28 12:40

You absolute idiot, how dare you release code.

Here it is in lisp,

(defun bbcodeify (sexp) (when (listp sexp) (format t "~a~{~a~^ ~}~a" (car sexp) (cdr sexp) (car sexp)) (mapcar #'bbcodeify (cdr sexp)))

Name: Anonymous 2007-12-28 12:42

fuck.. excuse me in too stoned
(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))

* (bbcodeify '(i (b this is bold and italic) and this just italic))

"[I][B]THIS IS BOLD AND ITALIC[B] AND THIS JUST ITALIC[I]"

Name: Anonymous 2007-12-28 12:44

>>11
DO IT IN PERL WITH A COUPLE OF REGEX THEN YOU ALL-TALK-BUT-CANT-WALK FAGGOT!!!!!

Name: Anonymous 2007-12-28 13:49

>>11
Hard-on for purely stack-allocated memory? I hope your fucking overly revered stack fucking overflows when you shit some nice large arrays on it because you were too fucking pussy to dynamically allocate them on the heap.

No, I have a hard-on for static arrays.  I don't care much where the data is stored.  I prefer global arrays, though.  There is really little reason to use local variables.  Multithreading, perhaps.

Name: Anonymous 2007-12-28 13:50

this thread is hilarious

Name: Anonymous 2007-12-28 15:40

OP here
>>10
Only these two? I forgot more, intentionally.
(eg # or rem or br)
That's why I put that comment there.
Left it as an exercise to the reader :P

>>11
Hard-on for purely stack-allocated memory? I hope your fucking overly revered stack fucking overflows when you shit some nice large arrays on it because you were too fucking pussy to dynamically allocate them on the heap.
Too much of a fucking pussy?
Are you right on your mind you fucking moron?
Not only it would make the size of my code 3x bigger, do you want such snippet to eat 10MB from your memory because the programmer wasn't a pussy?
You're a moron, what I could have done is to read input in chunks, less than what it takes for my static stack to fill, parse, print on stdout and repeat.
No fucking need for (re)allocations.

>>12
Release code?
Do you see a licence there? Or my name? Or some makefile?
(why the fuck would anyone put a licence on that anyway)
What I wanted to do is write something that works in C in < 10 minutes, post it on /prog/ and see what code Anon would post.
(like your lisp snippet)
Your lisp snippet however takes the expression as a list, my snip takes it from stdin, there are advantages to my snip. (not that it would take a lot of code to change yours to do that)

>>15
Actually I see more reasons to use a local object than threads :P

Name: Anonymous 2007-12-28 16:06

>>7
[b]"Fail"[b]

Name: Anonymous 2007-12-28 16:30

>>18
This may surprise you, but you've just invented the recursive failing meme

Name: Anonymous 2007-12-28 17:17

Name: Anonymous 2007-12-28 17:26


C:\>gcc.exe foo.c -o a
foo.c:2:19: stdio.h: No such file or directory
foo.c:3:20: string.h: No such file or directory
foo.c:19: error: parse error before "size_t"
foo.c:19: warning: no semicolon at end of struct or union
foo.c:21: warning: data definition has no type or storage class
foo.c:23: error: parse error before '*' token
foo.c:24: error: parse error before '*' token
foo.c:25: error: parse error before '*' token
foo.c: In function `main':
foo.c:36: error: `size_t' undeclared (first use in this function)
foo.c:36: error: (Each undeclared identifier is reported only once
foo.c:36: error: for each function it appears in.)
foo.c:36: error: parse error before "n"
foo.c:50: error: `stack' undeclared (first use in this function)
foo.c:53: error: `stdin' undeclared (first use in this function)
foo.c:65: error: `NULL' undeclared (first use in this function)
foo.c:66: error: `stdout' undeclared (first use in this function)
foo.c:71: error: `n' undeclared (first use in this function)
foo.c:74: error: `stderr' undeclared (first use in this function)

C:\>


lol

Name: Anonymous 2007-12-28 17:31

>>21
Since you don't have stdio and string, what do you expect?
I bet you don't have the libc either.

Name: Anonymous 2007-12-28 17:40

module Language.BBCode.Parser
  (parseBBCode)
  where
import Language.BBCode
import Text.ParserCombinators.Parsec

bbcode = many (bbcodeElement <|> bbcodeText)
bbcodeElement = do element <- try bbcodeOpenElement
                   content <- bbcode
                   bbcodeCloseElement element
                   return (Element element content)
bbcodeOpenElement = do char '['
                       s <- many1 (oneOf "abcdefghijklmnopqrstuvwxyz_#*")
                       char ']'
                       return s
bbcodeCloseElement s = string ("[/" ++ s ++ "]")
bbcodeText = many1 (noneOf "[") >>= return . Text

parseBBCode bb = case parse bbcode "" bb of
                   Left  e  -> error $ show e
                   Right bs -> bs

Name: Anonymous 2007-12-28 17:41

>>17
use (read) you fucking idiot

Name: Anonymous 2007-12-28 17:44

(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))


(defun bbcodeify (sexp) (cond ((atom sexp) sexp) ((listp sexp) (format nil "[~a]~{~a~^ ~}[~a]" (car sexp) (mapcar #'bbcodeify (cdr sexp)) (car sexp)))))



Name: Anonymous 2007-12-28 17:44

>>25
you forgot close tags have [/x]

Name: Anonymous 2007-12-28 17:45

Name: Anonymous 2007-12-28 17:49

>>24
I know, read my post:
Your lisp snippet however takes the expression as a list, my snip takes it from stdin, there are advantages to my snip. (not that it would take a lot of code to change yours to do that)

Name: Anonymous 2007-12-28 17:57

php -r "while(print(preg_replace('/\((b|i|m|o|s|u|aa|br|sub|sup|code|spoiler) (.*)\)/','[$1]$2[/$1]',fgets(STDIN))));"

Doesn't understand nested sexps, it doesn't exit ever and it uses around 80% CPU.

LOL

Name: Anonymous 2007-12-28 18:02

/r/ enterprisey scalable Java solution

Name: Anonymous 2007-12-28 18:10

>>30
in before class LispToBBCodeTranslatorGeneratorFactory...

Name: Anonymous 2007-12-28 18:13

>>31
Was that supposed to be funny? :|

Name: Anonymous 2007-12-28 18:14

>>27
What?

Name: Anonymous 2007-12-28 18:14

>>32
:| awkwaaard

Name: Anonymous 2007-12-28 18:18

>>34
Was that supposed to be funny? C:\

Name: Anonymous 2007-12-28 18:18

Name: Anonymous 2007-12-28 18:19

:Λ)

Name: Anonymous 2007-12-28 18:22

php -r "while(print(preg_replace('/\((b|i|m|o|s|u|aa|br|sub|sup|code|spoiler) (.*)\)/','[$1]$2[/$1]',fgets(STDIN))));"

LOL

Name: Anonymous 2007-12-28 18:25

⌐_⌐

Name: Anonymous 2007-12-28 18:26

>>38
(b this should be bolded) this should not (b and this should be bolded too)

This is a problem which can't be evaluated with a regular expression - you need to use a stack-based grammar.

Name: Anonymous 2007-12-28 18:46

>>32,34-37
Butthurt Java dick-end. Enjoy your enterprises.

Name: Anonymous 2007-12-28 19:08

>>40
It can with PCREs.

Name: Anonymous 2007-12-28 19:11

>>42
do it faggot.

Name: Anonymous 2007-12-28 19:29

Don't they teach you kids proper computer science any more?

Name: Anonymous 2007-12-28 19:31

>>44
You mean Java? Of course they do.

Name: Anonymous 2007-12-28 19:34

data:application/xhtml+xml;base64,PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIveGh0bWwxMS9EVEQveGh0bWwxMS5kdGQiPg0KPCEtLSAoQykgTWljcm9zb2Z0IENvcnBvcmF0aW9uIDIwMDcuIEFsbCByaWdodHMgcmVzZXJ2ZWQuIC0tPg0KPGh0bWwgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiPjxoZWFkPjxtZXRhIGh0dHAtZXF1aXY9IkNvbnRlbnQtVHlwZSIgY29udGVudD0iYXBwbGljYXRpb24veG1sK3hodG1sOyBjaGFyc2V0PVVURi04IiAvPg0KPHRpdGxlPkJCQ29kZSAyLjA8L3RpdGxlPg0KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4NCmh0bWwsYm9keXtoZWlnaHQ6MTAwJTttYXJnaW46MDtwYWRkaW5nOjA7fQ0KI291dHB1dCwjaW5wdXR7cG9zaXRpb246YWJzb2x1dGU7fQ0KI29me3BhZGRpbmc6MTBweDtvdmVyZmxvdzphdXRvO30NCiNpbnB1dHtiYWNrZ3JvdW5kOiNFRUU7dGV4dC1hbGlnbjpjZW50ZXI7fQ0KLnNwb2lsZXIgeyBiYWNrZ3JvdW5kOiAjMDAwOyBjb2xvcjogIzAwMDsgfQ0KLnNwb2lsZXI6aG92ZXIgeyBjb2xvcjogI0ZGRjsgfQ0KLmFhIHsgdGV4dC1hbGlnbjogbGVmdDsgZm9udC1mYW1pbHk6IElQQU1vbmFQR290aGljLE1vbmEsJ01TIFBHb3RoaWMnLFlPekZvbnRBQTk3ICFpbXBvcnRhbnQgfQ0KLm8ge3RleHQtZGVjb3Jh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gICAgIHsNCiAgICAgICAgICBmb3IgKHZhciB4PTA7IHg8dGFncy5sZW5ndGg7IHgrKykgLy8gc2VhcmNoIGZvciB2YWxpZCB0YWdzDQogICAgICAgICAgDQogICAgICAgICAgew0KICAgICAgICAgIHRyeXsNCiAgICAgICAgICAgIGlmIChyclsxXT09dGFnc1t4XVswXSkNCiAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgdmFyIHN1YnR5cGUgPSB0YWdzW3hdWzFdOw0KICAgICAgICAgICAgICBpZiAoc3VidHlwZT49MTAwMCkNCiAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIGV4Y2x1c2l2ZXRhZyA9IHJyWzFdOw0KICAgICAgICAgICAgICAgIHN1YnR5cGUgPSBzdWJ0eXBlIC0gMTAwMDsNCiAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICB0YWdzdGFjay5wdXNoKFsNCiAgICAgICAgICAgICAgICByci5pbmRleCwgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogcG9zaXRpb24gb2YgWyBvZiB0YWcgaW4gc3RyaW5nICovDQogICAgICAgICAgICAgICAgcnJbMF0ubGVuZ3RoLCAgICAgICAgICAgICAgICAgICAgICAgIC8qIGxlbmd0aCBvZiB0YWcgaW5jbHVkaW5nIFtdICovDQogICAgICAgICAgICAgICAgcnJbMV0sICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIHR5cGUgb2YgdGFnICovDQogICAgICAgICAgICAgICAgc3VidHlwZSwgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIHR5cGUgb2Ygc3Vic3RpdHV0aW9uICovDQogICAgICAgICAgICAgICAgKHRhZ3NbeF0ubGVuZ3RoPjIpP3RhZ3NbeF1bMl06cnJbMV0gIC8qIHdoYXQgdG8gc3Vic3RpdHV0ZSAqLw0KICAgICAgICAgICAgICAgIF0pOw0KICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICB9Y2F0Y2goZSl7YWxlcnQoZSsnXG4nK3gpO30gIH0NCiAgICAgICAgfQ0KICAgICAgfQ0KICAgICAgZWxzZSAvLyBpZiBpdCBpcyBhIGNsb3NpbmcgdGFnDQogICAgICB7DQoJaWYgKGV4Y2x1c2l2ZXRhZz09IiIgfHwgKCIvIitleGNsdXNpdmV0YWc9PXJyWzFdKSkNCiAgICAgICAgew0KICAgICAgICAgIHZhciBsdCA9IHRhZ3N0YWNrW3RhZ3N0YWNrLmxlbmd0aC0xXTsNCiAgICAgICAgICBpZiAobHQpDQogICAgICAgICAgew0KICAgICAgICAgICAgaWYgKCIvIitsdFsyXT09cnJbMV0pDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgIGkgPSBpLnN1YnN0cmluZygwLGx0WzBdKQ0KICAgICAgICAgICAgICAgICsgKGx0WzNdPT0wPyIiOigNCiAgICAgICAgICAgICAgICAgICAgKGx0WzNdPT0zPyIiOigNCiAgICAgICAgICAgICAgICAgICAgICAiPCINCiAgICAgICAgICAgICAgICAgICAgKyAobHRbM109PTI/InNwYW4gY2xhc3M9XCIiOiIiKQ0KICAgICAgICAgICAgICAgICAgICArIGx0WzRdDQogICAgICAgICAgICAgICAgICAgICsgKGx0WzNdPT0yPyJcIiI6IiIpDQogICAgICAgICAgICAgICAgICAgICsgIj4iDQogICAgICAgICAgICAgICAgICAgICkpDQogICAgICAgICAgICAgICAgICArIGkuc3Vic3RyaW5nKGx0WzBdK2x0WzFdLCByci5pbmRleCkNCiAgICAgICAgICAgICAgICAgICsgKGx0WzNdPT0zPyIiOigNCiAgICAgICAgICAgICAgICAgICAgICAiPC8iDQogICAgICAgICAgICAgICAgICAgICsgKGx0WzNdPT0yPyJzcGFuIjpsdFs0XSkNCiAgICAgICAgICAgICAgICAgICAgKyAiPiIgDQogICAgICAgICAgICAgICAgICAgICkpDQogICAgICAgICAgICAgICAgICApKQ0KICAgICAgICAgICAgICAgICsgaS5zdWJzdHJpbmcocnIuaW5kZXgrcnJbMF0ubGVuZ3RoLCBpLm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Hk+PC9odG1sPg0K

Name: Anonymous 2007-12-28 19:35

>>45
Surprised they haven't 'moved on' to C# yet..

Name: Anonymous 2007-12-28 19:52

>>1
I'm confused.. you have first 3 functions then 3 defines?

Name: Anonymous 2007-12-28 20:11

>>48
It's supposedly to specify the types, but it doesn't actually make any difference whatsoever; the compiler ignores his forward declarations.

Name: Anonymous 2007-12-28 20:22

>>49
It would throw a warning/error if you used different/not appropriate types

Name: Anonymous 2007-12-28 20:23

>>46
Old file is old.

Name: Anonymous 2007-12-28 21:31

>>50
It doesn't.

Name: Anonymous 2007-12-28 21:34

>>52
It does, faggot.

Name: Anonymous 2007-12-28 23:53

>>53
I just tried it - it doesn't.

Name: Anonymous 2007-12-28 23:59

Of course it doesn't. By the time any part of the compiler that cares about giving out warnings even gets to it, the preprocessor has already replaced all the #define'd macros.

Name: Anonymous 2007-12-29 1:10

OP here, the prototypes where left because I firstly implemented them as functions, also >>55 got it right.

Name: Anonymous 2007-12-29 3:26

>>46
that did not work

Name: Anonymous 2007-12-29 5:17

(map alltags '(op sucks shit))

Name: Anonymous 2007-12-29 5:22

what is this aids

Name: Anonymous 2007-12-29 5:34

>>40
PCRE are Touring-complete.

Name: Anonymous 2007-12-29 14:07

[spoiler][br]EXPERT PROGRAMMER [/br][/spoiler]

Name: Anonymous 2007-12-29 17:04

>>61
failure.

Name: Anonymous 2007-12-30 3:54

bump for codes

Name: Anonymous 2007-12-30 9:19

>>61
Joe Ossanna would be rolling over in his grave if he read that.

Name: Anonymous 2007-12-30 9:46

>>64
But can he read in the dark?

Name: Anonymous 2007-12-30 9:46

>>64
But can he read in the dark?

Name: Anonymous 2007-12-30 10:36

>>65,66
Why, of course he can -- he's one of the undead, I think he uses OpenBSD.

Name: Anonymous 2007-12-31 3:32


~$ echo 'aids (b bolded (i (o bold o i) bold ita)(b double bold)(spoiler spoilered(b bold too)))(b this took me entirely too long(spoiler especially since I had to compile perl 5.10)(u and I now hate you for making me do it))' | /usr/local/bin/perl510 -p -ne 's/\(([boiu]|spoiler|code|br)\s(([^()]+|(?R))*)\)/\[$1\]$2\[\/$1\]/ while m/[()]/;'
aids [b]bolded [i][o]bold o i[/o] bold ita[/i][b]double bold[/b][spoiler]spoilered[b]bold too[/b][/spoiler][/b][b]this took me entirely too long[spoiler]especially since I had to compile perl 5.10[/spoiler][u]and I now hate you for making me do it[/u][/b]

Name: Anonymous 2007-12-31 8:26


aids bolded bold o i bold itadouble boldspoileredbold toothis took me entirely too longespecially since I had to compile perl 5.10and I now hate you for making me do it

Name: Anonymous 2007-12-31 11:07

EXPERT BBCODE SYSTEM (that supports parentheses by using
the FORCED INDENTATION OF CODE)


$ cat bbsexpr.pl
#!/usr/bin/perl -p0
0while(s#\(([^\s()]+)\s?(((\(\s)|((?<=\s)\))|[^()]+|(?R))*)\)#\[$1]$2\[/$1]#s);s/\( /(/g;s/ \)/)/g;
$ cat test
(b (i (o (u EXPERT BBCODE SYSTEM)) ( that supports parentheses by using
the (sup FORCED INDENTATION OF CODE) )))
$ cat test | perl bbsexpr.pl
[b][i][o][u]EXPERT BBCODE SYSTEM[/u][/o] (that supports parentheses by using
the [sup]FORCED INDENTATION OF CODE[/sup])[/i][/b]

Name: Anonymous 2007-12-31 12:21

>>70
fucking awesome man perl++

Name: Anonymous 2007-12-31 16:12

>>70
rm -rf /
Lol, sneaky.

Name: Anonymous 2007-12-31 17:30

>>72
what the ruck???

Name: Anonymous 2007-12-31 19:23

>>70
$ cat test | perl bbsexpr.pl

We have a faggot in out midst.

Name: Anonymous 2007-12-31 20:42

>>74
what because they use bash or cat or what?
explain

Name: Anonymous 2007-12-31 21:10

>>75
useless use of cat and piping.

perl bbsexpr.pl < test

Name: Anonymous 2007-12-31 23:15

>>76
Input file syntax is ugly. It breaks the "input op output" scheme that reads and combines easily. < test perl bbsexpr.pl is better but still confusing and unclean.

Name: Anonymous 2008-01-01 1:14

>>76
Considering that that's the exact same instruction written slightly differently, I'd say you're a faggot.

Name: Anonymous 2008-01-01 2:25

>>78
Considering you're a faggot, I'd say you're a faggot.

Name: Anonymous 2008-01-01 2:50

>>78
Uhm, I wouldn't say they're exactly the same. >>76's method doesn't have to fork-exec cat, which in itself is quite an expensive process.
There is still ``piping'' however (redirection boils down to a call to dup2, with stdin/stdout being duplicated to the file descriptor instead of a pipe)

Name: Anonymous 2008-01-01 7:08

>>74
What? I thought cat file.txt|less was the way to go. Sometimes I get so excited, I run less file.txt|less.

Name: Anonymous 2008-01-01 17:04

>>79
Oh Sussman, I lolled.

Name: Anonymous 2008-01-01 17:06

>>80
Uhm,
WELL UHM UHM UHM, UHM UHM, UHM UHM UHM.

Name: Anonymous 2008-01-01 17:24

Player appears to have no name on the leaderboard or in kill messages.
Name in status command appears as "& &"

Name: Anonymous 2008-01-01 17:32

>>1
Compiles with no problems with Microsoft Visual Studio 8.

lol.

Name: Anonymous 2008-01-01 17:48

They're up to VS9 now.

Name: Anonymous 2008-01-02 0:20

>>85
well that makes sense.. it's valid C89

Name: Anonymous 2008-01-02 8:38

We had 'solutions' in C,lisp,pcre but not haskell.
haskellfags, where's your monad now?!

Name: Anonymous 2008-01-02 17:24

>>87
i lol'd

Name: Anonymous 2008-01-02 19:45

Name: Anonymous 2009-02-25 8:08

Favorite musical genre chiptunes   if that counts   socket connects and   disconnects Keyword is.

Name: Anonymous 2010-11-14 19:24


[/br]

Don't change these.
Name: Email:
Entire Thread Thread List