HB_BOOL hb_cdpCharCaseEq( PHB_CODEPAGE cdp, const char * szText1, HB_SIZE nLen1, HB_SIZE * pnPos1, const char * szText2, HB_SIZE nLen2, HB_SIZE * pnPos2 ) { HB_SYMBOL_UNUSED( cdp ); if( *pnPos1 < nLen1 && *pnPos2 < nLen2 ) { HB_UCHAR uc1 = szText1[ ( *pnPos1 )++ ], uc2 = szText2[ ( *pnPos2 )++ ]; return HB_TOUPPER( uc1 ) == HB_TOUPPER( uc2 ); } else return HB_FALSE; }
static void hb_cp_init( PHB_CODEPAGE cdp ) { HB_UCHAR * flags, * upper, * lower; int i; cdp->buffer = ( HB_UCHAR * ) hb_xgrab( 0x300 ); cdp->flags = flags = ( HB_UCHAR * ) cdp->buffer; cdp->upper = upper = ( HB_UCHAR * ) cdp->buffer + 0x100; cdp->lower = lower = ( HB_UCHAR * ) cdp->buffer + 0x200; for( i = 0; i < 0x100; ++i ) { flags[ i ] = 0; if( HB_ISDIGIT( i ) ) flags[ i ] |= HB_CDP_DIGIT; if( HB_ISALPHA( i ) ) flags[ i ] |= HB_CDP_ALPHA; if( HB_ISUPPER( i ) ) flags[ i ] |= HB_CDP_UPPER; if( HB_ISLOWER( i ) ) flags[ i ] |= HB_CDP_LOWER; upper[ i ] = ( HB_UCHAR ) HB_TOUPPER( i ); lower[ i ] = ( HB_UCHAR ) HB_TOLOWER( i ); } }
HB_FATTR hb_fsAttrEncode( const char * szAttr ) { const char * pos = szAttr; char ch; HB_FATTR nAttr = 0; HB_TRACE( HB_TR_DEBUG, ( "hb_fsAttrEncode(%p)", szAttr ) ); while( ( ch = ( char ) HB_TOUPPER( *pos ) ) != '\0' ) { switch( ch ) { case 'R': nAttr |= HB_FA_READONLY; break; case 'H': nAttr |= HB_FA_HIDDEN; break; case 'S': nAttr |= HB_FA_SYSTEM; break; case 'A': nAttr |= HB_FA_ARCHIVE; break; case 'D': nAttr |= HB_FA_DIRECTORY; break; case 'V': nAttr |= HB_FA_LABEL; break; case 'L': nAttr |= HB_FA_LINK; break; } pos++; } return nAttr; }
/* converts iChar to upper case */ int hb_charUpper( int iChar ) { #ifndef HB_CDP_SUPPORT_OFF PHB_CODEPAGE cdp = hb_cdppage(); if( cdp && cdp->nChars ) return ( unsigned char ) cdp->s_upper[ (unsigned char) iChar ]; else #endif return HB_TOUPPER( iChar ); }
static HB_BOOL s_fileAccept( PHB_FILE_FUNCS pFuncs, const char * pszFileName ) { HB_SYMBOL_UNUSED( pFuncs ); if( HB_TOUPPER( pszFileName[ 0 ] ) == 'C' && HB_TOUPPER( pszFileName[ 1 ] ) == 'O' && HB_TOUPPER( pszFileName[ 2 ] ) == 'M' ) { if( pszFileName[ 3 ] == '$' ) return strchr( pszFileName + 4, ':' ) != NULL; else if( pszFileName[ 3 ] >= '1' && pszFileName[ 3 ] <= '9' ) { pszFileName += 4; while( HB_ISDIGIT( *pszFileName ) ) ++pszFileName; return *pszFileName == ':'; } } return HB_FALSE; }
/* * Harbour Project source code: * String matching functions * * Copyright 1999-2001 Viktor Szakats <*****@*****.**> * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). * * As a special exception, the Harbour Project gives permission for * additional uses of the text contained in its release of Harbour. * * The exception is that, if you link the Harbour libraries with other * files to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public License. * Your use of that executable is in no way restricted on account of * linking the Harbour library code into it. * * This exception does not however invalidate any other reasons why * the executable file might be covered by the GNU General Public License. * * This exception applies only to the code released by the Harbour * Project under the name Harbour. If you copy code from other * Harbour Project or Free Software Foundation releases into a copy of * Harbour, as the General Public License permits, the exception does * not apply to the code that you add in this way. To avoid misleading * anyone as to the status of such modified files, you must delete * this exception notice from them. * * If you write modifications of your own for Harbour, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. * */ #include <ctype.h> #include "hbapi.h" #include "hbregex.h" #if defined( HB_OS_UNIX ) && !defined( __WATCOMC__ ) # include <fnmatch.h> #endif #if 0 /* disabled to eliminate warnings */ static BOOL hb_strMatchDOS( const char * pszString, const char * pszMask ) { HB_TRACE(HB_TR_DEBUG, ("hb_strMatchDOS(%s, %s)", pszString, pszMask)); while( *pszMask != '\0' && *pszString != '\0' ) { if( *pszMask == '*' ) { while( *pszMask == '*' ) { pszMask++; } if( *pszMask == '\0' ) { return TRUE; } else if( *pszMask == '?' ) { pszString++; } else { while( HB_TOUPPER( *pszString ) != HB_TOUPPER( *pszMask ) ) { if( *( ++pszString ) == '\0' ) { return FALSE; } } while( HB_TOUPPER( *pszString ) == HB_TOUPPER( *pszMask ) ) { if( *( ++pszString ) == '\0' ) { break; } } pszMask++; } } else if( HB_TOUPPER( *pszMask ) != HB_TOUPPER( *pszString ) && *pszMask != '?' ) { return FALSE; } else { pszMask++; pszString++; } } return ! ( ( *pszMask != '\0' && *pszString == '\0' && *pszMask != '*') || ( *pszMask == '\0' && *pszString != '\0' ) ); }
/* converts szText to upper case. Does not create a new string! */ char * hb_strUpper( char * szText, ULONG ulLen ) { HB_TRACE(HB_TR_DEBUG, ("hb_strUpper(%s, %lu)", szText, ulLen)); { ULONG i; #ifndef HB_CDP_SUPPORT_OFF PHB_CODEPAGE cdp = hb_cdppage(); if( cdp && cdp->nChars ) for( i = 0; i < ulLen; i++ ) szText[ i ] = ( char ) cdp->s_upper[ ( UCHAR ) szText[ i ] ]; else #endif for( i = 0; i < ulLen; i++ ) szText[ i ] = HB_TOUPPER( ( BYTE ) szText[ i ] ); } return szText; }
/* * Find a field index by name */ HB_USHORT hb_rddFieldIndex( AREAP pArea, const char * szName ) { HB_TRACE( HB_TR_DEBUG, ( "hb_rddFieldIndex(%p, %s)", pArea, szName ) ); while( HB_ISSPACE( *szName ) ) ++szName; if( *szName ) { HB_SIZE nLen = strlen( szName ); while( HB_ISSPACE( szName[ nLen - 1 ] ) ) --nLen; if( nLen <= HB_SYMBOL_NAME_LEN ) { char szFieldName[ HB_SYMBOL_NAME_LEN + 1 ]; PHB_DYNS pDynSym; szFieldName[ nLen ] = '\0'; while( nLen-- ) szFieldName[ nLen ] = HB_TOUPPER( szName[ nLen ] ); pDynSym = hb_dynsymFind( szFieldName ); if( pDynSym ) { LPFIELD pField = pArea->lpFields; HB_USHORT uiCount = 0; while( pField ) { ++uiCount; if( pDynSym == ( PHB_DYNS ) pField->sym ) return uiCount; pField = pField->lpfNext; } } } } return 0; }
static int s_filePortParams( const char * pszName, int * piTimeout, int * piBaud, int * piParity, int * piSize, int * piStop, int * piFlow ) { int iPort = 0, iLen, iValue; *piTimeout = -1; *piBaud = *piParity = *piSize = *piStop = *piFlow = 0; pszName += 3; if( *pszName == '$' ) { const char * pszParams = strchr( pszName, ':' ); if( pszParams != NULL && pszParams - pszName > 1 ) { char * pszPort = hb_strndup( pszName + 1, pszParams - pszName - 1 ); iPort = hb_comFindPort( pszPort, HB_TRUE ); hb_xfree( pszPort ); pszName = pszParams; } } else { while( HB_ISDIGIT( *pszName ) ) iPort = iPort * 10 + ( *pszName++ - '0' ); } while( iPort > 0 && *pszName ) { if( HB_ISDIGIT( *pszName ) ) { iValue = s_fileGetValue( pszName, &iLen ); if( iLen == 1 ) { if( iValue >= 1 && iValue <= 2 && *piStop == 0 ) *piStop = iValue; else if( iValue >= 5 && iValue <= 8 && *piSize == 0 ) *piSize = iValue; else iPort = -1; } else if( iLen == 2 && *piStop == 0 && *piSize == 0 ) { if( pszName[ 0 ] >= '1' && pszName[ 0 ] <= '2' && pszName[ 1 ] >= '5' && pszName[ 1 ] <= '8' ) { *piStop = pszName[ 0 ] - '0'; *piSize = pszName[ 1 ] - '0'; } else if( pszName[ 0 ] >= '5' && pszName[ 0 ] <= '8' && pszName[ 1 ] >= '1' && pszName[ 1 ] <= '2' ) { *piStop = pszName[ 1 ] - '0'; *piSize = pszName[ 0 ] - '0'; } else if( *piBaud ) iPort = -1; else *piBaud = iValue; } else if( *piBaud ) iPort = -1; else *piBaud = iValue; pszName += iLen; } else if( HB_ISALPHA( *pszName ) ) { if( hb_strnicmp( pszName, "RTS", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_IRTSCTS; pszName += 3; } else if( hb_strnicmp( pszName, "CTS", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_ORTSCTS; pszName += 3; } else if( hb_strnicmp( pszName, "DTR", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_IDTRDSR; pszName += 3; } else if( hb_strnicmp( pszName, "DSR", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_ODTRDSR; pszName += 3; } else if( hb_strnicmp( pszName, "DCD", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_DCD; pszName += 3; } else if( hb_strnicmp( pszName, "XOFF", 4 ) == 0 ) { *piFlow |= HB_COM_FLOW_XOFF; pszName += 4; } else if( hb_strnicmp( pszName, "XON", 3 ) == 0 ) { *piFlow |= HB_COM_FLOW_XON; pszName += 3; } else if( *piParity == 0 && ! HB_ISALPHA( pszName[ 1 ] ) ) { switch( *pszName ) { case 'N': case 'n': case 'E': case 'e': case 'O': case 'o': case 'S': case 's': case 'M': case 'm': *piParity = HB_TOUPPER( *pszName ); pszName++; break; default: iPort = -1; break; } } else iPort = -1; } else if( *pszName == ':' || *pszName == ',' || *pszName == ' ' ) pszName++; else iPort = -1; } if( *piBaud == 0 ) *piBaud = 9600; if( *piParity == 0 ) *piParity = 'N'; if( *piSize == 0 ) *piSize = 8; if( *piStop == 0 ) *piStop = 1; return iPort; }
int hb_charUpper( int iChar ) { return HB_TOUPPER( iChar ); }
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 ""; }
char * hb_dateFormat( const char * szDate, char * szFormattedDate, const char * szDateFormat ) { /* * NOTE: szFormattedDate must point to a buffer of at least 11 bytes. * szDateFormat must point to a buffer holding the date format to use. */ int format_count, digit_count, size; HB_TRACE( HB_TR_DEBUG, ( "hb_dateFormat(%s, %p, %s)", szDate, szFormattedDate, szDateFormat ) ); /* * Determine the maximum size of the formatted date string */ size = ( int ) strlen( szDateFormat ); if( size > 10 ) size = 10; if( szDate && strlen( szDate ) == 8 ) /* A valid date is always 8 characters */ { const char * szPtr; HB_BOOL used_d, used_m, used_y; format_count = 0; used_d = used_m = used_y = HB_FALSE; szPtr = szDateFormat; while( format_count < size ) { int digit = HB_TOUPPER( ( HB_UCHAR ) *szPtr ); szPtr++; digit_count = 1; while( HB_TOUPPER( ( HB_UCHAR ) *szPtr ) == digit && format_count < size ) { szPtr++; if( format_count + digit_count < size ) digit_count++; } switch( digit ) { case 'D': switch( digit_count ) { case 4: if( ! used_d && format_count < size ) { /* szFormattedDate[ format_count++ ] = '0'; */ szFormattedDate[ format_count++ ] = szDate[ 6 ]; digit_count--; } case 3: if( ! used_d && format_count < size ) { /* szFormattedDate[ format_count++ ] = '0'; */ szFormattedDate[ format_count++ ] = szDate[ 6 ]; digit_count--; } case 2: if( ! used_d && format_count < size ) { szFormattedDate[ format_count++ ] = szDate[ 6 ]; digit_count--; } default: if( ! used_d && format_count < size ) { szFormattedDate[ format_count++ ] = szDate[ 7 ]; digit_count--; } while( digit_count-- > 0 && format_count < size ) szFormattedDate[ format_count++ ] = ( char ) digit; } used_d = HB_TRUE; break; case 'M': switch( digit_count ) { case 4: if( ! used_m && format_count < size ) { /* szFormattedDate[ format_count++ ] = '0'; */ szFormattedDate[ format_count++ ] = szDate[ 4 ]; digit_count--; } case 3: if( ! used_m && format_count < size ) { /* szFormattedDate[ format_count++ ] = '0'; */ szFormattedDate[ format_count++ ] = szDate[ 4 ]; digit_count--; } case 2: if( ! used_m && format_count < size ) { szFormattedDate[ format_count++ ] = szDate[ 4 ]; digit_count--; } default: if( ! used_m && format_count < size ) { szFormattedDate[ format_count++ ] = szDate[ 5 ]; digit_count--; } while( digit_count-- > 0 && format_count < size ) szFormattedDate[ format_count++ ] = ( char ) digit; } used_m = HB_TRUE; break; case 'Y': switch( digit_count ) { case 4: if( ! used_y && format_count < size ) { szFormattedDate[ format_count++ ] = szDate[ 0 ]; digit_count--; } case 3: if( ! used_y && format_count < size ) { szFormattedDate[ format_count++ ] = szDate[ 1 ]; digit_count--; } case 2: if( ! used_y && format_count < size ) { szFormattedDate[ format_count++ ] = szDate[ 2 ]; digit_count--; } default: if( ! used_y && format_count < size ) { szFormattedDate[ format_count++ ] = szDate[ 3 ]; digit_count--; } while( digit_count-- > 0 && format_count < size ) szFormattedDate[ format_count++ ] = ( char ) digit; } used_y = HB_TRUE; break; default: while( digit_count-- > 0 && format_count < size ) szFormattedDate[ format_count++ ] = ( char ) digit; } } } else { /* Not a valid date string, so return a blank date with separators */ format_count = size; /* size is either 8 or 10 */ hb_strncpy( szFormattedDate, szDateFormat, size ); for( digit_count = 0; digit_count < size; digit_count++ ) { switch( szFormattedDate[ digit_count ] ) { case 'D': case 'd': case 'M': case 'm': case 'Y': case 'y': szFormattedDate[ digit_count ] = ' '; } } } szFormattedDate[ format_count ] = '\0'; return szFormattedDate; }
/* time modifiers: * H - hour * M - minutes * S - seconds * F - fractional part of seconds * P - PM/AM marker * maximal size of time pattern: * 16 for "hh:mm:ss:ffff pp" * always safe buffer size is 17 (+1 for 0) */ char * hb_timeFormat( char * szBuffer, const char * szTimeFormat, long lMilliSec ) { char * szTimeBuffer; int iHour, iMinutes, iSeconds, iMSec, iPM, i12; int size, i, value, digits, skip; HB_TRACE( HB_TR_DEBUG, ( "hb_timeFormat(%p, %s, %ld)", szBuffer, szTimeFormat, lMilliSec ) ); hb_timeDecode( lMilliSec, &iHour, &iMinutes, &iSeconds, &iMSec ); szTimeBuffer = szBuffer; size = ( int ) hb_strnlen( szTimeFormat, 16 ); iPM = i12 = 0; for( i = 0; i < size; ++i ) { if( HB_TOUPPER( szTimeFormat[ i ] ) == 'P' ) { if( iHour >= 12 ) { iPM = 1; iHour -= 12; } if( iHour == 0 ) iHour += 12; if( iHour < 10 ) i12 = 1; break; } } i = 0; while( i < size ) { int count = -i; int ch = HB_TOUPPER( szTimeFormat[ i ] ); ++i; while( ch == HB_TOUPPER( szTimeFormat[ i ] ) && i < size ) ++i; count += i; switch( ch ) { case 'H': value = iHour; if( count == 2 && value >= 0 ) { if( i12 ) { *szTimeBuffer++ = ' '; --count; } digits = count; } else digits = 1; iHour = -1; break; case 'M': value = iMinutes; iMinutes = -1; digits = count > 2 ? 1 : count; break; case 'S': value = iSeconds; iSeconds = -1; digits = count > 2 ? 1 : count; break; case 'F': value = iMSec; iMSec = -1; digits = count > 4 ? 1 : count; switch( digits ) { case 4: value *= 10; break; case 2: value = ( value + 5 ) / 10; break; case 1: value = ( value + 50 ) / 100; break; } break; case 'P': if( iPM >= 0 ) { *szTimeBuffer++ = iPM ? 'P' : 'A'; if( --count ) { *szTimeBuffer++ = 'M'; --count; } iPM = -1; } default: digits = value = 0; } if( digits && value >= 0 ) { skip = digits; count -= digits; do { szTimeBuffer[ --digits ] = ( char ) ( '0' + value % 10 ); value /= 10; } while( digits ); szTimeBuffer += skip; } while( count-- ) *szTimeBuffer++ = ( char ) ch; } *szTimeBuffer = '\0'; return szBuffer; }