InputSource.C 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: InputSource.C /main/1 1996/07/29 16:55:11 cde-hp $ */
  24. // Copyright (c) 1994 James Clark
  25. // See the file COPYING for copying permission.
  26. #ifdef __GNUG__
  27. #pragma implementation
  28. #endif
  29. #include "splib.h"
  30. #include "InputSource.h"
  31. #include "MarkupScan.h"
  32. #ifdef SP_NAMESPACE
  33. namespace SP_NAMESPACE {
  34. #endif
  35. InputSource::InputSource(InputSourceOrigin *origin, const Char *start,
  36. const Char *end)
  37. : origin_(origin), start_(start), end_(end), cur_(start), accessError_(0),
  38. startLocation_(origin, 0), multicode_(0), scanSuppress_(0),
  39. scanSuppressSingle_(false), scanSuppressIndex_(0)
  40. {
  41. }
  42. void InputSource::reset(const Char *start,
  43. const Char *end)
  44. {
  45. origin_ = origin_->copy();
  46. start_ = start;
  47. end_ = end;
  48. cur_ = start_;
  49. startLocation_ = Location(origin_.pointer(), 0);
  50. multicode_ = 0;
  51. scanSuppress_ = 0;
  52. markupScanTable_.clear();
  53. }
  54. InputSource::~InputSource()
  55. {
  56. }
  57. void InputSource::advanceStartMulticode(const Char *to)
  58. {
  59. while (start_ < to) {
  60. switch (markupScanTable_[*start_]) {
  61. case MarkupScan::normal:
  62. break;
  63. case MarkupScan::in:
  64. scanSuppress_ = 0;
  65. break;
  66. case MarkupScan::out:
  67. if (!scanSuppress()) {
  68. scanSuppress_ = 1;
  69. scanSuppressSingle_ = 0;
  70. }
  71. break;
  72. case MarkupScan::suppress:
  73. // what's the effect of MSSCHAR followed by MSSCHAR
  74. if (!scanSuppress()) {
  75. scanSuppress_ = 1;
  76. scanSuppressSingle_ = 1;
  77. scanSuppressIndex_ = startLocation_.index() + 1;
  78. }
  79. break;
  80. }
  81. start_++;
  82. startLocation_ += 1;
  83. }
  84. }
  85. void InputSource::willNotRewind()
  86. {
  87. }
  88. #ifdef SP_NAMESPACE
  89. }
  90. #endif