Numerous style normalizations from John:

* Convert "return( value );" to "return value;"
 * Normalize spacing around semicolons.
 * Remove extraneous parens.
 * Split multi-statement lines into multiple lines.  (Mostly things
   of the form: "if( condition ) return;".)


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@361 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
rkrolib 2003-11-21 21:15:58 +00:00
parent 7e7ff3191d
commit 354569a7c4
11 changed files with 406 additions and 402 deletions

View File

@ -62,18 +62,21 @@ extern SFG_StrokeFont fgStrokeMonoRoman;
*/
static SFG_Font* fghFontByID( void* font )
{
/*
* XXX Use a macro, a table of some kind, or else split these
* XXX statements properly. Jamming "return" on the end of an
* XXX "if" is just bad style, IMHO.
*/
if( font == GLUT_BITMAP_8_BY_13 ) return &fgFontFixed8x13;
if( font == GLUT_BITMAP_9_BY_15 ) return &fgFontFixed9x15;
if( font == GLUT_BITMAP_HELVETICA_10 ) return &fgFontHelvetica10;
if( font == GLUT_BITMAP_HELVETICA_12 ) return &fgFontHelvetica12;
if( font == GLUT_BITMAP_HELVETICA_18 ) return &fgFontHelvetica18;
if( font == GLUT_BITMAP_TIMES_ROMAN_10 ) return &fgFontTimesRoman10;
if( font == GLUT_BITMAP_TIMES_ROMAN_24 ) return &fgFontTimesRoman24;
if( font == GLUT_BITMAP_8_BY_13 )
return &fgFontFixed8x13;
if( font == GLUT_BITMAP_9_BY_15 )
return &fgFontFixed9x15;
if( font == GLUT_BITMAP_HELVETICA_10 )
return &fgFontHelvetica10;
if( font == GLUT_BITMAP_HELVETICA_12 )
return &fgFontHelvetica12;
if( font == GLUT_BITMAP_HELVETICA_18 )
return &fgFontHelvetica18;
if( font == GLUT_BITMAP_TIMES_ROMAN_10 )
return &fgFontTimesRoman10;
if( font == GLUT_BITMAP_TIMES_ROMAN_24 )
return &fgFontTimesRoman24;
fgError( "font 0x%08x not found", font );
return 0; /*** NOT REACHED ***/
}
@ -84,12 +87,11 @@ static SFG_Font* fghFontByID( void* font )
*/
static SFG_StrokeFont* fghStrokeByID( void* font )
{
/*
* XXX Same comment as above about jamming "return" in after an
* XXX "if".
*/
if( font == GLUT_STROKE_ROMAN ) return &fgStrokeRoman;
if( font == GLUT_STROKE_MONO_ROMAN ) return &fgStrokeMonoRoman;
if( font == GLUT_STROKE_ROMAN )
return &fgStrokeRoman;
if( font == GLUT_STROKE_MONO_ROMAN )
return &fgStrokeMonoRoman;
fgError( "stroke font 0x%08x not found", font );
return 0; /*** NOT REACHED ***/
}

View File

@ -230,7 +230,7 @@ void fgDeinitialize( void )
fgDestroyStructure( );
while( (timer = ( SFG_Timer * )fgState.Timers.First) )
while( timer = ( SFG_Timer * )fgState.Timers.First )
{
fgListRemove ( &fgState.Timers, &timer->Node );
free( timer );
@ -376,9 +376,9 @@ ReadInteger(char *string, char **NextString)
}
*NextString = string;
if (Sign >= 0)
return (Result);
return Result;
else
return (-Result);
return -Result;
}
static int XParseGeometry (
@ -394,7 +394,8 @@ static int XParseGeometry (
int tempX = 0, tempY = 0;
char *nextCharacter;
if ( (string == NULL) || (*string == '\0')) return(mask);
if ( (string == NULL) || (*string == '\0'))
return mask;
if (*string == '=')
string++; /* ignore possible '=' at beg of geometry spec */
@ -402,7 +403,7 @@ static int XParseGeometry (
if (*strind != '+' && *strind != '-' && *strind != 'x') {
tempWidth = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
return 0;
strind = nextCharacter;
mask |= WidthValue;
}
@ -411,7 +412,7 @@ static int XParseGeometry (
strind++;
tempHeight = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
return 0;
strind = nextCharacter;
mask |= HeightValue;
}
@ -421,7 +422,7 @@ static int XParseGeometry (
strind++;
tempX = -ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return (0);
return 0;
strind = nextCharacter;
mask |= XNegative;
}
@ -430,7 +431,7 @@ static int XParseGeometry (
strind++;
tempX = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
return 0;
strind = nextCharacter;
}
mask |= XValue;
@ -439,7 +440,7 @@ static int XParseGeometry (
strind++;
tempY = -ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
return 0;
strind = nextCharacter;
mask |= YNegative;
}
@ -448,7 +449,7 @@ static int XParseGeometry (
strind++;
tempY = ReadInteger(strind, &nextCharacter);
if (strind == nextCharacter)
return(0);
return 0;
strind = nextCharacter;
}
mask |= YValue;
@ -458,7 +459,7 @@ static int XParseGeometry (
/* If strind isn't at the end of the string the it's an invalid
geometry specification. */
if (*strind != '\0') return (0);
if (*strind != '\0') return 0;
if (mask & XValue)
*x = tempX;
@ -468,7 +469,7 @@ static int XParseGeometry (
*width = tempWidth;
if (mask & HeightValue)
*height = tempHeight;
return (mask);
return mask;
}
#endif

View File

@ -132,10 +132,10 @@ int FGAPIENTRY glutGet( GLenum eWhat )
switch (eWhat)
{
case GLUT_INIT_STATE:
return ( fgState.Initialised ) ;
return fgState.Initialised;
case GLUT_ELAPSED_TIME:
return( fgElapsedTime() );
return fgElapsedTime();
}
freeglut_assert_ready;
@ -148,15 +148,15 @@ int FGAPIENTRY glutGet( GLenum eWhat )
/*
* Following values are stored in fgState and fgDisplay global structures
*/
case GLUT_SCREEN_WIDTH: return( fgDisplay.ScreenWidth );
case GLUT_SCREEN_HEIGHT: return( fgDisplay.ScreenHeight );
case GLUT_SCREEN_WIDTH_MM: return( fgDisplay.ScreenWidthMM );
case GLUT_SCREEN_HEIGHT_MM: return( fgDisplay.ScreenHeightMM );
case GLUT_INIT_WINDOW_X: return( fgState.Position.X );
case GLUT_INIT_WINDOW_Y: return( fgState.Position.Y );
case GLUT_INIT_WINDOW_WIDTH: return( fgState.Size.X );
case GLUT_INIT_WINDOW_HEIGHT: return( fgState.Size.Y );
case GLUT_INIT_DISPLAY_MODE: return( fgState.DisplayMode );
case GLUT_SCREEN_WIDTH: return fgDisplay.ScreenWidth ;
case GLUT_SCREEN_HEIGHT: return fgDisplay.ScreenHeight ;
case GLUT_SCREEN_WIDTH_MM: return fgDisplay.ScreenWidthMM ;
case GLUT_SCREEN_HEIGHT_MM: return fgDisplay.ScreenHeightMM;
case GLUT_INIT_WINDOW_X: return fgState.Position.X ;
case GLUT_INIT_WINDOW_Y: return fgState.Position.Y ;
case GLUT_INIT_WINDOW_WIDTH: return fgState.Size.X ;
case GLUT_INIT_WINDOW_HEIGHT: return fgState.Size.Y ;
case GLUT_INIT_DISPLAY_MODE: return fgState.DisplayMode ;
/*
* The window/context specific queries are handled mostly by
@ -166,14 +166,14 @@ int FGAPIENTRY glutGet( GLenum eWhat )
/*
* XXX Multisampling. Return what I know about multisampling.
*/
return( 0 );
return 0;
#if TARGET_HOST_UNIX_X11
/*
* The rest of GLX queries under X are general enough to use a macro to
* check them
*/
# define GLX_QUERY(a,b) case a: return( fghGetConfig( b ) );
# define GLX_QUERY(a,b) case a: return fghGetConfig( b );
GLX_QUERY( GLUT_WINDOW_RGBA, GLX_RGBA );
GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER, GLX_DOUBLEBUFFER );
@ -202,9 +202,9 @@ int FGAPIENTRY glutGet( GLenum eWhat )
* We've got a RGBA visual, so there is no colormap at all.
* The other possibility is that we have no current window set.
*/
return( 0 );
return 0;
}
return( fgStructure.Window->Window.VisualInfo->visual->map_entries );
return fgStructure.Window->Window.VisualInfo->visual->map_entries;
/*
* Those calls are somewhat similiar, as they use XGetWindowAttributes()
@ -219,7 +219,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
Window w;
if( fgStructure.Window == NULL )
return( 0 );
return 0;
XTranslateCoordinates(
fgDisplay.Display,
@ -234,7 +234,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
}
if ( w == 0 )
return( 0 );
return 0;
XTranslateCoordinates(
fgDisplay.Display,
fgStructure.Window->Window.Handle,
@ -253,7 +253,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
XWindowAttributes winAttributes;
if( fgStructure.Window == NULL )
return( 0 );
return 0;
XGetWindowAttributes(
fgDisplay.Display,
fgStructure.Window->Window.Handle,
@ -277,9 +277,9 @@ int FGAPIENTRY glutGet( GLenum eWhat )
*/
case GLUT_WINDOW_FORMAT_ID:
if( fgStructure.Window == NULL )
return( 0 );
return 0;
return( fgStructure.Window->Window.VisualInfo->visualid );
return fgStructure.Window->Window.VisualInfo->visualid;
#elif TARGET_HOST_WIN32
@ -289,50 +289,50 @@ int FGAPIENTRY glutGet( GLenum eWhat )
case GLUT_WINDOW_RGBA:
glGetBooleanv ( GL_RGBA_MODE, &boolValue );
returnValue = boolValue ? 1 : 0;
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_DOUBLEBUFFER:
glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue );
returnValue = boolValue ? 1 : 0;
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_STEREO:
glGetBooleanv ( GL_STEREO, &boolValue );
returnValue = boolValue ? 1 : 0;
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_RED_SIZE:
glGetIntegerv ( GL_RED_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_GREEN_SIZE:
glGetIntegerv ( GL_GREEN_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_BLUE_SIZE:
glGetIntegerv ( GL_BLUE_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_ALPHA_SIZE:
glGetIntegerv ( GL_ALPHA_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_ACCUM_RED_SIZE:
glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_ACCUM_GREEN_SIZE:
glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_ACCUM_BLUE_SIZE:
glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_DEPTH_SIZE:
glGetIntegerv ( GL_DEPTH_BITS, &returnValue );
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_BUFFER_SIZE:
returnValue = 1 ; /* ????? */
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_STENCIL_SIZE:
returnValue = 0 ; /* ????? */
return ( returnValue ) ;
return returnValue;
case GLUT_WINDOW_X:
case GLUT_WINDOW_Y:
@ -387,28 +387,28 @@ int FGAPIENTRY glutGet( GLenum eWhat )
switch( eWhat )
{
case GLUT_WINDOW_X: return( winRect.left );
case GLUT_WINDOW_Y: return( winRect.top );
case GLUT_WINDOW_WIDTH: return( winRect.right - winRect.left );
case GLUT_WINDOW_HEIGHT: return( winRect.bottom - winRect.top );
case GLUT_WINDOW_X: return winRect.left ;
case GLUT_WINDOW_Y: return winRect.top ;
case GLUT_WINDOW_WIDTH: return winRect.right - winRect.left;
case GLUT_WINDOW_HEIGHT: return winRect.bottom - winRect.top;
}
}
break;
case GLUT_WINDOW_BORDER_WIDTH :
return ( GetSystemMetrics( SM_CXSIZEFRAME ) ) ;
return GetSystemMetrics( SM_CXSIZEFRAME );
case GLUT_WINDOW_HEADER_HEIGHT :
return ( GetSystemMetrics( SM_CYCAPTION ) ) ;
return GetSystemMetrics( SM_CYCAPTION );
case GLUT_DISPLAY_MODE_POSSIBLE:
return( fgSetupPixelFormat( fgStructure.Window, GL_TRUE,
PFD_MAIN_PLANE ) );
return fgSetupPixelFormat( fgStructure.Window, GL_TRUE,
PFD_MAIN_PLANE );
case GLUT_WINDOW_FORMAT_ID:
if( fgStructure.Window != NULL )
return( GetPixelFormat( fgStructure.Window->Window.Device ) );
return( 0 );
return GetPixelFormat( fgStructure.Window->Window.Device );
return 0;
#endif
@ -416,24 +416,24 @@ int FGAPIENTRY glutGet( GLenum eWhat )
* The window structure queries
*/
case GLUT_WINDOW_PARENT:
if( fgStructure.Window == NULL ) return( 0 );
if( fgStructure.Window->Parent == NULL ) return( 0 );
return( fgStructure.Window->Parent->ID );
if( fgStructure.Window == NULL ) return 0;
if( fgStructure.Window->Parent == NULL ) return 0;
return fgStructure.Window->Parent->ID;
case GLUT_WINDOW_NUM_CHILDREN:
if( fgStructure.Window == NULL )
return( 0 );
return( fgListLength( &fgStructure.Window->Children ) );
return 0;
return fgListLength( &fgStructure.Window->Children );
case GLUT_WINDOW_CURSOR:
if( fgStructure.Window == NULL )
return( 0 );
return( fgStructure.Window->State.Cursor );
return 0;
return fgStructure.Window->State.Cursor;
case GLUT_MENU_NUM_ITEMS:
if( fgStructure.Menu == NULL )
return( 0 );
return( fgListLength( &fgStructure.Menu->Entries ) );
return 0;
return fgListLength( &fgStructure.Menu->Entries );
case GLUT_ACTION_ON_WINDOW_CLOSE:
return fgState.ActionOnWindowClose;
@ -442,13 +442,14 @@ int FGAPIENTRY glutGet( GLenum eWhat )
return VERSION_MAJOR * 10000 + VERSION_MINOR * 100 + VERSION_PATCH;
case GLUT_RENDERING_CONTEXT:
return ( fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT : GLUT_CREATE_NEW_CONTEXT ) ;
return fgState.UseCurrentContext ? GLUT_USE_CURRENT_CONTEXT
: GLUT_CREATE_NEW_CONTEXT;
default:
fgWarning( "glutGet(): missing enum handle %i\n", eWhat );
break;
}
return( -1 );
return -1;
}
/*
@ -473,12 +474,12 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
* XXX Though in actuality, we can probably assume BOTH a
* XXX mouse and keyboard for most/all of our users.
*/
return( TRUE );
return TRUE ;
#if TARGET_HOST_UNIX_X11
case GLUT_HAS_MOUSE:
return( TRUE );
return TRUE ;
case GLUT_NUM_MOUSE_BUTTONS:
/*
@ -500,7 +501,7 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
* XXX XFree86...) It is at least worth taking a look at
* XXX this file.
*/
return( 3 );
return 3 ;
#elif TARGET_HOST_WIN32
@ -509,13 +510,13 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
* The Windows can be booted without a mouse.
* It would be nice to have this reported.
*/
return( GetSystemMetrics( SM_MOUSEPRESENT ) );
return GetSystemMetrics( SM_MOUSEPRESENT );
case GLUT_NUM_MOUSE_BUTTONS:
/*
* We are much more fortunate under Win32 about this...
*/
return( GetSystemMetrics( SM_CMOUSEBUTTONS ) );
return GetSystemMetrics( SM_CMOUSEBUTTONS );
#endif
@ -526,27 +527,27 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
/*
* XXX WARNING: THIS IS A BIG LIE!
*/
return( 0 );
return 0;
case GLUT_HAS_SPACEBALL:
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
case GLUT_HAS_TABLET:
return( FALSE );
return FALSE;
case GLUT_NUM_SPACEBALL_BUTTONS:
case GLUT_NUM_BUTTON_BOX_BUTTONS:
case GLUT_NUM_DIALS:
case GLUT_NUM_TABLET_BUTTONS:
return( 0 );
return 0;
case GLUT_DEVICE_IGNORE_KEY_REPEAT:
return( fgState.IgnoreKeyRepeat );
return fgState.IgnoreKeyRepeat;
case GLUT_DEVICE_KEY_REPEAT:
/*
* XXX WARNING: THIS IS A BIG LIE!
*/
return( GLUT_KEY_REPEAT_DEFAULT );
return GLUT_KEY_REPEAT_DEFAULT;
default:
fgWarning( "glutDeviceGet(): missing enum handle %i\n", eWhat );
@ -556,7 +557,7 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
/*
* And now -- the failure.
*/
return( -1 );
return -1;
}
/*
@ -567,10 +568,10 @@ int FGAPIENTRY glutGetModifiers( void )
if( fgState.Modifiers == 0xffffffff )
{
fgWarning( "glutGetModifiers() called outside an input callback" );
return( 0 );
return 0;
}
return( fgState.Modifiers );
return fgState.Modifiers;
}
/*
@ -592,13 +593,13 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat )
#if TARGET_HOST_UNIX_X11
case GLUT_OVERLAY_POSSIBLE:
return( FALSE );
return FALSE;
case GLUT_LAYER_IN_USE:
return( GLUT_NORMAL );
return GLUT_NORMAL;
case GLUT_HAS_OVERLAY:
return( FALSE );
return FALSE;
case GLUT_TRANSPARENT_INDEX:
/*
@ -606,29 +607,29 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat )
*
* XXX HUH?
*/
return( 0 );
return 0;
case GLUT_NORMAL_DAMAGED:
/*
* XXX Actually I do not know. Maybe.
*/
return( FALSE );
return FALSE;
case GLUT_OVERLAY_DAMAGED:
return( -1 );
return -1;
#elif TARGET_HOST_WIN32
case GLUT_OVERLAY_POSSIBLE:
/* return( fgSetupPixelFormat( fgStructure.Window, GL_TRUE,
PFD_OVERLAY_PLANE ) ); */
/* return fgSetupPixelFormat( fgStructure.Window, GL_TRUE,
PFD_OVERLAY_PLANE ); */
return FALSE ;
case GLUT_LAYER_IN_USE:
return( GLUT_NORMAL );
return GLUT_NORMAL;
case GLUT_HAS_OVERLAY:
return( FALSE );
return FALSE;
case GLUT_TRANSPARENT_INDEX:
/*
@ -636,16 +637,16 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat )
*
* XXX HUH?
*/
return( 0 );
return 0;
case GLUT_NORMAL_DAMAGED:
/*
* XXX Actually I do not know. Maybe.
*/
return( FALSE );
return FALSE;
case GLUT_OVERLAY_DAMAGED:
return( -1 );
return -1;
#endif
default:
@ -656,7 +657,7 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat )
/*
* And fail. That's good. Programs do love failing.
*/
return( -1 );
return -1;
}
/*** END OF FILE ***/

View File

@ -279,7 +279,7 @@ void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
assert( window );
freeglut_assert_ready;
while( (subWindow = ( SFG_Window * )window->Children.First) )
while( subWindow = ( SFG_Window * )window->Children.First )
fgDestroyWindow( subWindow, needToClose );
/*
@ -402,7 +402,7 @@ void fgDestroyMenu( SFG_Menu* menu )
* Now we are pretty sure the menu is not used anywhere
* and that we can remove all of its entries
*/
while( (entry = ( SFG_MenuEntry * )menu->Entries.First) )
while( entry = ( SFG_MenuEntry * )menu->Entries.First )
{
fgListRemove( &menu->Entries, &entry->Node );
@ -457,10 +457,10 @@ void fgDestroyStructure( void )
/*
* Make sure all windows and menus have been deallocated
*/
while( (menu = ( SFG_Menu * )fgStructure.Menus.First) )
while( menu = ( SFG_Menu * )fgStructure.Menus.First )
fgDestroyMenu( menu );
while( (window = ( SFG_Window * )fgStructure.Windows.First) )
while( window = ( SFG_Window * )fgStructure.Windows.First )
fgDestroyWindow( window, GL_TRUE );
}
@ -651,7 +651,7 @@ void fgListAppend(SFG_List *list, SFG_Node *node)
{
SFG_Node *ln;
if ( (ln = (SFG_Node *)list->Last) )
if ( ln = (SFG_Node *)list->Last )
{
ln->Next = node;
node->Prev = ln;
@ -670,9 +670,9 @@ void fgListRemove(SFG_List *list, SFG_Node *node)
{
SFG_Node *ln;
if( (ln = (SFG_Node *)node->Next) )
if( ln = (SFG_Node *)node->Next )
ln->Prev = node->Prev;
if( (ln = (SFG_Node *)node->Prev) )
if( ln = (SFG_Node *)node->Prev )
ln->Next = node->Next;
if( (ln = (SFG_Node *)list->First) == node )
list->First = node->Next;