1.1 --- a/src/c2html.c Fri Jun 21 12:27:45 2013 +0200 1.2 +++ b/src/c2html.c Fri Jun 21 12:49:46 2013 +0200 1.3 @@ -149,6 +149,15 @@ 1.4 return 0; 1.5 } 1.6 1.7 +int iscapsonly(char *word, size_t wp) { 1.8 + for (size_t i = 0 ; i < wp ; i++) { 1.9 + if (!isupper(word[i]) && word[i] != '_') { 1.10 + return 0; 1.11 + } 1.12 + } 1.13 + return 1; 1.14 +} 1.15 + 1.16 void parseline(char *src, char *dest) { 1.17 size_t sp = 0, dp = 0; 1.18 /* indent */ 1.19 @@ -167,8 +176,7 @@ 1.20 memcpy(&(dest[dp]), "<span class=\"c2html-comment\">", 29); 1.21 dp += 29; 1.22 } 1.23 - // a fucking /* comment */ 1.24 - /* again // / */ 1.25 + 1.26 for (char c = src[sp] ; c ; c=src[++sp]) { 1.27 /* comments */ 1.28 if (c == '/') { 1.29 @@ -221,6 +229,9 @@ 1.30 } else if (isdirective(word)) { 1.31 memcpy(&(dest[dp]), "<span class=\"c2html-directive\">", 31); 1.32 dp += 31; 1.33 + } else if (iscapsonly(word, wp)) { 1.34 + memcpy(&(dest[dp]), "<span class=\"c2html-macroconst\">", 32); 1.35 + dp += 32; 1.36 } else { 1.37 closespan = 0; 1.38 } 1.39 @@ -231,9 +242,9 @@ 1.40 memcpy(&(dest[dp]), "</span>", 7); 1.41 dp += 7; 1.42 } 1.43 - memset(word, 0, WORDBUF_SIZE); 1.44 - wp = 0; 1.45 } 1.46 + memset(word, 0, WORDBUF_SIZE); 1.47 + wp = 0; 1.48 dp = writeescapedchar(dest, dp, c); 1.49 } else { 1.50 /* read word */ 1.51 @@ -286,7 +297,7 @@ 1.52 for (int i = 0 ; i < inputfile->count ; i++) { 1.53 parseline(inputfile->lines[i], line); 1.54 printf("<span class=\"c2html-lineno\">%*d:</span> %s", 1.55 - lnw, i, line); 1.56 + lnw, i+1, line); 1.57 } 1.58 free(line); 1.59 printf("</pre>\n");