structured source code

Thu, 23 Jan 2014 09:19:37 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 23 Jan 2014 09:19:37 +0100
changeset 21
537aec525835
parent 20
ebbf0776c1bc
child 22
f463693b5eeb

structured source code

LICENSE file | annotate | diff | comparison | revisions
Makefile file | annotate | diff | comparison | revisions
conf.mk file | annotate | diff | comparison | revisions
src/Makefile file | annotate | diff | comparison | revisions
src/c2html.c file | annotate | diff | comparison | revisions
src/ccodegen.c file | annotate | diff | comparison | revisions
src/ccodegen.h file | annotate | diff | comparison | revisions
src/codegens.c file | annotate | diff | comparison | revisions
src/codegens.h file | annotate | diff | comparison | revisions
src/javacodegen.c file | annotate | diff | comparison | revisions
src/javacodegen.h file | annotate | diff | comparison | revisions
src/obj.mk file | annotate | diff | comparison | revisions
     1.1 --- a/LICENSE	Fri Aug 30 11:23:44 2013 +0200
     1.2 +++ b/LICENSE	Thu Jan 23 09:19:37 2014 +0100
     1.3 @@ -1,4 +1,4 @@
     1.4 -Copyright 2013 Mike Becker. All rights reserved.
     1.5 +Copyright 2014 Mike Becker. All rights reserved.
     1.6  
     1.7  Redistribution and use in source and binary forms, with or without
     1.8  modification, are permitted provided that the following conditions are met:
     2.1 --- a/Makefile	Fri Aug 30 11:23:44 2013 +0200
     2.2 +++ b/Makefile	Thu Jan 23 09:19:37 2014 +0100
     2.3 @@ -31,7 +31,7 @@
     2.4  all: clean compile
     2.5  	
     2.6  compile: build
     2.7 -	cd src; $(MAKE) $(BIN)
     2.8 +	cd src; $(MAKE)
     2.9  
    2.10  build:
    2.11  	$(MKDIR) build
     3.1 --- a/conf.mk	Fri Aug 30 11:23:44 2013 +0200
     3.2 +++ b/conf.mk	Thu Jan 23 09:19:37 2014 +0100
     3.3 @@ -36,8 +36,4 @@
     3.4  CFLAGS  = -g -O2 -std=gnu99 -Wall -Werror -pedantic
     3.5  LD      = gcc
     3.6  LDFLAGS =
     3.7 -OBJEXT  = o
     3.8 -LIBEXT  = a
     3.9 -AR      = ar
    3.10 -ARFLAGS = -r
    3.11 -
    3.12 +OBJ_EXT = .o
     4.1 --- a/src/Makefile	Fri Aug 30 11:23:44 2013 +0200
     4.2 +++ b/src/Makefile	Thu Jan 23 09:19:37 2014 +0100
     4.3 @@ -28,14 +28,17 @@
     4.4  
     4.5  include ../conf.mk
     4.6  
     4.7 -DST = ../build
     4.8 +SRC  = c2html.c
     4.9 +SRC += codegens.c
    4.10 +SRC += ccodegen.c
    4.11 +SRC += javacodegen.c
    4.12  
    4.13 -include obj.mk
    4.14 +OBJ = $(SRC:%.c=../build/%$(OBJ_EXT))
    4.15  
    4.16 -$(BIN): $(OBJ)
    4.17 -	$(LD) -o $(DST)/$@ $^ $(LDFLAGS)
    4.18 +all: $(OBJ)
    4.19 +	$(LD) -o ../build/$(BIN) $^ $(LDFLAGS)
    4.20  	
    4.21  
    4.22 -$(DST)/%.$(OBJEXT): %.c
    4.23 +../build/%$(OBJ_EXT): %.c
    4.24  	$(CC) -o $@ $(CFLAGS) -c $<
    4.25  
     5.1 --- a/src/c2html.c	Fri Aug 30 11:23:44 2013 +0200
     5.2 +++ b/src/c2html.c	Thu Jan 23 09:19:37 2014 +0100
     5.3 @@ -1,7 +1,7 @@
     5.4  /*
     5.5   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     5.6   *
     5.7 - * Copyright 2013 Mike Becker. All rights reserved.
     5.8 + * Copyright 2014 Mike Becker. All rights reserved.
     5.9   *
    5.10   * Redistribution and use in source and binary forms, with or without
    5.11   * modification, are permitted provided that the following conditions are met:
    5.12 @@ -34,56 +34,10 @@
    5.13  #include <unistd.h>
    5.14  #include <ctype.h>
    5.15  
    5.16 +#include "javacodegen.h"
    5.17 +#include "ccodegen.h"
    5.18 +
    5.19  #define INPUTBUF_SIZE 2048
    5.20 -#define WORDBUF_SIZE 64
    5.21 -
    5.22 -const char* ckeywords[] = {
    5.23 -    "auto", "break", "case", "char", "const", "continue", "default", "do",
    5.24 -    "double", "else", "enum", "extern", "float", "for", "goto", "if", "int",
    5.25 -    "long", "register", "return", "short", "signed", "sizeof", "static",
    5.26 -    "struct", "switch", "typedef", "union", "unsigned", "void", "volatile",
    5.27 -    "while", NULL
    5.28 -};
    5.29 -
    5.30 -const char* jkeywords[] = {
    5.31 -    "abstract", "continue", "for", "new", "switch", "assert", "default", "goto",
    5.32 -    "package", "synchronized", "boolean", "do", "if", "private", "this",
    5.33 -    "break", "double", "implements", "protected", "throw", "byte", "else",
    5.34 -    "import", "public", "throws", "case", "enum", "instanceof", "return",
    5.35 -    "transient", "catch", "extends", "int", "short", "try", "char", "final",
    5.36 -    "interface", "static", "void", "class", "finally", "long", "strictfp",
    5.37 -    "volatile", "const", "float", "native", "super", "while", NULL
    5.38 -};
    5.39 -
    5.40 -#define iswordcharacter(c) (isalnum(c) || c=='_' || c=='#' || c=='@')
    5.41 -
    5.42 -int isctype(char *word, size_t len) {
    5.43 -    return (word[len-2] == '_' && word[len-1] == 't');
    5.44 -}
    5.45 -
    5.46 -int iscdirective(char *word) {
    5.47 -    return (word[0] == '#');
    5.48 -}
    5.49 -
    5.50 -int isjtype(char *word, size_t len) {
    5.51 -    return isupper(word[0]);
    5.52 -}
    5.53 -
    5.54 -int isjdirective(char *word) {
    5.55 -    return word[0] == '@';
    5.56 -}
    5.57 -
    5.58 -typedef struct _highlighter_t highlighter_t;
    5.59 -
    5.60 -struct _highlighter_t {
    5.61 -    const char** keywords;
    5.62 -    int(*istype)(char*,size_t);
    5.63 -    int(*isdirective)(char*);
    5.64 -    void(*parser)(char*,char*,highlighter_t*);
    5.65 -    int iscommentml;
    5.66 -    char word[WORDBUF_SIZE];
    5.67 -    char includefile[FILENAME_MAX];
    5.68 -};
    5.69  
    5.70  typedef struct {
    5.71      char* outfilename;
    5.72 @@ -169,190 +123,6 @@
    5.73      return inputfile;
    5.74  }
    5.75  
    5.76 -size_t writeescapedchar(char *dest, size_t dp, char c) {
    5.77 -    if (c == '>') {
    5.78 -        dest[dp++] = '&'; dest[dp++] = 'g'; dest[dp++] = 't'; dest[dp++] = ';';
    5.79 -    } else if (c == '<') {
    5.80 -        dest[dp++] = '&'; dest[dp++] = 'l'; dest[dp++] = 't'; dest[dp++] = ';';
    5.81 -    } else {
    5.82 -        dest[dp++] = c;
    5.83 -    }
    5.84 -
    5.85 -    return dp;
    5.86 -}
    5.87 -
    5.88 -int iskeyword(char *word, const char** keywords) {
    5.89 -    for (int i = 0 ; keywords[i] ; i++) {
    5.90 -        if (strncmp(keywords[i], word, WORDBUF_SIZE) == 0) {
    5.91 -            return 1;
    5.92 -        }
    5.93 -    }
    5.94 -    return 0;
    5.95 -}
    5.96 -
    5.97 -int iscapsonly(char *word, size_t wp) {
    5.98 -    for (size_t i = 0 ; i < wp ; i++) {
    5.99 -        if (!isupper(word[i]) && word[i] != '_') {
   5.100 -            return 0;
   5.101 -        }
   5.102 -    }
   5.103 -    return 1;
   5.104 -}
   5.105 -
   5.106 -void parseline(char *src, char *dest, highlighter_t *hltr) {
   5.107 -    hltr->parser(src, dest, hltr);
   5.108 -}
   5.109 -
   5.110 -void cjparseline(char *src, char *dest, highlighter_t *hltr) {
   5.111 -    size_t sp = 0, dp = 0;
   5.112 -    /* indent */
   5.113 -    while (isspace(src[sp])) {
   5.114 -        dest[dp++] = src[sp++];
   5.115 -    }
   5.116 -
   5.117 -    memset(hltr->word, 0, WORDBUF_SIZE);
   5.118 -    size_t wp = 0, ifp = 0;
   5.119 -    int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0;
   5.120 -    int isescaping = 0;
   5.121 -
   5.122 -    if (hltr->iscommentml) {
   5.123 -        iscomment = 1;
   5.124 -        memcpy(&(dest[dp]), "<span class=\"c2html-comment\">", 29);
   5.125 -        dp += 29;
   5.126 -    }
   5.127 -
   5.128 -    for (char c = src[sp] ; c ; c=src[++sp]) {
   5.129 -        /* comments */
   5.130 -        if (c == '/') {
   5.131 -            if (hltr->iscommentml && sp > 0 && src[sp-1] == '*') {
   5.132 -                iscomment = 0;
   5.133 -                hltr->iscommentml = 0;
   5.134 -                memcpy(&(dest[dp]), "/</span>", 8);
   5.135 -                dp += 8;
   5.136 -                continue;
   5.137 -            } else if (!iscomment && (src[sp+1] == '/' || src[sp+1] == '*')) {
   5.138 -                iscomment = 1;
   5.139 -                hltr->iscommentml = (src[sp+1] == '*');
   5.140 -                memcpy(&(dest[dp]), "<span class=\"c2html-comment\">", 29);
   5.141 -                dp += 29;
   5.142 -            }
   5.143 -        }
   5.144 -
   5.145 -        if (iscomment) {
   5.146 -            if (c == '\n') {
   5.147 -                memcpy(&(dest[dp]), "</span>", 7);
   5.148 -                dp += 7;
   5.149 -            }
   5.150 -            dp = writeescapedchar(dest, dp, c);
   5.151 -        } else if (isinclude) {
   5.152 -            if (c == '<') {
   5.153 -                memcpy(&(dest[dp]), "<span class=\"c2html-stdinclude\">", 32);
   5.154 -                dp += 32;
   5.155 -                dp = writeescapedchar(dest, dp, c);
   5.156 -            } else if (c == '\"') {
   5.157 -                if (parseinclude) {
   5.158 -                    dest[dp++] = '\"';
   5.159 -                    dest[dp++] = '>';
   5.160 -                    memcpy(&(dest[dp]), hltr->includefile, ifp);
   5.161 -                    dp += ifp;
   5.162 -
   5.163 -                    dp = writeescapedchar(dest, dp, c);
   5.164 -                    memcpy(&(dest[dp]), "</a>", 4);
   5.165 -                    dp += 4;
   5.166 -                    parseinclude = 0;
   5.167 -                } else {
   5.168 -                    memcpy(&(dest[dp]),
   5.169 -                        "<a class=\"c2html-userinclude\" href=", 35);
   5.170 -                    dp += 35;
   5.171 -                    dp = writeescapedchar(dest, dp, c);
   5.172 -                    ifp = 0;
   5.173 -                    hltr->includefile[ifp++] = '\"';
   5.174 -                    parseinclude = 1;
   5.175 -                }
   5.176 -            } else if (c == '>') {
   5.177 -                dp = writeescapedchar(dest, dp, c);
   5.178 -                memcpy(&(dest[dp]), "</span>", 7);
   5.179 -                dp += 7;
   5.180 -            } else {
   5.181 -                if (parseinclude) {
   5.182 -                    hltr->includefile[ifp++] = c;
   5.183 -                }
   5.184 -                dp = writeescapedchar(dest, dp, c);
   5.185 -            }
   5.186 -        } else {
   5.187 -            /* strings */
   5.188 -            if (!isescaping && (c == '\'' || c == '\"')) {
   5.189 -                isstring ^= 1;
   5.190 -                if (isstring) {
   5.191 -                    memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28);
   5.192 -                    dp += 28;
   5.193 -                    dp = writeescapedchar(dest, dp, c);
   5.194 -                } else {
   5.195 -                    dp = writeescapedchar(dest, dp, c);
   5.196 -                    memcpy(&(dest[dp]), "</span>", 7);
   5.197 -                    dp += 7;
   5.198 -                }
   5.199 -            } else {
   5.200 -                if (isstring) {
   5.201 -                    dp = writeescapedchar(dest, dp, c);
   5.202 -                } else if (!iswordcharacter(c)) {
   5.203 -                    /* interpret word int_t */
   5.204 -                    if (wp > 0 && wp < WORDBUF_SIZE) {
   5.205 -                        int closespan = 1;
   5.206 -                        if (iskeyword(hltr->word, hltr->keywords)) {
   5.207 -                            memcpy(&(dest[dp]),
   5.208 -                                "<span class=\"c2html-keyword\">", 29);
   5.209 -                            dp += 29;
   5.210 -                        } else if (hltr->istype(hltr->word, wp)) {
   5.211 -                            memcpy(&(dest[dp]),
   5.212 -                                "<span class=\"c2html-type\">", 26);
   5.213 -                            dp += 26;
   5.214 -                        } else if (hltr->isdirective(hltr->word)) {
   5.215 -                            isinclude = !strncmp(
   5.216 -                                "#include", hltr->word, WORDBUF_SIZE);
   5.217 -                            memcpy(&(dest[dp]),
   5.218 -                                "<span class=\"c2html-directive\">", 31);
   5.219 -                            dp += 31;
   5.220 -                        } else if (iscapsonly(hltr->word, wp)) {
   5.221 -                            memcpy(&(dest[dp]),
   5.222 -                                "<span class=\"c2html-macroconst\">", 32);
   5.223 -                            dp += 32;
   5.224 -                        } else {
   5.225 -                            closespan = 0;
   5.226 -                        }
   5.227 -                        for (int i = 0 ; i < wp ; i++) {
   5.228 -                            dp = writeescapedchar(dest, dp, hltr->word[i]);
   5.229 -                        }
   5.230 -                        if (closespan) {
   5.231 -                            memcpy(&(dest[dp]), "</span>", 7);
   5.232 -                            dp += 7;
   5.233 -                        }
   5.234 -                    }
   5.235 -                    memset(hltr->word, 0, WORDBUF_SIZE);
   5.236 -                    wp = 0;
   5.237 -                    dp = writeescapedchar(dest, dp, c);
   5.238 -                } else {
   5.239 -                    /* read word */
   5.240 -                    if (wp < WORDBUF_SIZE) {
   5.241 -                        hltr->word[wp++] = c;
   5.242 -                    } else if (wp == WORDBUF_SIZE) {
   5.243 -                        for (int i = 0 ; i < WORDBUF_SIZE ; i++) {
   5.244 -                            dp = writeescapedchar(dest, dp, hltr->word[i]);
   5.245 -                        }
   5.246 -                        wp++;
   5.247 -                        dp = writeescapedchar(dest, dp, c);
   5.248 -                    } else {
   5.249 -                        dp = writeescapedchar(dest, dp, c);
   5.250 -                    }
   5.251 -                }
   5.252 -            }
   5.253 -
   5.254 -            isescaping = !isescaping & (c == '\\');
   5.255 -        }
   5.256 -    }
   5.257 -    dest[dp] = 0;
   5.258 -}
   5.259 -
   5.260  void printhelp() {
   5.261      printf("Formats source code using HTML.\n\nUsage:\n"
   5.262          "  c2html [Options] FILE\n\n"
   5.263 @@ -382,7 +152,7 @@
   5.264      highlighter.isdirective = iscdirective;
   5.265      highlighter.istype = isctype;
   5.266      highlighter.keywords = ckeywords;
   5.267 -    highlighter.parser = cjparseline;
   5.268 +    highlighter.parser = cparseline;
   5.269  
   5.270      char optc;
   5.271      while ((optc = getopt(argc, argv, "hjo:p")) != -1) {
   5.272 @@ -396,6 +166,7 @@
   5.273                  highlighter.isdirective = isjdirective;
   5.274                  highlighter.istype = isjtype;
   5.275                  highlighter.keywords = jkeywords;
   5.276 +                highlighter.parser = jparseline;
   5.277                  break;
   5.278              case 'p':
   5.279                  settings.highlight = 0;
   5.280 @@ -432,7 +203,7 @@
   5.281              int lnw = lnint(inputfile->count);
   5.282              for (int i = 0 ; i < inputfile->count ; i++) {
   5.283                  if (settings.highlight) {
   5.284 -                    parseline(inputfile->lines[i], line, &highlighter);
   5.285 +                    highlighter.parser(inputfile->lines[i], line, &highlighter);
   5.286                  } else {
   5.287                      line = inputfile->lines[i];
   5.288                  }
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/ccodegen.c	Thu Jan 23 09:19:37 2014 +0100
     6.3 @@ -0,0 +1,198 @@
     6.4 +/*
     6.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     6.6 + *
     6.7 + * Copyright 2014 Mike Becker. All rights reserved.
     6.8 + *
     6.9 + * Redistribution and use in source and binary forms, with or without
    6.10 + * modification, are permitted provided that the following conditions are met:
    6.11 + *
    6.12 + *   1. Redistributions of source code must retain the above copyright
    6.13 + *      notice, this list of conditions and the following disclaimer.
    6.14 + *
    6.15 + *   2. Redistributions in binary form must reproduce the above copyright
    6.16 + *      notice, this list of conditions and the following disclaimer in the
    6.17 + *      documentation and/or other materials provided with the distribution.
    6.18 + *
    6.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    6.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    6.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    6.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    6.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    6.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    6.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    6.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    6.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    6.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    6.29 + * POSSIBILITY OF SUCH DAMAGE.
    6.30 + *
    6.31 + */
    6.32 +
    6.33 +#include "ccodegen.h"
    6.34 +#include <string.h>
    6.35 +#include <ctype.h>
    6.36 +
    6.37 +const char* ckeywords[] = {
    6.38 +    "auto", "break", "case", "char", "const", "continue", "default", "do",
    6.39 +    "double", "else", "enum", "extern", "float", "for", "goto", "if", "int",
    6.40 +    "long", "register", "return", "short", "signed", "sizeof", "static",
    6.41 +    "struct", "switch", "typedef", "union", "unsigned", "void", "volatile",
    6.42 +    "while", NULL
    6.43 +};
    6.44 +
    6.45 +int isctype(char *word, size_t len) {
    6.46 +    return (word[len-2] == '_' && word[len-1] == 't');
    6.47 +}
    6.48 +
    6.49 +int iscdirective(char *word) {
    6.50 +    return (word[0] == '#');
    6.51 +}
    6.52 +
    6.53 +void cparseline(char *src, char *dest, highlighter_t *hltr) {
    6.54 +    size_t sp = 0, dp = 0;
    6.55 +    /* indent */
    6.56 +    while (isspace(src[sp])) {
    6.57 +        dest[dp++] = src[sp++];
    6.58 +    }
    6.59 +
    6.60 +    memset(hltr->word, 0, WORDBUF_SIZE);
    6.61 +    size_t wp = 0, ifp = 0;
    6.62 +    int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0;
    6.63 +    int isescaping = 0;
    6.64 +
    6.65 +    if (hltr->iscommentml) {
    6.66 +        iscomment = 1;
    6.67 +        memcpy(&(dest[dp]), "<span class=\"c2html-comment\">", 29);
    6.68 +        dp += 29;
    6.69 +    }
    6.70 +
    6.71 +    for (char c = src[sp] ; c ; c=src[++sp]) {
    6.72 +        /* comments */
    6.73 +        if (c == '/') {
    6.74 +            if (hltr->iscommentml && sp > 0 && src[sp-1] == '*') {
    6.75 +                iscomment = 0;
    6.76 +                hltr->iscommentml = 0;
    6.77 +                memcpy(&(dest[dp]), "/</span>", 8);
    6.78 +                dp += 8;
    6.79 +                continue;
    6.80 +            } else if (!iscomment && (src[sp+1] == '/' || src[sp+1] == '*')) {
    6.81 +                iscomment = 1;
    6.82 +                hltr->iscommentml = (src[sp+1] == '*');
    6.83 +                memcpy(&(dest[dp]), "<span class=\"c2html-comment\">", 29);
    6.84 +                dp += 29;
    6.85 +            }
    6.86 +        }
    6.87 +
    6.88 +        if (iscomment) {
    6.89 +            if (c == '\n') {
    6.90 +                memcpy(&(dest[dp]), "</span>", 7);
    6.91 +                dp += 7;
    6.92 +            }
    6.93 +            dp = writeescapedchar(dest, dp, c);
    6.94 +        } else if (isinclude) {
    6.95 +            if (c == '<') {
    6.96 +                memcpy(&(dest[dp]), "<span class=\"c2html-stdinclude\">", 32);
    6.97 +                dp += 32;
    6.98 +                dp = writeescapedchar(dest, dp, c);
    6.99 +            } else if (c == '\"') {
   6.100 +                if (parseinclude) {
   6.101 +                    dest[dp++] = '\"';
   6.102 +                    dest[dp++] = '>';
   6.103 +                    memcpy(&(dest[dp]), hltr->includefile, ifp);
   6.104 +                    dp += ifp;
   6.105 +
   6.106 +                    dp = writeescapedchar(dest, dp, c);
   6.107 +                    memcpy(&(dest[dp]), "</a>", 4);
   6.108 +                    dp += 4;
   6.109 +                    parseinclude = 0;
   6.110 +                } else {
   6.111 +                    memcpy(&(dest[dp]),
   6.112 +                        "<a class=\"c2html-userinclude\" href=", 35);
   6.113 +                    dp += 35;
   6.114 +                    dp = writeescapedchar(dest, dp, c);
   6.115 +                    ifp = 0;
   6.116 +                    hltr->includefile[ifp++] = '\"';
   6.117 +                    parseinclude = 1;
   6.118 +                }
   6.119 +            } else if (c == '>') {
   6.120 +                dp = writeescapedchar(dest, dp, c);
   6.121 +                memcpy(&(dest[dp]), "</span>", 7);
   6.122 +                dp += 7;
   6.123 +            } else {
   6.124 +                if (parseinclude) {
   6.125 +                    hltr->includefile[ifp++] = c;
   6.126 +                }
   6.127 +                dp = writeescapedchar(dest, dp, c);
   6.128 +            }
   6.129 +        } else {
   6.130 +            /* strings */
   6.131 +            if (!isescaping && (c == '\'' || c == '\"')) {
   6.132 +                isstring ^= 1;
   6.133 +                if (isstring) {
   6.134 +                    memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28);
   6.135 +                    dp += 28;
   6.136 +                    dp = writeescapedchar(dest, dp, c);
   6.137 +                } else {
   6.138 +                    dp = writeescapedchar(dest, dp, c);
   6.139 +                    memcpy(&(dest[dp]), "</span>", 7);
   6.140 +                    dp += 7;
   6.141 +                }
   6.142 +            } else {
   6.143 +                if (isstring) {
   6.144 +                    dp = writeescapedchar(dest, dp, c);
   6.145 +                } else if (!iswordcharacter(c)) {
   6.146 +                    /* interpret word int_t */
   6.147 +                    if (wp > 0 && wp < WORDBUF_SIZE) {
   6.148 +                        int closespan = 1;
   6.149 +                        if (iskeyword(hltr->word, hltr->keywords)) {
   6.150 +                            memcpy(&(dest[dp]),
   6.151 +                                "<span class=\"c2html-keyword\">", 29);
   6.152 +                            dp += 29;
   6.153 +                        } else if (hltr->istype(hltr->word, wp)) {
   6.154 +                            memcpy(&(dest[dp]),
   6.155 +                                "<span class=\"c2html-type\">", 26);
   6.156 +                            dp += 26;
   6.157 +                        } else if (hltr->isdirective(hltr->word)) {
   6.158 +                            isinclude = !strncmp(
   6.159 +                                "#include", hltr->word, WORDBUF_SIZE);
   6.160 +                            memcpy(&(dest[dp]),
   6.161 +                                "<span class=\"c2html-directive\">", 31);
   6.162 +                            dp += 31;
   6.163 +                        } else if (iscapsonly(hltr->word, wp)) {
   6.164 +                            memcpy(&(dest[dp]),
   6.165 +                                "<span class=\"c2html-macroconst\">", 32);
   6.166 +                            dp += 32;
   6.167 +                        } else {
   6.168 +                            closespan = 0;
   6.169 +                        }
   6.170 +                        for (int i = 0 ; i < wp ; i++) {
   6.171 +                            dp = writeescapedchar(dest, dp, hltr->word[i]);
   6.172 +                        }
   6.173 +                        if (closespan) {
   6.174 +                            memcpy(&(dest[dp]), "</span>", 7);
   6.175 +                            dp += 7;
   6.176 +                        }
   6.177 +                    }
   6.178 +                    memset(hltr->word, 0, WORDBUF_SIZE);
   6.179 +                    wp = 0;
   6.180 +                    dp = writeescapedchar(dest, dp, c);
   6.181 +                } else {
   6.182 +                    /* read word */
   6.183 +                    if (wp < WORDBUF_SIZE) {
   6.184 +                        hltr->word[wp++] = c;
   6.185 +                    } else if (wp == WORDBUF_SIZE) {
   6.186 +                        for (int i = 0 ; i < WORDBUF_SIZE ; i++) {
   6.187 +                            dp = writeescapedchar(dest, dp, hltr->word[i]);
   6.188 +                        }
   6.189 +                        wp++;
   6.190 +                        dp = writeescapedchar(dest, dp, c);
   6.191 +                    } else {
   6.192 +                        dp = writeescapedchar(dest, dp, c);
   6.193 +                    }
   6.194 +                }
   6.195 +            }
   6.196 +
   6.197 +            isescaping = !isescaping & (c == '\\');
   6.198 +        }
   6.199 +    }
   6.200 +    dest[dp] = 0;
   6.201 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/ccodegen.h	Thu Jan 23 09:19:37 2014 +0100
     7.3 @@ -0,0 +1,51 @@
     7.4 +/*
     7.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     7.6 + *
     7.7 + * Copyright 2014 Mike Becker. All rights reserved.
     7.8 + *
     7.9 + * Redistribution and use in source and binary forms, with or without
    7.10 + * modification, are permitted provided that the following conditions are met:
    7.11 + *
    7.12 + *   1. Redistributions of source code must retain the above copyright
    7.13 + *      notice, this list of conditions and the following disclaimer.
    7.14 + *
    7.15 + *   2. Redistributions in binary form must reproduce the above copyright
    7.16 + *      notice, this list of conditions and the following disclaimer in the
    7.17 + *      documentation and/or other materials provided with the distribution.
    7.18 + *
    7.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    7.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    7.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    7.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    7.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    7.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    7.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    7.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    7.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    7.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    7.29 + * POSSIBILITY OF SUCH DAMAGE.
    7.30 + *
    7.31 + */
    7.32 +
    7.33 +#ifndef CCODEGEN_H
    7.34 +#define	CCODEGEN_H
    7.35 +
    7.36 +#include "codegens.h"
    7.37 +#include <stddef.h>
    7.38 +
    7.39 +#ifdef	__cplusplus
    7.40 +extern "C" {
    7.41 +#endif
    7.42 +
    7.43 +extern const char* ckeywords[];
    7.44 +
    7.45 +int isctype(char *word, size_t len);
    7.46 +int iscdirective(char *word);
    7.47 +void cparseline(char *src, char *dest, highlighter_t *hltr);
    7.48 +
    7.49 +#ifdef	__cplusplus
    7.50 +}
    7.51 +#endif
    7.52 +
    7.53 +#endif	/* CCODEGEN_H */
    7.54 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/codegens.c	Thu Jan 23 09:19:37 2014 +0100
     8.3 @@ -0,0 +1,63 @@
     8.4 +/*
     8.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     8.6 + *
     8.7 + * Copyright 2014 Mike Becker. All rights reserved.
     8.8 + *
     8.9 + * Redistribution and use in source and binary forms, with or without
    8.10 + * modification, are permitted provided that the following conditions are met:
    8.11 + *
    8.12 + *   1. Redistributions of source code must retain the above copyright
    8.13 + *      notice, this list of conditions and the following disclaimer.
    8.14 + *
    8.15 + *   2. Redistributions in binary form must reproduce the above copyright
    8.16 + *      notice, this list of conditions and the following disclaimer in the
    8.17 + *      documentation and/or other materials provided with the distribution.
    8.18 + *
    8.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    8.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    8.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    8.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    8.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    8.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    8.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    8.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    8.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    8.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    8.29 + * POSSIBILITY OF SUCH DAMAGE.
    8.30 + *
    8.31 + */
    8.32 +
    8.33 +#include <ctype.h>
    8.34 +#include <string.h>
    8.35 +#include "codegens.h"
    8.36 +
    8.37 +
    8.38 +size_t writeescapedchar(char *dest, size_t dp, char c) {
    8.39 +    if (c == '>') {
    8.40 +        dest[dp++] = '&'; dest[dp++] = 'g'; dest[dp++] = 't'; dest[dp++] = ';';
    8.41 +    } else if (c == '<') {
    8.42 +        dest[dp++] = '&'; dest[dp++] = 'l'; dest[dp++] = 't'; dest[dp++] = ';';
    8.43 +    } else {
    8.44 +        dest[dp++] = c;
    8.45 +    }
    8.46 +
    8.47 +    return dp;
    8.48 +}
    8.49 +
    8.50 +int iskeyword(char *word, const char** keywords) {
    8.51 +    for (int i = 0 ; keywords[i] ; i++) {
    8.52 +        if (strncmp(keywords[i], word, WORDBUF_SIZE) == 0) {
    8.53 +            return 1;
    8.54 +        }
    8.55 +    }
    8.56 +    return 0;
    8.57 +}
    8.58 +
    8.59 +int iscapsonly(char *word, size_t wp) {
    8.60 +    for (size_t i = 0 ; i < wp ; i++) {
    8.61 +        if (!isupper(word[i]) && word[i] != '_') {
    8.62 +            return 0;
    8.63 +        }
    8.64 +    }
    8.65 +    return 1;
    8.66 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/codegens.h	Thu Jan 23 09:19:37 2014 +0100
     9.3 @@ -0,0 +1,66 @@
     9.4 +/*
     9.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     9.6 + *
     9.7 + * Copyright 2014 Mike Becker. All rights reserved.
     9.8 + *
     9.9 + * Redistribution and use in source and binary forms, with or without
    9.10 + * modification, are permitted provided that the following conditions are met:
    9.11 + *
    9.12 + *   1. Redistributions of source code must retain the above copyright
    9.13 + *      notice, this list of conditions and the following disclaimer.
    9.14 + *
    9.15 + *   2. Redistributions in binary form must reproduce the above copyright
    9.16 + *      notice, this list of conditions and the following disclaimer in the
    9.17 + *      documentation and/or other materials provided with the distribution.
    9.18 + *
    9.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    9.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    9.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    9.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
    9.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    9.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    9.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    9.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    9.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    9.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    9.29 + * POSSIBILITY OF SUCH DAMAGE.
    9.30 + *
    9.31 + */
    9.32 +
    9.33 +#ifndef CODEGENS_H
    9.34 +#define	CODEGENS_H
    9.35 +
    9.36 +#include <stdio.h>
    9.37 +
    9.38 +#ifdef	__cplusplus
    9.39 +extern "C" {
    9.40 +#endif
    9.41 +
    9.42 +#define WORDBUF_SIZE 64
    9.43 +
    9.44 +#define iswordcharacter(c) (isalnum(c) || c=='_' || c=='#' || c=='@')
    9.45 +    
    9.46 +typedef struct _highlighter_t highlighter_t;
    9.47 +typedef void(*parser_fnc)(char*,char*,highlighter_t*);
    9.48 +
    9.49 +struct _highlighter_t {
    9.50 +    const char** keywords;
    9.51 +    int(*istype)(char*,size_t);
    9.52 +    int(*isdirective)(char*);
    9.53 +    parser_fnc parser;
    9.54 +    int iscommentml;
    9.55 +    char word[WORDBUF_SIZE];
    9.56 +    char includefile[FILENAME_MAX];
    9.57 +};
    9.58 +
    9.59 +size_t writeescapedchar(char *dest, size_t dp, char c);
    9.60 +int iskeyword(char *word, const char** keywords);
    9.61 +int iscapsonly(char *word, size_t wp);
    9.62 +
    9.63 +
    9.64 +#ifdef	__cplusplus
    9.65 +}
    9.66 +#endif
    9.67 +
    9.68 +#endif	/* CODEGENS_H */
    9.69 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/javacodegen.c	Thu Jan 23 09:19:37 2014 +0100
    10.3 @@ -0,0 +1,165 @@
    10.4 +/*
    10.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    10.6 + *
    10.7 + * Copyright 2014 Mike Becker. All rights reserved.
    10.8 + *
    10.9 + * Redistribution and use in source and binary forms, with or without
   10.10 + * modification, are permitted provided that the following conditions are met:
   10.11 + *
   10.12 + *   1. Redistributions of source code must retain the above copyright
   10.13 + *      notice, this list of conditions and the following disclaimer.
   10.14 + *
   10.15 + *   2. Redistributions in binary form must reproduce the above copyright
   10.16 + *      notice, this list of conditions and the following disclaimer in the
   10.17 + *      documentation and/or other materials provided with the distribution.
   10.18 + *
   10.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   10.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   10.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   10.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   10.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   10.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   10.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   10.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   10.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   10.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   10.29 + * POSSIBILITY OF SUCH DAMAGE.
   10.30 + *
   10.31 + */
   10.32 +
   10.33 +#include "javacodegen.h"
   10.34 +#include <string.h>
   10.35 +#include <ctype.h>
   10.36 +
   10.37 +const char* jkeywords[] = {
   10.38 +    "abstract", "continue", "for", "new", "switch", "assert", "default", "goto",
   10.39 +    "package", "synchronized", "boolean", "do", "if", "private", "this",
   10.40 +    "break", "double", "implements", "protected", "throw", "byte", "else",
   10.41 +    "import", "public", "throws", "case", "enum", "instanceof", "return",
   10.42 +    "transient", "catch", "extends", "int", "short", "try", "char", "final",
   10.43 +    "interface", "static", "void", "class", "finally", "long", "strictfp",
   10.44 +    "volatile", "const", "float", "native", "super", "while", NULL
   10.45 +};
   10.46 +
   10.47 +int isjtype(char *word, size_t len) {
   10.48 +    return isupper(word[0]);
   10.49 +}
   10.50 +
   10.51 +int isjdirective(char *word) {
   10.52 +    return word[0] == '@';
   10.53 +}
   10.54 +
   10.55 +void jparseline(char *src, char *dest, highlighter_t *hltr) {
   10.56 +    size_t sp = 0, dp = 0;
   10.57 +    /* indent */
   10.58 +    while (isspace(src[sp])) {
   10.59 +        dest[dp++] = src[sp++];
   10.60 +    }
   10.61 +
   10.62 +    memset(hltr->word, 0, WORDBUF_SIZE);
   10.63 +    size_t wp = 0;
   10.64 +    int isstring = 0, iscomment = 0, isimport = 0;
   10.65 +    int isescaping = 0;
   10.66 +
   10.67 +    if (hltr->iscommentml) {
   10.68 +        iscomment = 1;
   10.69 +        memcpy(&(dest[dp]), "<span class=\"c2html-comment\">", 29);
   10.70 +        dp += 29;
   10.71 +    }
   10.72 +
   10.73 +    for (char c = src[sp] ; c ; c=src[++sp]) {
   10.74 +        /* comments */
   10.75 +        if (c == '/') {
   10.76 +            if (hltr->iscommentml && sp > 0 && src[sp-1] == '*') {
   10.77 +                iscomment = 0;
   10.78 +                hltr->iscommentml = 0;
   10.79 +                memcpy(&(dest[dp]), "/</span>", 8);
   10.80 +                dp += 8;
   10.81 +                continue;
   10.82 +            } else if (!iscomment && (src[sp+1] == '/' || src[sp+1] == '*')) {
   10.83 +                iscomment = 1;
   10.84 +                hltr->iscommentml = (src[sp+1] == '*');
   10.85 +                memcpy(&(dest[dp]), "<span class=\"c2html-comment\">", 29);
   10.86 +                dp += 29;
   10.87 +            }
   10.88 +        }
   10.89 +
   10.90 +        if (iscomment) {
   10.91 +            if (c == '\n') {
   10.92 +                memcpy(&(dest[dp]), "</span>", 7);
   10.93 +                dp += 7;
   10.94 +            }
   10.95 +            dp = writeescapedchar(dest, dp, c);
   10.96 +        } else if (isimport) {
   10.97 +            // TODO: local imports
   10.98 +        } else {
   10.99 +            /* strings */
  10.100 +            if (!isescaping && (c == '\'' || c == '\"')) {
  10.101 +                isstring ^= 1;
  10.102 +                if (isstring) {
  10.103 +                    memcpy(&(dest[dp]), "<span class=\"c2html-string\">", 28);
  10.104 +                    dp += 28;
  10.105 +                    dp = writeescapedchar(dest, dp, c);
  10.106 +                } else {
  10.107 +                    dp = writeescapedchar(dest, dp, c);
  10.108 +                    memcpy(&(dest[dp]), "</span>", 7);
  10.109 +                    dp += 7;
  10.110 +                }
  10.111 +            } else {
  10.112 +                if (isstring) {
  10.113 +                    dp = writeescapedchar(dest, dp, c);
  10.114 +                } else if (!iswordcharacter(c)) {
  10.115 +                    /* interpret word int_t */
  10.116 +                    if (wp > 0 && wp < WORDBUF_SIZE) {
  10.117 +                        int closespan = 1;
  10.118 +                        if (iskeyword(hltr->word, hltr->keywords)) {
  10.119 +                            memcpy(&(dest[dp]),
  10.120 +                                "<span class=\"c2html-keyword\">", 29);
  10.121 +                            dp += 29;
  10.122 +                        } else if (hltr->istype(hltr->word, wp)) {
  10.123 +                            memcpy(&(dest[dp]),
  10.124 +                                "<span class=\"c2html-type\">", 26);
  10.125 +                            dp += 26;
  10.126 +                        } else if (hltr->isdirective(hltr->word)) {
  10.127 +                            memcpy(&(dest[dp]),
  10.128 +                                "<span class=\"c2html-directive\">", 31);
  10.129 +                            dp += 31;
  10.130 +                        } else if (iscapsonly(hltr->word, wp)) {
  10.131 +                            memcpy(&(dest[dp]),
  10.132 +                                "<span class=\"c2html-macroconst\">", 32);
  10.133 +                            dp += 32;
  10.134 +                        } else {
  10.135 +                            closespan = 0;
  10.136 +                        }
  10.137 +                        for (int i = 0 ; i < wp ; i++) {
  10.138 +                            dp = writeescapedchar(dest, dp, hltr->word[i]);
  10.139 +                        }
  10.140 +                        if (closespan) {
  10.141 +                            memcpy(&(dest[dp]), "</span>", 7);
  10.142 +                            dp += 7;
  10.143 +                        }
  10.144 +                    }
  10.145 +                    memset(hltr->word, 0, WORDBUF_SIZE);
  10.146 +                    wp = 0;
  10.147 +                    dp = writeescapedchar(dest, dp, c);
  10.148 +                } else {
  10.149 +                    /* read word */
  10.150 +                    if (wp < WORDBUF_SIZE) {
  10.151 +                        hltr->word[wp++] = c;
  10.152 +                    } else if (wp == WORDBUF_SIZE) {
  10.153 +                        for (int i = 0 ; i < WORDBUF_SIZE ; i++) {
  10.154 +                            dp = writeescapedchar(dest, dp, hltr->word[i]);
  10.155 +                        }
  10.156 +                        wp++;
  10.157 +                        dp = writeescapedchar(dest, dp, c);
  10.158 +                    } else {
  10.159 +                        dp = writeescapedchar(dest, dp, c);
  10.160 +                    }
  10.161 +                }
  10.162 +            }
  10.163 +
  10.164 +            isescaping = !isescaping & (c == '\\');
  10.165 +        }
  10.166 +    }
  10.167 +    dest[dp] = 0;
  10.168 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/javacodegen.h	Thu Jan 23 09:19:37 2014 +0100
    11.3 @@ -0,0 +1,52 @@
    11.4 +/*
    11.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    11.6 + *
    11.7 + * Copyright 2014 Mike Becker. All rights reserved.
    11.8 + *
    11.9 + * Redistribution and use in source and binary forms, with or without
   11.10 + * modification, are permitted provided that the following conditions are met:
   11.11 + *
   11.12 + *   1. Redistributions of source code must retain the above copyright
   11.13 + *      notice, this list of conditions and the following disclaimer.
   11.14 + *
   11.15 + *   2. Redistributions in binary form must reproduce the above copyright
   11.16 + *      notice, this list of conditions and the following disclaimer in the
   11.17 + *      documentation and/or other materials provided with the distribution.
   11.18 + *
   11.19 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   11.20 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   11.21 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   11.22 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   11.23 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   11.24 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   11.25 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   11.26 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   11.27 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   11.28 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   11.29 + * POSSIBILITY OF SUCH DAMAGE.
   11.30 + *
   11.31 + */
   11.32 +
   11.33 +#ifndef JAVACODEGEN_H
   11.34 +#define	JAVACODEGEN_H
   11.35 +
   11.36 +#include "codegens.h"
   11.37 +#include <stddef.h>
   11.38 +
   11.39 +#ifdef	__cplusplus
   11.40 +extern "C" {
   11.41 +#endif
   11.42 +
   11.43 +extern const char* jkeywords[];
   11.44 +
   11.45 +int isjtype(char *word, size_t len);
   11.46 +int isjdirective(char *word);
   11.47 +void jparseline(char *src, char *dest, highlighter_t *hltr);
   11.48 +
   11.49 +
   11.50 +#ifdef	__cplusplus
   11.51 +}
   11.52 +#endif
   11.53 +
   11.54 +#endif	/* JAVACODEGEN_H */
   11.55 +
    12.1 --- a/src/obj.mk	Fri Aug 30 11:23:44 2013 +0200
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,31 +0,0 @@
    12.4 -#
    12.5 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    12.6 -#
    12.7 -# Copyright 2013 Mike Becker. All rights reserved.
    12.8 -#
    12.9 -# Redistribution and use in source and binary forms, with or without
   12.10 -# modification, are permitted provided that the following conditions are met:
   12.11 -#
   12.12 -#   1. Redistributions of source code must retain the above copyright
   12.13 -#      notice, this list of conditions and the following disclaimer.
   12.14 -#
   12.15 -#   2. Redistributions in binary form must reproduce the above copyright
   12.16 -#      notice, this list of conditions and the following disclaimer in the
   12.17 -#      documentation and/or other materials provided with the distribution.
   12.18 -#
   12.19 -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   12.20 -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   12.21 -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   12.22 -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   12.23 -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   12.24 -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   12.25 -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   12.26 -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   12.27 -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   12.28 -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   12.29 -# POSSIBILITY OF SUCH DAMAGE.
   12.30 -#
   12.31 -
   12.32 -OBJ = $(addsuffix .$(OBJEXT),$(addprefix $(DST)/, \
   12.33 -    c2html \
   12.34 -))

mercurial