Minor bugs in orxParam

Hi,

I encountered two minor issues in orxParam.

1) Release linux build does not display help message:
$ orx -h
Displays nothing

I think changing debug level to log will do the trick:
diff --git a/code/src/main/orxParam.c b/code/src/main/orxParam.c
index e80511e..74d71d9 100644
--- a/code/src/main/orxParam.c
+++ b/code/src/main/orxParam.c
@@ -82,7 +82,7 @@
     _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_TERMINAL,                                                  
                        orxDEBUG_KU32_STATIC_FLAG_FILE                                                       
                       |orxDEBUG_KU32_STATIC_FLAG_CONSOLE);                                                  
-    _orxDebug_Log(orxDEBUG_LEVEL_PARAM, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__)
+    _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, ##__VA_ARGS__); 
     _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL);                                  
   } while(orxFALSE)
 
@@ -97,7 +97,7 @@
       _orxDebug_SetFlags(orxDEBUG_KU32_STATIC_FLAG_TERMINAL,                                                
                          orxDEBUG_KU32_STATIC_FLAG_FILE                                                     
                         |orxDEBUG_KU32_STATIC_FLAG_CONSOLE);                                                
-      _orxDebug_Log(orxDEBUG_LEVEL_PARAM, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__)
+      _orxDebug_Log(orxDEBUG_LEVEL_LOG, (const orxSTRING)__FUNCTION__, __FILE__, __LINE__, STRING, __VA_ARGS__); 
       _orxDebug_SetFlags(u32DebugFlags, orxDEBUG_KU32_STATIC_MASK_USER_ALL);                                
     } while(orxFALSE)

BTW
After the last changes to debug stuff help displays with timestamps :D
[09:25:11] [LOG] Options:
[09:25:11] [LOG] -c        --config                   Loads the specified configuration file.
[09:25:11] [LOG] -h        --help                     Display this help. You can use extra parameter to display complete description (-h <param>).
Guess the orxDEBUG_KU32_STATIC_FLAG_FILE is the culprit ...

2) When defining an orxPARAM structure and setting the zLongName attribute to orxNULL the parameter will not be automatically processed after call to orxParam_Register.

A patch:
diff --git a/code/src/main/orxParam.c b/code/src/main/orxParam.c
index e80511e..0293bc6 100644
--- a/code/src/main/orxParam.c
+++ b/code/src/main/orxParam.c
@@ -601,10 +601,10 @@ orxSTATUS orxFASTCALL orxParam_Register(const orxPARAM *_pstParam)
           {
             /* Adds it to table */
             orxHashTable_Add(sstParam.pstHashTable, u32LongName, pstParamInfo);
-
-            /* Process params */
-            eResult = orxParam_Process(pstParamInfo);
           }
+
+          /* Process params */
+          eResult = orxParam_Process(pstParamInfo);
         }
       }
       else

Cheers,
Graag

Comments

  • edited September 2012
    Hi Graag,

    thanks for the report!

    I fixed the first one by enabling PARAM debug level when the orxParam module gets initialized and the second one is the same fix as you proposed.
    Let me know if that works for you! :)
  • edited September 2012
    Hi,

    First one is fine. I'm just curious, does the help message have to contain timestamps?

    Second one - almost there ... ;-)

    An assert is triggered in orxParam_Process when the parameter is not specified on the command line. Sorry I did not spot this earlier :blush: .

    Here's what fixed it for me:
    diff --git a/code/src/main/orxParam.c b/code/src/main/orxParam.c
    index 00f4bba..de3efc6 100644
    --- a/code/src/main/orxParam.c
    +++ b/code/src/main/orxParam.c
    @@ -273,13 +273,16 @@ static orxSTATUS orxFASTCALL orxParam_Process(orxPARAM_INFO *_pstParamInfo)
           /* Not found? */
           if(azParamList == orxNULL)
           {
    -        const orxSTRING zParamValue;
    +        const orxSTRING zParamValue = orxSTRING_EMPTY;
     
             /* Pushes config section */
             orxConfig_PushSection(orxPARAM_KZ_CONFIG_SECTION);
     
    -        /* Gets its value */
    -        zParamValue = orxConfig_GetString(_pstParamInfo->stParam.zLongName);
    +        if(_pstParamInfo->stParam.zLongName != orxNULL)
    +        {
    +            /* Gets its value */
    +            zParamValue = orxConfig_GetString(_pstParamInfo->stParam.zLongName);
    +        }
     
             /* Found? */
             if(zParamValue != orxSTRING_EMPTY)
    

    Cheers,
    Graag
  • edited September 2012
    You drive a hard bargain! ;)

    Ok, fixed the extraneous tags when display param help (they appeared with a recent refactor I made) and the assert as per your suggestion. :)
Sign In or Register to comment.