示例#1
0
void hb_compI18nAddPlural( HB_COMP_DECL, const char ** szTexts, HB_ULONG ulCount, const char * szContext, const char * szModule, HB_UINT uiLine )
{
   PHB_I18NSTRING pString;

   pString = hb_compI18nAddSingle( HB_COMP_PARAM, szTexts[ 0 ], szContext, szModule, uiLine );
   if( ulCount == 1 )
   {
      /* set the same string as plural form to mark it as plural text */
      if( ! pString->uiPlurals )
      {
         pString->szPlurals[ 0 ] = pString->szText;
         pString->uiPlurals = 1;
      }
   }
   else
   {
      HB_ULONG ul, ulPlural;

      for( ul = 1; ul < ulCount && pString->uiPlurals < HB_I18N_PLURAL_MAX; ++ul )
      {
         const char * szText = hb_compIdentifierNew( HB_COMP_PARAM, szTexts[ ul ], HB_IDENT_COPY );

         for( ulPlural = 0; ulPlural < pString->uiPlurals; ++ulPlural )
         {
            if( pString->szPlurals[ ulPlural ] == szText )
            {
               szText = NULL;
               break;
            }
         }
         if( szText )
            pString->szPlurals[ pString->uiPlurals++ ] = szText;
      }
   }
}
示例#2
0
文件: ppcomp.c 项目: Andygon/core
static void hb_pp_hb_inLine( void * cargo, char * szFunc,
                             char * pBuffer, HB_SIZE nSize, int iLine )
{
   HB_COMP_DECL = ( PHB_COMP ) cargo;

   if( HB_COMP_PARAM->iLanguage != HB_LANG_C )
   {
      int iCurrLine = HB_COMP_PARAM->currLine;
      HB_COMP_PARAM->currLine = iLine;
      hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_REQUIRES_C, NULL, NULL );
      HB_COMP_PARAM->fError = HB_FALSE;
      HB_COMP_PARAM->currLine = iCurrLine;
   }
   else
   {
      PHB_HINLINE pInline = hb_compInlineAdd( HB_COMP_PARAM,
         hb_compIdentifierNew( HB_COMP_PARAM, szFunc, HB_IDENT_COPY ), iLine );
      pInline->pCode = ( HB_BYTE * ) hb_xgrab( nSize + 1 );
      memcpy( pInline->pCode, pBuffer, nSize );
      pInline->pCode[ nSize ] = '\0';
      pInline->nPCodeSize = nSize;
   }
}
示例#3
0
static PHB_I18NSTRING hb_compI18nAddSingle( HB_COMP_DECL, const char * szText, const char * szContext,
                                            const char * szModule, HB_UINT uiLine )
{
   PHB_I18NTABLE  pI18n;
   PHB_I18NSTRING pString;
   HB_UINT        uiLeft, uiRight, uiMiddle;
   int            iCompare;

   if( ! HB_COMP_PARAM->pI18n )
      HB_COMP_PARAM->pI18n = hb_compI18nCreate();
   pI18n = HB_COMP_PARAM->pI18n;

   szText = hb_compIdentifierNew( HB_COMP_PARAM, szText, HB_IDENT_COPY );
   if( szContext )
      szContext = hb_compIdentifierNew( HB_COMP_PARAM, szContext, HB_IDENT_COPY );

   if( pI18n->uiCount >= pI18n->uiAllocated )
   {
      if( pI18n->pString )
      {
         pI18n->uiAllocated += 32;
         pI18n->pString = ( PHB_I18NSTRING ) hb_xrealloc( pI18n->pString, sizeof( HB_I18NSTRING )
                                                                          * pI18n->uiAllocated );
      }
      else
      {
         pI18n->pString = ( PHB_I18NSTRING ) hb_xgrab( sizeof( HB_I18NSTRING ) * 32 );
         pI18n->uiAllocated = 32;
      }
   }

   uiLeft = 0;
   uiRight = pI18n->uiCount;

   while( uiLeft < uiRight )
   {
      uiMiddle = ( uiLeft + uiRight ) >> 1;

      iCompare = hb_compI18nCompare( &pI18n->pString[ uiMiddle ], szText, szContext );

      if( iCompare == 0 )
      {
         pString = &pI18n->pString[ uiMiddle ];

         if( pString->uiPosCount )
         {
            pString->pPosLst = ( PHB_I18NPOS ) hb_xrealloc( pString->pPosLst, ( pString->uiPosCount + 1 ) * sizeof( HB_I18NPOS ) );
            pString->pPosLst[ pString->uiPosCount ].uiLine = uiLine;
            pString->pPosLst[ pString->uiPosCount ].szFile = szModule;
            pString->uiPosCount++;
         }
         else
         {
            pString->pPosLst = ( PHB_I18NPOS ) hb_xgrab( sizeof( HB_I18NPOS ) );
            pString->pPosLst[ 0 ].uiLine = uiLine;
            pString->pPosLst[ 0 ].szFile = szModule;
            pString->uiPosCount = 1;
         }
         return pString;
      }
      else if( iCompare < 0 )
         uiLeft = uiMiddle + 1;
      else
         uiRight = uiMiddle;
   }

   memmove( &pI18n->pString[ uiLeft + 1 ], &pI18n->pString[ uiLeft ],
            ( pI18n->uiCount - uiLeft ) * sizeof( HB_I18NSTRING ) );

   pString = &pI18n->pString[ uiLeft ];
   pString->szText = szText;
   pString->szContext = szContext;
   pString->pPos.uiLine = uiLine;
   pString->pPos.szFile = szModule;
   pString->uiPosCount = 0;
   pString->uiPlurals = 0;

   pI18n->uiCount++;

   return pString;
}