Re: [Opengl3dwm-devel] Spacing and indentation ISSUES!
Status: Pre-Alpha
Brought to you by:
zarnick
|
From: <bul...@gm...> - 2006-04-12 18:25:42
|
erm, is it just me or is that not K&R?
I thought else statements were like this:
}else{
and not like
}else
{
anyways, doesn't matter I hate it:)
On Wednesday 12 April 2006 07:46, Alon Dakik wrote:
> Okay, You guys need to put line spaces between statements. I found
> several obvious bugs that you guys missed.
>
> Here is an exact copy of 2 sections in the code from main.c
>
>
>
> Your code:
>
> for(i=0;i<10;i++){
> Cubes[i].type = i;
> Cubes[i].size = i*100;
> Cubes[i].posx = 2+i;
> Cubes[i].posy = 0.0;
> Cubes[i].posz = i%3;
> Cubes[i].blend = TRUE;
> if(i%2==0){
> Cubes[i].roty = 1;
> Cubes[i].ang = ang;
> }
> else
> Cubes[i].blend=FALSE;
> Cubes[i].selected=FALSE;
> Cubes[i].id=i;
> }
> //Let's start the SDL
> mode = SDL_OPENGL|SDL_HWPALETTE;
> if(config.fscreen == TRUE)
> mode |= SDL_FULLSCREEN;
> FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
> if(FMSystem_initSDL(mode,config)!=SUCESS){
> FMError_perror("FMSystem");
> exit(errno);
> }
>
>
>
>
> Here is what I think the above code should look like. Notice you
> missed brackets on the else statement.
>
>
> for (i=0; i<10; i++ ){
> Cubes[i].type = i;
> Cubes[i].size = i*100;
> Cubes[i].posx = 2+i;
> Cubes[i].posy = 0.0;
> Cubes[i].posz = i%3;
> Cubes[i].blend = TRUE;
>
> if ( i%2 == 0 ){
> Cubes[i].roty = 1;
> Cubes[i].ang = ang;
> }
> else {
> Cubes[i].blend=FALSE;
> Cubes[i].selected=FALSE;
> Cubes[i].id=i;
> }
>
> }
>
> //Let's start the SDL
> mode = SDL_OPENGL|SDL_HWPALETTE;
>
> if(config.fscreen == TRUE)
> mode |= SDL_FULLSCREEN;
>
> FMLog_log("[I] Starting SDL.\n",LOGVERBOSE);
>
> if(FMSystem_initSDL(mode,config)!=SUCESS){
> FMError_perror("FMSystem");
> exit(errno);
> }
>
>
>
> See how much cleaner that is? and how you missed { } on the else
> statement? You should write code just like you write your own
> language. With
> spaces and line breaks to make it more readable and easier to find bugs.
>
> Another example..
>
> Your code...
>
> while(SDL_PollEvent(&event)){
> if(event.type==SDL_QUIT)
> done = TRUE;
> if(event.type==SDL_KEYDOWN){
> if(event.key.keysym.sym==SDLK_ESCAPE)
> done = TRUE;
> }
> }
>
> Spaced out code:
>
>
> while ( SDL_PollEvent(&event) ) {
>
> if( event.type==SDL_QUIT )
> done = TRUE;
>
> if ( event.type==SDL_KEYDOWN ) {
> if ( event.key.keysym.sym == SDLK_ESCAPE )
> done = TRUE;
> }
> }
>
>
>
> That is a whole lot more readable than what is currently in main.c.
>
> I'm just trying to add functionality for someone to type in a
> directory and use my FMDir lib... but right now I have to clean up
> code :/
|