コード例 #1
0
ファイル: fx_basic_buffer.cpp プロジェクト: 151706061/PDFium
CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (int i)
{
    char buf[32];
    FXSYS_itoa(i, buf, 10);
    AppendBlock(buf, (FX_STRSIZE)FXSYS_strlen(buf));
    return *this;
}
コード例 #2
0
TEST(fxcrt, EmptyByteString) {
  CFX_ByteString empty_str;
  EXPECT_TRUE(empty_str.IsEmpty());
  EXPECT_EQ(0, empty_str.GetLength());
  const FX_CHAR* cstr = empty_str.c_str();
  EXPECT_EQ(0, FXSYS_strlen(cstr));
}
コード例 #3
0
void CFX_ByteString::FormatV(const FX_CHAR* pFormat, va_list argList) {
  va_list argListSave;
#if defined(__ARMCC_VERSION) ||                                              \
    (!defined(_MSC_VER) && (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || \
                            _FX_CPU_ == _FX_ARM64_)) ||                      \
    defined(__native_client__)
  va_copy(argListSave, argList);
#else
  argListSave = argList;
#endif
  int nMaxLen = 0;
  for (const FX_CHAR* pStr = pFormat; *pStr != 0; pStr++) {
    if (*pStr != '%' || *(pStr = pStr + 1) == '%') {
      nMaxLen += FXSYS_strlen(pStr);
      continue;
    }
    int nItemLen = 0;
    int nWidth = 0;
    for (; *pStr != 0; pStr++) {
      if (*pStr == '#') {
        nMaxLen += 2;
      } else if (*pStr == '*') {
        nWidth = va_arg(argList, int);
      } else if (*pStr != '-' && *pStr != '+' && *pStr != '0' && *pStr != ' ') {
        break;
      }
    }
コード例 #4
0
CFX_ByteString::CFX_ByteString(const FX_CHAR* pStr, FX_STRSIZE nLen) {
  if (nLen < 0)
    nLen = pStr ? FXSYS_strlen(pStr) : 0;

  if (nLen)
    m_pData.Reset(StringData::Create(pStr, nLen));
}
コード例 #5
0
ファイル: fx_basic_buffer.cpp プロジェクト: abbro-ca/pdfium
CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (FX_DWORD i)
{
    char buf[32];
    FXSYS_itoa(i, buf, 10);
    AppendBlock(buf, FXSYS_strlen(buf));
    return *this;
}
コード例 #6
0
ファイル: fx_codepage.cpp プロジェクト: primiano/pdfium-merge
FX_WORD FX_GetCodePageFromStringA(const FX_CHAR* pStr, int32_t iLength) {
  FXSYS_assert(pStr != NULL);
  if (iLength < 0) {
    iLength = FXSYS_strlen(pStr);
  }
  if (iLength == 0) {
    return 0xFFFF;
  }
  uint32_t uHash = FX_HashCode_String_GetA(pStr, iLength, TRUE);
  int32_t iStart = 0, iMid;
  int32_t iEnd = sizeof(g_FXCPHashTable) / sizeof(FX_STR2CPHASH) - 1;
  FXSYS_assert(iEnd >= 0);
  do {
    iMid = (iStart + iEnd) / 2;
    const FX_STR2CPHASH& cp = g_FXCPHashTable[iMid];
    if (uHash == cp.uHash) {
      return (FX_WORD)cp.uCodePage;
    } else if (uHash < cp.uHash) {
      iEnd = iMid - 1;
    } else {
      iStart = iMid + 1;
    }
  } while (iStart <= iEnd);
  return 0xFFFF;
}
コード例 #7
0
const CFX_ByteString& CFX_ByteString::operator=(const FX_CHAR* pStr) {
  if (!pStr || !pStr[0])
    clear();
  else
    AssignCopy(pStr, FXSYS_strlen(pStr));

  return *this;
}
コード例 #8
0
static FX_WORD FX_GetCharsetFromLang(const FX_CHAR* pLang, int32_t iLength) {
  FXSYS_assert(pLang);
  if (iLength < 0) {
    iLength = FXSYS_strlen(pLang);
  }
  uint32_t uHash = FX_GetLangHashCode(pLang);
  return FX_GetCsFromLangCode(uHash);
}
コード例 #9
0
static FX_WORD FX_GetCharsetFromLang(FX_LPCSTR pLang, FX_INT32 iLength)
{
    FXSYS_assert(pLang);
    if (iLength < 0) {
        iLength = FXSYS_strlen(pLang);
    }
    FX_UINT32 uHash = FX_GetLangHashCode(pLang);
    return FX_GetCsFromLangCode(uHash);
}
コード例 #10
0
FX_DWORD FXSYS_GetFullPathName(FX_LPCSTR filename, FX_DWORD buflen, FX_LPSTR buf, FX_LPSTR* filepart)
{
    int srclen = FXSYS_strlen(filename);
    if (buf == NULL || (int)buflen < srclen + 1) {
        return srclen + 1;
    }
    FXSYS_strcpy(buf, filename);
    return srclen;
}
コード例 #11
0
bool CFX_ByteString::operator==(const char* ptr) const {
  if (!m_pData)
    return !ptr || !ptr[0];

  if (!ptr)
    return m_pData->m_nDataLength == 0;

  return FXSYS_strlen(ptr) == m_pData->m_nDataLength &&
         FXSYS_memcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
コード例 #12
0
uint32_t FX_GetLangHashCode(const FX_CHAR* pStr) {
  FXSYS_assert(pStr);
  int32_t iLength = FXSYS_strlen(pStr);
  const FX_CHAR* pStrEnd = pStr + iLength;
  uint32_t uHashCode = 0;
  while (pStr < pStrEnd) {
    uHashCode = 31 * uHashCode + tolower(*pStr++);
  }
  return uHashCode;
}
コード例 #13
0
FX_DWORD FXSYS_GetFullPathName(const FX_CHAR* filename,
                               FX_DWORD buflen,
                               FX_CHAR* buf,
                               FX_CHAR** filepart) {
  int srclen = FXSYS_strlen(filename);
  if (buf == NULL || (int)buflen < srclen + 1) {
    return srclen + 1;
  }
  FXSYS_strcpy(buf, filename);
  return srclen;
}
コード例 #14
0
FX_UINT32 FX_GetLangHashCode( FX_LPCSTR pStr)
{
    FXSYS_assert( pStr != NULL);
    FX_INT32 iLength = FXSYS_strlen(pStr);
    FX_LPCSTR pStrEnd = pStr + iLength;
    FX_UINT32 uHashCode = 0;
    while ( pStr < pStrEnd) {
        uHashCode = 31 * uHashCode + tolower(*pStr++);
    }
    return uHashCode;
}
コード例 #15
0
void CPSOutput::OutputPS(const FX_CHAR* string, int len) {
  if (len < 0) {
    len = (int)FXSYS_strlen(string);
  }
  int sent_len = 0;
  while (len > 0) {
    int send_len = len > 1024 ? 1024 : len;
    *(FX_WORD*)m_pBuf = send_len;
    FXSYS_memcpy(m_pBuf + 2, string + sent_len, send_len);
    ExtEscape(m_hDC, PASSTHROUGH, send_len + 2, m_pBuf, 0, NULL);
    sent_len += send_len;
    len -= send_len;
  }
}
コード例 #16
0
CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) {
  char buf[32];
  FXSYS_itoa(i, buf, 10);
  FX_STRSIZE len = FXSYS_strlen(buf);
  if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) {
    ExpandBuf(len * sizeof(FX_WCHAR));
  }
  ASSERT(m_pBuffer);
  FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize);
  for (FX_STRSIZE j = 0; j < len; j++) {
    *str++ = buf[j];
  }
  m_DataSize += len * sizeof(FX_WCHAR);
  return *this;
}
コード例 #17
0
static FX_UINT32 FPF_GetHashCode_StringA(FX_LPCSTR pStr, FX_INT32 iLength, FX_BOOL bIgnoreCase = FALSE)
{
    if (!pStr) {
        return 0;
    }
    if (iLength < 0) {
        iLength = FXSYS_strlen(pStr);
    }
    FX_LPCSTR pStrEnd = pStr + iLength;
    FX_UINT32 uHashCode = 0;
    if (bIgnoreCase) {
        while (pStr < pStrEnd) {
            uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++);
        }
    } else {
        while (pStr < pStrEnd) {
            uHashCode = 31 * uHashCode + *pStr ++;
        }
    }
    return uHashCode;
}
コード例 #18
0
ファイル: fpf_skiafontmgr.cpp プロジェクト: gradescope/pdfium
static uint32_t FPF_GetHashCode_StringA(const FX_CHAR* pStr,
                                        int32_t iLength,
                                        FX_BOOL bIgnoreCase = FALSE) {
  if (!pStr) {
    return 0;
  }
  if (iLength < 0) {
    iLength = FXSYS_strlen(pStr);
  }
  const FX_CHAR* pStrEnd = pStr + iLength;
  uint32_t uHashCode = 0;
  if (bIgnoreCase) {
    while (pStr < pStrEnd) {
      uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++);
    }
  } else {
    while (pStr < pStrEnd) {
      uHashCode = 31 * uHashCode + *pStr++;
    }
  }
  return uHashCode;
}
コード例 #19
0
void CFX_ByteString::ReleaseBuffer(FX_STRSIZE nNewLength) {
  if (!m_pData)
    return;

  if (nNewLength == -1)
    nNewLength = FXSYS_strlen(m_pData->m_String);

  nNewLength = std::min(nNewLength, m_pData->m_nAllocLength);
  if (nNewLength == 0) {
    clear();
    return;
  }

  ASSERT(m_pData->m_nRefs == 1);
  m_pData->m_nDataLength = nNewLength;
  m_pData->m_String[nNewLength] = 0;
  if (m_pData->m_nAllocLength - nNewLength >= 32) {
    // Over arbitrary threshold, so pay the price to relocate.  Force copy to
    // always occur by holding a second reference to the string.
    CFX_ByteString preserve(*this);
    ReallocBeforeWrite(nNewLength);
  }
}
コード例 #20
0
CFX_ByteString::CFX_ByteString(const FX_CHAR* ptr)
    : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
コード例 #21
0
const CFX_ByteString& CFX_ByteString::operator+=(const FX_CHAR* pStr) {
  if (pStr)
    Concat(pStr, FXSYS_strlen(pStr));

  return *this;
}
コード例 #22
0
ファイル: fx_codec_png.cpp プロジェクト: documentcloud/pdfium
static void _png_load_bmp_attribute(png_structp png_ptr,
                                    png_infop info_ptr,
                                    CFX_DIBAttribute* pAttribute) {
  if (pAttribute) {
#if defined(PNG_pHYs_SUPPORTED)
    pAttribute->m_nXDPI = png_get_x_pixels_per_meter(png_ptr, info_ptr);
    pAttribute->m_nYDPI = png_get_y_pixels_per_meter(png_ptr, info_ptr);
    png_uint_32 res_x, res_y;
    int unit_type;
    png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type);
    switch (unit_type) {
      case PNG_RESOLUTION_METER:
        pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER;
        break;
      default:
        pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_NONE;
    }
#endif
#if defined(PNG_iCCP_SUPPORTED)
    png_charp icc_name;
    png_bytep icc_profile;
    png_uint_32 icc_proflen;
    int compress_type;
    png_get_iCCP(png_ptr, info_ptr, &icc_name, &compress_type, &icc_profile,
                 &icc_proflen);
#endif
    int bTime = 0;
#if defined(PNG_tIME_SUPPORTED)
    png_timep t = nullptr;
    png_get_tIME(png_ptr, info_ptr, &t);
    if (t) {
      FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));
      FXSYS_snprintf((FX_CHAR*)pAttribute->m_strTime,
                     sizeof(pAttribute->m_strTime), "%4u:%2u:%2u %2u:%2u:%2u",
                     t->year, t->month, t->day, t->hour, t->minute, t->second);
      pAttribute->m_strTime[sizeof(pAttribute->m_strTime) - 1] = 0;
      bTime = 1;
    }
#endif
#if defined(PNG_TEXT_SUPPORTED)
    int i;
    FX_STRSIZE len;
    const FX_CHAR* buf;
    int num_text;
    png_textp text = nullptr;
    png_get_text(png_ptr, info_ptr, &text, &num_text);
    for (i = 0; i < num_text; i++) {
      len = FXSYS_strlen(text[i].key);
      buf = "Time";
      if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) {
        if (!bTime) {
          FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));
          FXSYS_memcpy(
              pAttribute->m_strTime, text[i].text,
              std::min(sizeof(pAttribute->m_strTime) - 1, text[i].text_length));
        }
      } else {
        buf = "Author";
        if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) {
          pAttribute->m_strAuthor =
              CFX_ByteString(reinterpret_cast<uint8_t*>(text[i].text),
                             static_cast<FX_STRSIZE>(text[i].text_length));
        }
      }
    }
#endif
  }
}