codeform version 1.2.0 #2
Codeform, a syntax highlighter [intended] for C and C++.
Codeform's main page: http://dwks.theprogrammingsite.com/myprogs/codeform.htm
Direct download link: http://dwks.theprogrammingsite.com/m...n/codeform.zip
"clip" download link (Windows clipboard utilities): http://dwks.theprogrammingsite.com/m.../down/clip.zip
Since the other threads were sadly lost in the recent presumed board restore from a backup, I'm starting another codeform thread. With good reason. Here is a list of the things I have done in the past two days:
- (Incomplete) Rules files for highlighting other rules files and phpbb were added. From names.txt:
cfrule codeform rules files
phpbb (PhpBB) BBCode (just like vbb but with [color=black] around everything)
- The static variables in add_rule() were removed into struct rules_t (as struct prevrule_t pr). There are now no global or static variables in codeform, though there is a rather complex structure that is passed to most functions (at least in part). :) Oh well.
- [bugfix] (related to the static variables) A rare memory leak occured when the last rule already existed:
It was fixed by freeing prevrule_t from main() with a call to the new function free_prevrule().
- Several spelling mistakes in the source file were fixed. Some undoubtable remain. :)
- [bugfix] Many keywords starting with the same characters would cause some to be ignored under certain conditions due to a problem with find_rule_new():
- [bugfix] A variable directly following an undefined variable would be ignored, due to an oversight in find_var_replace():
- [bugfix] A memory leak of at least BUFSIZ characters per input file occured. (The leak was the longest line in the file as a multiple of BUFSIZ, rounded up. So if BUFSIZ was 512 and there was a line in the file 530 characters long, 1024 characters would have been leaked.) It was fixed by adding free(line) into read_file().
- [bugfix] A memory leak occured for every parameter passed to the program. free_argument() was calling free() instead of free_strings().
- [bugfix] When reading rules files with DOS-style newlines under Linux, repeated sections ("*") were taken as literal "*"s. (This was manifest with codeform online.) chomp_newline() was added which chomps '\r's as well as '\n's.
- [bugfix] One byte too many was being allocated for every variable name in add_var9).
- One call to strlen() was eliminated by making remove_escapes() cooperate with shrink_string(). :)
There are still some things to fix, however: Valgrind still shows a few hundred bytes leaked for very complex rules files (down from several thousand, thanks to all of the memory leak bug fixes). (It's the first time I've ever used Valgrind; it's amazing.) I'm pretty sure there's something up with the previous-rule code in add_rule() et al.
HOWTO.txt is sort of out of date.
I want to add Perl support (a rather large undertaking, don't expect it within days ;) ).
Also see the TODO list for other things that I still need to do:
I haven't forgotten about the Win32 functions, don't worry, but the lists are gone now so it will take me a while . . . .
| TODO list for future versions of codeform |
- ? Optimise rule searching by looking in the previous position first
- Add support for "\n" and "\param" in specific comments ("" and /*! */)
- Make a "function" rule: \w+\s+\(
- ? Don't print closing tags for same-coloured nested comments
- Provide a default rules directory that is searched first
- Make "escaped newline" (\) character specifiable
- Don't count #es in #defines as new comments;
don't allow nestcoms to include themselves
[done] - Allow multiple prev pointers!
[done] - free static variables in add_rule()
- Make input, output and styles rules files separate
- Support indent-style code beautifying
Codeform online still isn't working. Any ideas? How can I run a program as a restricted user from a priviledged Perl script?