![]() |
03-23-2007, 04:34 PM
|
#1 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
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:
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: Code:
/*-------------------------------------------*\
| TODO list for future versions of codeform |
\*-------------------------------------------*/
Short-term
- ? 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()
Long-term
- Make input, output and styles rules files separate
Distant long-term
- 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?
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! Last edited by dwks : 03-23-2007 at 04:55 PM. |
dwks is online now
|
|
03-23-2007, 04:56 PM
|
#2 |
|
Registered User
Join Date: Dec 2002
Posts: 295
|
Would you like me to put the win api list back up?
|
kryptkat is offline
|
|
03-23-2007, 05:14 PM
|
#3 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Sure. Or you could create the codeform rules files yourself if you're feeling up to it.
![]() Perhaps something like this: Code:
=keyword keyworddarkb= keyworddarka= auto:$(keyworddarkb):$(keyworddarka) bool:*:* break:*:* case:*:* ... Code:
#!/usr/bin/perl
print "=keyword\n\nkeyworddarkb=\nkeyworddarka=\n\n";
chomp($l = <>);
print "$l:\$(keyworddarkb):\$(keyworddarka)\n";
while(<>) {
chomp;
print "$_:*:*\n";
}
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! Last edited by dwks : 03-23-2007 at 05:18 PM. |
dwks is online now
|
|
03-23-2007, 05:20 PM
|
#4 |
|
Registered User
Join Date: Dec 2002
Posts: 295
|
Code:
=keyword keyworddarkb= keyworddarka= auto:$(keyworddarkb):$(keyworddarka) bool:*:* break:*:* case:*:* ... Code:
#!/usr/bin/perl
print "=keyword\n\nkeyworddarkb=\nkeyworddarka=\n\n";
$l = <>;
print "$l:$(keyworddarkb):$(keyworddarka)\n"
while(<>) {
print "$_:*:*\n";
}
|
kryptkat is offline
|
|
03-23-2007, 05:24 PM
|
#5 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
I'll
run it for you then. (It's a Perl interpreter BTW.) Post the list (as
an attachment!) if you have it handy. If not, I'll start looking . . . .
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
dwks is online now
|
|
03-23-2007, 05:36 PM
|
#6 |
|
Registered User
Join Date: Dec 2002
Posts: 295
|
put it all on one file.txt
note to self.... dx9 and gdi need to add |
kryptkat is offline
|
|
03-23-2007, 05:56 PM
|
#7 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Here it is . . . generated by this:
Code:
#!/usr/bin/perl
print "=keyword\n\nkeyworddarkb=\nkeyworddarka=\n\n";
chomp($l = <>);
$l =~ s/\s*\(?\s*$//;
print "$l:\$(keyworddarkb):\$(keyworddarka)\n";
while($l = <>) {
chomp($l);
$l =~ s/\(?\s*$//;
if($l =~ /\/\*(.*)\*\// || $l =~ /(. Functions)/) {
print "# $1\n";
}
elsif($l ne '') {
print "$l:*:*\n";
}
}
Code:
$ ./codeform -f rules/cpp_vbb_1 -f rules/winapi ... ![]() [edit] Stupid attachments. You can't have a file with no extension . . . remove the .txt. [/edit]
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! Last edited by dwks : 03-23-2007 at 06:00 PM. |
dwks is online now
|
|
03-23-2007, 06:02 PM
|
#8 |
|
The Superheterodyne
Join Date: Dec 2005
Location: Ireland
Posts: 1,542
|
Might
be worth putting in some documentation about the clipboard programs too
so people can use your code formatter along with your clipboard thing.
__________________
I've got to get a girlfriend, just for the summer, until this wears off. She'll be a summery girl. She'll have hair. She'll have summery friends who know how to be outside. She'll play tennis and wear dresses and have bare feet, and in the autumn, I'll ditch her, because she's my summer girl! |
twomers is offline
|
|
03-24-2007, 04:24 AM
|
#9 |
|
Registered User
Join Date: Dec 2002
Posts: 295
|
tested
it. it hangs. let it run all night just to see if it was slow or not
working. 9pm to 7:30am is enough time to know that it crashed.
first thought colins on math functions second thought two rule files third thought comments in file. fourth thought perl script messed up fifth thought multiple references of the same functions manually edit win api file retry with manually made rule file. other thoughts as to why it crashed? [edit] how large of .c file can it handle? [/edit] Last edited by kryptkat : 03-24-2007 at 04:26 AM. |
kryptkat is offline
|
|
03-24-2007, 09:26 AM
|
#10 |
|
Registered User
Join Date: Dec 2002
Posts: 295
|
care to try that again?
here is the list sorted with the duplicates removed and the comments removed. it is ready for a perl script to turn it to a winapi rule file. note there is gdi in there hbitmap and bitblit i think all of it . |
kryptkat is offline
|
|
03-24-2007, 12:52 PM
|
#11 | ||
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Quote:
Comments in file beginning with '#' are fine -- "/**/" comments are not. I think I got rid of them though. The Perl script may well have messed up. ![]() Multiple functions of the same name would cause the duplicates to be ignored (only the first one counts). Quote:
I expect the problems you encountered were due to a bug in the codeform I uploaded . . . I've re-uploaded it again, having done the following changes last night (it was a late night...):
Valgrind now reports no memory leaks for codeform! Even for rules/c_1_css. But it does report "invalid read"s, whatever that is. (Enlighten me?) I will indeed re-create the winapi file and test it this time (I'm on the right computer). I'll report back in a few minutes.
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
||
dwks is online now
|
|
03-24-2007, 01:06 PM
|
#12 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Okay, download the latest version; rules/winapi is included in it. I tested it with this command line and it worked:
Code:
C:\>codeform -f rules\_html -f rules\c_1ext -f rules\winapi rules\winapi ![]() [edit] For nicer colours try Code:
C:\>codeform -f rules\_html -f rules\c_1 -f rules\winapi rules\winapi Code:
=keyword keyworddarkb= keyworddarka= AbnormalTermination:$(keyworddarkb):$(keyworddarka) AbortDoc:*:* AbortPath:*:* AbortPrinter:*:* AbortProc:*:* ABORTPROC:*:* AbortSystemShutdown:*:* accept:*:* AcceptEx:*:* AccessNtmsLibraryDoor:*:* ACMDRIVERENUMCB:*:* ACMDRIVERPROC:*:* ACMFILTERCHOOSEHOOKPROC:*:* ACMFILTERENUMCB:*:* ACMFILTERTAGENUMCB:*:* ACMFORMATCHOOSEHOOKPROC:*:* ACMFORMATENUMCB:*:* ACMFORMATTAGENUMCB:*:* ...etc... The executable included in the .ZIP is not compiled with my normal compiler but it should still work. The linux executable included is ancient. If you're using linux just compile it yourself. Type "make clean" and then "make". ![]()
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! Last edited by dwks : 03-24-2007 at 01:09 PM. |
dwks is online now
|
|
03-24-2007, 02:16 PM
|
#13 | |
|
Registered User
Join Date: Dec 2002
Posts: 295
|
Quote:
was looking over your changes....good to know. i do not have linux. the winapi file is large and i hope it will add to the progs popularity. it has helped fix a few progs already. if i had realized you were going to run it through a prog to make the rule file i would have plucked cleaned stuffed and baked the file in the first place. thank you. |
|
kryptkat is offline
|
|
03-24-2007, 03:05 PM
|
#14 | |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
I used another Perl program that basically takes codeform.c and copies it 100 times into another file. Here are the results:
Code:
timeit: 14285 ms
Volume in drive [edited]
Volume Serial Number is [edited]
Directory of [edited]
24/03/2007 03:59 PM 7,098,100 bigfile
24/03/2007 03:59 PM 20,343,374 bigfile.htm
2 File(s) 27,441,474 bytes
0 Dir(s) 56,410,112 bytes free
A 7MB file was processed in 14.3 seconds (admittedly, it was in the background but this is a really fast computer).Quote:
All I did was write a program to parse it and tested and uploaded it . . . you did all of the work.Sorry that the change list is not very legible. I wrote it as I was coding and never intended to put it on the internet or anything.
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
|
dwks is online now
|
|
03-31-2007, 03:29 AM
|
#15 |
|
What's a "pointer"?
Join Date: Mar 2007
Location: Allocated on the heap.
Posts: 215
|
DWKS, perhaps look into the <pre></pre> tags and keep tabs?, Rather than converting them to spaces...?
Think about it, its an extra 3 bytes per tab... It all adds up. Not to mention it makes the highlighted source easier to "cut & paste" while keeping its original formatting. Anywho just thought i'd comment. |
zacs7 is offline
|
|
03-31-2007, 01:09 PM
|
#16 | |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Quote:
The HTML output format does indeed use <pre></pre> tags. (See the files rules/_html.) If you wanted to have tabs converted to spaces or vice versa you could either do it yourself with a separate program -- it's quite easy; I think I have at least five programs that do it -- or create rules that look like this: Code:
=keyword <tab>::<space><space><space><space>:# converts tabs to spaces <space><space><space><space>:<tab>:# converts spaces to tabs Comments are much appreciated. ![]()
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
|
dwks is online now
|
|
03-31-2007, 04:13 PM
|
#17 |
|
What's a "pointer"?
Join Date: Mar 2007
Location: Allocated on the heap.
Posts: 215
|
You should make a CGI version to perhaps?
![]()
__________________
Ubuntu 6.10 GCC 4.1.1 Linux vs Vista Kernel I made $20 today just by watering this guy's lawn in speedos. |
zacs7 is offline
|
|
03-31-2007, 04:58 PM
|
#18 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Guess what? I was doing just that. If you'd signed up before the board crashed,
I could link you to the thread, but alas it is gone. I wrote a Perl
script which ran codeform on the remote server. It worked perfectly,
but codeform was running as a priviledged user, opening up tons of
security holes. Unfortunately there doesn't seem to be a user called nobody on that server. So I guess I could host codeform version 1.2.0 online, as it is called, but would it be a good idea? . . . .
My only idea was to restrict the input file to, say, 32KB, to reduce the risk of buffer overruns. Codeform, as I mentioned, does not have any memory leaks when run through Valgrind, but it does have lots of "Invalid read"s. I don't know what those are but I'm guessing they're related to buffer overruns. Once I fix those I think I will host codeform online. We'll see. If you have a server that will run Perl scripts that can execute other programs which may or may not have buffer overruns, let me know. ![]()
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
dwks is online now
|
|
03-31-2007, 05:14 PM
|
#19 |
|
What's a "pointer"?
Join Date: Mar 2007
Location: Allocated on the heap.
Posts: 215
|
I did sign-up before the board crashed
I lost my account...Anywho, as you mentioned in the other thread perhaps link to standard-c functions ? And maybe something for the future: use anchors for user declared functions so you can 'skip' to their declarations, eg Code:
<pre>
void Foo(void);
int main(void)
{
<a href="#foo">Foo</a>();
return 0;
}
<a name="foo"></a>
void Foo(void)
{
return;
}
</pre>
, specially not one with, DuN-DUN-DUN PERL!:P
__________________
Ubuntu 6.10 GCC 4.1.1 Linux vs Vista Kernel I made $20 today just by watering this guy's lawn in speedos. Last edited by zacs7 : 03-31-2007 at 05:18 PM. |
zacs7 is offline
|
|
03-31-2007, 05:23 PM
|
#20 | ||||
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Quote:
Quote:
Code:
linkfuncbb=[url= linkfuncba=] linkfunca=[/url] linkfuncurl=http://www.opengroup.org/pubs/online/7908799/xsh/ =keyword atoi:$(linkfuncbb)$(linkfuncurl)atoi$(linkfuncba):$(linkfunca) printf:$(linkfuncbb)$(linkfuncurl)printf$(linkfuncba):$(linkfunca) ) I still need to find a list of C functions, though. (Feel free to find one. :P) It's used like so:Code:
$ codeform -f rules/c_1_vbb -f rules/clinkfunc Quote:
Quote:
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
||||
dwks is online now
|
|
03-31-2007, 05:33 PM
|
#21 |
|
What's a "pointer"?
Join Date: Mar 2007
Location: Allocated on the heap.
Posts: 215
|
I created a IRC bot a while ago, in the process I made a list of most of the standard C functions....
See the attachment, I know it doesn't contain URLS, but its a start - and it does explain what each does. Perhaps you could add tooltips for the standard funcs instead (so it doesn't rely on the internet)
__________________
Ubuntu 6.10 GCC 4.1.1 Linux vs Vista Kernel I made $20 today just by watering this guy's lawn in speedos. |
zacs7 is offline
|
|
03-31-2007, 05:44 PM
|
#22 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Thanks
for the list. I'll transform it into some codeform files as soon as I
can (probably by tomorrow night). One to turn "printf" into
Code:
$(clinkfuncbb)$(clinkfuncurl)printf$(clinkfuncba)printf$(clinkfunca) Code:
[url=http://www.opengroup.org/pubs/online/7908799/xsh/printf]printf[/url] Code:
<a alt="printf(f, ...) is equivalent to fprintf(stdout, f, ...)">printf</a> ![]()
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
dwks is online now
|
|
04-01-2007, 04:13 AM
|
#23 |
|
What's a "pointer"?
Join Date: Mar 2007
Location: Allocated on the heap.
Posts: 215
|
yes well :P, I didn't write the descriptions they're from the web...
![]()
__________________
Ubuntu 6.10 GCC 4.1.1 Linux vs Vista Kernel I made $20 today just by watering this guy's lawn in speedos. |
zacs7 is offline
|
|
04-02-2007, 12:01 PM
|
#24 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Sorry,
I haven't finished the clinkfunc rules (as they are to be called) yet.
My estimates are always off . . . six months before I first released
codeform I said "codeform should be finished within two weeks or maybe
three."
I have implemented doubling-the-allocated-memory-size. It hasn't been uploaded yet though. (It's a simple two line change to get_string().) I have attached the latest version of codeform online's Perl script in case anyone's interested. [edit] I attached the wrong file. I'm also attaching the Perl script now. [/edit]
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! Last edited by dwks : 04-02-2007 at 02:56 PM. |
dwks is online now
|
|
04-02-2007, 12:38 PM
|
#25 |
|
Crazy Fool
Join Date: Jan 2003
Location: Canada
Posts: 2,207
|
how about linking standard (or common lib) functions to online definitions (like online man pages or something).
__________________
jeff.bagu.org - Terrain rendering and other random stuff |
Perspective is offline
|
|
04-02-2007, 01:53 PM
|
#26 |
|
Registered User
Join Date: Dec 2002
Posts: 295
|
note. i did put math.h functions names in winapi list. they are included just the names.
note 2. if anyone wants dx9 list. i may start on it sometime. |
kryptkat is offline
|
|
04-02-2007, 02:52 PM
|
#27 | ||
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
Quote:
Quote:
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
||
dwks is online now
|
|
04-02-2007, 05:02 PM
|
#28 |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
I've decided to risk it and host codeform version 1.2.0 online. Perhaps it should have a new thread -- but too late now.
![]() Codeform version 1.2.0 online: http://dwks.theprogrammingsite.com/m...e/cfonline.htm Tell me how you like it. If you find any bugs please let me know. Just as before, input files are limited to 32KB in size. The Windows API rules are also supported (only for style 1). I may not keep codeform online up and running forever, but if I stop hosting it I'll let everyone know here. [edit] The Perl script is attached, with .txt added. [/edit]
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! |
dwks is online now
|
|
04-02-2007, 05:37 PM
|
#29 |
|
Perfect Gentleman
Join Date: Apr 2006
Location: MI
Posts: 1,256
|
> If you find any bugs please let me know.
The browser will parse #include <header> as #include, and template stuff will also act up, which is wrong. At least let your users knw this is the case to avoid a surprise. Other than that, you've done a nifty job so far. |
citizen is online now
|
|
04-03-2007, 11:46 AM
|
#30 | |
|
DWK
Join Date: Apr 2005
Location: Canada
Posts: 4,239
|
What do you mean?
Code:
#include <stdio.h> template <typename t> Code:
#include <stdio.h> Code:
=keyword #include:[color=green]:[/color] #define:...etc... Quote:
![]()
__________________
dwk Seek and ye shall find. quaere et invenies. (Latin by dwks.) "Only those who will risk going too far can possibly find out how far one can go." -- TS Eliot "I have not failed. I've just found 10,000 ways that won't work." -- Thomas Alva Edison "The only real mistake is the one from which we learn nothing." -- John Powell My website: http://dwks.theprogrammingsite.com/ Other programming boards: codeform version 1.2.0 is here! Last edited by dwks : 04-03-2007 at 12:16 PM. |
|
dwks is online now
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|