<commit_before>// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_FDE_CSS_FDE_CSSSYNTAX_H_
#define XFA_FDE_CSS_FDE_CSSSYNTAX_H_

#include "xfa/fde/css/fde_css.h"
#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/crt/fgas_stream.h"

class CFDE_CSSTextBuf : public CFX_Target {
 public:
  CFDE_CSSTextBuf();
  ~CFDE_CSSTextBuf() override;

  FX_BOOL AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen);
  FX_BOOL EstimateSize(int32_t iAllocSize);
  int32_t LoadFromStream(IFX_Stream* pTxtStream,
                         int32_t iStreamOffset,
                         int32_t iMaxChars,
                         FX_BOOL& bEOS);
  FX_BOOL AppendChar(FX_WCHAR wch) {
    if (m_iDatLen >= m_iBufLen && !ExpandBuf(m_iBufLen * 2)) {
      return FALSE;
    }
    return (m_pBuffer[m_iDatLen++] = wch), TRUE;
  }
  void Clear() { m_iDatPos = m_iDatLen = 0; }
  void Reset();
  int32_t TrimEnd() {
    while (m_iDatLen > 0 && m_pBuffer[m_iDatLen - 1] <= ' ') {
      --m_iDatLen;
    }
    AppendChar(0);
    return --m_iDatLen;
  }<commit_msg>Avoid dubious use of comma operator in fde_csssyntax.h<commit_after>// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_FDE_CSS_FDE_CSSSYNTAX_H_
#define XFA_FDE_CSS_FDE_CSSSYNTAX_H_

#include "xfa/fde/css/fde_css.h"
#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/crt/fgas_stream.h"

class CFDE_CSSTextBuf : public CFX_Target {
 public:
  CFDE_CSSTextBuf();
  ~CFDE_CSSTextBuf() override;

  FX_BOOL AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen);
  FX_BOOL EstimateSize(int32_t iAllocSize);
  int32_t LoadFromStream(IFX_Stream* pTxtStream,
                         int32_t iStreamOffset,
                         int32_t iMaxChars,
                         FX_BOOL& bEOS);
  bool AppendChar(FX_WCHAR wch) {
    if (m_iDatLen >= m_iBufLen && !ExpandBuf(m_iBufLen * 2))
      return false;
    m_pBuffer[m_iDatLen++] = wch;
    return true;
  }
  void Clear() { m_iDatPos = m_iDatLen = 0; }
  void Reset();
  int32_t TrimEnd() {
    while (m_iDatLen > 0 && m_pBuffer[m_iDatLen - 1] <= ' ') {
      --m_iDatLen;
    }
    AppendChar(0);
    return --m_iDatLen;
  }
{'fraction_non_alphanumeric': 0.10395256916996047, 'fraction_numerical': 0.019762845849802372, 'mean_word_length': 3.0888529886914378, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4011104', 'n_tokens_mistral': 1036, 'n_tokens_neox': 970, 'n_words': 213}