36 lines
987 B
Plaintext
36 lines
987 B
Plaintext
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
@(define (output-charset num cset)
|
||
|
@list{
|
||
|
unsigned char @(format "cset~a" num) [] = {
|
||
|
@(string-join (map number->string cset) ",")
|
||
|
};
|
||
|
size_t @(format "cset~a_size" num) = @(length cset);
|
||
|
|
||
|
})
|
||
|
|
||
|
@(for/list ([i (in-naturals)] [cset (in-vector pattern)])
|
||
|
(output-charset i cset))
|
||
|
|
||
|
int main() {
|
||
|
char buf [ @(+ 2 (vector-length pattern)) ];
|
||
|
buf [ @(vector-length pattern) ] = '\n';
|
||
|
buf [ @(add1 (vector-length pattern)) ] = '\0';
|
||
|
@(for/list ([num (in-naturals)] [cset (in-vector pattern)])
|
||
|
(define iter (format "i~a" num))
|
||
|
(define cset (format "cset~a" num))
|
||
|
(define csetsize (format "cset~a_size" num))
|
||
|
@list{
|
||
|
for (size_t @iter = 0; @iter < @csetsize ; @iter ++) @"{"
|
||
|
@"buf[" @num @"]" = @cset @"[" @iter @"];"
|
||
|
@"\n"
|
||
|
})
|
||
|
|
||
|
fwrite(buf, 1, @(add1 (vector-length pattern)), stdout);
|
||
|
|
||
|
@(for/list ([cset (in-vector pattern)]) "}")
|
||
|
}
|
||
|
|