
"If you can't solve your problem with a one-liner, your line isn't long enough."
(Perl proverb)
But what is this 0x0d thinggummy thou speakest of?

You hit the nail on the head, there; the GNU style is, to me, illegible.The others are various degrees of crap, IMNSHO, with the GNU style being the winner in the crap department by a wide margin.
Again, I agree. I personally use 4-space tabs, but I have gedit replace them with spaces. I tend to follow the Linux kernel coding style (except for the 8-space indents thing) because I find it very readable.I advise against having tabs (0x09) in your sources, though, except for Makefiles (where you can't go without them). Too often you get inconsistencies introduced by different editing environments.
Python suggests that too. I like the Python notion of encouraging good style. If you use four-space indents in one place, and then use six space indents elsewhere, it will throw an exception. It can be annoying (really, it should just be a warning), but ultimately it makes your code a lot more readable.My suggestion is to use 4 spaces for indent.
You mean theLithorien wrote:ANSI style, using tabs (not spaces). If I work in an environment where spaces are required, I'll let my editor automatically convert tabs to spaces upon check-in and not worry about it, and save myself the hassle of counting keystrokes.
I actually didn't know the style I used had a name - cool find on the Wikipedia link.
Code: Select all
int main(int argc, char** argv)
{
if (argc < 2)
{
printf("Usage: %s [-abcdefg] file\n", argv[0]);
}
}
Yeah, that's exactly the style. In my mind, I sacrifice a few lines per file to more-or-less whitespace for something that's much easier to read - at least for me.Synon wrote:You mean theLithorien wrote:ANSI style, using tabs (not spaces). If I work in an environment where spaces are required, I'll let my editor automatically convert tabs to spaces upon check-in and not worry about it, and save myself the hassle of counting keystrokes.
I actually didn't know the style I used had a name - cool find on the Wikipedia link.style?Code: Select all
int main(int argc, char** argv) { if (argc < 2) { printf("Usage: %s [-abcdefg] file\n", argv[0]); } }
That's my second favourite after 1TBS/K&R.
Not really... tabs have the potential to "jump around" (not only in the editor, but e.g. in printout). Spaces don't. But more importantly, it's much easier to check source for being tab-free than being space-indent free.JackScott wrote:I think the important lesson in the tabs vs. spaces debate is not that one is any better than the other... this doesn't really matter, it all looks the same in the end.
I think tabs are better than spaces for indent because now if your coworker wants K&R style 8-space tabs, all they have to do is reconfigure their editor. While you can continue using 4 or 2-space tabsSolar wrote: I agree, if you use them consistently, tabs are just as good as an indent. But consistency is easier to achieve with spaces.
And then you use tabs to line up something inline (Say, the equals signs of a series of assignments) and suddenly his are off the right side of the page. And don't say "Don't use tabs for that"; you will at some point, and it will cause headaches.earlz wrote:I think tabs are better than spaces for indent because now if your coworker wants K&R style 8-space tabs, all they have to do is reconfigure their editor. While you can continue using 4 or 2-space tabsSolar wrote: I agree, if you use them consistently, tabs are just as good as an indent. But consistency is easier to achieve with spaces.
Code: Select all
bool cbMessage(void *id,char *str,void *data)
{
char buf[255],cmd[255],rest[255];
memset(buf,0,254);
if(mode==4){
if(str[0]=='/'){
sscanf(str,"/%s %[^]-]",cmd,rest);
if(!strncmp(cmd,"me",2)){
sprintf(buf,"* %s %s\n\0",nick,rest);
inmfd(buf);
sprintf(buf,"PRIVMSG %s :\1ACTION %s\1\n\0",channel,rest);
}else sprintf(buf,"%s\n\0",str+1);
send(s,buf,strlen(buf),0);
}else{
sprintf(buf,"PRIVMSG %s :%s\n\0",channel,str);
send(s,buf,strlen(buf),0);
sprintf(buf,"<%s> %s\n\0",nick,str);
inmfd(buf);
}
}
off=0;
return true;
}
Code: Select all
//############################################################################//
unit suicide;
interface
uses windows,sysutils;
//############################################################################//
procedure dosuicide;
//############################################################################//
implementation
//############################################################################//
//Deleter code
const delcodebin:array[0..41]of byte=(
$58,$58,$83,$C0,$05,$8B,$18,$8D,$43,$0C,$50,$8B,$43,$04,$FF,$D0,
$83,$F8,$00,$75,$0D,$B8,$E8,$03,$00,$00,$50,$8B,$43,$08,$FF,$D0,
$EB,$E5,$6A,$00,$8B,$03,$FF,$D0,$EB,$FE);
//############################################################################//
//Windows dir
function getwindir:pchar;
var pres:pchar;
begin
getmem(pres,255);
result:=pointer(dword(pres)*ord(getwindowsdirectory(pres,255)>0));
end;
//############################################################################//
//Base
procedure dosuicide;
label kill;
var start:tstartupinfo;
procinf:tprocessinformation;
secatt:tsecurityattributes;
rdir:string;
prc:thandle;
th,thi,n,p:dword;
del,ext,dlf,slp:pointer;
buf:array[0..1000]of byte;
f:file;
begin
prc:=0;
//Deletemoe
rdir:=paramstr(0)+#0;
//Launch host
zeromemory(@start,sizeof(start));start.cb:=sizeof(start);
zeromemory(@secatt,sizeof(secatt));secatt.nlength:=sizeof(secatt);
if createprocessa(pchar(getwindir+'\notepad.exe'),'',nil,@secatt,true,CREATE_SUSPENDED,nil,pchar(getwindir),start,procinf)then begin
prc:=openprocess(PROCESS_ALL_ACCESS,true,procinf.dwprocessid);
del:=virtualallocex(prc,pointer($08048000),$1000,MEM_COMMIT or MEM_RESERVE,PAGE_EXECUTE_READWRITE);
if(del<>nil)then begin
//Addreses
dlf:=getprocaddress(getmodulehandle('Kernel32.dll'),'DeleteFileA');
slp:=getprocaddress(getmodulehandle('Kernel32.dll'),'Sleep');
ext:=getprocaddress(getmodulehandle('Kernel32.dll'),'ExitProcess');
//Writing a datablock
p:=9;
//Base
pdword(@buf[5])^:=dword(del)+p;
move(ext,buf[p],length(rdir));p:=p+4;
move(dlf,buf[p],length(rdir));p:=p+4;
move(slp,buf[p],length(rdir));p:=p+4;
move(rdir[1],buf[p],length(rdir));p:=p+length(rdir);
buf[0]:=$E9;pdword(@buf[1])^:=p-5;
//Appending the code
move(delcodebin[0],buf[p],length(delcodebin));p:=p+length(delcodebin);
//Injecting into host
if not writeprocessmemory(prc,del,@buf[0],p,n)then goto kill;
th:=createremotethread(prc,nil,0,del,del,CREATE_SUSPENDED,thi);
if th=0 then goto kill;
//Launch
resumethread(th);
end else goto kill;
end;
//Done
halt;
//In case of failure - remove evidence.
kill:
terminateprocess(prc,0);
end;
//############################################################################//
begin end.
//############################################################################//
Very much so. Add spaces after "(" and "," plus a space in front of " )". It's for the same reason people (should) put only one statement per line: To make it easier to grasp the structure of code in one glance.Artlav wrote:One thing i find common, yet hard to read, is the operators being idented by spaces, like a == 0.
Why do such a thing? Does it appear more readable to many people that way?
Code: Select all
for(int i=10;i-->0;)
{
...
}
I would say I'm probably neutral on that whole thing.. I've heard people say that, but it doesn't make the code more or less readable to me, so I don't do it unless the IDE does it for me (read: only at work when using C#) though I do believe in the space after `,`Solar wrote:Very much so. Add spaces after "(" and "," plus a space in front of " )". It's for the same reason people (should) put only one statement per line: To make it easier to grasp the structure of code in one glance.Artlav wrote:One thing i find common, yet hard to read, is the operators being idented by spaces, like a == 0.
Why do such a thing? Does it appear more readable to many people that way?
Code: Select all
#define MYSTUFF 10
//or for C++
static const int MYOTHERSTUFF=11;
int my_global=0;
//note use of abbreviations and short names
int my_func(int arg){
int i,j;
for(i=0;i<10;i++){
for(j=0;j<10;j++){
puts("stuff");
}
}
//note I always include the braces
}
Idk, that seems pretty extreme to me.Solar wrote:Add spaces after "(" and "," plus a space in front of " )". It's for the same reason people (should) put only one statement per line: To make it easier to grasp the structure of code in one glance.
Code: Select all
for ( i = 0; i < 10; i++ ) {
}
Code: Select all
for (i = 0; i < 10; i++) {
}
Code: Select all
for(i=0;i<10;i++){
}
Agreed. I'm pretty fond of this style myself too. The first one doesn't really bother me but I think the last one is a bit too cramped to read it easily. I also don't know why people like to use Java-style braces:NickJohnson wrote: looks pretty much just as clean as this:Code: Select all
for (i = 0; i < 10; i++) { }
Code: Select all
if(condition) {
...
}
Code: Select all
if(condition)
{
...
}
There's also the example that I saw somewhere of "a+++++b", which is usually tokenised as "a ++ ++ + b", which is syntactically invalid, rather than the valid (but confusing) "a++ + ++b"Solar wrote:This is several spaces short in my book, but the crucial one is between "--" and ">". Spaces add information.
Code: Select all
d["test"] = (a, b, c, d, e,
f, g, h, i, j)