Ejemplo n.º 1
0
static void hb_compChkDefineSwitch( HB_COMP_DECL, const char * pszSwitch )
{
   if( pszSwitch && HB_ISOPTSEP( pszSwitch[ 0 ] ) )
   {
      if( pszSwitch[ 1 ] == 'd' || pszSwitch[ 1 ] == 'D' )
      {
         if( pszSwitch[ 2 ] )
         {
            char * szDefText = hb_strdup( pszSwitch + 2 ), * szAssign;

            szAssign = strchr( szDefText, '=' );
            if( szAssign )
               *szAssign++ = '\0';
            hb_pp_addDefine( HB_COMP_PARAM->pLex->pPP, szDefText, szAssign );
            hb_xfree( szDefText );
         }
      }
      else if( ( pszSwitch[ 1 ] == 'U' || pszSwitch[ 1 ] == 'u' ) &&
               ( pszSwitch[ 2 ] == 'N' || pszSwitch[ 2 ] == 'n' ) &&
               ( pszSwitch[ 3 ] == 'D' || pszSwitch[ 3 ] == 'd' ) &&
               ( pszSwitch[ 4 ] == 'E' || pszSwitch[ 4 ] == 'e' ) &&
               ( pszSwitch[ 5 ] == 'F' || pszSwitch[ 5 ] == 'f' ) &&
               pszSwitch[ 6 ] == ':' )
      {
         char *szDefText = hb_strdup( pszSwitch + 7 );
         unsigned int i = 0;

         while( szDefText[ i ] && ! HB_ISOPTSEP( szDefText[ i ] ) )
         {
            i++;
         }
         szDefText[ i ] = '\0';

         if( szDefText[ 0 ] )
         {
            if( hb_stricmp( szDefText, ".ARCH." ) == 0 )
               hb_pp_delDefine( HB_COMP_PARAM->pLex->pPP, szDefText );
         }
         hb_xfree( szDefText );
      }
   }
}
Ejemplo n.º 2
0
/* check command line parameters */
void hb_compChkCommandLine( HB_COMP_DECL, int argc, const char * const argv[] )
{
   int i;

   for( i = 1; i < argc && ! HB_COMP_PARAM->fExit; ++i )
   {
      const char * szSwitch = argv[ i ];

      if( HB_ISOPTSEP( szSwitch[ 0 ] ) )
      {
         do
            szSwitch = hb_compChkParseSwitch( HB_COMP_PARAM, szSwitch, HB_FALSE );
         while( *szSwitch != '\0' );
      }
   }
}
Ejemplo n.º 3
0
static const char * hb_compChkAddDefine( HB_COMP_DECL, const char * szSwitch,
                                         HB_BOOL fAdd, HB_BOOL fEnv )
{
   const char * szSwPtr = szSwitch;
   HB_SIZE nValue = 0;

   while( *szSwPtr && *szSwPtr != ' ' && ! HB_ISOPTSEP( *szSwPtr ) )
   {
      if( *szSwPtr == '=' )
      {
         nValue = szSwPtr - szSwitch;
         szSwPtr += hb_compChkOptionLen( szSwPtr, fEnv );
         break;
      }
      ++szSwPtr;
   }
   if( szSwPtr > szSwitch && *szSwitch != '=' )
   {
      char * szDefine = hb_strndup( szSwitch, szSwPtr - szSwitch );
      char * szValue = NULL;
      PHB_PPDEFINE * pDefinePtr;

      if( nValue )
      {
         szValue = szDefine + nValue;
         *szValue++ = '\0';
      }
      if( ! fAdd )
         szValue = s_szUndefineMarker;

      pDefinePtr = &HB_COMP_PARAM->ppdefines;
      while( *pDefinePtr != NULL &&
             strcmp( ( *pDefinePtr )->szName, szDefine ) != 0 )
         pDefinePtr = &( *pDefinePtr )->pNext;

      if( *pDefinePtr == NULL )
      {
         *pDefinePtr = ( PHB_PPDEFINE ) hb_xgrab( sizeof( HB_PPDEFINE ) );
         ( *pDefinePtr )->pNext = NULL;
      }
      else
         hb_xfree( ( *pDefinePtr )->szName );
      ( *pDefinePtr )->szName = szDefine;
      ( *pDefinePtr )->szValue = szValue;
   }
   return szSwPtr;
}
Ejemplo n.º 4
0
int main( int argc, char * argv[] )
{
   char *         szFile         = NULL, * szRuleFile = NULL, * szWordFile = NULL, * szVerFile = NULL;
   char *         szLogFile      = NULL;
   BOOL           fQuiet         = FALSE, fWrite = FALSE, fChgLog = FALSE;
   char *         szChangeLogID  = NULL, * szLastEntry = NULL;
   int            iResult        = 0, i;
   PHB_PP_STATE   pState;

   pState = hb_pp_new();

   if( argc >= 2 )
   {
      szFile = argv[ 1 ];
      for( i = 2; szFile && i < argc; i++ )
      {
         if( ! HB_ISOPTSEP( argv[ i ][ 0 ] ) )
            szFile = NULL;
         else
         {
            switch( argv[ i ][ 1 ] )
            {
               case 'q':
               case 'Q':
                  if( argv[ i ][ 2 ] )
                     szFile = NULL;
                  else
                     fQuiet = TRUE;
                  break;

               case 'w':
               case 'W':
                  if( argv[ i ][ 2 ] )
                     szFile = NULL;
                  else
                     fWrite = TRUE;
                  break;

               case 'c':
               case 'C':
                  fChgLog = TRUE;
                  if( argv[ i ][ 2 ] )
                     szLogFile = argv[ i ] + 2;
                  break;

               case 'i':
               case 'I':
                  if( argv[ i ][ 2 ] )
                     hb_pp_addSearchPath( pState, argv[ i ] + 2, FALSE );
                  else
                     szFile = NULL;
                  break;

               case 'o':
               case 'O':
                  if( argv[ i ][ 2 ] )
                     szRuleFile = argv[ i ] + 2;
                  else
                     szFile = NULL;
                  break;

               case 'x':
               case 'X':
                  if( argv[ i ][ 2 ] )
                     szWordFile = argv[ i ] + 2;
                  else
                     szWordFile = NULL;
                  break;

               case 'v':
               case 'V':
                  if( argv[ i ][ 2 ] )
                     szVerFile = argv[ i ] + 2;
                  else
                     szFile = NULL;
                  break;

               default:
                  szFile = NULL;
                  break;
            }
         }
      }
   }

   if( szFile )
   {
      hb_pp_init( pState, fQuiet, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );
      if( hb_pp_inFile( pState, szFile, TRUE, NULL, TRUE ) )
      {
         char * szSVNID = ( char * ) hb_xgrab( 10 );
         char * szSVNDateID = ( char * ) hb_xgrab( 10 );
         if( fWrite )
         {
            char        szFileName[ HB_PATH_MAX ];
            PHB_FNAME   pFileName;

            pFileName               = hb_fsFNameSplit( szFile );
            pFileName->szExtension  = ".ppo";
            hb_fsFNameMerge( szFileName, pFileName );
            hb_xfree( pFileName );

            hb_pp_outFile( pState, szFileName, NULL );
         }

         if( fChgLog )
            iResult = hb_pp_parseChangelog( pState, szLogFile, fQuiet,
                                            szSVNID, szSVNDateID, &szChangeLogID, &szLastEntry );

         if( iResult == 0 )
            iResult = hb_pp_preprocesfile( pState, szRuleFile, szWordFile );

         if( iResult == 0 && szVerFile )
            iResult = hb_pp_generateVerInfo( szVerFile, szSVNID, szSVNDateID,
                                             szChangeLogID, szLastEntry );

         hb_xfree( szSVNID );
         hb_xfree( szSVNDateID );
      }
      else
         iResult = 1;
   }
   else
   {
      hb_pp_usage( argv[ 0 ] );
      iResult = 1;
   }

   if( szChangeLogID )
      hb_xfree( szChangeLogID );
   if( szLastEntry )
      hb_xfree( szLastEntry );

   hb_pp_free( pState );

   return iResult;
}
Ejemplo n.º 5
0
static const char * hb_compChkParseSwitch( HB_COMP_DECL, const char * szSwitch,
                                           HB_BOOL fEnv )
{
   const char * szSwPtr = szSwitch;

   if( szSwPtr[ 0 ] == '-' && szSwPtr[ 1 ] == '-' )
   {
      if( strncmp( szSwPtr + 2, "version", 7 ) == 0 )
      {
         szSwPtr += 9;
         HB_COMP_PARAM->fLogo = HB_TRUE;
         HB_COMP_PARAM->fQuiet = HB_TRUE;
      }
      else if( strncmp( szSwPtr + 2, "help", 4 ) == 0 )
      {
         szSwPtr += 6;
         HB_COMP_PARAM->fLogo = HB_TRUE;
         HB_COMP_PARAM->fQuiet = HB_FALSE;
         HB_COMP_PARAM->fExit = HB_FALSE;
      }
   }
   else if( HB_ISOPTSEP( *szSwPtr ) )
   {
      ++szSwPtr;
      switch( HB_TOUPPER( *szSwPtr ) )
      {
         case 'A':
            ++szSwPtr;
            if( *szSwPtr == '-' )
            {
               ++szSwPtr;
               HB_COMP_PARAM->fAutoMemvarAssume = HB_FALSE;
            }
            else
               HB_COMP_PARAM->fAutoMemvarAssume = HB_TRUE;
            break;

         case 'B':
         {
            char *szOption = hb_compChkOptionDup( szSwPtr );

            if( strcmp( szOption, "BUILD" ) == 0 )
            {
               HB_COMP_PARAM->fBuildInfo = HB_TRUE;
               szSwPtr += 5;
            }
            else if( szSwPtr[ 1 ] == '-' )
            {
               HB_COMP_PARAM->fDebugInfo = HB_FALSE;
               szSwPtr += 2;
            }
            else
            {
               HB_COMP_PARAM->fDebugInfo = HB_TRUE;
               HB_COMP_PARAM->fLineNumbers = HB_TRUE;
               ++szSwPtr;
            }
            hb_xfree( szOption );
            break;
         }

         case 'C':
         {
            char *szOption = hb_compChkOptionDup( szSwPtr );

            if( strlen( szOption ) >= 4 &&
                strncmp( "CREDITS", szOption, strlen( szOption ) ) == 0 )
            {
               HB_COMP_PARAM->fCredits = HB_TRUE;
               szSwPtr += strlen( szOption );
            }
            hb_xfree( szOption );
            break;
         }

         case 'D':
            szSwPtr = hb_compChkAddDefine( HB_COMP_PARAM, szSwPtr + 1, HB_TRUE, fEnv );
            break;

         case 'E':
            if( HB_TOUPPER( szSwPtr[ 1 ] ) == 'S' )
            {
               switch( szSwPtr[ 2 ] )
               {
                  case '1':
                     szSwPtr += 3;
                     HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_SETEXIT;
                     break;
                  case '2':
                     szSwPtr += 3;
                     HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DELTARGET;
                     break;
                  case '0':
                     ++szSwPtr;
                     /* no break; */
                  default:
                     szSwPtr += 2;
                     HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DEFAULT;
                     break;
               }
            }
            break;

         case 'F':
            switch( HB_TOUPPER( szSwPtr[ 1 ] ) )
            {
               case 'N':
                  if( szSwPtr[ 2 ] == ':' )
                  {
                     if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'U' )
                     {
                        szSwPtr += 4;
                        hb_setSetFileCase( HB_SET_CASE_UPPER );
                     }
                     else if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'L' )
                     {
                        szSwPtr += 4;
                        hb_setSetFileCase( HB_SET_CASE_LOWER );
                     }
                  }
                  else
                  {
                     szSwPtr += 2;
                     if( *szSwPtr == '-' )
                        ++szSwPtr;
                     hb_setSetFileCase( HB_SET_CASE_MIXED );
                  }
                  break;
               case 'D':
                  if( szSwPtr[ 2 ] == ':' )
                  {
                     if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'U' )
                     {
                        szSwPtr += 4;
                        hb_setSetDirCase( HB_SET_CASE_UPPER );
                     }
                     else if( HB_TOUPPER( szSwPtr[ 3 ] ) == 'L' )
                     {
                        szSwPtr += 4;
                        hb_setSetDirCase( HB_SET_CASE_LOWER );
                     }
                  }
                  else
                  {
                     szSwPtr += 2;
                     if( *szSwPtr == '-' )
                        ++szSwPtr;
                     hb_setSetDirCase( HB_SET_CASE_MIXED );
                  }
                  break;
               case 'P':
                  szSwPtr += 2;
                  if( *szSwPtr == ':' )
                  {
                     if( szSwPtr[ 1 ] && szSwPtr[ 1 ] != ' ' )
                     {
                        hb_setSetDirSeparator( szSwPtr[ 1 ] );
                        szSwPtr += 2;
                     }
                  }
                  else
                  {
                     if( *szSwPtr == '-' )
                        ++szSwPtr;
                     hb_setSetDirSeparator( HB_OS_PATH_DELIM_CHR );
                  }
                  break;
               case 'S':
                  szSwPtr += 2;
                  if( *szSwPtr == '-' )
                  {
                     ++szSwPtr;
                     hb_setSetTrimFileName( HB_FALSE );
                  }
                  else
                     hb_setSetTrimFileName( HB_TRUE );
            }
            break;

         case 'G':
            switch( HB_TOUPPER( szSwPtr[ 1 ] ) )
            {
               case 'C':
                  HB_COMP_PARAM->iLanguage = HB_LANG_C;
                  szSwPtr += 2;
                  switch( *szSwPtr )
                  {
                     case '1':
                        ++szSwPtr;
                        HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_NORMAL;
                        break;
                     case '2':
                        ++szSwPtr;
                        HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_VERBOSE;
                        break;
                     case '3':
                        ++szSwPtr;
                        HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_REALCODE;
                        break;
                     case '0':
                        ++szSwPtr;
                        /* no break; */
                     default:
                        HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_COMPACT;
                        break;
                  }
                  break;

               case 'H':
                  HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ;
                  szSwPtr += 2;
                  break;

               case 'D':
                  if( HB_COMP_PARAM->szDepExt )
                  {
                     hb_xfree( HB_COMP_PARAM->szDepExt );
                     HB_COMP_PARAM->szDepExt = NULL;
                  }
                  szSwPtr += 2;
                  if( *szSwPtr == '-' )
                  {
                     HB_COMP_PARAM->iTraceInclude = 0;
                     ++szSwPtr;
                  }
                  else
                  {
                     HB_COMP_PARAM->iTraceInclude = 2;
                     if( *szSwPtr == '.' )
                        szSwPtr = hb_compChkOptionGet( szSwPtr, &HB_COMP_PARAM->szDepExt, fEnv );
                  }
                  break;

               case 'E':
                  szSwPtr += 2;
                  switch( *szSwPtr )
                  {
                     case '1':
                        ++szSwPtr;
                        HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_IDE;
                        break;
                     case '0':
                        ++szSwPtr;
                        /* no break; */
                     default:
                        HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_CLIPPER;
                        break;
                  }
                  break;

               default:
                  hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL );
                  break;
            }
            break;

         case 'H':
         case '?':
            /* HELP message */
            break;

         case 'I':
            ++szSwPtr;
            switch( *szSwPtr )
            {
               case '-':
                  HB_COMP_PARAM->fINCLUDE = HB_FALSE;
                  ++szSwPtr;
                  break;
               case '+':
                  HB_COMP_PARAM->fINCLUDE = HB_TRUE;
                  ++szSwPtr;
                  break;
               default:
                  szSwPtr = hb_compChkOptionAddPath( HB_COMP_PARAM, szSwPtr, fEnv );
            }
            break;

         case 'J':
            ++szSwPtr;
            HB_COMP_PARAM->fI18n = HB_TRUE;
            if( *szSwPtr )
               szSwPtr = hb_compChkOptionFName( szSwPtr, &HB_COMP_PARAM->pI18nFileName, fEnv );
            break;

         case 'K':
            ++szSwPtr;
            while( *szSwPtr && ! HB_COMP_PARAM->fExit )
            {
               int ch = HB_TOUPPER( *szSwPtr );

               ++szSwPtr;
               switch( ch )
               {
                  case '?':
                     hb_compPrintLogo( HB_COMP_PARAM );
                     hb_compPrintModes( HB_COMP_PARAM );
                     HB_COMP_PARAM->fLogo = HB_FALSE;
                     HB_COMP_PARAM->fQuiet = HB_TRUE;
                     break;

                  case 'H':
                     /* default Harbour mode */
                     if( *szSwPtr == '-' )
                     {
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HARBOUR;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_HARBOUR;
                     break;

                  case 'C':
                     /* clear all flags - minimal set of features */
                     HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS;
                     HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP |
                                                 HB_COMPFLAG_MACROTEXT;
                     break;

                  case 'X':
                     if( *szSwPtr == '-' )
                     {
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_XBASE;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_XBASE;
                     break;

                  case 'I':
                     if( *szSwPtr == '-' )
                     {
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HB_INLINE;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE;
                     break;

                  case 'J':
                     if( *szSwPtr == '+' )
                     {
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP;
                     break;

                  case 'M':
                     if( *szSwPtr == '+' )
                     {
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_MACROTEXT;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT;
                     break;

                  case 'D':
                     if( *szSwPtr == '-' )
                     {
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACRODECL;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_MACRODECL;
                     break;

                  case 'R':
                     if( *szSwPtr == '-' )
                     {
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_RT_MACRO;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO;
                     break;

                  case 'S':
                     if( *szSwPtr == '-' )
                     {
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_ARRSTR;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_ARRSTR;
                     break;

                  case 'O':
                     if( *szSwPtr == '-' )
                     {
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_EXTOPT;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT;
                     break;

                  case 'U':
                     if( *szSwPtr == '-' )
                     {
                        HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP;
                        ++szSwPtr;
                     }
                     else
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP;
                     break;

                  default:
                     ch = -1;
                     --szSwPtr;
               }
               if( ch == -1 )
                  break;
            }
            break;

         case 'L':
            ++szSwPtr;
            if( *szSwPtr == '-' )
            {
               HB_COMP_PARAM->fLineNumbers = HB_TRUE;
               ++szSwPtr;
            }
            else
               HB_COMP_PARAM->fLineNumbers = HB_FALSE;
            break;

         case 'M':
            ++szSwPtr;
            if( *szSwPtr == '-' )
            {
               HB_COMP_PARAM->fSingleModule = HB_FALSE;
               ++szSwPtr;
            }
            else
               HB_COMP_PARAM->fSingleModule = HB_TRUE;
            break;

         case 'N':
            ++szSwPtr;
            HB_COMP_PARAM->fNoStartUp = *szSwPtr == '1';
            switch( *szSwPtr )
            {
               case '-':
                  HB_COMP_PARAM->iStartProc = 0;
                  ++szSwPtr;
                  break;
               case '2':
                  HB_COMP_PARAM->iStartProc = 2;
                  ++szSwPtr;
                  break;
               case '0':
               case '1':
                  ++szSwPtr;
                  /* no break; */
               default:
                  HB_COMP_PARAM->iStartProc = 1;
                  break;
            }
            break;

         case 'O':
            szSwPtr = hb_compChkOptionFName( szSwPtr + 1, &HB_COMP_PARAM->pOutPath, fEnv );
            break;

         case 'P':
            ++szSwPtr;
            if( *szSwPtr == '+' )
            {
               HB_COMP_PARAM->fPPT = HB_TRUE;
               ++szSwPtr;
            }
            else
            {
               if( HB_COMP_PARAM->pPpoPath )
               {
                  hb_xfree( HB_COMP_PARAM->pPpoPath );
                  HB_COMP_PARAM->pPpoPath = NULL;
               }
               if( *szSwPtr == '-' )
               {
                  HB_COMP_PARAM->fPPT = HB_COMP_PARAM->fPPO = HB_FALSE;
                  ++szSwPtr;
               }
               else
               {
                  if( *szSwPtr )
                     szSwPtr = hb_compChkOptionFName( szSwPtr, &HB_COMP_PARAM->pPpoPath, fEnv );
                  HB_COMP_PARAM->fPPO = HB_TRUE;
               }
            }
            break;

         case 'Q':
            ++szSwPtr;
            switch( *szSwPtr )
            {
               case 'l':
               case 'L':
                  HB_COMP_PARAM->fGauge = HB_FALSE;
                  ++szSwPtr;
                  break;
               case '2':
                  HB_COMP_PARAM->fFullQuiet = HB_TRUE;
                  /* no break */
               case '0':
                  HB_COMP_PARAM->fLogo = HB_FALSE;
                  ++szSwPtr;
                  /* no break */
               default:
                  HB_COMP_PARAM->fQuiet = HB_TRUE;
            }
            break;

         case 'R':
            ++szSwPtr;
            if( szSwPtr[ 0 ] == ':' )
            {
               if( HB_ISDIGIT( szSwPtr[ 1 ] ) )
               {
                  int iCycles = 0;
                  ++szSwPtr;
                  while( HB_ISDIGIT( *szSwPtr ) )
                     iCycles = iCycles * 10 + *szSwPtr++ - '0';
                  if( iCycles > 0 )
                     HB_COMP_PARAM->iMaxTransCycles = iCycles;
               }
            }
            else
            {
               /* NOTE: ignored for Cl*pper compatibility:
                        /r[<lib>] request linker to search <lib> (or none) */
               hb_compChkIgnoredInfo( HB_COMP_PARAM, "-r[<lib>]" );
               szSwPtr = hb_compChkOptionGet( szSwPtr, NULL, fEnv );
            }
            break;

         case 'S':
            ++szSwPtr;
            switch( *szSwPtr )
            {
               case '-':
                  HB_COMP_PARAM->iSyntaxCheckOnly = 0;
                  ++szSwPtr;
                  break;
               case 'm':
               case 'M':
                  HB_COMP_PARAM->iSyntaxCheckOnly = 2;
                  ++szSwPtr;
                  break;
               default:
                  HB_COMP_PARAM->iSyntaxCheckOnly = 1;
                  break;
            }
            break;

         case 'T':
            /* NOTE: ignored for Cl*pper compatibility:
                     /t<path> path for temp file creation */
            hb_compChkIgnoredInfo( HB_COMP_PARAM, "-t<path>" );
            szSwPtr = hb_compChkOptionGet( szSwPtr + 1, NULL, fEnv );
            break;

         case 'U':
            if( hb_strnicmp( szSwPtr, "UNDEF:", 6 ) == 0 )
            {
               if( hb_strnicmp( szSwPtr + 6, ".ARCH.", 6 ) == 0 )
               {
                  HB_COMP_PARAM->fNoArchDefs = HB_TRUE;
                  szSwPtr += 12;
               }
               else
                  szSwPtr = hb_compChkAddDefine( HB_COMP_PARAM, szSwPtr + 6, HB_FALSE, fEnv );
               break;
            }
            ++szSwPtr;
            /* extended definitions file: -u+<file> */
            if( *szSwPtr == '+' )
            {
               if( szSwPtr[ 1 ] && hb_compChkOptionLen( szSwPtr + 1, fEnv ) > 0 )
               {
                  HB_COMP_PARAM->szStdChExt = ( char ** )
                     ( HB_COMP_PARAM->iStdChExt == 0 ?
                        hb_xgrab( sizeof( char * ) ) :
                        hb_xrealloc( HB_COMP_PARAM->szStdChExt,
                                     ( HB_COMP_PARAM->iStdChExt + 1 ) *
                                     sizeof( char * ) ) );
                  szSwPtr = hb_compChkOptionGet( szSwPtr + 1,
                                                 &HB_COMP_PARAM->szStdChExt[ HB_COMP_PARAM->iStdChExt++ ],
                                                 fEnv );
               }
            }
            else
            {
               if( HB_COMP_PARAM->szStdCh )
                  hb_xfree( HB_COMP_PARAM->szStdCh );
               szSwPtr = hb_compChkOptionGet( szSwPtr, &HB_COMP_PARAM->szStdCh, fEnv );
            }
            break;

         case 'V':
            ++szSwPtr;
            if( *szSwPtr == '-' )
            {
               HB_COMP_PARAM->fForceMemvars = HB_FALSE;
               ++szSwPtr;
            }
            else
               HB_COMP_PARAM->fForceMemvars = HB_TRUE;
            break;

         case 'W':
            ++szSwPtr;
            HB_COMP_PARAM->iWarnings = 1;
            if( *szSwPtr >= '0' && *szSwPtr <= '3' )
            {
               HB_COMP_PARAM->iWarnings = *szSwPtr - '0';
               ++szSwPtr;
            }
            break;

#ifdef YYDEBUG
         case 'Y':
            ++szSwPtr;
            extern int hb_comp_yydebug;
            hb_comp_yydebug = HB_TRUE;
            break;
#endif

         case 'Z':
            ++szSwPtr;
            if( *szSwPtr == '-' )
            {
               HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS;
               ++szSwPtr;
            }
            else
               HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS;
            break;
      }
   }

   if( ! HB_COMP_PARAM->fExit )
   {
      if( szSwPtr - szSwitch <= 1 ||
          ( *szSwPtr != '\0' && *szSwPtr != ' ' && ! HB_ISOPTSEP( *szSwPtr ) ) )
         hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F',
                          fEnv ? HB_COMP_ERR_BADOPTION : HB_COMP_ERR_BADPARAM,
                          szSwitch, NULL );
      else
         return szSwPtr;
   }

   return "";
}
Ejemplo n.º 6
0
int main( int argc, char * argv[] )
{
  FILE * handl_o;
  char szFileName[ _POSIX_PATH_MAX + 1 ];
  char szPpoName[ _POSIX_PATH_MAX + 1 ];
  int iArg = 1;
  BOOL bOutTable = FALSE;
  BOOL bOutNew = FALSE;
  DEFINES * stdef;
  COMMANDS * stcmd;

  HB_TRACE(HB_TR_DEBUG, ("main(%d, %p)", argc, argv));

  printf( "Harbour Preprocessor (old revision) %d.%d.%d\n",
     HB_VER_MAJOR, HB_VER_MINOR, HB_VER_REVISION );
  printf( "Copyright (c) 1999-2008, http://www.harbour-project.org/\n" );

  hb_pp_Table();
  stdef = hb_pp_topDefine;
  stcmd = hb_pp_topCommand;
  hb_pp_Init();

  while( iArg < argc )
    {
      if( HB_ISOPTSEP(argv[ iArg ][ 0 ]))
        {
          switch( argv[ iArg ][ 1 ] )
            {
            case 'd':
            case 'D':   /* defines a #define from the command line */
              {
                 char *szDefText = hb_strdup( argv[iArg] + 2 ), *pAssign, *sDefLine;
                 unsigned int i = 0;

                 while( i < strlen( szDefText ) && ! HB_ISOPTSEP( szDefText[ i ] ) )
                    i++;

                 szDefText[ i ] = '\0';
                 if( szDefText )
                 {
                    if( ( pAssign = strchr( szDefText, '=' ) ) == NULL )
                    {
                       hb_pp_AddDefine_( szDefText, 0 );
                    }
                    else
                    {
                       szDefText[ pAssign - szDefText ] = '\0';

                       /* hb_pp_AddDefine_( szDefText,  pAssign + 1 ); */
                       sDefLine = hb_xstrcpy( NULL, szDefText, " ", pAssign + 1, NULL );
                       hb_pp_ParseDefine_( sDefLine );
                       hb_xfree( sDefLine );
                    }
                 }

                 hb_xfree( szDefText );
              }
              break;
            case 'i':
            case 'I':
              AddSearchPath( argv[ iArg ]+2, &hb_comp_pIncludePath );
              break;
            case 'o':
            case 'O':
              bOutTable = TRUE;
              break;
            case 'n':
            case 'N':
              bOutNew = TRUE;
              break;
            case 'w':
            case 'W':
              s_iWarnings = 1;
              if( argv[ iArg ][ 2 ] )
                {  /*there is -w<0,1,2,3> probably */
                  s_iWarnings = argv[ iArg ][ 2 ] - '0';
                  if( s_iWarnings < 0 || s_iWarnings > 3 )
                    printf( "\nInvalid command line option: %s\n", argv[ iArg ] );
                }
              break;
            default:
              printf( "\nInvalid command line option: %s\n", &argv[ iArg ][ 1 ] );
              break;
            }
        }
      else  hb_comp_pFileName = hb_fsFNameSplit( argv[ iArg ] );
      iArg++;
    }

  if( hb_comp_pFileName )
    {
      if( ! hb_comp_pFileName->szExtension )
        hb_comp_pFileName->szExtension =".prg";

      hb_fsFNameMerge( szFileName, hb_comp_pFileName );

      if( !hb_pp_fopen( szFileName ) )
        {
          printf("\nCan't open %s\n", szFileName );
          return 1;
        }

      printf( "\nParsing file %s\n", szFileName );
    }
  else
    {
      printf( "\nSyntax:  %s <file[.prg]> [options]"
              "\n"
              "\nOptions:  /d<id>[=<val>]   #define <id>"
              "\n          /i<path>         add #include file search path"
              "\n          /o               creates hbpp.out with all tables"
              "\n          /n               with those only, which defined in your file"
              "\n          /w               enable warnings"
              "\n"
              , argv[ 0 ] );

      if( bOutTable )
        OutTable( NULL, NULL );

      return 1;
    }

  hb_comp_pFileName->szExtension = ".ppo";
  hb_fsFNameMerge( szPpoName, hb_comp_pFileName );

  if( ( handl_o = fopen( szPpoName, "wt" ) ) == NULL )
    {
      printf("\nCan't open %s\n", szPpoName );
      return 1;
    }

  {
    char * szInclude = hb_getenv( "INCLUDE" );

    if( szInclude )
      {
        char * pPath;
        char * pDelim;

        pPath = szInclude;
        while( ( pDelim = strchr( pPath, HB_OS_PATH_LIST_SEP_CHR ) ) != NULL )
          {
            *pDelim = '\0';
            AddSearchPath( pPath, &hb_comp_pIncludePath );
            pPath = pDelim + 1;
          }
        AddSearchPath( pPath, &hb_comp_pIncludePath );
        hb_xfree( szInclude );
      }
  }

  hb_buffer = ( char* ) hb_xgrab( HB_PP_STR_SIZE );
  while( hb_pp_Internal_( handl_o,hb_buffer ) > 0 );
  fclose( hb_comp_files.pLast->handle );
  hb_xfree( hb_comp_files.pLast->pBuffer );
  hb_xfree( hb_comp_files.pLast );
  hb_xfree( hb_buffer );
  fclose( handl_o );

  if( bOutTable )
    OutTable( NULL, NULL );
  else if( bOutNew )
    OutTable( stdef, stcmd );

  printf( "\nOk" );

  return 0;
}
Ejemplo n.º 7
0
void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const Args[] )
{
   /* If iArg is passed check the command line options */
   if( iArg )
   {
      int i;

      /* Check all switches in command line
         They start with an OS_OPT_DELIMITER char
       */
      for( i = 1; i < iArg && ! HB_COMP_PARAM->fExit; i++ )
      {
         const char * szSwitch = Args[ i ];

         if( ! HB_ISOPTSEP( szSwitch[ 0 ] ) )
            continue;

         if( szSwitch[ 0 ] == '-' )
         {
            int  j = 1;
            char Switch[ 7 ];

            Switch[ 0 ] = '-';

            while( szSwitch[ j ] && ! HB_COMP_PARAM->fExit )
            {
               Switch[ 1 ] = szSwitch[ j ];

               if( szSwitch[ j + 1 ] == '-' )
               {
                  Switch[ 2 ] = '-';
                  Switch[ 3 ] = '\0';

                  hb_compChkEnvironVar( HB_COMP_PARAM, Switch );

                  j += 2;
                  continue;
               }
               else
               {
                  switch( Switch[ 1 ] )
                  {
                     case 'b':
                     case 'B':
                        if( ( szSwitch[ j + 1 ] == 'U' || szSwitch[ j + 1 ] == 'u' ) &&
                            ( szSwitch[ j + 2 ] == 'I' || szSwitch[ j + 2 ] == 'i' ) &&
                            ( szSwitch[ j + 3 ] == 'L' || szSwitch[ j + 3 ] == 'l' ) &&
                            ( szSwitch[ j + 4 ] == 'D' || szSwitch[ j + 4 ] == 'd' ) )
                        {
                           Switch[ 2 ] = 'U';
                           Switch[ 3 ] = 'I';
                           Switch[ 4 ] = 'L';
                           Switch[ 5 ] = 'D';
                           Switch[ 6 ] = '\0';

                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );

                           j += 5;
                           continue;
                        }
                        else if( ! szSwitch[ j + 1 ] )
                        {
                           Switch[ 2 ] = '\0';
                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                           j += 1;
                           continue;
                        }
                        break;

                     case 'c':
                     case 'C':
                        if( ( szSwitch[ j + 1 ] == 'R' || szSwitch[ j + 1 ] == 'r' ) &&
                            ( szSwitch[ j + 2 ] == 'E' || szSwitch[ j + 2 ] == 'e' ) &&
                            ( szSwitch[ j + 3 ] == 'D' || szSwitch[ j + 3 ] == 'd' ) )
                        {
                           Switch[ 2 ] = 'R';
                           Switch[ 3 ] = 'E';
                           Switch[ 4 ] = 'D';
                           Switch[ 5 ] = '\0';

                           j += 4;

                           if( szSwitch[ j ] == 'I' || szSwitch[ j ] == 'i' )
                           {
                              j++;
                              if( szSwitch[ j ] == 'T' || szSwitch[ j ] == 't' )
                              {
                                 j++;
                                 if( szSwitch[ j ] == 'S' || szSwitch[ j ] == 's' )
                                 {
                                    j++;
                                 }
                              }
                           }
                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                        }
                        else
                        {
                           Switch[ 2 ] = '\0';
                           hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL );
                        }
                        continue;

                     case 'd':
                     case 'D':
                        szSwitch += ( j - 1 );
                        hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );

                        /* Accept rest as part of #define and continue with next Args[]. */
                        j = ( int ) strlen( szSwitch );
                        continue;

                     case 'e':
                     case 'E':
                        if( ( szSwitch[ j + 1 ] == 'S' || szSwitch[ j + 1 ] == 's' ) &&
                            HB_ISDIGIT( szSwitch[ j + 2 ] ) )
                        {
                           Switch[ 2 ] = 'S';
                           Switch[ 3 ] = szSwitch[ j + 2 ];
                           Switch[ 4 ] = '\0';

                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                           j += 3;
                        }
                        else
                        {
                           Switch[ 2 ] = '\0';
                           hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL );
                        }
                        continue;

                     case 'g':
                     case 'G':
                        if( szSwitch[ j + 1 ] == 'd' || szSwitch[ j + 1 ] == 'D' )
                        {
                           szSwitch += ( j - 1 );
                           hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
                           j = ( int ) strlen( szSwitch );
                        }
                        else
                        {
                           /* Required argument */
                           Switch[ 2 ] = szSwitch[ j + 1 ];
                           if( Switch[ 2 ] )
                           {
                              if( HB_ISDIGIT( szSwitch[ j + 2 ] ) )
                              {
                                 /* Optional argument */
                                 Switch[ 3 ] = szSwitch[ j + 2 ];
                                 Switch[ 4 ] = '\0';
                                 j += 3;
                              }
                              else
                              {
                                 /* No optional argument */
                                 Switch[ 3 ] = '\0';
                                 j += 2;
                              }
                              hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                           }
                           else
                              hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, Switch, NULL );
                        }
                        continue;

                     case 'i':
                     case 'I':
                        szSwitch += ( j - 1 );
                        hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );

                        /* Accept rest as IncludePath and continue with next Args[]. */
                        j = ( int ) strlen( szSwitch );
                        continue;

                     case 'j':
                     case 'J':
                        szSwitch += ( j - 1 );
                        hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
                        j = ( int ) strlen( szSwitch );
                        continue;

                     case 'k':
                     case 'K':
                        szSwitch += ( j - 1 );
                        hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );

                        /* Accept rest as part of #define and continue with next Args[]. */
                        j = ( int ) strlen( szSwitch );
                        continue;

                     case 'n':
                     case 'N':
                        /* Required argument */
                        if( szSwitch[ j + 1 ] )
                        {
                           /* Optional argument */
                           Switch[ 2 ] = szSwitch[ j + 1 ];
                           Switch[ 3 ] = '\0';
                           j += 2;
                        }
                        else
                        {
                           /* No optional argument */
                           Switch[ 2 ] = '\0';
                           j += 1;
                        }
                        hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                        continue;

                     case 'o':
                     case 'O':
                        szSwitch += ( j - 1 );
                        hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );

                        /* Accept rest as OutputPath and continue with next Args[]. */
                        j = ( int ) strlen( szSwitch );
                        continue;

                     case 'p':
                     case 'P':
                        if( szSwitch[ j + 1 ] )
                        {
                           szSwitch += ( j - 1 );
                           hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );

                           /* Accept rest as PPOPath and continue with next Args[]. */
                           j += ( int ) strlen( szSwitch ) - 1;
                        }
                        else
                        {
                           Switch[ 2 ] = '\0';
                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                           j++;
                        }
                        continue;

                     case 'q':
                     case 'Q':
                        if( HB_ISDIGIT( szSwitch[ j + 1 ] ) )
                        {
                           Switch[ 2 ] = szSwitch[ j + 1 ];
                           Switch[ 3 ] = '\0';

                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );

                           j += 2;
                           continue;
                        }
                        else
                        {
                           Switch[ 2 ] = '\0';
                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                        }

                        break;

                     case 'r':
                     case 'R':
                        hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
                        j = ( int ) strlen( szSwitch ) - 1;
                        break;

                     case 's':
                     case 'S':
                        ++j;
                        Switch[ 2 ] = Switch[ 3 ] = Switch[ 4 ] = '\0';
                        if( szSwitch[ j ] == 'm' || szSwitch[ j ] == 'M' )
                        {
                           Switch[ 2 ] = szSwitch[ j++ ];
                           if( HB_ISDIGIT( szSwitch[ j ] ) || szSwitch[ j ] == '-' )
                              Switch[ 3 ] = szSwitch[ j++ ];
                        }
                        hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                        continue;

                     case 'u':
                     case 'U':
                        szSwitch += ( j - 1 );
                        hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );

                        /* Accept rest as part of .ch Path or "undef:<id>" and continue with next Args[]. */
                        j = ( int ) strlen( szSwitch );
                        continue;

                     case 'w':
                     case 'W':
                        if( HB_ISDIGIT( szSwitch[ j + 1 ] ) )
                        {
                           Switch[ 2 ] = szSwitch[ j + 1 ];
                           Switch[ 3 ] = '\0';

                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );

                           j += 2;
                           continue;
                        }
                        else
                        {
                           Switch[ 2 ] = '\0';
                           hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                        }

                        break;

                     case 'x':
                     case 'X':
                        szSwitch += ( j - 1 );
                        hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );

                        /* Accept rest as INIT Symbol and continue with next Args[]. */
                        j = ( int ) strlen( szSwitch );
                        continue;

                     case '-':
                     {
                        int l = ++j;
                        while( szSwitch[ j ] && ! HB_ISOPTSEP( szSwitch[ j ] ) )
                           j++;
                        if( szSwitch[ l - 1 ] == '-' && j - l == 7 &&
                            memcmp( &szSwitch[ l ], "version", 7 ) == 0 )
                        {
                           HB_COMP_PARAM->fLogo = HB_TRUE;
                           HB_COMP_PARAM->fQuiet = HB_TRUE;
                        }
                        else if( szSwitch[ l - 1 ] == '-' && j - l == 4 &&
                                 memcmp( &szSwitch[ l ], "help", 4 ) == 0 )
                        {
                           HB_COMP_PARAM->fLogo = HB_TRUE;
                           HB_COMP_PARAM->fQuiet = HB_FALSE;
                           HB_COMP_PARAM->fExit = HB_FALSE;
                        }
                        else
                           hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, &szSwitch[ l ], NULL );
                        if( szSwitch[ j ] )
                           ++j;
                        continue;
                     }
                     default:
                        Switch[ 2 ] = '\0';
                        hb_compChkEnvironVar( HB_COMP_PARAM, Switch );
                  }
               }

               j++;
            }
            continue;
         }

         while( ! HB_COMP_PARAM->fExit )
         {
            int j = 1;
            const char * szSwitch1 = szSwitch + j; /* hack to avoid what is seems a bug in 'Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)' / XCode 4.1 [vszakats] */

            while( *szSwitch1 && ! HB_ISOPTSEP( *szSwitch1 ) )
            {
               j++;
               szSwitch1++;
            }

            if( szSwitch[ j ] == '/' )
            {
               char * szTmp = hb_strndup( szSwitch, j );
               hb_compChkEnvironVar( HB_COMP_PARAM, szTmp );
               hb_xfree( szTmp );
               szSwitch += j;
            }
            else
            {
               hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
               break;
            }
         }
      }
   }
   else /* Check the environment variables */
   {
      /* NOTE: CLIPPERCMD enviroment variable
         is overriden if HARBOURCMD exists
       */
      char * szStrEnv = hb_getenv( "HARBOURCMD" );

      if( ! szStrEnv || szStrEnv[ 0 ] == '\0' )
      {
         if( szStrEnv )
            hb_xfree( szStrEnv );

         szStrEnv = hb_getenv( "CLIPPERCMD" );
      }

      if( szStrEnv )
      {
         char * szSwitch, * szPtr;

         szPtr = szStrEnv;
         while( *szPtr && ! HB_COMP_PARAM->fExit )
         {
            while( *szPtr == ' ' )
               ++szPtr;
            szSwitch = szPtr;
            if( *szSwitch )
            {
               while( *++szPtr )
               {
                  if( *szPtr == ' ' )
                  {
                     *szPtr++ = '\0';
                     break;
                  }
               }
               hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch );
            }
         }
         hb_xfree( szStrEnv );
      }
   }
}
Ejemplo n.º 8
0
static void hb_compChkEnvironVar( HB_COMP_DECL, const char * szSwitch )
{
   if( szSwitch && ! HB_COMP_PARAM->fExit )
   {
      const char * s = szSwitch;

      /* If szSwitch doesn't start with a HB_OSOPTSEP char
       * show an error
       */
      if( ! HB_ISOPTSEP( *s ) )
         hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
      else
      {
         s++;
         switch( *s )
         {
            case 'a':
            case 'A':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->fAutoMemvarAssume = HB_FALSE;
               else
                  HB_COMP_PARAM->fAutoMemvarAssume = HB_TRUE;
               break;

            case 'b':
            case 'B':
            {
               unsigned int i = 0;
               char *szOption = hb_strupr( hb_strdup( s ) );

               while( i < strlen( szOption ) && ! HB_ISOPTSEP( szOption[ i ] ) )
                  i++;
               szOption[ i ] = '\0';

               if( strcmp( szOption, "BUILD" ) == 0 )
                  HB_COMP_PARAM->fBuildInfo = HB_TRUE;
               else
               {
                  if( *( s + 1 ) == '-' )
                     HB_COMP_PARAM->fDebugInfo = HB_FALSE;
                  else
                  {
                     HB_COMP_PARAM->fDebugInfo = HB_TRUE;
                     HB_COMP_PARAM->fLineNumbers = HB_TRUE;
                  }
               }

               hb_xfree( szOption );
               break;
            }

            case 'c':
            case 'C':
            {
               unsigned int i = 0;
               char *szOption = hb_strupr( hb_strdup( s ) );

               while( i < strlen( szOption ) && ! HB_ISOPTSEP( szOption[ i ] ) )
                  i++;
               szOption[ i ] = '\0';

               if( strcmp( szOption, "CREDITS" ) == 0 ||
                   strcmp( szOption, "CREDIT" ) == 0 ||
                   strcmp( szOption, "CREDI" ) == 0 ||
                   strcmp( szOption, "CRED" ) == 0 )
                  HB_COMP_PARAM->fCredits = HB_TRUE;
               else
                  hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, szOption, NULL );

               hb_xfree( szOption );
               break;
            }

            case 'd':
            case 'D':
               /* NOTE: Ignore these -d switches will be processed separately */
               break;

            case 'e':
            case 'E':
               if( *( s + 1 ) == 's' || *( s + 1 ) == 'S' )
               {
                  switch( *( s + 2 ) )
                  {
                     case '\0':
                     case '0':
                        HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DEFAULT;
                        break;

                     case '1':
                        HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_SETEXIT;
                        break;

                     case '2':
                        HB_COMP_PARAM->iExitLevel = HB_EXITLEVEL_DELTARGET;
                        break;

                     default:
                        hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                  }
               }
               else
                  hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );

               break;

            case 'g':
            case 'G':
               switch( *( s + 1 ) )
               {
                  case 'c':
                  case 'C':
                     HB_COMP_PARAM->iLanguage = HB_LANG_C;

                     switch( *( s + 2 ) )
                     {
                        case '3':
                           HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_REALCODE;
                           break;

                        case '2':
                           HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_VERBOSE;
                           break;

                        case '1':
                           HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_NORMAL;
                           break;

                        case '\0':
                        case '0':
                           HB_COMP_PARAM->iGenCOutput = HB_COMPGENC_COMPACT;
                           break;

                        default:
                           hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                     }
                     break;

                  case 'h':
                  case 'H':
                     HB_COMP_PARAM->iLanguage = HB_LANG_PORT_OBJ;
                     break;

                  case 'd':
                  case 'D':
                     if( HB_COMP_PARAM->szDepExt )
                     {
                        hb_xfree( HB_COMP_PARAM->szDepExt );
                        HB_COMP_PARAM->szDepExt = NULL;
                     }
                     if( s[ 2 ] == '-' )
                        HB_COMP_PARAM->iTraceInclude = 0;
                     else if( s[ 2 ] == '.' || s[ 2 ] == '\0' )
                     {
                        HB_COMP_PARAM->iTraceInclude = 2;
                        if( s[ 2 ] != '\0' )
                           HB_COMP_PARAM->szDepExt = hb_strdup( s + 2 );
                     }
                     else
                        hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                     break;

                  case 'e':
                  case 'E':
                     switch( *( s + 2 ) )
                     {
                        case '1':
                           HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_IDE;
                           break;

                        case '\0':
                        case '0':
                           HB_COMP_PARAM->iErrorFmt = HB_ERRORFMT_CLIPPER;
                           break;

                        default:
                           hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                     }
                     break;

                  default:
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL );
                     break;
               }
               break;

               /* NOTE:
                  h or H from HELP or help
                */
            case 'h':
            case 'H':
            case '?':
               break;

               /* NOTE:
                  It already has support for several include files
                */
            case 'i':
            case 'I':
               switch( *( s + 1 ) )
               {
                  case '-':
                     HB_COMP_PARAM->fINCLUDE = HB_FALSE;
                     break;

                  case '+':
                     HB_COMP_PARAM->fINCLUDE = HB_TRUE;
                     break;

                  default:
                     hb_pp_addSearchPath( HB_COMP_PARAM->pLex->pPP, s + 1, HB_FALSE );
               }
               break;

            case 'j':
            case 'J':
               HB_COMP_PARAM->fI18n = HB_TRUE;
               if( s[ 1 ] )
                  HB_COMP_PARAM->pI18nFileName = hb_fsFNameSplit( s + 1 );
               break;

            case 'k':
            case 'K':
            {
               int i = 1;

               while( s[ i ] && ! HB_COMP_PARAM->fExit )
               {
                  switch( s[ i++ ] )
                  {
                     case '?':
                        hb_compPrintLogo( HB_COMP_PARAM );
                        hb_compPrintModes( HB_COMP_PARAM );
                        HB_COMP_PARAM->fLogo = HB_FALSE;
                        HB_COMP_PARAM->fQuiet = HB_TRUE;
                        break;

                     case 'h':
                     case 'H':
                        /* default Harbour mode */
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HARBOUR;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_HARBOUR;
                        break;

                     case 'c':
                     case 'C':
                        /* clear all flags - minimal set of features */
                        HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS;
                        HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP |
                                                    HB_COMPFLAG_MACROTEXT;
                        break;

                     case 'x':
                     case 'X':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_XBASE;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_XBASE;
                        break;

                     case 'i':
                     case 'I':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_HB_INLINE;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_HB_INLINE;
                        break;

                     case 'j':
                     case 'J':
                        if( s[ i ] == '+' )
                        {
                           i++;
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP;
                        }
                        else
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_OPTJUMP;
                        break;

                     case 'm':
                     case 'M':
                        if( s[ i ] == '+' )
                        {
                           i++;
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_MACROTEXT;
                        }
                        else
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACROTEXT;
                        break;

                     case 'd':
                     case 'D':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_MACRODECL;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_MACRODECL;
                        break;

                     case 'r':
                     case 'R':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_RT_MACRO;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_RT_MACRO;
                        break;

                     case 's':
                     case 'S':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_ARRSTR;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_ARRSTR;
                        break;

                     case 'o':
                     case 'O':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_EXTOPT;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_EXTOPT;
                        break;

                     case 'u':
                     case 'U':
                        if( s[ i ] == '-' )
                        {
                           i++;
                           HB_COMP_PARAM->supported &= ~HB_COMPFLAG_USERCP;
                        }
                        else
                           HB_COMP_PARAM->supported |= HB_COMPFLAG_USERCP;
                        break;

                     default:
                        hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
                        break;
                  }
               }
               break;
            }

            case 'l':
            case 'L':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->fLineNumbers = HB_TRUE;
               else
                  HB_COMP_PARAM->fLineNumbers = HB_FALSE;
               break;

            case 'm':
            case 'M':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->fSingleModule = HB_FALSE;
               else
                  HB_COMP_PARAM->fSingleModule = HB_TRUE;
               break;

            case 'n':
            case 'N':
               HB_COMP_PARAM->fNoStartUp = s[ 1 ] == '1';
               switch( s[ 1 ] )
               {
                  case '-':
                     HB_COMP_PARAM->iStartProc = 0;
                     break;
                  case '\0':
                  case '0':
                  case '1':
                     HB_COMP_PARAM->iStartProc = 1;
                     break;
                  case '2':
                     HB_COMP_PARAM->iStartProc = 2;
                     break;
                  default:
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               }
               break;

            case 'o':
            case 'O':
               HB_COMP_PARAM->pOutPath = hb_fsFNameSplit( s + 1 );
               break;

               /* Added for preprocessor needs */
            case 'p':
            case 'P':
               if( s[ 1 ] == '+' && s[ 2 ] == '\0' )
                  HB_COMP_PARAM->fPPT = HB_TRUE;
               else
               {
                  if( HB_COMP_PARAM->pPpoPath )
                  {
                     hb_xfree( HB_COMP_PARAM->pPpoPath );
                     HB_COMP_PARAM->pPpoPath = NULL;
                  }
                  if( s[ 1 ] == '-' && s[ 2 ] == '\0' )
                     HB_COMP_PARAM->fPPO = HB_FALSE;
                  else
                  {
                     if( s[ 1 ] )
                        HB_COMP_PARAM->pPpoPath = hb_fsFNameSplit( s + 1 );
                     HB_COMP_PARAM->fPPO = HB_TRUE;
                  }
               }
               break;

            case 'q':
            case 'Q':
               switch( *( s + 1 ) )
               {
                  case '2':
                     HB_COMP_PARAM->fFullQuiet = HB_TRUE;
                  case '0':
                     HB_COMP_PARAM->fLogo = HB_FALSE;
                  default:
                     HB_COMP_PARAM->fQuiet = HB_TRUE;
               }
               break;

            case 'r':
            case 'R':
               if( *( s + 1 ) == ':' )
               {
                  int iOverflow;
                  int iCycles = ( int ) hb_strValInt( s + 2, &iOverflow );

                  if( ! iOverflow && iCycles > 0 )
                     HB_COMP_PARAM->iMaxTransCycles = iCycles;
               }
               else
               {
                  /* TODO: Implement this switch */
                  hb_notSupportedInfo( HB_COMP_PARAM, s );
               }
               break;

            case 's':
            case 'S':
               switch( *( s + 1 ) )
               {
                  case '\0':
                     HB_COMP_PARAM->iSyntaxCheckOnly = 1;
                     break;
                  case '-':
                     HB_COMP_PARAM->iSyntaxCheckOnly = 0;
                     break;
                  case 'm':
                  case 'M':
                     if( s[ 2 ] == '\0' )
                     {
                        HB_COMP_PARAM->iSyntaxCheckOnly = 2;
                        break;
                     }
                  default:
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               }
               break;

            case 't':
            case 'T':
               /* TODO: Implement this switch */
               hb_notSupportedInfo( HB_COMP_PARAM, s );
               break;

            case 'u':
            case 'U':
               if( ( s[ 1 ] == 'N' || s[ 1 ] == 'n' ) &&
                   ( s[ 2 ] == 'D' || s[ 2 ] == 'd' ) &&
                   ( s[ 3 ] == 'E' || s[ 3 ] == 'e' ) &&
                   ( s[ 4 ] == 'F' || s[ 4 ] == 'f' ) && s[ 5 ] == ':' )
               {
                  /* NOTE: Ignore these -undef: switches (will be processed
                   *       separately) except -undef:.arch.
                   */
                  if( s[ 6 ] == '.' &&
                      ( s[  7 ] == 'A' || s[  7 ] == 'a' ) &&
                      ( s[  8 ] == 'R' || s[  8 ] == 'r' ) &&
                      ( s[  9 ] == 'C' || s[  9 ] == 'c' ) &&
                      ( s[ 10 ] == 'H' || s[ 10 ] == 'h' ) &&
                      s[ 11 ] == '.' )
                  {
                     HB_COMP_PARAM->fNoArchDefs = HB_TRUE;
                  }
                  break;
               }
               /* extended definitions file (-u+<file>) */
               if( s[ 1 ] == '+' )
               {
                  if( s[ 2 ] )
                  {
                     if( HB_COMP_PARAM->iStdChExt == 0 )
                        HB_COMP_PARAM->szStdChExt = ( char ** )
                           hb_xgrab( sizeof( char * ) );
                     else
                        HB_COMP_PARAM->szStdChExt = ( char ** )
                           hb_xrealloc( HB_COMP_PARAM->szStdChExt,
                                        ( HB_COMP_PARAM->iStdChExt + 1 ) *
                                        sizeof( char * ) );
                     HB_COMP_PARAM->szStdChExt[ HB_COMP_PARAM->iStdChExt++ ] =
                           hb_strdup( s + 2 );
                  }
                  else
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               }
               else
               {
                  if( HB_COMP_PARAM->szStdCh )
                     hb_xfree( HB_COMP_PARAM->szStdCh );
                  HB_COMP_PARAM->szStdCh = hb_strdup( s + 1 );
               }
               break;

            case 'v':
            case 'V':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->fForceMemvars = HB_FALSE;
               else
                  HB_COMP_PARAM->fForceMemvars = HB_TRUE;
               break;

            case 'w':
            case 'W':
               HB_COMP_PARAM->iWarnings = 1;
               if( s[ 1 ] )       /* there is -w<0,1,2,3> probably */
               {
                  HB_COMP_PARAM->iWarnings = s[ 1 ] - '0';
                  if( HB_COMP_PARAM->iWarnings < 0 || HB_COMP_PARAM->iWarnings > 3 )
                     hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               }
               break;

            case 'x':
            case 'X':
            {
               unsigned int i = 1;
               while( s[ i ] && ! HB_ISOPTSEP( s[ i ] ) &&
                      i < sizeof( HB_COMP_PARAM->szPrefix ) - 1 )
               {
                  ++i;
               }
               if( i > 1 )
               {
                  memcpy( HB_COMP_PARAM->szPrefix, s + 1, i - 1 );
                  HB_COMP_PARAM->szPrefix[ i - 1 ] = '_';
                  HB_COMP_PARAM->szPrefix[ i ] = '\0';
               }
               else
               {
                  hb_snprintf( HB_COMP_PARAM->szPrefix,
                               sizeof( HB_COMP_PARAM->szPrefix ),
                               "%08lX_", PackDateTime() );
               }
               break;
            }

#ifdef YYDEBUG
            case 'y':
            case 'Y':
               yydebug = HB_TRUE;
               break;
#endif

            case 'z':
            case 'Z':
               if( *( s + 1 ) == '-' )
                  HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS;
               else
                  HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS;
               break;

            default:
               hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL );
               break;
         }
      }
   }
}
Ejemplo n.º 9
0
int main( int argc, char * argv[] )
{
   char * szFile = NULL, * szRuleFile = NULL, * szVerFile = NULL;
   char * szStdCh = NULL, * szLogFile = NULL, * szInclude;
   HB_BOOL fWrite = HB_FALSE, fChgLog = HB_FALSE;
   char * szChangeLogID = NULL, * szLastEntry = NULL;
   int iRevID = 0, iResult = 0, iQuiet = 0, i;
   char * szPPRuleFuncName = NULL;
   PHB_PP_STATE pState;

   pState = hb_pp_new();

   if( argc >= 2 )
   {
      szFile = argv[ 1 ];
      for( i = 2; szFile && i < argc; i++ )
      {
         if( ! HB_ISOPTSEP( argv[ i ][ 0 ] ) )
            szFile = NULL;
         else
         {
            switch( argv[ i ][ 1 ] )
            {
               case 'q':
               case 'Q':
                  if( ! argv[ i ][ 2 ] )
                     iQuiet = 1;
                  else if( argv[ i ][ 2 ] == '-' && ! argv[ i ][ 3 ] )
                     iQuiet = 0;
                  else if( argv[ i ][ 2 ] >= '0' && argv[ i ][ 2 ] <= '2' && ! argv[ i ][ 3 ] )
                     iQuiet = argv[ i ][ 2 ] - '0';
                  else
                     szFile = NULL;
                  break;

               case 'd':
               case 'D':
                  if( ! argv[ i ][ 2 ] )
                     szFile = NULL;
                  else
                  {
                     char * szDefText = hb_strdup( argv[ i ] + 2 ), * szAssign;

                     szAssign = strchr( szDefText, '=' );
                     if( szAssign )
                        *szAssign++ = '\0';
                     hb_pp_addDefine( pState, szDefText, szAssign );
                     hb_xfree( szDefText );
                  }
                  break;

               case 'e':
               case 'E':
                  if( argv[ i ][ 2 ] )
                     szPPRuleFuncName = argv[ i ] + 2;
                  else
                     szPPRuleFuncName = NULL;
                  break;

               case 'w':
               case 'W':
                  if( argv[ i ][ 2 ] )
                     szFile = NULL;
                  else
                     fWrite = HB_TRUE;
                  break;

               case 'c':
               case 'C':
                  fChgLog = HB_TRUE;
                  if( argv[ i ][ 2 ] )
                     szLogFile = argv[ i ] + 2;
                  break;

               case 'i':
               case 'I':
                  if( argv[ i ][ 2 ] )
                     hb_pp_addSearchPath( pState, argv[ i ] + 2, HB_FALSE );
                  else
                     szFile = NULL;
                  break;

               case 'o':
               case 'O':
                  if( argv[ i ][ 2 ] )
                     szRuleFile = argv[ i ] + 2;
                  else
                     szFile = NULL;
                  break;

               case 'v':
               case 'V':
                  if( argv[ i ][ 2 ] )
                     szVerFile = argv[ i ] + 2;
                  else
                     szFile = NULL;
                  break;

               case 'u':
               case 'U':
                  if( argv[ i ][ 2 ] )
                     szStdCh = argv[ i ] + 2;
                  else
                     szStdCh = NULL;
                  break;

               default:
                  szFile = NULL;
                  break;
            }
         }
      }
   }

   if( iQuiet < 2 )
   {
      printf( "Harbour Preprocessor %d.%d.%d%s\n",
              HB_VER_MAJOR, HB_VER_MINOR, HB_VER_RELEASE, HB_VER_STATUS );
      printf( "Copyright (c) 1999-2014, http://harbour-project.org/\n" );
   }

   if( szFile )
   {
      if( ! szRuleFile && ! szVerFile )
         fWrite = HB_TRUE;

      hb_pp_init( pState, iQuiet != 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL );

      szInclude = hb_getenv( "INCLUDE" );
      if( szInclude )
      {
         if( szInclude[ 0 ] )
            hb_pp_addSearchPath( pState, szInclude, HB_FALSE );
         hb_xfree( szInclude );
      }

      if( szStdCh )
         hb_pp_readRules( pState, szStdCh );

      if( hb_pp_inFile( pState, szFile, HB_TRUE, NULL, HB_TRUE ) )
      {
         if( fWrite )
         {
            char szFileName[ HB_PATH_MAX ];
            PHB_FNAME pFileName;

            pFileName = hb_fsFNameSplit( szFile );
            pFileName->szExtension = ".ppo";
            hb_fsFNameMerge( szFileName, pFileName );
            hb_xfree( pFileName );

            hb_pp_outFile( pState, szFileName, NULL );
         }

         if( fChgLog )
            iResult = hb_pp_parseChangelog( pState, szLogFile, iQuiet,
                                            &iRevID, &szChangeLogID, &szLastEntry );

         if( iResult == 0 )
            iResult = hb_pp_preprocesfile( pState, szRuleFile, szPPRuleFuncName );

         if( iResult == 0 && szVerFile )
            iResult = hb_pp_generateVerInfo( szVerFile, iRevID,
                                             szChangeLogID, szLastEntry );
         if( iResult == 0 && hb_pp_errorCount( pState ) > 0 )
            iResult = 1;
      }
      else
         iResult = 1;
   }
   else
   {
      hb_pp_usage( argv[ 0 ] );
      iResult = 1;
   }

   if( szChangeLogID )
      hb_xfree( szChangeLogID );
   if( szLastEntry )
      hb_xfree( szLastEntry );

   hb_pp_free( pState );

   return iResult;
}
Ejemplo n.º 10
0
void hb_compChkFileSwitches( int argc, char * argv[] )
{
   int i, n;

   for( i = 1; i < argc; ++i )
   {
      if( HB_ISOPTSEP( argv[ i ][ 0 ] ) && argv[ i ][ 1 ] == 'f' )
      {
         n = 0;
         switch( argv[ i ][ 2 ] )
         {
            case 'n':
               if( ! argv[ i ][ 3 ] )
               {
                  s_iFileCase = HB_SET_CASE_MIXED;
                  n = 3;
               }
               else if( argv[ i ][ 3 ] == ':' )
               {
                  if( argv[ i ][ 4 ] == 'u' )
                  {
                     s_iFileCase = HB_SET_CASE_UPPER;
                     n = 5;
                  }
                  else if( argv[ i ][ 4 ] == 'l' )
                  {
                     s_iFileCase = HB_SET_CASE_LOWER;
                     n = 5;
                  }
               }
               else if( argv[ i ][ 3 ] == '-' )
               {
                  s_iFileCase = HB_SET_CASE_MIXED;
                  n = 4;
               }
               break;

            case 'd':
               if( ! argv[ i ][ 3 ] )
               {
                  s_iDirCase = HB_SET_CASE_MIXED;
                  n = 3;
               }
               else if( argv[ i ][ 3 ] == ':' )
               {
                  if( argv[ i ][ 4 ] == 'u' )
                  {
                     s_iDirCase = HB_SET_CASE_UPPER;
                     n = 5;
                  }
                  else if( argv[ i ][ 4 ] == 'l' )
                  {
                     s_iDirCase = HB_SET_CASE_LOWER;
                     n = 5;
                  }
               }
               else if( argv[ i ][ 3 ] == '-' )
               {
                  s_iDirCase = HB_SET_CASE_MIXED;
                  n = 4;
               }
               break;

            case 'p':
               if( ! argv[ i ][ 3 ] )
               {
                  s_cDirSep = HB_OS_PATH_DELIM_CHR;
                  n = 3;
               }
               else if( argv[ i ][ 3 ] == '-' )
               {
                  s_cDirSep = HB_OS_PATH_DELIM_CHR;
                  n = 4;
               }
               else if( argv[ i ][ 3 ] == ':' && argv[ i ][ 4 ] )
               {
                  s_cDirSep = argv[ i ][ 4 ];
                  n = 5;
               }
               break;

            case 's':
               if( ! argv[ i ][ 3 ] )
               {
                  s_fFnTrim = HB_TRUE;
                  n = 3;
               }
               else if( argv[ i ][ 3 ] == '-' )
               {
                  s_fFnTrim = HB_FALSE;
                  n = 4;
               }
               break;
         }
         if( n )
         {
            argv[ i ] += n;
            if( argv[ i ][ 0 ] )
               --i;
            else
               argv[ i ] = ( char * ) "-";
         }
      }
   }
}