Comment Filterer

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mr. xsism

Comment Filterer

Post by mr. xsism »

hey, i was bored yesterday and coded this in about 2 hours. Hope you guys find it useful. Tell me what you think? it is ment for single char '\n' terminated comments. So it won't really work for C but it works great with asm and sql code.

<a href="http://www.osdever.net/temp/xsism/remove.zip" target="newwin">Get it here.</a>

i hope this board allows html ;)
carbonBased

RE:Comment Filterer

Post by carbonBased »

Why would you want to _remove_ comments?  (I'm simply guessing by the .zip name... I'm at work, and can't download the actual app...)

Unless you're stealing/borrowing/using someone elses code constantly and don't want anyone to know...?

Cheers,
Jeff
mr. xsism

RE:Comment Filterer

Post by mr. xsism »

oh yeah, that's it, i was stealing some code from like 20 diff people, and they all had different comment methods :P

no

kj and i were actually backing up our mysql DB and there was a problem importing it to a diff version mysql so we had to take out a ton o '#' comments but there was too many. So i made this thing real fast used it and added some functionality after the basic idea worked.

It may come in handy for cutting down on src size if you want a clean, commentless tree? I'm sure there are plenty of uses. Besides, ocde is easier to read when it isn't litered with comments.

mr. xsism
carbonBased

RE:Comment Filterer

Post by carbonBased »

Fair enough :)  I've actually had similar issues with my web server not liking mysqldump's -- comments.  However, this is where awk really comes in handy, though...

/^--/ { skip=1}
{
  if(skip == 0) print $0;
  skip = 0
}

That's what I use to remove 'em :)  If you're using a unix system, you should check it out... you can do some pretty trippy stuff in even less time...

Cheers,
Jeff
mr. xsism

RE:Comment Filterer

Post by mr. xsism »

kool, when i'm in linux next time i'll check it out. I use linux occasionally :)

mr. xsism :D
Post Reply